Skip to content

Commit

Permalink
gui: don't accept clicks outside modal dialogs. fixes #140
Browse files Browse the repository at this point in the history
  • Loading branch information
hanatos committed Oct 6, 2024
1 parent 84e48df commit cc7536f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/gui/render_darkroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void render_darkroom()
struct nk_context *ctx = &vkdt.ctx;
const float row_height = ctx->style.font->height + 2 * ctx->style.tab.padding.y;
bounds = (struct nk_rect){ vkdt.win.width - vkdt.state.panel_wd, 0, vkdt.state.panel_wd, vkdt.state.panel_ht };
if(!vkdt.wstate.fullscreen_view && nk_begin(ctx, "darkroom panel right", bounds, 0))
if(!vkdt.wstate.fullscreen_view && nk_begin(ctx, "darkroom panel right", bounds, (disabled ? NK_WINDOW_NO_INPUT : 0)))
{ // right panel
// draw histogram image:
const int display_frame = vkdt.graph_dev.double_buffer % 2;
Expand Down
10 changes: 6 additions & 4 deletions src/gui/render_nodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ gui_nodes_t nodes;

void render_nodes_right_panel()
{
const int disabled = vkdt.wstate.popup;
struct nk_context *ctx = &vkdt.ctx;
struct nk_rect bounds = { vkdt.win.width - vkdt.state.panel_wd, 0, vkdt.state.panel_wd, vkdt.state.panel_ht };
if(!nk_begin(ctx, "nodes panel", bounds, 0))
if(!nk_begin(ctx, "nodes panel", bounds, disabled ? NK_WINDOW_NO_INPUT : 0))
{
NK_UPDATE_ACTIVE;
nk_end(ctx);
Expand Down Expand Up @@ -78,7 +79,7 @@ void render_nodes_right_panel()
struct nk_rect bounds = {0, 0, vkdt.win1.width, vkdt.win1.height};
wd = vkdt.win1.width;
nk_style_push_style_item(ctx, &ctx->style.window.fixed_background, nk_style_item_color(vkdt.style.colour[NK_COLOR_DT_BACKGROUND]));
if(!nk_begin(ctx, "vkdt secondary", bounds, NK_WINDOW_NO_SCROLLBAR))
if(!nk_begin(ctx, "vkdt secondary", bounds, NK_WINDOW_NO_SCROLLBAR | (disabled ? NK_WINDOW_NO_INPUT : 0)))
visible = 0;
}
if(visible)
Expand Down Expand Up @@ -137,6 +138,7 @@ void render_nodes_right_panel()

void render_nodes()
{
const int disabled = vkdt.wstate.popup;
struct nk_context *ctx = &vkdt.ctx;
int num_modules = vkdt.graph_dev.num_modules;
render_darkroom_modals(); // comes first so we can add a module popup from the context menu
Expand All @@ -150,7 +152,7 @@ void render_nodes()
}
struct nk_rect bounds = { vkdt.state.center_x, vkdt.state.center_y, vkdt.state.center_wd, vkdt.state.center_ht };
nk_style_push_style_item(&vkdt.ctx, &vkdt.ctx.style.window.fixed_background, nk_style_item_color(vkdt.style.colour[NK_COLOR_DT_BACKGROUND]));
if(!nk_begin(ctx, "nodes center", bounds, NK_WINDOW_NO_SCROLLBAR))
if(!nk_begin(ctx, "nodes center", bounds, NK_WINDOW_NO_SCROLLBAR | (disabled ? NK_WINDOW_NO_INPUT : 0)))
{
nk_style_pop_style_item(&vkdt.ctx);
NK_UPDATE_ACTIVE;
Expand Down Expand Up @@ -225,7 +227,7 @@ void render_nodes()
0.6*vkdt.state.center_wd, 0.6*vkdt.state.center_ht);
if(vkdt.wstate.popup == s_popup_edit_hotkeys)
{
if(nk_begin(&vkdt.ctx, "edit nodes hotkeys", bounds, NK_WINDOW_NO_SCROLLBAR))
if(nk_begin(&vkdt.ctx, "edit nodes hotkeys", bounds, NK_WINDOW_NO_SCROLLBAR | (disabled ? NK_WINDOW_NO_INPUT : 0)))
{
int ok = hk_edit(hk_nodes, NK_LEN(hk_nodes));
if(ok) vkdt.wstate.popup = 0;
Expand Down

0 comments on commit cc7536f

Please sign in to comment.