diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-20 14:27:39 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-09-20 14:27:39 +0300 |
commit | 09fad74ebcf09044251adb32d422d1c2f47f693d (patch) | |
tree | be22a7b38166ba49eefe8c95bf59043857617dc9 | |
parent | 8adc74e242ee6305d4a9016b1e6f31036b742067 (diff) |
Widget: Expanded flags to 64 bits
Ran out of room in 32 bits, more flags needed for arranging.
m--------- | lib/the_Foundation | 0 | ||||
-rw-r--r-- | src/ui/util.c | 3 | ||||
-rw-r--r-- | src/ui/widget.c | 17 | ||||
-rw-r--r-- | src/ui/widget.h | 79 |
4 files changed, 45 insertions, 54 deletions
diff --git a/lib/the_Foundation b/lib/the_Foundation | |||
Subproject ab8f6e0769db2ec74846beea0f36561b85bf2c7 | Subproject 4b041220b889a65e0dd5ec861e3c6982c968f0f | ||
diff --git a/src/ui/util.c b/src/ui/util.c index 51c83a8b..bdc1c813 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -604,9 +604,8 @@ iWidget *makeSheet_Widget(const char *id) { | |||
604 | setBackgroundColor_Widget(sheet, uiBackground_ColorId); | 604 | setBackgroundColor_Widget(sheet, uiBackground_ColorId); |
605 | setFlags_Widget(sheet, | 605 | setFlags_Widget(sheet, |
606 | mouseModal_WidgetFlag | keepOnTop_WidgetFlag | arrangeVertical_WidgetFlag | | 606 | mouseModal_WidgetFlag | keepOnTop_WidgetFlag | arrangeVertical_WidgetFlag | |
607 | arrangeSize_WidgetFlag, | 607 | arrangeSize_WidgetFlag | centerHorizontal_WidgetFlag, |
608 | iTrue); | 608 | iTrue); |
609 | setFlags2_Widget(sheet, centerHorizontal_WidgetFlag2, iTrue); | ||
610 | return sheet; | 609 | return sheet; |
611 | } | 610 | } |
612 | 611 | ||
diff --git a/src/ui/widget.c b/src/ui/widget.c index cace9568..d218d7ee 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -71,7 +71,6 @@ iDefineObjectConstruction(Widget) | |||
71 | void init_Widget(iWidget *d) { | 71 | void init_Widget(iWidget *d) { |
72 | init_String(&d->id); | 72 | init_String(&d->id); |
73 | d->flags = 0; | 73 | d->flags = 0; |
74 | d->flags2 = 0; | ||
75 | d->rect = zero_Rect(); | 74 | d->rect = zero_Rect(); |
76 | d->bgColor = none_ColorId; | 75 | d->bgColor = none_ColorId; |
77 | d->frameColor = none_ColorId; | 76 | d->frameColor = none_ColorId; |
@@ -120,11 +119,11 @@ const iString *id_Widget(const iWidget *d) { | |||
120 | return &d->id; | 119 | return &d->id; |
121 | } | 120 | } |
122 | 121 | ||
123 | int flags_Widget(const iWidget *d) { | 122 | int64_t flags_Widget(const iWidget *d) { |
124 | return d->flags; | 123 | return d->flags; |
125 | } | 124 | } |
126 | 125 | ||
127 | void setFlags_Widget(iWidget *d, int flags, iBool set) { | 126 | void setFlags_Widget(iWidget *d, int64_t flags, iBool set) { |
128 | iChangeFlags(d->flags, flags, set); | 127 | iChangeFlags(d->flags, flags, set); |
129 | if (flags & keepOnTop_WidgetFlag) { | 128 | if (flags & keepOnTop_WidgetFlag) { |
130 | if (set) { | 129 | if (set) { |
@@ -136,10 +135,6 @@ void setFlags_Widget(iWidget *d, int flags, iBool set) { | |||
136 | } | 135 | } |
137 | } | 136 | } |
138 | 137 | ||
139 | void setFlags2_Widget(iWidget *d, int flags2, iBool set) { | ||
140 | iChangeFlags(d->flags2, flags2, set); | ||
141 | } | ||
142 | |||
143 | void setPos_Widget(iWidget *d, iInt2 pos) { | 138 | void setPos_Widget(iWidget *d, iInt2 pos) { |
144 | d->rect.pos = pos; | 139 | d->rect.pos = pos; |
145 | setFlags_Widget(d, fixedPosition_WidgetFlag, iTrue); | 140 | setFlags_Widget(d, fixedPosition_WidgetFlag, iTrue); |
@@ -248,7 +243,7 @@ void arrange_Widget(iWidget *d) { | |||
248 | if (d->flags & moveToParentRightEdge_WidgetFlag) { | 243 | if (d->flags & moveToParentRightEdge_WidgetFlag) { |
249 | d->rect.pos.x = width_Rect(innerRect_Widget_(d->parent)) - width_Rect(d->rect); | 244 | d->rect.pos.x = width_Rect(innerRect_Widget_(d->parent)) - width_Rect(d->rect); |
250 | } | 245 | } |
251 | if (d->flags2 & centerHorizontal_WidgetFlag2) { | 246 | if (d->flags & centerHorizontal_WidgetFlag) { |
252 | centerHorizontal_Widget_(d); | 247 | centerHorizontal_Widget_(d); |
253 | } | 248 | } |
254 | if (d->flags & resizeToParentWidth_WidgetFlag) { | 249 | if (d->flags & resizeToParentWidth_WidgetFlag) { |
@@ -366,7 +361,7 @@ void arrange_Widget(iWidget *d) { | |||
366 | if (child->flags & fixedPosition_WidgetFlag) { | 361 | if (child->flags & fixedPosition_WidgetFlag) { |
367 | continue; | 362 | continue; |
368 | } | 363 | } |
369 | if (child->flags2 & centerHorizontal_WidgetFlag2) { | 364 | if (child->flags & centerHorizontal_WidgetFlag) { |
370 | continue; | 365 | continue; |
371 | } | 366 | } |
372 | if (d->flags & (arrangeHorizontal_WidgetFlag | arrangeVertical_WidgetFlag)) { | 367 | if (d->flags & (arrangeHorizontal_WidgetFlag | arrangeVertical_WidgetFlag)) { |
@@ -419,7 +414,7 @@ void arrange_Widget(iWidget *d) { | |||
419 | } | 414 | } |
420 | } | 415 | } |
421 | } | 416 | } |
422 | if (d->flags2 & centerHorizontal_WidgetFlag2) { | 417 | if (d->flags & centerHorizontal_WidgetFlag) { |
423 | centerHorizontal_Widget_(d); | 418 | centerHorizontal_Widget_(d); |
424 | } | 419 | } |
425 | } | 420 | } |
@@ -637,7 +632,7 @@ iAny *addChildPos_Widget(iWidget *d, iAnyObject *child, enum iWidgetAddPos addPo | |||
637 | return child; | 632 | return child; |
638 | } | 633 | } |
639 | 634 | ||
640 | iAny *addChildFlags_Widget(iWidget *d, iAnyObject *child, int childFlags) { | 635 | iAny *addChildFlags_Widget(iWidget *d, iAnyObject *child, int64_t childFlags) { |
641 | setFlags_Widget(child, childFlags, iTrue); | 636 | setFlags_Widget(child, childFlags, iTrue); |
642 | return addChild_Widget(d, child); | 637 | return addChild_Widget(d, child); |
643 | } | 638 | } |
diff --git a/src/ui/widget.h b/src/ui/widget.h index 34e46c0b..a2be30e9 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h | |||
@@ -44,47 +44,46 @@ iBeginDeclareClass(Widget) | |||
44 | iEndDeclareClass(Widget) | 44 | iEndDeclareClass(Widget) |
45 | 45 | ||
46 | enum iWidgetFlag { | 46 | enum iWidgetFlag { |
47 | hidden_WidgetFlag = iBit(1), | 47 | hidden_WidgetFlag = iBit(1), |
48 | disabled_WidgetFlag = iBit(2), | 48 | disabled_WidgetFlag = iBit(2), |
49 | hover_WidgetFlag = iBit(3), /* eligible for mouse hover */ | 49 | hover_WidgetFlag = iBit(3), /* eligible for mouse hover */ |
50 | selected_WidgetFlag = iBit(4), | 50 | selected_WidgetFlag = iBit(4), |
51 | pressed_WidgetFlag = iBit(5), | 51 | pressed_WidgetFlag = iBit(5), |
52 | alignLeft_WidgetFlag = iBit(6), | 52 | alignLeft_WidgetFlag = iBit(6), |
53 | alignRight_WidgetFlag = iBit(7), | 53 | alignRight_WidgetFlag = iBit(7), |
54 | frameless_WidgetFlag = iBit(8), | 54 | frameless_WidgetFlag = iBit(8), |
55 | commandOnClick_WidgetFlag = iBit(9), | 55 | commandOnClick_WidgetFlag = iBit(9), |
56 | drawKey_WidgetFlag = iBit(10), | 56 | commandOnMouseMiss_WidgetFlag = iBit(10), |
57 | focusable_WidgetFlag = iBit(11), | 57 | drawKey_WidgetFlag = iBit(11), |
58 | tight_WidgetFlag = iBit(12), /* smaller padding */ | 58 | focusable_WidgetFlag = iBit(12), |
59 | keepOnTop_WidgetFlag = iBit(13), /* gets events first; drawn last */ | 59 | tight_WidgetFlag = iBit(13), /* smaller padding */ |
60 | mouseModal_WidgetFlag = iBit(14), /* eats all unprocessed mouse events */ | 60 | keepOnTop_WidgetFlag = iBit(14), /* gets events first; drawn last */ |
61 | commandOnMouseMiss_WidgetFlag = iBit(15), | 61 | mouseModal_WidgetFlag = iBit(15), /* eats all unprocessed mouse events */ |
62 | /* arrange behavior */ | 62 | /* arrangement */ |
63 | fixedPosition_WidgetFlag = iBit(16), | 63 | fixedPosition_WidgetFlag = iBit(17), |
64 | arrangeHorizontal_WidgetFlag = iBit(17), /* arrange children horizontally */ | 64 | arrangeHorizontal_WidgetFlag = iBit(18), /* arrange children horizontally */ |
65 | arrangeVertical_WidgetFlag = iBit(18), /* arrange children vertically */ | 65 | arrangeVertical_WidgetFlag = iBit(19), /* arrange children vertically */ |
66 | arrangeWidth_WidgetFlag = iBit(19), /* area of children becomes parent size */ | 66 | arrangeWidth_WidgetFlag = iBit(20), /* area of children becomes parent size */ |
67 | arrangeHeight_WidgetFlag = iBit(20), /* area of children becomes parent size */ | 67 | arrangeHeight_WidgetFlag = iBit(21), /* area of children becomes parent size */ |
68 | resizeWidthOfChildren_WidgetFlag = iBit(21), | 68 | resizeWidthOfChildren_WidgetFlag = iBit(22), |
69 | resizeHeightOfChildren_WidgetFlag = iBit(22), | 69 | resizeHeightOfChildren_WidgetFlag = iBit(23), |
70 | expand_WidgetFlag = iBit(23), | 70 | expand_WidgetFlag = iBit(24), |
71 | fixedWidth_WidgetFlag = iBit(24), | 71 | fixedWidth_WidgetFlag = iBit(25), |
72 | fixedHeight_WidgetFlag = iBit(25), | 72 | fixedHeight_WidgetFlag = iBit(26), |
73 | resizeChildrenToWidestChild_WidgetFlag = iBit(26), | 73 | resizeChildrenToWidestChild_WidgetFlag = iBit(27), |
74 | resizeToParentWidth_WidgetFlag = iBit(27), | 74 | resizeToParentWidth_WidgetFlag = iBit(28), |
75 | resizeToParentHeight_WidgetFlag = iBit(28), | 75 | resizeToParentHeight_WidgetFlag = iBit(29), |
76 | moveToParentRightEdge_WidgetFlag = iBit(29), | 76 | collapse_WidgetFlag = iBit(30), /* if hidden, arrange size to zero */ |
77 | collapse_WidgetFlag = iBit(30), /* when hidden, arrange size to zero */ | ||
78 | wasCollapsed_WidgetFlag = iBit(31), | ||
79 | /* combinations */ | 77 | /* combinations */ |
80 | arrangeSize_WidgetFlag = arrangeWidth_WidgetFlag | arrangeHeight_WidgetFlag, | 78 | arrangeSize_WidgetFlag = arrangeWidth_WidgetFlag | arrangeHeight_WidgetFlag, |
81 | resizeChildren_WidgetFlag = resizeWidthOfChildren_WidgetFlag | resizeHeightOfChildren_WidgetFlag, | 79 | resizeChildren_WidgetFlag = resizeWidthOfChildren_WidgetFlag | resizeHeightOfChildren_WidgetFlag, |
82 | fixedSize_WidgetFlag = fixedWidth_WidgetFlag | fixedHeight_WidgetFlag, | 80 | fixedSize_WidgetFlag = fixedWidth_WidgetFlag | fixedHeight_WidgetFlag, |
83 | }; | 81 | }; |
84 | 82 | ||
85 | enum iWidgetFlag2 { | 83 | /* 64-bit extended flags */ |
86 | centerHorizontal_WidgetFlag2 = iBit(1), | 84 | #define wasCollapsed_WidgetFlag iBit64(32) |
87 | }; | 85 | #define centerHorizontal_WidgetFlag iBit64(33) |
86 | #define moveToParentRightEdge_WidgetFlag iBit64(34) | ||
88 | 87 | ||
89 | enum iWidgetAddPos { | 88 | enum iWidgetAddPos { |
90 | back_WidgetAddPos, | 89 | back_WidgetAddPos, |
@@ -99,8 +98,7 @@ enum iWidgetFocusDir { | |||
99 | struct Impl_Widget { | 98 | struct Impl_Widget { |
100 | iObject object; | 99 | iObject object; |
101 | iString id; | 100 | iString id; |
102 | int flags; | 101 | int64_t flags; |
103 | int flags2; | ||
104 | iRect rect; | 102 | iRect rect; |
105 | int padding[4]; /* left, top, right, bottom */ | 103 | int padding[4]; /* left, top, right, bottom */ |
106 | int bgColor; | 104 | int bgColor; |
@@ -136,7 +134,7 @@ void destroy_Widget (iWidget *); /* widget removed and deleted later */ | |||
136 | void destroyPending_Widget(void); | 134 | void destroyPending_Widget(void); |
137 | 135 | ||
138 | const iString *id_Widget (const iWidget *); | 136 | const iString *id_Widget (const iWidget *); |
139 | int flags_Widget (const iWidget *); | 137 | int64_t flags_Widget (const iWidget *); |
140 | iRect bounds_Widget (const iWidget *); /* outer bounds */ | 138 | iRect bounds_Widget (const iWidget *); /* outer bounds */ |
141 | iRect innerBounds_Widget (const iWidget *); | 139 | iRect innerBounds_Widget (const iWidget *); |
142 | iInt2 localCoord_Widget (const iWidget *, iInt2 coord); | 140 | iInt2 localCoord_Widget (const iWidget *, iInt2 coord); |
@@ -170,8 +168,7 @@ iBool isSelected_Widget (const iAnyObject *); | |||
170 | iBool isCommand_Widget (const iWidget *d, const SDL_Event *ev, const char *cmd); | 168 | iBool isCommand_Widget (const iWidget *d, const SDL_Event *ev, const char *cmd); |
171 | iBool hasParent_Widget (const iWidget *d, const iWidget *someParent); | 169 | iBool hasParent_Widget (const iWidget *d, const iWidget *someParent); |
172 | void setId_Widget (iWidget *, const char *id); | 170 | void setId_Widget (iWidget *, const char *id); |
173 | void setFlags_Widget (iWidget *, int flags, iBool set); | 171 | void setFlags_Widget (iWidget *, int64_t flags, iBool set); |
174 | void setFlags2_Widget (iWidget *, int flags2, iBool set); | ||
175 | void setPos_Widget (iWidget *, iInt2 pos); | 172 | void setPos_Widget (iWidget *, iInt2 pos); |
176 | void setSize_Widget (iWidget *, iInt2 size); | 173 | void setSize_Widget (iWidget *, iInt2 size); |
177 | void setPadding_Widget (iWidget *, int left, int top, int right, int bottom); | 174 | void setPadding_Widget (iWidget *, int left, int top, int right, int bottom); |
@@ -181,7 +178,7 @@ void setFrameColor_Widget (iWidget *, int frameColor); | |||
181 | void setCommandHandler_Widget (iWidget *, iBool (*handler)(iWidget *, const char *)); | 178 | void setCommandHandler_Widget (iWidget *, iBool (*handler)(iWidget *, const char *)); |
182 | iAny * addChild_Widget (iWidget *, iAnyObject *child); /* holds a ref */ | 179 | iAny * addChild_Widget (iWidget *, iAnyObject *child); /* holds a ref */ |
183 | iAny * addChildPos_Widget (iWidget *, iAnyObject *child, enum iWidgetAddPos addPos); | 180 | iAny * addChildPos_Widget (iWidget *, iAnyObject *child, enum iWidgetAddPos addPos); |
184 | iAny * addChildFlags_Widget(iWidget *, iAnyObject *child, int childFlags); /* holds a ref */ | 181 | iAny * addChildFlags_Widget(iWidget *, iAnyObject *child, int64_t childFlags); /* holds a ref */ |
185 | iAny * removeChild_Widget (iWidget *, iAnyObject *child); /* returns a ref */ | 182 | iAny * removeChild_Widget (iWidget *, iAnyObject *child); /* returns a ref */ |
186 | iAny * child_Widget (iWidget *, size_t index); /* O(n) */ | 183 | iAny * child_Widget (iWidget *, size_t index); /* O(n) */ |
187 | size_t childIndex_Widget (const iWidget *, const iAnyObject *child); /* O(n) */ | 184 | size_t childIndex_Widget (const iWidget *, const iAnyObject *child); /* O(n) */ |