diff options
author | Marvin Borner | 2021-06-30 13:10:14 +0200 |
---|---|---|
committer | Marvin Borner | 2021-06-30 13:10:14 +0200 |
commit | 73a7db5b48eab615a0f6258e0196a1260a88cbbb (patch) | |
tree | 58e4aa589a2026e58ce5b313d736dc5f6cc1e1c2 | |
parent | 5a4eea5c6b39d221fe4828cb279c68c60bad8fae (diff) |
Fixed child location algorithm
-rw-r--r-- | apps/chess/main.c | 1 | ||||
-rw-r--r-- | libs/libgui/gui.c | 14 |
2 files changed, 6 insertions, 9 deletions
diff --git a/apps/chess/main.c b/apps/chess/main.c index d8c52c1..0270ec1 100644 --- a/apps/chess/main.c +++ b/apps/chess/main.c @@ -97,7 +97,6 @@ static void mouseclick(struct gui_event_mouse *event) selected = vec2(-1, -1); } else if (clicked_piece->piece) { - gui_widget_redraw(win, clicked_piece->widget); selected = clicked; } } diff --git a/libs/libgui/gui.c b/libs/libgui/gui.c index 144ead8..56457e8 100644 --- a/libs/libgui/gui.c +++ b/libs/libgui/gui.c @@ -115,13 +115,12 @@ static vec2 gui_layout_position(struct gui_widget *parent) while (iterator) { struct gui_widget *widget = iterator->data; - if (layout == GUI_HLAYOUT) { - pos.x += MAX(widget->bg.size.x, widget->fg.size.x) + parent->margin.x; - } else if (layout == GUI_VLAYOUT) { - pos.y += MAX(widget->bg.size.y, widget->fg.size.y) + parent->margin.y; - } else { + if (layout == GUI_HLAYOUT) + pos.x += widget->bg.size.x + parent->margin.x; + else if (layout == GUI_VLAYOUT) + pos.y += widget->bg.size.y + parent->margin.y; + else gui_error(EINVAL); - } iterator = iterator->next; } @@ -247,7 +246,6 @@ void gui_draw_line(u32 win_id, u32 widget_id, enum gui_layer layer, vec2 pos1, v * Widgets */ -// TODO: Fix child location algorithm static u8 gui_widget_child_at(struct gui_widget *widget, vec2 pos, struct gui_widget *buf) { if (!widget || !widget->children || !buf) @@ -263,7 +261,7 @@ static u8 gui_widget_child_at(struct gui_widget *widget, vec2 pos, struct gui_wi pos.y <= w->pos.y + w->bg.size.y) ret = w; - if (w->children->head && gui_widget_child_at(w, pos, &sub)) + if (w->children->head && gui_widget_child_at(w, vec2_sub(pos, w->pos), &sub)) ret = ⊂ iterator = iterator->next; } |