Compare commits
3 Commits
master
...
nk_input_i
Author | SHA1 | Date | |
---|---|---|---|
|
ce04e74550 | ||
|
4dab13fa6f | ||
|
533ed01948 |
11
nuklear.h
11
nuklear.h
@ -4747,6 +4747,7 @@ NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, en
|
||||
NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
|
||||
NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
|
||||
NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
|
||||
@ -18166,6 +18167,12 @@ nk_input_is_mouse_released(const struct nk_input *i, enum nk_buttons id)
|
||||
return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked);
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_input_is_mouse_moved(const struct nk_input *i)
|
||||
{
|
||||
if (!i) return nk_false;
|
||||
return i->mouse.delta.x != 0 || i->mouse.delta.y != 0;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key)
|
||||
{
|
||||
const struct nk_key *k;
|
||||
@ -20084,7 +20091,7 @@ nk_panel_end(struct nk_context *ctx)
|
||||
|
||||
/* hide scroll if no user input */
|
||||
if (window->flags & NK_WINDOW_SCROLL_AUTO_HIDE) {
|
||||
int has_input = ctx->input.mouse.delta.x != 0 || ctx->input.mouse.delta.y != 0 || ctx->input.mouse.scroll_delta.y != 0;
|
||||
int has_input = nk_input_is_mouse_moved(&ctx->input) || ctx->input.mouse.scroll_delta.y != 0;
|
||||
int is_window_hovered = nk_window_is_hovered(ctx);
|
||||
int any_item_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED);
|
||||
if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
|
||||
@ -27492,7 +27499,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
|
||||
in->mouse.buttons[NK_BUTTON_LEFT].clicked) {
|
||||
nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
|
||||
} else if (is_hovered && in->mouse.buttons[NK_BUTTON_LEFT].down &&
|
||||
(in->mouse.delta.x != 0.0f || in->mouse.delta.y != 0.0f)) {
|
||||
nk_input_is_mouse_moved(in)) {
|
||||
nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
|
||||
cursor_follow = nk_true;
|
||||
} else if (is_hovered && in->mouse.buttons[NK_BUTTON_RIGHT].clicked &&
|
||||
|
@ -4525,6 +4525,7 @@ NK_API nk_bool nk_input_is_mouse_click_down_in_rect(const struct nk_input *i, en
|
||||
NK_API nk_bool nk_input_any_mouse_click_in_rect(const struct nk_input*, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_prev_hovering_rect(const struct nk_input*, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_hovering_rect(const struct nk_input*, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_moved(const struct nk_input*);
|
||||
NK_API nk_bool nk_input_mouse_clicked(const struct nk_input*, enum nk_buttons, struct nk_rect);
|
||||
NK_API nk_bool nk_input_is_mouse_down(const struct nk_input*, enum nk_buttons);
|
||||
NK_API nk_bool nk_input_is_mouse_pressed(const struct nk_input*, enum nk_buttons);
|
||||
|
@ -233,7 +233,7 @@ nk_do_edit(nk_flags *state, struct nk_command_buffer *out,
|
||||
in->mouse.buttons[NK_BUTTON_LEFT].clicked) {
|
||||
nk_textedit_click(edit, mouse_x, mouse_y, font, row_height);
|
||||
} else if (is_hovered && in->mouse.buttons[NK_BUTTON_LEFT].down &&
|
||||
(in->mouse.delta.x != 0.0f || in->mouse.delta.y != 0.0f)) {
|
||||
nk_input_is_mouse_moved(in)) {
|
||||
nk_textedit_drag(edit, mouse_x, mouse_y, font, row_height);
|
||||
cursor_follow = nk_true;
|
||||
} else if (is_hovered && in->mouse.buttons[NK_BUTTON_RIGHT].clicked &&
|
||||
|
@ -253,6 +253,12 @@ nk_input_is_mouse_released(const struct nk_input *i, enum nk_buttons id)
|
||||
return (!i->mouse.buttons[id].down && i->mouse.buttons[id].clicked);
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_input_is_mouse_moved(const struct nk_input *i)
|
||||
{
|
||||
if (!i) return nk_false;
|
||||
return i->mouse.delta.x != 0 || i->mouse.delta.y != 0;
|
||||
}
|
||||
NK_API nk_bool
|
||||
nk_input_is_key_pressed(const struct nk_input *i, enum nk_keys key)
|
||||
{
|
||||
const struct nk_key *k;
|
||||
|
@ -486,7 +486,7 @@ nk_panel_end(struct nk_context *ctx)
|
||||
|
||||
/* hide scroll if no user input */
|
||||
if (window->flags & NK_WINDOW_SCROLL_AUTO_HIDE) {
|
||||
int has_input = ctx->input.mouse.delta.x != 0 || ctx->input.mouse.delta.y != 0 || ctx->input.mouse.scroll_delta.y != 0;
|
||||
int has_input = nk_input_is_mouse_moved(&ctx->input) || ctx->input.mouse.scroll_delta.y != 0;
|
||||
int is_window_hovered = nk_window_is_hovered(ctx);
|
||||
int any_item_active = (ctx->last_widget_state & NK_WIDGET_STATE_MODIFIED);
|
||||
if ((!has_input && is_window_hovered) || (!is_window_hovered && !any_item_active))
|
||||
|
Loading…
Reference in New Issue
Block a user