From 338e3f2d588cec5570cb4360e0010a2bf678cd78 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Tue, 25 Apr 2023 15:10:27 +0300 Subject: [PATCH] support growing target for scrollable node --- src/scrollable-node.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/scrollable-node.c b/src/scrollable-node.c index adab202..b3f9c56 100644 --- a/src/scrollable-node.c +++ b/src/scrollable-node.c @@ -51,13 +51,17 @@ int scrollable_handle(UINode *node, enum UIEvent ev, size_t d, void *p) if (target->width_policy == UI_SIZE_POLICY_DYNAMIC) { node_dispatch(target, UI_EVENT_GET_WIDTH, 0, &w); target->rect.w = w; + } else if (target->width_policy == UI_SIZE_POLICY_GROW) { + target->rect.w = node->parent->rect.w; } if (target->height_policy == UI_SIZE_POLICY_DYNAMIC) { node_dispatch(target, UI_EVENT_GET_HEIGHT, 0, &h); target->rect.h = h; + } else if (target->height_policy == UI_SIZE_POLICY_GROW) { + target->rect.h = node->parent->rect.h; } - target->rect.x = -n->x_scroll; - target->rect.y = -n->y_scroll; + target->rect.x = n->x_scroll ? -n->x_scroll : 0; + target->rect.y = n->y_scroll ? -n->y_scroll : 0; node_dispatch(target, UI_EVENT_RELAYOUT, 0, NULL); break; }