diff options
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index 11ec1b07..85672c04 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -760,16 +760,24 @@ void arrange_Widget(iWidget *d) { | |||
760 | } | 760 | } |
761 | 761 | ||
762 | iBool isBeingVisuallyOffsetByReference_Widget(const iWidget *d) { | 762 | iBool isBeingVisuallyOffsetByReference_Widget(const iWidget *d) { |
763 | if (d->flags & refChildrenOffset_WidgetFlag) { | 763 | return visualOffsetByReference_Widget(d) != 0; |
764 | } | ||
765 | |||
766 | int visualOffsetByReference_Widget(const iWidget *d) { | ||
767 | if (d->offsetRef && d->flags & refChildrenOffset_WidgetFlag) { | ||
768 | int offX = 0; | ||
764 | iConstForEach(ObjectList, i, children_Widget(d->offsetRef)) { | 769 | iConstForEach(ObjectList, i, children_Widget(d->offsetRef)) { |
765 | const iWidget *child = i.object; | 770 | const iWidget *child = i.object; |
766 | if (child == d) continue; | 771 | if (child == d) continue; |
767 | if (child->flags & (visualOffset_WidgetFlag | dragged_WidgetFlag)) { | 772 | if (child->flags & (visualOffset_WidgetFlag | dragged_WidgetFlag)) { |
768 | return iTrue; | 773 | // const float factor = width_Widget(d) / (float) size_Root(d->root).x; |
774 | const int invOff = width_Widget(d) - iRound(value_Anim(&child->visualOffset)); | ||
775 | offX -= invOff / 4; | ||
769 | } | 776 | } |
770 | } | 777 | } |
778 | return offX; | ||
771 | } | 779 | } |
772 | return iFalse; | 780 | return 0; |
773 | } | 781 | } |
774 | 782 | ||
775 | static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) { | 783 | static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) { |
@@ -786,14 +794,7 @@ static void applyVisualOffset_Widget_(const iWidget *d, iInt2 *pos) { | |||
786 | pos->y -= value_Anim(d->animOffsetRef); | 794 | pos->y -= value_Anim(d->animOffsetRef); |
787 | } | 795 | } |
788 | if (d->flags & refChildrenOffset_WidgetFlag) { | 796 | if (d->flags & refChildrenOffset_WidgetFlag) { |
789 | iConstForEach(ObjectList, i, children_Widget(d->offsetRef)) { | 797 | pos->x += visualOffsetByReference_Widget(d); |
790 | const iWidget *child = i.object; | ||
791 | if (child == d) continue; | ||
792 | if (child->flags & (visualOffset_WidgetFlag | dragged_WidgetFlag)) { | ||
793 | const int invOff = size_Root(d->root).x - iRound(value_Anim(&child->visualOffset)); | ||
794 | pos->x -= invOff / 4; | ||
795 | } | ||
796 | } | ||
797 | } | 798 | } |
798 | } | 799 | } |
799 | 800 | ||
@@ -1081,7 +1082,9 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
1081 | if (~d->flags & dragged_WidgetFlag) { | 1082 | if (~d->flags & dragged_WidgetFlag) { |
1082 | setFlags_Widget(d, dragged_WidgetFlag, iTrue); | 1083 | setFlags_Widget(d, dragged_WidgetFlag, iTrue); |
1083 | } | 1084 | } |
1084 | setVisualOffset_Widget(d, arg_Command(command_UserEvent(ev)), 10, 0); | 1085 | setVisualOffset_Widget(d, arg_Command(command_UserEvent(ev)) * |
1086 | width_Widget(d) / size_Root(d->root).x, | ||
1087 | 10, 0); | ||
1085 | return iTrue; | 1088 | return iTrue; |
1086 | } | 1089 | } |
1087 | } | 1090 | } |
@@ -1129,6 +1132,17 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) { | |||
1129 | return iFalse; | 1132 | return iFalse; |
1130 | } | 1133 | } |
1131 | 1134 | ||
1135 | int backgroundFadeColor_Widget(void) { | ||
1136 | switch (colorTheme_App()) { | ||
1137 | case light_ColorTheme: | ||
1138 | return gray25_ColorId; | ||
1139 | case pureWhite_ColorTheme: | ||
1140 | return gray50_ColorId; | ||
1141 | default: | ||
1142 | return black_ColorId; | ||
1143 | } | ||
1144 | } | ||
1145 | |||
1132 | void drawBackground_Widget(const iWidget *d) { | 1146 | void drawBackground_Widget(const iWidget *d) { |
1133 | if (d->flags & noBackground_WidgetFlag) { | 1147 | if (d->flags & noBackground_WidgetFlag) { |
1134 | return; | 1148 | return; |
@@ -1151,8 +1165,7 @@ void drawBackground_Widget(const iWidget *d) { | |||
1151 | drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); | 1165 | drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); |
1152 | } | 1166 | } |
1153 | const iBool isFaded = fadeBackground && | 1167 | const iBool isFaded = fadeBackground && |
1154 | ~d->flags & noFadeBackground_WidgetFlag;/* && | 1168 | ~d->flags & noFadeBackground_WidgetFlag; |
1155 | ~d->flags & destroyPending_WidgetFlag;*/ | ||
1156 | if (isFaded) { | 1169 | if (isFaded) { |
1157 | iPaint p; | 1170 | iPaint p; |
1158 | init_Paint(&p); | 1171 | init_Paint(&p); |
@@ -1163,19 +1176,7 @@ void drawBackground_Widget(const iWidget *d) { | |||
1163 | p.alpha *= (area > 0 ? visibleArea / area : 0.0f); | 1176 | p.alpha *= (area > 0 ? visibleArea / area : 0.0f); |
1164 | } | 1177 | } |
1165 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); | 1178 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_BLEND); |
1166 | int fadeColor; | 1179 | fillRect_Paint(&p, rect_Root(d->root), backgroundFadeColor_Widget()); |
1167 | switch (colorTheme_App()) { | ||
1168 | default: | ||
1169 | fadeColor = black_ColorId; | ||
1170 | break; | ||
1171 | case light_ColorTheme: | ||
1172 | fadeColor = gray25_ColorId; | ||
1173 | break; | ||
1174 | case pureWhite_ColorTheme: | ||
1175 | fadeColor = gray50_ColorId; | ||
1176 | break; | ||
1177 | } | ||
1178 | fillRect_Paint(&p, rect_Root(d->root), fadeColor); | ||
1179 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); | 1180 | SDL_SetRenderDrawBlendMode(renderer_Window(get_Window()), SDL_BLENDMODE_NONE); |
1180 | } | 1181 | } |
1181 | if (d->bgColor >= 0 || d->frameColor >= 0) { | 1182 | if (d->bgColor >= 0 || d->frameColor >= 0) { |