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.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 81853c2a..23891999 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -223,6 +223,9 @@ void setVisualOffset_Widget(iWidget *d, int value, uint32_t span, int animFlags)
223 setFlags_Widget(d, visualOffset_WidgetFlag, iTrue); 223 setFlags_Widget(d, visualOffset_WidgetFlag, iTrue);
224 if (span == 0) { 224 if (span == 0) {
225 init_Anim(&d->visualOffset, value); 225 init_Anim(&d->visualOffset, value);
226 if (value == 0) {
227 setFlags_Widget(d, visualOffset_WidgetFlag, iFalse); /* offset is being reset */
228 }
226 } 229 }
227 else { 230 else {
228 setValue_Anim(&d->visualOffset, value, span); 231 setValue_Anim(&d->visualOffset, value, span);
@@ -346,6 +349,9 @@ void arrange_Widget(iWidget *d) {
346 else if (d->flags & moveToParentRightEdge_WidgetFlag) { 349 else if (d->flags & moveToParentRightEdge_WidgetFlag) {
347 d->rect.pos.x = width_Rect(innerRect_Widget_(d->parent)) - width_Rect(d->rect); 350 d->rect.pos.x = width_Rect(innerRect_Widget_(d->parent)) - width_Rect(d->rect);
348 } 351 }
352 else if (d->flags & moveToParentBottomEdge_WidgetFlag) {
353 d->rect.pos.y = height_Rect(innerRect_Widget_(d->parent)) - height_Rect(d->rect);
354 }
349 else if (d->flags & centerHorizontal_WidgetFlag) { 355 else if (d->flags & centerHorizontal_WidgetFlag) {
350 centerHorizontal_Widget_(d); 356 centerHorizontal_Widget_(d);
351 } 357 }
@@ -455,8 +461,12 @@ void arrange_Widget(iWidget *d) {
455 iForEach(ObjectList, i, d->children) { 461 iForEach(ObjectList, i, d->children) {
456 iWidget *child = as_Widget(i.object); 462 iWidget *child = as_Widget(i.object);
457 if (isArranged_Widget_(child) && ~child->flags & parentCannotResize_WidgetFlag) { 463 if (isArranged_Widget_(child) && ~child->flags & parentCannotResize_WidgetFlag) {
458 if (dirs.x) setWidth_Widget_(child, child->flags & unpadded_WidgetFlag ? unpaddedChildSize.x : childSize.x); 464 if (dirs.x) {
459 if (dirs.y) setHeight_Widget_(child, child->flags & unpadded_WidgetFlag ? unpaddedChildSize.y : childSize.y); 465 setWidth_Widget_(child, child->flags & unpadded_WidgetFlag ? unpaddedChildSize.x : childSize.x);
466 }
467 if (dirs.y && ~child->flags & parentCannotResizeHeight_WidgetFlag) {
468 setHeight_Widget_(child, child->flags & unpadded_WidgetFlag ? unpaddedChildSize.y : childSize.y);
469 }
460 } 470 }
461 } 471 }
462 } 472 }
@@ -493,7 +503,8 @@ void arrange_Widget(iWidget *d) {
493 pos.y += child->rect.size.y; 503 pos.y += child->rect.size.y;
494 } 504 }
495 } 505 }
496 else if ((d->flags & resizeChildren_WidgetFlag) == resizeChildren_WidgetFlag) { 506 else if ((d->flags & resizeChildren_WidgetFlag) == resizeChildren_WidgetFlag &&
507 ~child->flags & moveToParentBottomEdge_WidgetFlag) {
497 child->rect.pos = pos; 508 child->rect.pos = pos;
498 } 509 }
499 else if (d->flags & resizeWidthOfChildren_WidgetFlag) { 510 else if (d->flags & resizeWidthOfChildren_WidgetFlag) {
@@ -522,7 +533,9 @@ void arrange_Widget(iWidget *d) {
522 iForEach(ObjectList, j, d->children) { 533 iForEach(ObjectList, j, d->children) {
523 iWidget *child = as_Widget(j.object); 534 iWidget *child = as_Widget(j.object);
524 if (child->flags & 535 if (child->flags &
525 (resizeToParentWidth_WidgetFlag | moveToParentLeftEdge_WidgetFlag | 536 (resizeToParentWidth_WidgetFlag |
537 moveToParentLeftEdge_WidgetFlag |
538 moveToParentBottomEdge_WidgetFlag |
526 moveToParentRightEdge_WidgetFlag)) { 539 moveToParentRightEdge_WidgetFlag)) {
527 arrange_Widget(child); 540 arrange_Widget(child);
528 } 541 }
@@ -542,6 +555,10 @@ void arrange_Widget(iWidget *d) {
542 } 555 }
543 } 556 }
544 } 557 }
558// if (d->flags & moveToParentBottomEdge_WidgetFlag) {
559// /* TODO: Fix this: not DRY. See beginning of method. */
560// d->rect.pos.y = height_Rect(innerRect_Widget_(d->parent)) - height_Rect(d->rect);
561// }
545 if (d->flags & centerHorizontal_WidgetFlag) { 562 if (d->flags & centerHorizontal_WidgetFlag) {
546 centerHorizontal_Widget_(d); 563 centerHorizontal_Widget_(d);
547 } 564 }
@@ -574,6 +591,14 @@ iRect bounds_Widget(const iWidget *d) {
574 return bounds; 591 return bounds;
575} 592}
576 593
594iRect boundsWithoutVisualOffset_Widget(const iWidget *d) {
595 iRect bounds = d->rect;
596 for (const iWidget *w = d->parent; w; w = w->parent) {
597 addv_I2(&bounds.pos, w->rect.pos);
598 }
599 return bounds;
600}
601
577iInt2 localCoord_Widget(const iWidget *d, iInt2 coord) { 602iInt2 localCoord_Widget(const iWidget *d, iInt2 coord) {
578 for (const iWidget *w = d; w; w = w->parent) { 603 for (const iWidget *w = d; w; w = w->parent) {
579 subv_I2(&coord, w->rect.pos); 604 subv_I2(&coord, w->rect.pos);