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.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 05bb62cc..cace9568 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -71,6 +71,7 @@ iDefineObjectConstruction(Widget)
71void init_Widget(iWidget *d) { 71void 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;
74 d->rect = zero_Rect(); 75 d->rect = zero_Rect();
75 d->bgColor = none_ColorId; 76 d->bgColor = none_ColorId;
76 d->frameColor = none_ColorId; 77 d->frameColor = none_ColorId;
@@ -135,6 +136,10 @@ void setFlags_Widget(iWidget *d, int flags, iBool set) {
135 } 136 }
136} 137}
137 138
139void setFlags2_Widget(iWidget *d, int flags2, iBool set) {
140 iChangeFlags(d->flags2, flags2, set);
141}
142
138void setPos_Widget(iWidget *d, iInt2 pos) { 143void setPos_Widget(iWidget *d, iInt2 pos) {
139 d->rect.pos = pos; 144 d->rect.pos = pos;
140 setFlags_Widget(d, fixedPosition_WidgetFlag, iTrue); 145 setFlags_Widget(d, fixedPosition_WidgetFlag, iTrue);
@@ -228,6 +233,13 @@ static size_t numArrangedChildren_Widget_(const iWidget *d) {
228 return count; 233 return count;
229} 234}
230 235
236static void centerHorizontal_Widget_(iWidget *d) {
237 d->rect.pos.x = ((d->parent ? width_Rect(innerRect_Widget_(d->parent))
238 : rootSize_Window(get_Window()).x) -
239 width_Rect(d->rect)) /
240 2;
241}
242
231void arrange_Widget(iWidget *d) { 243void arrange_Widget(iWidget *d) {
232 if (isCollapsed_Widget_(d)) { 244 if (isCollapsed_Widget_(d)) {
233 setFlags_Widget(d, wasCollapsed_WidgetFlag, iTrue); 245 setFlags_Widget(d, wasCollapsed_WidgetFlag, iTrue);
@@ -236,6 +248,9 @@ void arrange_Widget(iWidget *d) {
236 if (d->flags & moveToParentRightEdge_WidgetFlag) { 248 if (d->flags & moveToParentRightEdge_WidgetFlag) {
237 d->rect.pos.x = width_Rect(innerRect_Widget_(d->parent)) - width_Rect(d->rect); 249 d->rect.pos.x = width_Rect(innerRect_Widget_(d->parent)) - width_Rect(d->rect);
238 } 250 }
251 if (d->flags2 & centerHorizontal_WidgetFlag2) {
252 centerHorizontal_Widget_(d);
253 }
239 if (d->flags & resizeToParentWidth_WidgetFlag) { 254 if (d->flags & resizeToParentWidth_WidgetFlag) {
240 setWidth_Widget_(d, width_Rect(innerRect_Widget_(d->parent))); 255 setWidth_Widget_(d, width_Rect(innerRect_Widget_(d->parent)));
241 } 256 }
@@ -351,6 +366,9 @@ void arrange_Widget(iWidget *d) {
351 if (child->flags & fixedPosition_WidgetFlag) { 366 if (child->flags & fixedPosition_WidgetFlag) {
352 continue; 367 continue;
353 } 368 }
369 if (child->flags2 & centerHorizontal_WidgetFlag2) {
370 continue;
371 }
354 if (d->flags & (arrangeHorizontal_WidgetFlag | arrangeVertical_WidgetFlag)) { 372 if (d->flags & (arrangeHorizontal_WidgetFlag | arrangeVertical_WidgetFlag)) {
355 if (child->flags & moveToParentRightEdge_WidgetFlag) { 373 if (child->flags & moveToParentRightEdge_WidgetFlag) {
356 continue; /* Not part of the sequential arrangement .*/ 374 continue; /* Not part of the sequential arrangement .*/
@@ -401,6 +419,9 @@ void arrange_Widget(iWidget *d) {
401 } 419 }
402 } 420 }
403 } 421 }
422 if (d->flags2 & centerHorizontal_WidgetFlag2) {
423 centerHorizontal_Widget_(d);
424 }
404 } 425 }
405} 426}
406 427