we don't need to relayout on each scroll

This commit is contained in:
hippoz 2023-04-26 23:41:18 +03:00
parent 7f7a6684e4
commit 2ca13c6334
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -1,5 +1,6 @@
#include "scrollable-node.h" #include "scrollable-node.h"
#include "node.h" #include "node.h"
#include "window.h"
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -42,7 +43,9 @@ int scrollable_handle(UINode *node, enum UIEvent ev, size_t d, void *p)
if (n->y_scroll > scroll_end) { if (n->y_scroll > scroll_end) {
n->y_scroll = scroll_end; n->y_scroll = scroll_end;
} }
node_request_relayout(n->node.parent); target->rect.x = n->x_scroll ? -n->x_scroll : 0;
target->rect.y = n->y_scroll ? -n->y_scroll : 0;
window_invalidate_node(node->window, node);
break; break;
} }
case UI_EVENT_RELAYOUT: { case UI_EVENT_RELAYOUT: {
@ -60,8 +63,6 @@ int scrollable_handle(UINode *node, enum UIEvent ev, size_t d, void *p)
} else if (target->height_policy == UI_SIZE_POLICY_GROW) { } else if (target->height_policy == UI_SIZE_POLICY_GROW) {
target->rect.h = node->parent->rect.h; 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;
node_dispatch(target, UI_EVENT_RELAYOUT, 0, NULL); node_dispatch(target, UI_EVENT_RELAYOUT, 0, NULL);
break; break;
} }