Merge branch 'master' of github.com:Immediate-Mode-UI/Nuklear into horizontal_rule

This commit is contained in:
Rob Loach 2022-04-18 23:28:25 -04:00
commit 200032f0c2
No known key found for this signature in database
GPG Key ID: 627C60834A74A21A
4 changed files with 36 additions and 2 deletions

View File

@ -4667,6 +4667,9 @@ struct nk_mouse_button {
struct nk_mouse {
struct nk_mouse_button buttons[NK_BUTTON_MAX];
struct nk_vec2 pos;
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
struct nk_vec2 down_pos;
#endif
struct nk_vec2 prev;
struct nk_vec2 delta;
struct nk_vec2 scroll_delta;
@ -17894,6 +17897,13 @@ nk_input_button(struct nk_context *ctx, enum nk_buttons id, int x, int y, nk_boo
btn->clicked_pos.y = (float)y;
btn->down = down;
btn->clicked++;
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
if (down == 1 && id == NK_BUTTON_LEFT)
{
in->mouse.down_pos.x = btn->clicked_pos.x;
in->mouse.down_pos.y = btn->clicked_pos.y;
}
#endif
}
NK_API void
nk_input_scroll(struct nk_context *ctx, struct nk_vec2 val)
@ -17954,7 +17964,12 @@ nk_input_has_mouse_click_in_rect(const struct nk_input *i, enum nk_buttons id,
const struct nk_mouse_button *btn;
if (!i) return nk_false;
btn = &i->mouse.buttons[id];
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h)
|| !NK_INBOX(i->mouse.down_pos.x,i->mouse.down_pos.y,b.x,b.y,b.w,b.h))
#else
if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h))
#endif
return nk_false;
return nk_true;
}
@ -29651,7 +29666,9 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
/// - [y]: Minor version with non-breaking API and library changes
/// - [z]: Patch version with no direct changes to the API
///
/// - 2022/04/15 (4.9.7) - Added nk_rule_horizontal() widget
/// - 2022/04/19 (4.9.8) - Added nk_rule_horizontal() widget
/// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
/// only trigger when the mouse position was inside the same button on down
/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS
/// - 2021/12/22 (4.9.5) - Revert layout bounds not accounting for padding due to regressions
/// - 2021/12/22 (4.9.4) - Fix checking hovering when window is minimized

View File

@ -7,7 +7,9 @@
/// - [y]: Minor version with non-breaking API and library changes
/// - [z]: Patch version with no direct changes to the API
///
/// - 2022/04/15 (4.9.7) - Added nk_rule_horizontal() widget
/// - 2022/04/19 (4.9.8) - Added nk_rule_horizontal() widget
/// - 2022/04/18 (4.9.7) - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
/// only trigger when the mouse position was inside the same button on down
/// - 2022/02/03 (4.9.6) - Allow overriding the NK_INV_SQRT function, similar to NK_SIN and NK_COS
/// - 2021/12/22 (4.9.5) - Revert layout bounds not accounting for padding due to regressions
/// - 2021/12/22 (4.9.4) - Fix checking hovering when window is minimized

View File

@ -4446,6 +4446,9 @@ struct nk_mouse_button {
struct nk_mouse {
struct nk_mouse_button buttons[NK_BUTTON_MAX];
struct nk_vec2 pos;
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
struct nk_vec2 down_pos;
#endif
struct nk_vec2 prev;
struct nk_vec2 delta;
struct nk_vec2 scroll_delta;

View File

@ -83,6 +83,13 @@ nk_input_button(struct nk_context *ctx, enum nk_buttons id, int x, int y, nk_boo
btn->clicked_pos.y = (float)y;
btn->down = down;
btn->clicked++;
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
if (down == 1 && id == NK_BUTTON_LEFT)
{
in->mouse.down_pos.x = btn->clicked_pos.x;
in->mouse.down_pos.y = btn->clicked_pos.y;
}
#endif
}
NK_API void
nk_input_scroll(struct nk_context *ctx, struct nk_vec2 val)
@ -143,7 +150,12 @@ nk_input_has_mouse_click_in_rect(const struct nk_input *i, enum nk_buttons id,
const struct nk_mouse_button *btn;
if (!i) return nk_false;
btn = &i->mouse.buttons[id];
#ifdef NK_BUTTON_TRIGGER_ON_RELEASE
if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h)
|| !NK_INBOX(i->mouse.down_pos.x,i->mouse.down_pos.y,b.x,b.y,b.w,b.h))
#else
if (!NK_INBOX(btn->clicked_pos.x,btn->clicked_pos.y,b.x,b.y,b.w,b.h))
#endif
return nk_false;
return nk_true;
}