Change popup toggling semantics

For gui elements like tree tabs, tree nodes and windows themselves,
you can repeatedly click the same "minimize" region and it keeps
toggling that element. This was not the case with "popup" type of
elements. This commit slightly changes how the popups close once
they are already open.

Like before, the user can close the popup by just clicking outside
the popups region. Now the user can also close the popup by clicking
the "header" region of the popup.
This commit is contained in:
Vinh Truong 2016-07-10 10:14:29 +03:00
parent 507a264f91
commit 383d0f94bd

View File

@ -18639,13 +18639,13 @@ nk_nonblock_begin(struct nk_panel *layout, struct nk_context *ctx,
win->popup.win = popup; win->popup.win = popup;
nk_command_buffer_init(&popup->buffer, &ctx->memory, NK_CLIPPING_ON); nk_command_buffer_init(&popup->buffer, &ctx->memory, NK_CLIPPING_ON);
} else { } else {
/* check if user clicked outside the popup and close if so */ /* close the popup if user pressed outside or in the header */
int clicked, in_body, in_header; int pressed, in_body, in_header;
clicked = nk_input_has_mouse_click(&ctx->input, NK_BUTTON_LEFT); pressed = nk_input_is_mouse_pressed(&ctx->input, NK_BUTTON_LEFT);
in_body = nk_input_is_mouse_click_in_rect(&ctx->input, NK_BUTTON_LEFT, body); in_body = nk_input_is_mouse_hovering_rect(&ctx->input, body);
in_header = nk_input_is_mouse_click_in_rect(&ctx->input, NK_BUTTON_LEFT, header); in_header = nk_input_is_mouse_hovering_rect(&ctx->input, header);
if (clicked && !in_body && !in_header) if (pressed && (!in_body || in_header))
is_active = nk_false; is_active = nk_false;
} }