diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-02 19:33:57 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-12-02 19:33:57 +0200 |
commit | 8e7c651faa2e7525cc2e4251516585f89b822ab8 (patch) | |
tree | b3e037f39714e8c33001a7abcdd5c6a160f990a9 /src/ui/widget.c | |
parent | 50c5abbbeab07e3ccd67da5caafe7325467f1396 (diff) |
Widget: Widget rearrangement issues
There were issues where popup menus would only get wider and never narrower. Arrangements should not be dependent on the results of a previous one.
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index cedda461..254c2590 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -31,6 +31,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
31 | #include "util.h" | 31 | #include "util.h" |
32 | #include "window.h" | 32 | #include "window.h" |
33 | 33 | ||
34 | #include "labelwidget.h" | ||
35 | |||
34 | #include <the_Foundation/ptrarray.h> | 36 | #include <the_Foundation/ptrarray.h> |
35 | #include <the_Foundation/ptrset.h> | 37 | #include <the_Foundation/ptrset.h> |
36 | #include <SDL_mouse.h> | 38 | #include <SDL_mouse.h> |
@@ -836,6 +838,12 @@ static void arrange_Widget_(iWidget *d) { | |||
836 | } | 838 | } |
837 | 839 | ||
838 | static void resetArrangement_Widget_(iWidget *d) { | 840 | static void resetArrangement_Widget_(iWidget *d) { |
841 | if (d->flags & resizeToParentWidth_WidgetFlag) { | ||
842 | d->rect.size.x = 0; | ||
843 | } | ||
844 | if (d->flags & resizeToParentHeight_WidgetFlag) { | ||
845 | d->rect.size.y = 0; | ||
846 | } | ||
839 | iForEach(ObjectList, i, children_Widget(d)) { | 847 | iForEach(ObjectList, i, children_Widget(d)) { |
840 | iWidget *child = as_Widget(i.object); | 848 | iWidget *child = as_Widget(i.object); |
841 | resetArrangement_Widget_(child); | 849 | resetArrangement_Widget_(child); |
@@ -847,6 +855,14 @@ static void resetArrangement_Widget_(iWidget *d) { | |||
847 | ~child->flags & fixedWidth_WidgetFlag) { | 855 | ~child->flags & fixedWidth_WidgetFlag) { |
848 | child->rect.size.x = 0; | 856 | child->rect.size.x = 0; |
849 | } | 857 | } |
858 | if (d->flags & resizeChildrenToWidestChild_WidgetFlag) { | ||
859 | if (isInstance_Object(child, &Class_LabelWidget)) { | ||
860 | updateSize_LabelWidget((iLabelWidget *) child); | ||
861 | } | ||
862 | else { | ||
863 | child->rect.size.x = 0; | ||
864 | } | ||
865 | } | ||
850 | if (d->flags & arrangeVertical_WidgetFlag) { | 866 | if (d->flags & arrangeVertical_WidgetFlag) { |
851 | child->rect.pos.y = 0; | 867 | child->rect.pos.y = 0; |
852 | } | 868 | } |