support growing target for scrollable node

This commit is contained in:
hippoz 2023-04-25 15:10:27 +03:00
parent d8601f23f5
commit 338e3f2d58
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -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;
}