Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect widget LEFT state #559

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/nuklear_button.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ nk_button_behavior(nk_flags *state, struct nk_rect r,
#endif
}
}
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(i, r))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(i, r))
*state |= NK_WIDGET_STATE_LEFT;

if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(i, r))
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(i, r))
*state |= NK_WIDGET_STATE_LEFT;
}

return ret;
}
NK_LIB const struct nk_style_item*
Expand Down
13 changes: 9 additions & 4 deletions src/nuklear_color_picker.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,15 @@ nk_color_picker_behavior(nk_flags *state,
/* set color picker widget state */
if (nk_input_is_mouse_hovering_rect(in, *bounds))
*state = NK_WIDGET_STATE_HOVERED;
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, *bounds))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(in, *bounds))
*state |= NK_WIDGET_STATE_LEFT;

if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(in, *bounds)
RobLoach marked this conversation as resolved.
Show resolved Hide resolved
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(in, *bounds))
*state |= NK_WIDGET_STATE_LEFT;
}

return value_changed;
}
NK_LIB void
Expand Down
11 changes: 7 additions & 4 deletions src/nuklear_progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ nk_progress_behavior(nk_flags *state, struct nk_input *in,
}
}
/* set progressbar widget state */
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, r))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(in, r))
*state |= NK_WIDGET_STATE_LEFT;
if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(in, r))
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(in, r))
*state |= NK_WIDGET_STATE_LEFT;
}
return value;
}
NK_LIB void
Expand Down
11 changes: 7 additions & 4 deletions src/nuklear_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ nk_drag_behavior(nk_flags *state, const struct nk_input *in,
}
*state = NK_WIDGET_STATE_ACTIVE;
}
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, drag))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(in, drag))
*state |= NK_WIDGET_STATE_LEFT;
if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(in, drag))
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(in, drag))
*state |= NK_WIDGET_STATE_LEFT;
}
}
NK_LIB void
nk_property_behavior(nk_flags *ws, const struct nk_input *in,
Expand Down
11 changes: 7 additions & 4 deletions src/nuklear_scrollbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,13 @@ nk_scrollbar_behavior(nk_flags *state, struct nk_input *in,
if (o == NK_VERTICAL) scroll_offset = target - scroll->h;
}
}
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, *scroll))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(in, *scroll))
*state |= NK_WIDGET_STATE_LEFT;
if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(in, *scroll))
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(in, *scroll))
*state |= NK_WIDGET_STATE_LEFT;
}
return scroll_offset;
}
NK_LIB void
Expand Down
12 changes: 7 additions & 5 deletions src/nuklear_slider.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ nk_slider_behavior(nk_flags *state, struct nk_rect *logical_cursor,
/* slider widget state */
if (nk_input_is_mouse_hovering_rect(in, bounds))
*state = NK_WIDGET_STATE_HOVERED;
if (*state & NK_WIDGET_STATE_HOVER &&
!nk_input_is_mouse_prev_hovering_rect(in, bounds))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(in, bounds))
*state |= NK_WIDGET_STATE_LEFT;
if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(in, bounds))
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(in, bounds))
*state |= NK_WIDGET_STATE_LEFT;
}
return slider_value;
}
NK_LIB void
Expand Down
11 changes: 7 additions & 4 deletions src/nuklear_toggle.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ nk_toggle_behavior(const struct nk_input *in, struct nk_rect select,
*state = NK_WIDGET_STATE_ACTIVE;
active = !active;
}
if (*state & NK_WIDGET_STATE_HOVER && !nk_input_is_mouse_prev_hovering_rect(in, select))
*state |= NK_WIDGET_STATE_ENTERED;
else if (nk_input_is_mouse_prev_hovering_rect(in, select))
*state |= NK_WIDGET_STATE_LEFT;
if (*state & NK_WIDGET_STATE_HOVER) {
if (!nk_input_is_mouse_prev_hovering_rect(in, select))
*state |= NK_WIDGET_STATE_ENTERED;
} else {
if (nk_input_is_mouse_prev_hovering_rect(in, select))
*state |= NK_WIDGET_STATE_LEFT;
}
return active;
}
NK_LIB void
Expand Down