summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/widget.c35
-rw-r--r--src/ui/widget.h1
2 files changed, 34 insertions, 2 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index bbd5f465..b07b5709 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -155,7 +155,16 @@ static void setHeight_Widget_(iWidget *d, int height) {
155 } 155 }
156} 156}
157 157
158iLocalDef iBool isCollapsed_Widget_(const iWidget *d) {
159 return (d->flags & (hidden_WidgetFlag | collapse_WidgetFlag)) ==
160 (hidden_WidgetFlag | collapse_WidgetFlag);
161}
162
158void arrange_Widget(iWidget *d) { 163void arrange_Widget(iWidget *d) {
164 if (isCollapsed_Widget_(d)) {
165 setFlags_Widget(d, wasCollapsed_WidgetFlag, iTrue);
166 return;
167 }
159 if (d->flags & moveToParentRightEdge_WidgetFlag) { 168 if (d->flags & moveToParentRightEdge_WidgetFlag) {
160 d->rect.pos.x = width_Rect(d->parent->rect) - width_Rect(d->rect); 169 d->rect.pos.x = width_Rect(d->parent->rect) - width_Rect(d->rect);
161 } 170 }
@@ -172,6 +181,25 @@ void arrange_Widget(iWidget *d) {
172 /* Resize children to fill the parent widget. */ 181 /* Resize children to fill the parent widget. */
173 const size_t childCount = size_ObjectList(d->children); 182 const size_t childCount = size_ObjectList(d->children);
174 if (d->flags & resizeChildren_WidgetFlag) { 183 if (d->flags & resizeChildren_WidgetFlag) {
184 /* Collapse hidden children. */
185 iForEach(ObjectList, c, d->children) {
186 iWidget *child = as_Widget(c.object);
187 if (isCollapsed_Widget_(child)) {
188 if (d->flags & arrangeHorizontal_WidgetFlag) {
189 setWidth_Widget_(child, 0);
190 }
191 if (d->flags & arrangeVertical_WidgetFlag) {
192 setHeight_Widget_(child, 0);
193 }
194 }
195 else if (child->flags & wasCollapsed_WidgetFlag) {
196 setFlags_Widget(child, wasCollapsed_WidgetFlag, iFalse);
197 /* Undo collapse and determine the normal size again. */
198 if (child->flags & arrangeSize_WidgetFlag) {
199 arrange_Widget(child);
200 }
201 }
202 }
175 const int expCount = numExpandingChildren_Widget_(d); 203 const int expCount = numExpandingChildren_Widget_(d);
176 /* Only resize the expanding children, not touching the others. */ 204 /* Only resize the expanding children, not touching the others. */
177 if (expCount > 0) { 205 if (expCount > 0) {
@@ -185,6 +213,7 @@ void arrange_Widget(iWidget *d) {
185 avail = divi_I2(avail, expCount); 213 avail = divi_I2(avail, expCount);
186 iForEach(ObjectList, j, d->children) { 214 iForEach(ObjectList, j, d->children) {
187 iWidget *child = as_Widget(j.object); 215 iWidget *child = as_Widget(j.object);
216 if (isCollapsed_Widget_(child)) continue;
188 if (child->flags & expand_WidgetFlag) { 217 if (child->flags & expand_WidgetFlag) {
189 if (d->flags & arrangeHorizontal_WidgetFlag) { 218 if (d->flags & arrangeHorizontal_WidgetFlag) {
190 setWidth_Widget_(child, avail.x); 219 setWidth_Widget_(child, avail.x);
@@ -217,8 +246,10 @@ void arrange_Widget(iWidget *d) {
217 } 246 }
218 iForEach(ObjectList, i, d->children) { 247 iForEach(ObjectList, i, d->children) {
219 iWidget *child = as_Widget(i.object); 248 iWidget *child = as_Widget(i.object);
220 setWidth_Widget_(child, childSize.x); 249 if (!isCollapsed_Widget_(child)) {
221 setHeight_Widget_(child, childSize.y); 250 setWidth_Widget_(child, childSize.x);
251 setHeight_Widget_(child, childSize.y);
252 }
222 } 253 }
223 } 254 }
224 } 255 }
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 6b8545c3..10e24678 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -48,6 +48,7 @@ enum iWidgetFlag {
48 resizeToParentHeight_WidgetFlag = iBit(27), 48 resizeToParentHeight_WidgetFlag = iBit(27),
49 moveToParentRightEdge_WidgetFlag = iBit(28), 49 moveToParentRightEdge_WidgetFlag = iBit(28),
50 collapse_WidgetFlag = iBit(29), /* when hidden, arrange size to zero */ 50 collapse_WidgetFlag = iBit(29), /* when hidden, arrange size to zero */
51 wasCollapsed_WidgetFlag = iBit(30),
51}; 52};
52 53
53enum iWidgetAddPos { 54enum iWidgetAddPos {