Compare commits
No commits in common. "996d6fb5201c104f75dc55d5c79bb99ad73859d2" and "d8601f23f522ed552055bf5a3f6905fe0342fce1" have entirely different histories.
996d6fb520
...
d8601f23f5
3 changed files with 6 additions and 31 deletions
23
src/main.c
23
src/main.c
|
@ -116,29 +116,6 @@ int app_handle(struct UINode *node, void *data, int event_type, size_t d, void *
|
|||
text_input->text_node = text_node_new(&text_input->node, state->font, UINeutral50, NULL);
|
||||
}
|
||||
|
||||
/* a bunch of buttons */
|
||||
{
|
||||
UINode *scroll_container = node_new(node, "buttons_scroll_container");
|
||||
scroll_container->width_policy = UI_SIZE_POLICY_GROW;
|
||||
scroll_container->height_policy = UI_SIZE_POLICY_GROW;
|
||||
|
||||
UIScrollableNode *scroll = scrollable_new(scroll_container, NULL);
|
||||
UINode *buttons = node_new(scroll_container, "buttons");
|
||||
buttons->width_policy = UI_SIZE_POLICY_GROW;
|
||||
buttons->height_policy = UI_SIZE_POLICY_DYNAMIC;
|
||||
scroll->target = buttons;
|
||||
|
||||
box_layout_new(buttons, UI_DIRECTION_VERTICAL);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
UINode *button = node_new(buttons, "button");
|
||||
state_background_node_new(button, UIPurple600, UIPurple700, UIPurple800, 6.0);
|
||||
text_node_new(button, state->font, UINeutral50, "button");
|
||||
dispatcher_new(button, UI_EVENT_UNPRESSED, INCREMENT_COUNT, state, app_handle);
|
||||
button->width_policy = UI_SIZE_POLICY_GROW;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SIDEBAR_BEGIN_ANIMATE: {
|
||||
|
|
|
@ -48,8 +48,10 @@ UINode *node_by_point(UINode *root, double x, double y)
|
|||
{
|
||||
for (int i = 0; i < root->nodes_count; i++) {
|
||||
UINode *node = root->nodes[i];
|
||||
if (ui_rect_contains_point(&node->rect, x - node->window_rel_x, y - node->window_rel_y) && !(node->flags & UI_NODE_DISABLED)) {
|
||||
return node_by_point(node, x, y);
|
||||
double local_x = x - node->window_rel_x;
|
||||
double local_y = y - node->window_rel_y;
|
||||
if (ui_rect_contains_point(&node->rect, local_x, local_y) && !(node->flags & UI_NODE_DISABLED)) {
|
||||
return node_by_point(node, local_x, local_y);
|
||||
}
|
||||
}
|
||||
return root;
|
||||
|
|
|
@ -51,17 +51,13 @@ 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 ? -n->x_scroll : 0;
|
||||
target->rect.y = n->y_scroll ? -n->y_scroll : 0;
|
||||
target->rect.x = -n->x_scroll;
|
||||
target->rect.y = -n->y_scroll;
|
||||
node_dispatch(target, UI_EVENT_RELAYOUT, 0, NULL);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue