From 996d6fb5201c104f75dc55d5c79bb99ad73859d2 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Tue, 25 Apr 2023 15:11:05 +0300 Subject: [PATCH] add a bunch of buttons to the test application for testing performance --- src/main.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/main.c b/src/main.c index 0361a13..db5c41a 100644 --- a/src/main.c +++ b/src/main.c @@ -116,6 +116,29 @@ 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: {