diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-14 15:09:54 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-05-14 15:09:54 +0300 |
commit | 21b16be87fec3ec163fb52b94619ba5f3b5df6d2 (patch) | |
tree | 73df8c1469f9d7f4186b40ea7b8d34c5b6dfd7bf /src/ui/widget.c | |
parent | 7f737f1b88448a8a2ccca716a09e3b37fb0c08f9 (diff) |
Mobile and iOS: Various fixes and cleanup
Several regressions occurred when the split view mode was implemented.
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index 1a0b2ce7..dd0c1b05 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -151,6 +151,11 @@ void setFlags_Widget(iWidget *d, int64_t flags, iBool set) { | |||
151 | removeOne_PtrArray(onTop, d); | 151 | removeOne_PtrArray(onTop, d); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | if (d->flags & arrangeWidth_WidgetFlag && | ||
155 | d->flags & resizeToParentWidth_WidgetFlag) { | ||
156 | printf("[Widget] Conflicting flags for "); | ||
157 | identify_Widget(d); | ||
158 | } | ||
154 | } | 159 | } |
155 | } | 160 | } |
156 | 161 | ||
@@ -210,7 +215,7 @@ void setVisualOffset_Widget(iWidget *d, int value, uint32_t span, int animFlags) | |||
210 | else { | 215 | else { |
211 | setValue_Anim(&d->visualOffset, value, span); | 216 | setValue_Anim(&d->visualOffset, value, span); |
212 | d->visualOffset.flags = animFlags; | 217 | d->visualOffset.flags = animFlags; |
213 | addTicker_App(visualOffsetAnimation_Widget_, d); | 218 | addTickerRoot_App(visualOffsetAnimation_Widget_, d->root, d); |
214 | } | 219 | } |
215 | } | 220 | } |
216 | 221 | ||
@@ -471,12 +476,19 @@ static void arrange_Widget_(iWidget *d) { | |||
471 | const int expCount = numExpandingChildren_Widget_(d); | 476 | const int expCount = numExpandingChildren_Widget_(d); |
472 | TRACE(d, "%d expanding children", expCount); | 477 | TRACE(d, "%d expanding children", expCount); |
473 | /* Resize children to fill the parent widget. */ | 478 | /* Resize children to fill the parent widget. */ |
479 | iAssert((d->flags & (resizeToParentWidth_WidgetFlag | arrangeWidth_WidgetFlag)) != | ||
480 | (resizeToParentWidth_WidgetFlag | arrangeWidth_WidgetFlag)); | ||
474 | if (d->flags & resizeChildren_WidgetFlag) { | 481 | if (d->flags & resizeChildren_WidgetFlag) { |
475 | const iInt2 dirs = init_I2((d->flags & resizeWidthOfChildren_WidgetFlag) != 0, | 482 | const iInt2 dirs = init_I2((d->flags & resizeWidthOfChildren_WidgetFlag) != 0, |
476 | (d->flags & resizeHeightOfChildren_WidgetFlag) != 0); | 483 | (d->flags & resizeHeightOfChildren_WidgetFlag) != 0); |
477 | #if !defined (NDEBUG) | 484 | #if !defined (NDEBUG) |
478 | /* Check for conflicting flags. */ | 485 | /* Check for conflicting flags. */ |
479 | if (dirs.x) iAssert(~d->flags & arrangeWidth_WidgetFlag); | 486 | if (dirs.x) { |
487 | if (d->flags & arrangeWidth_WidgetFlag) { | ||
488 | identify_Widget(d); | ||
489 | } | ||
490 | iAssert(~d->flags & arrangeWidth_WidgetFlag); | ||
491 | } | ||
480 | if (dirs.y) iAssert(~d->flags & arrangeHeight_WidgetFlag); | 492 | if (dirs.y) iAssert(~d->flags & arrangeHeight_WidgetFlag); |
481 | #endif | 493 | #endif |
482 | TRACE(d, "resize children, x:%d y:%d (own size: %dx%d)", dirs.x, dirs.y, | 494 | TRACE(d, "resize children, x:%d y:%d (own size: %dx%d)", dirs.x, dirs.y, |
@@ -715,8 +727,10 @@ static void resetArrangement_Widget_(iWidget *d) { | |||
715 | } | 727 | } |
716 | 728 | ||
717 | void arrange_Widget(iWidget *d) { | 729 | void arrange_Widget(iWidget *d) { |
718 | resetArrangement_Widget_(d); /* back to initial default sizes */ | 730 | if (d) { |
719 | arrange_Widget_(d); | 731 | resetArrangement_Widget_(d); /* back to initial default sizes */ |
732 | arrange_Widget_(d); | ||
733 | } | ||
720 | } | 734 | } |
721 | 735 | ||
722 | static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) { | 736 | static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) { |
@@ -919,9 +933,11 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
919 | } | 933 | } |
920 | } | 934 | } |
921 | if (class_Widget(d)->processEvent(d, ev)) { | 935 | if (class_Widget(d)->processEvent(d, ev)) { |
936 | iAssert(get_Root() == d->root); | ||
922 | return iTrue; | 937 | return iTrue; |
923 | } | 938 | } |
924 | } | 939 | } |
940 | iAssert(get_Root() == d->root); | ||
925 | return iFalse; | 941 | return iFalse; |
926 | } | 942 | } |
927 | 943 | ||
@@ -994,6 +1010,7 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
994 | } | 1010 | } |
995 | if (ev->user.code == command_UserEventCode && d->commandHandler && | 1011 | if (ev->user.code == command_UserEventCode && d->commandHandler && |
996 | d->commandHandler(d, ev->user.data1)) { | 1012 | d->commandHandler(d, ev->user.data1)) { |
1013 | iAssert(get_Root() == d->root); | ||
997 | return iTrue; | 1014 | return iTrue; |
998 | } | 1015 | } |
999 | break; | 1016 | break; |
@@ -1586,7 +1603,7 @@ static void printInfo_Widget_(const iWidget *d) { | |||
1586 | cstr_String(text_LabelWidget((const iLabelWidget *) d)), | 1603 | cstr_String(text_LabelWidget((const iLabelWidget *) d)), |
1587 | cstr_String(command_LabelWidget((const iLabelWidget *) d))); | 1604 | cstr_String(command_LabelWidget((const iLabelWidget *) d))); |
1588 | } | 1605 | } |
1589 | printf("size:%dx%d {min:%dx%d} [%d..%d %d:%d] flags:%08llx%s%s%s%s%s\n", | 1606 | printf("size:%dx%d {min:%dx%d} [%d..%d %d:%d] flags:%08llx%s%s%s%s%s%s%s\n", |
1590 | d->rect.size.x, d->rect.size.y, | 1607 | d->rect.size.x, d->rect.size.y, |
1591 | d->minSize.x, d->minSize.y, | 1608 | d->minSize.x, d->minSize.y, |
1592 | d->padding[0], d->padding[2], | 1609 | d->padding[0], d->padding[2], |
@@ -1596,7 +1613,9 @@ static void printInfo_Widget_(const iWidget *d) { | |||
1596 | d->flags & tight_WidgetFlag ? " tight" : "", | 1613 | d->flags & tight_WidgetFlag ? " tight" : "", |
1597 | d->flags & fixedWidth_WidgetFlag ? " fixW" : "", | 1614 | d->flags & fixedWidth_WidgetFlag ? " fixW" : "", |
1598 | d->flags & fixedHeight_WidgetFlag ? " fixH" : "", | 1615 | d->flags & fixedHeight_WidgetFlag ? " fixH" : "", |
1599 | d->flags & resizeToParentWidth_WidgetFlag ? " rsPrnW" : ""); | 1616 | d->flags & resizeToParentWidth_WidgetFlag ? " prnW" : "", |
1617 | d->flags & arrangeWidth_WidgetFlag ? " aW" : "", | ||
1618 | d->flags & resizeWidthOfChildren_WidgetFlag ? " rsWChild" : ""); | ||
1600 | } | 1619 | } |
1601 | 1620 | ||
1602 | static void printTree_Widget_(const iWidget *d, int indent) { | 1621 | static void printTree_Widget_(const iWidget *d, int indent) { |