summaryrefslogtreecommitdiff
path: root/src/ui/widget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r--src/ui/widget.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index d31f7577..4eac7ecf 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -59,6 +59,7 @@ void init_Widget(iWidget *d) {
59 d->minSize = zero_I2(); 59 d->minSize = zero_I2();
60 d->sizeRef = NULL; 60 d->sizeRef = NULL;
61 d->offsetRef = NULL; 61 d->offsetRef = NULL;
62 d->animOffsetRef = NULL;
62 d->bgColor = none_ColorId; 63 d->bgColor = none_ColorId;
63 d->frameColor = none_ColorId; 64 d->frameColor = none_ColorId;
64 init_Anim(&d->visualOffset, 0.0f); 65 init_Anim(&d->visualOffset, 0.0f);
@@ -101,9 +102,6 @@ static void aboutToBeDestroyed_Widget_(iWidget *d) {
101 setFocus_Widget(NULL); 102 setFocus_Widget(NULL);
102 return; 103 return;
103 } 104 }
104 if (flags_Widget(d) & keepOnTop_WidgetFlag) {
105 removeOne_PtrArray(onTop_Root(d->root), d);
106 }
107 remove_Periodic(periodic_App(), d); 105 remove_Periodic(periodic_App(), d);
108 if (isHover_Widget(d)) { 106 if (isHover_Widget(d)) {
109 get_Window()->hover = NULL; 107 get_Window()->hover = NULL;
@@ -771,6 +769,9 @@ static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) {
771 pos->y += off; 769 pos->y += off;
772 } 770 }
773 } 771 }
772 if (d->animOffsetRef) {
773 pos->y -= value_Anim(d->animOffsetRef);
774 }
774 if (d->flags & refChildrenOffset_WidgetFlag) { 775 if (d->flags & refChildrenOffset_WidgetFlag) {
775 iConstForEach(ObjectList, i, children_Widget(d->offsetRef)) { 776 iConstForEach(ObjectList, i, children_Widget(d->offsetRef)) {
776 const iWidget *child = i.object; 777 const iWidget *child = i.object;
@@ -843,6 +844,12 @@ iBool containsExpanded_Widget(const iWidget *d, iInt2 windowCoord, int expand) {
843 addY_I2(d->rect.size, 844 addY_I2(d->rect.size,
844 d->flags & drawBackgroundToBottom_WidgetFlag ? size_Root(d->root).y : 0) 845 d->flags & drawBackgroundToBottom_WidgetFlag ? size_Root(d->root).y : 0)
845 }; 846 };
847 /* Apply the animated offset. (Visual offsets don't affect interaction.) */
848 for (const iWidget *w = d; w; w = w->parent) {
849 if (w->animOffsetRef) {
850 windowCoord.y += value_Anim(w->animOffsetRef);
851 }
852 }
846 return contains_Rect(expand ? expanded_Rect(bounds, init1_I2(expand)) : bounds, 853 return contains_Rect(expand ? expanded_Rect(bounds, init1_I2(expand)) : bounds,
847 windowToInner_Widget(d, windowCoord)); 854 windowToInner_Widget(d, windowCoord));
848} 855}
@@ -857,6 +864,9 @@ iLocalDef iBool isMouseEvent_(const SDL_Event *ev) {
857} 864}
858 865
859static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) { 866static iBool filterEvent_Widget_(const iWidget *d, const SDL_Event *ev) {
867 if (d->flags & destroyPending_WidgetFlag) {
868 return iFalse; /* no more events handled */
869 }
860 const iBool isKey = isKeyboardEvent_(ev); 870 const iBool isKey = isKeyboardEvent_(ev);
861 const iBool isMouse = isMouseEvent_(ev); 871 const iBool isMouse = isMouseEvent_(ev);
862 if ((d->flags & disabled_WidgetFlag) || (d->flags & hidden_WidgetFlag && 872 if ((d->flags & disabled_WidgetFlag) || (d->flags & hidden_WidgetFlag &&
@@ -1102,8 +1112,8 @@ void drawBackground_Widget(const iWidget *d) {
1102 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); 1112 drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30);
1103 } 1113 }
1104 const iBool isFaded = fadeBackground && 1114 const iBool isFaded = fadeBackground &&
1105 ~d->flags & noFadeBackground_WidgetFlag && 1115 ~d->flags & noFadeBackground_WidgetFlag;/* &&
1106 ~d->flags & destroyPending_WidgetFlag; 1116 ~d->flags & destroyPending_WidgetFlag;*/
1107 if (isFaded) { 1117 if (isFaded) {
1108 iPaint p; 1118 iPaint p;
1109 init_Paint(&p); 1119 init_Paint(&p);