UI Slider Widget
Objective
Added a premade UI slider widget. Fixes #6196.
Solution
- Added a
RelativeCursorPositioncomponent that updates alongsideInteraction, which stores the cursor position relative to the node. - Added a
Slidercomponent that stores values specific to sliders - Added a
SliderBundleand aSliderHandleBundle - Added
update_slider_valueandupdate_slider_handlesystems - Made a slider example in the
uidirectory
Changelog
- There is an easy way to create UI sliders now
- If applicable, organize changes under "Added", "Changed", or "Fixed" sub-headings
- Added:
-
RelativeCursorPositioncomponent -
Slidercomponent -
SliderBundle -
SliderHandleBundle -
update_slider_valueandupdate_slider_handlesystems - slider example
-
how the example looks like:
https://user-images.githubusercontent.com/8672791/195031790-b3a0c314-32f1-4c58-bb6b-c2c868a2a2ed.mp4
Based on this approach, I've started working on #6517. Does it make sense that both the slider widget and the progress-widget shares the same representation of "progress"?
Something like this?
struct Progress
{
/// Max value
max: f32,
/// Min value
min: f32,
/// Current value of the widget. Somewhere between min and max.
value: f32,
}
Then SliderWidget could look like
struct Slider
{
progress: Progress,
step: f32,
}
And the ProgressBarWidget could look like
struct ProgressBar
{
progress: Progress,
direction: Direction,
}
Note that for the Progress struct, you can't have public fields: you must use getters and setters to ensure invariants. I do generally think you could share those components though.
@Weibye Are you going to open a PR with the Progress struct? If so, please mention it in this thread.
@Weibye Are you going to open a PR with the
Progressstruct? If so, please mention it in this thread.
Yes! Will try to have it up by end of day.
I tried fixing the merge conflicts, but I think I just broke it even more. Closing in favor of #7116 .