diff options
Diffstat (limited to 'src/ui/widget.c')
-rw-r--r-- | src/ui/widget.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c index 67ce1345..c1c920d2 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -54,6 +54,7 @@ void init_Widget(iWidget *d) { | |||
54 | d->flags = 0; | 54 | d->flags = 0; |
55 | d->rect = zero_Rect(); | 55 | d->rect = zero_Rect(); |
56 | d->minSize = zero_I2(); | 56 | d->minSize = zero_I2(); |
57 | d->sizeRef = NULL; | ||
57 | d->bgColor = none_ColorId; | 58 | d->bgColor = none_ColorId; |
58 | d->frameColor = none_ColorId; | 59 | d->frameColor = none_ColorId; |
59 | init_Anim(&d->visualOffset, 0.0f); | 60 | init_Anim(&d->visualOffset, 0.0f); |
@@ -329,6 +330,9 @@ static void setWidth_Widget_(iWidget *d, int width) { | |||
329 | 330 | ||
330 | static void setHeight_Widget_(iWidget *d, int height) { | 331 | static void setHeight_Widget_(iWidget *d, int height) { |
331 | iAssert(height >= 0); | 332 | iAssert(height >= 0); |
333 | if (d->sizeRef) { | ||
334 | return; /* height defined by another widget */ | ||
335 | } | ||
332 | TRACE(d, "attempt to set height to %d (current: %d, min height: %d)", height, d->rect.size.y, d->minSize.y); | 336 | TRACE(d, "attempt to set height to %d (current: %d, min height: %d)", height, d->rect.size.y, d->minSize.y); |
333 | height = iMax(height, d->minSize.y); | 337 | height = iMax(height, d->minSize.y); |
334 | if (~d->flags & fixedHeight_WidgetFlag) { //} || d->flags & collapse_WidgetFlag) { | 338 | if (~d->flags & fixedHeight_WidgetFlag) { //} || d->flags & collapse_WidgetFlag) { |
@@ -415,6 +419,10 @@ static void boundsOfChildren_Widget_(const iWidget *d, iRect *bounds_out) { | |||
415 | 419 | ||
416 | static void arrange_Widget_(iWidget *d) { | 420 | static void arrange_Widget_(iWidget *d) { |
417 | TRACE(d, "arranging..."); | 421 | TRACE(d, "arranging..."); |
422 | if (d->sizeRef) { | ||
423 | d->rect.size.y = height_Widget(d->sizeRef); | ||
424 | TRACE(d, "use referenced height: %d", d->rect.size.y); | ||
425 | } | ||
418 | if (d->flags & moveToParentLeftEdge_WidgetFlag) { | 426 | if (d->flags & moveToParentLeftEdge_WidgetFlag) { |
419 | d->rect.pos.x = d->padding[0]; /* FIXME: Shouldn't this be d->parent->padding[0]? */ | 427 | d->rect.pos.x = d->padding[0]; /* FIXME: Shouldn't this be d->parent->padding[0]? */ |
420 | TRACE(d, "move to parent left edge: %d", d->rect.pos.x); | 428 | TRACE(d, "move to parent left edge: %d", d->rect.pos.x); |
@@ -1035,6 +1043,7 @@ void drawBackground_Widget(const iWidget *d) { | |||
1035 | init_Paint(&p); | 1043 | init_Paint(&p); |
1036 | drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); | 1044 | drawSoftShadow_Paint(&p, bounds_Widget(d), 12 * gap_UI, black_ColorId, 30); |
1037 | } | 1045 | } |
1046 | |||
1038 | if (fadeBackground && ~d->flags & noFadeBackground_WidgetFlag) { | 1047 | if (fadeBackground && ~d->flags & noFadeBackground_WidgetFlag) { |
1039 | iPaint p; | 1048 | iPaint p; |
1040 | init_Paint(&p); | 1049 | init_Paint(&p); |
@@ -1131,10 +1140,10 @@ void drawChildren_Widget(const iWidget *d) { | |||
1131 | } | 1140 | } |
1132 | } | 1141 | } |
1133 | /* Root draws the on-top widgets on top of everything else. */ | 1142 | /* Root draws the on-top widgets on top of everything else. */ |
1134 | if (!d->parent) { | 1143 | if (d == d->root->widget) { |
1135 | iConstForEach(PtrArray, i, onTop_Root(d->root)) { | 1144 | iConstForEach(PtrArray, i, onTop_Root(d->root)) { |
1136 | const iWidget *top = *i.value; | 1145 | const iWidget *top = *i.value; |
1137 | draw_Widget(top); | 1146 | class_Widget(top)->draw(top); |
1138 | } | 1147 | } |
1139 | } | 1148 | } |
1140 | } | 1149 | } |