improve spacing

efd/v1
Dominik Madarász 2023-01-16 14:23:12 +01:00
parent 82a8bbdaf8
commit 701c15fde1
3 changed files with 11 additions and 5 deletions

View File

@ -46,8 +46,8 @@ void notification_draw(void) {
for (zpl_isize i = cnt; i >= 0; --i) { for (zpl_isize i = cnt; i >= 0; --i) {
notification *notif = (notifications + 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), 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_BORDER | NK_WINDOW_TITLE | NK_WINDOW_DYNAMIC)) {
{ {
nk_layout_row_dynamic(game_ui, 0, 1); nk_layout_row_dynamic(game_ui, 0, 1);
nk_label_wrap(game_ui, notif->text); nk_label_wrap(game_ui, notif->text);
@ -56,7 +56,7 @@ void notification_draw(void) {
zpl_array_remove_at(notifications, i); 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); nk_end(game_ui);
} }

View File

@ -145,7 +145,7 @@ void tooltip__draw_node(tooltip_node *node) {
tooltip *desc = node->desc; tooltip *desc = node->desc;
Vector2 mpos = GetMousePosition(); 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)) { NK_WINDOW_BORDER | NK_WINDOW_NO_SCROLLBAR | NK_WINDOW_DYNAMIC | NK_WINDOW_TITLE | NK_WINDOW_MOVABLE)) {
tooltip_draw_contents(desc); tooltip_draw_contents(desc);
@ -171,7 +171,8 @@ void tooltip__draw_node(tooltip_node *node) {
// suggest closing tooltip // suggest closing tooltip
struct nk_vec2 wpos = nk_window_get_position(game_ui); struct nk_vec2 wpos = nk_window_get_position(game_ui);
struct nk_vec2 wsize = nk_window_get_content_region_size(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) { if (Vector2Distance(mpos, tp_pos) <= TOOLTIP_MOUSE_DIST) {
tooltip__should_stay_open = true; tooltip__should_stay_open = true;
} }

View File

@ -19638,6 +19638,11 @@ nk_panel_begin(struct nk_context *ctx, const char *title, enum nk_panel_type pan
/* draw header background */ /* draw header background */
header.h += 1.0f; 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) { switch(background->type) {
case NK_STYLE_ITEM_IMAGE: case NK_STYLE_ITEM_IMAGE:
text.background = nk_rgba(0,0,0,0); text.background = nk_rgba(0,0,0,0);