Make slider behave like progress bar#802
Make slider behave like progress bar#802aganm wants to merge 1 commit intoImmediate-Mode-UI:masterfrom
Conversation
RobLoach
left a comment
There was a problem hiding this comment.
Thanks for the updates. Looks pretty good to me, I'll leave this open for a couple others to review.
|
i fully support this PR. I think it is a wonderful addition; but the implementation of new behavior leaves me with a question for @RobLoach . In my head, a progress bar is a visual output only. a status indicator. user input would have no place in a progress bar. Yet, we see with this PR that the update is for the slider bar to call the Why does the progress bar have user input? I find this very confusing. What makes a progress bar different than a slider if they both support input? I haven't made a progress bar using this framework yet... how do i disable the user input for the progress bar? |
|
To make it even more fluid you may consider adding this line to rn, slider will work as this. Imagine slider with 3 values, 0, 1, and 2. When you move the mouse, value will change to 1, when mouse is at 50% of slider, 49% and value will go back down to 0. This is not how most sliders seem to be work. With this one line, value will jump to 1, at 25% of mouse, and will go back down at 24%. I hope you get what I mean. Values will change in the middle between values, which I - personally - find to be more natural way to operate slider. |
|
This how slider will feel with that change: https://jsfiddle.net/guf6t9jy |
|
Did some digging, and it appears OPs behavior can be done in This also fixes some of the bad behavior with slider based on progress bar when |
|
Would recommend updating PR to use the slider behavior instead of progress bar for consistency. |
|
Thanks to mlyszczek the perfect slider is almost there... but - left_mouse_click_in_cursor = in && nk_input_has_mouse_click_down_in_rect(in,
- NK_BUTTON_LEFT, *visual_cursor, nk_true);
+ left_mouse_click_in_cursor = in && (
+ nk_input_has_mouse_click_down_in_rect(in, NK_BUTTON_LEFT, *visual_cursor, nk_true)
+ || nk_input_has_mouse_click_down_in_rect(in, NK_BUTTON_LEFT, bounds, nk_true)); |
I thought that the slider widget was very annoying to use because you have to put your mouse exactly on the knob to drag it along the axis of the widget:
A much smoother behavior is the one of the progress bar, where you can click anywhere on the widget, and the knob will automatically be changed to this position. So I simply reused the progress bar behavior inside of the slider and it works perfectly smooth and is much more pleasant to use: