diff options
author | Marvin Borner | 2020-12-02 22:30:31 +0100 |
---|---|---|
committer | Marvin Borner | 2020-12-02 22:33:55 +0100 |
commit | d525526f52c76156c4b9ee5ee4f14ed0d06547bc (patch) | |
tree | 36d127f82a658c9406116627fc70ae328ab3414f | |
parent | a80021fa96b07d4ae26d9f85099f4bce09a8f5b3 (diff) |
More window resizing..
Almost kinda works now
-rw-r--r-- | libgui/gui.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/libgui/gui.c b/libgui/gui.c index a38dd85..8494221 100644 --- a/libgui/gui.c +++ b/libgui/gui.c @@ -284,7 +284,7 @@ void gui_sync_container(struct element *elem) // TODO: Handle container flags } -void gui_sync(struct element *elem) +void gui_only_sync(struct element *elem) { switch (elem->type) { case GUI_TYPE_BUTTON: @@ -305,11 +305,46 @@ void gui_sync(struct element *elem) default: break; } +} +void gui_sync(struct element *elem) +{ + gui_only_sync(elem); merge_elements(get_root(elem->window_id)); gfx_redraw_focused(); } +void gui_sync_recursive(struct element *container) +{ + if (!container || !container->childs || !container->childs->head) + return; + + struct node *iterator = container->childs->head; + while (iterator != NULL) { + gui_only_sync(iterator->data); + gui_sync_recursive(iterator->data); + iterator = iterator->next; + } +} + +void gui_sync_window(u32 window_id) +{ + struct element *root = get_root(window_id); + + if (!root || !root->childs || !root->childs->head) + return; + + struct node *iterator = root->childs->head; + while (iterator != NULL) { + gui_only_sync(iterator->data); + gui_sync_recursive(iterator->data); + iterator = iterator->next; + } + + merge_elements(root); + gfx_redraw_focused(); +} + struct element *gui_add_button(struct element *container, int x, int y, enum font_type font_type, const char *text, u32 color_bg, u32 color_fg) { @@ -524,9 +559,7 @@ void gui_event_loop(struct element *container) struct gui_event_resize *event = msg->data; struct element *root = get_root(container->window_id); root->ctx = event->new_ctx; - gui_sync_container(container); - merge_elements(root); - gfx_redraw_focused(); + gui_sync_window(container->window_id); break; } } |