From 701c15fde13c1b124f8b3f49547388e6bcad080d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 16 Jan 2023 14:23:12 +0100 Subject: [PATCH] improve spacing --- code/foundation/src/gui/notifications.c | 6 +++--- code/foundation/src/gui/tooltip.c | 5 +++-- code/vendors/raylib-nuklear/include/nuklear.h | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/code/foundation/src/gui/notifications.c b/code/foundation/src/gui/notifications.c index 65f2160..a3b4ad4 100644 --- a/code/foundation/src/gui/notifications.c +++ b/code/foundation/src/gui/notifications.c @@ -46,8 +46,8 @@ void notification_draw(void) { for (zpl_isize i = cnt; i >= 0; --i) { notification *notif = (notifications + i); - if (nk_begin_titled(game_ui, zpl_bprintf("%dnotif%s", i, notif->title), notif->title, nk_rect(width - 220, ypos, 200, 120), - NK_WINDOW_BORDER | NK_WINDOW_TITLE)) { + if (nk_begin_titled(game_ui, zpl_bprintf("%dnotif%s", i, notif->title), notif->title, nk_rect(width - 220, ypos, 200, 1200), + NK_WINDOW_BORDER | NK_WINDOW_TITLE | NK_WINDOW_DYNAMIC)) { { nk_layout_row_dynamic(game_ui, 0, 1); nk_label_wrap(game_ui, notif->text); @@ -56,7 +56,7 @@ void notification_draw(void) { zpl_array_remove_at(notifications, i); } } - ypos += nk_window_get_height(game_ui) + 5; + ypos += nk_window_get_panel(game_ui)->row.height + 80; nk_end(game_ui); } diff --git a/code/foundation/src/gui/tooltip.c b/code/foundation/src/gui/tooltip.c index 4296a50..7c2177b 100644 --- a/code/foundation/src/gui/tooltip.c +++ b/code/foundation/src/gui/tooltip.c @@ -145,7 +145,7 @@ void tooltip__draw_node(tooltip_node *node) { tooltip *desc = node->desc; Vector2 mpos = GetMousePosition(); - if (nk_begin_titled(game_ui, zpl_bprintf("%d%s", (int)node->xpos, desc->name), desc->name, nk_rect(node->xpos, node->ypos, 400, 3200), + if (nk_begin_titled(game_ui, zpl_bprintf("%d%s", (int)node->xpos, desc->name), desc->name, nk_rect(node->xpos, node->ypos, 300, 3200), NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_DYNAMIC | NK_WINDOW_TITLE | NK_WINDOW_MOVABLE)) { tooltip_draw_contents(desc); @@ -171,7 +171,8 @@ void tooltip__draw_node(tooltip_node *node) { // suggest closing tooltip struct nk_vec2 wpos = nk_window_get_position(game_ui); struct nk_vec2 wsize = nk_window_get_content_region_size(game_ui); - Vector2 tp_pos = (Vector2) { .x = wpos.x + wsize.x/2.0f, .y = wpos.y }; + struct nk_panel *wpanel = nk_window_get_panel(game_ui); + Vector2 tp_pos = (Vector2) { .x = wpos.x + wsize.x/2.0f, .y = wpos.y + wpanel->row.height / 2.0f }; if (Vector2Distance(mpos, tp_pos) <= TOOLTIP_MOUSE_DIST) { tooltip__should_stay_open = true; } diff --git a/code/vendors/raylib-nuklear/include/nuklear.h b/code/vendors/raylib-nuklear/include/nuklear.h index febee39..aa6bac6 100644 --- a/code/vendors/raylib-nuklear/include/nuklear.h +++ b/code/vendors/raylib-nuklear/include/nuklear.h @@ -19638,6 +19638,11 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan /* draw header background */ header.h += 1.0f; + /* fix the small gap seen when we use dynamic windows with title */ + if (win->flags & NK_WINDOW_DYNAMIC) { + header.h += 5.0f; + } + switch(background->type) { case NK_STYLE_ITEM_IMAGE: text.background = nk_rgba(0,0,0,0);