WIP commit for relative slider widgets.
This makes sliders change from the current value towards the direction the mouse moves while dragging, instead of jumping to the value along the slider when clicking.
[x] Relative behaviour
[x] Holding Shift while dragging makes the value change slower
[x] Holding Ctrl will snap to step if an Int, or (step * 0.1) for Floats. Will probably change this to (step * 0.01) for Floats so it adjusts the same amount that the mouse does when adjusting the slider.
[x] Increment/Decrement buttons
[x] Increment/Decrement using Control + Scroll(Up/Down), this follows similar logic to the Ctrl snapping.
[x] Cancelling a drag or input by pressing Escape or Right Clicking, so the value returns to what it was before starting to change it.
[x] Validate input when pressing Enter instead of onChange to allow anything to be typed in to the number input.
[x] Able to force snapping to step using forceSnap option. This forces Ints to snap to the step interval
[ ] Polish UI
Bugs with implementation as of right now:
[x] Can not do negatives as input validation is still happening onChange instead of when confirming by pressing Enter. This also means you can't type any non-number character. In the future it might be nice to be able to evaluate math formulas in number fields. Like 2*4 evaluating to 8 on confirm.
[x] Fix it so that It will not visually change some slider groups that aren't made by calling form.slider.
Stuff that can be in another PR, but would be nice to implement now.
[ ] Setting a precision setting (for floats), so a slider specifically rounds to/displays 1.1, or 1.11, or 1.11, etc. when being dragged.
[ ] Reset to default value when pressing backspace while hovering over a slider.
[ ] Having a soft min/max and hard min/max. Soft min max would limit sliders to a range, and Hard would limit the value. Say, you want the max denoising steps to be 100 when dragging a slider, but want a power user to be able to set it higher if they need by clicking and changing the value.
Notes:
I did not add the theme changes to this, as you wanted them in a different PR. I think it would be okay to have a different commit in this one though, since they need to be edited to make the text for these easier to read.
This does include the shadows, but it only effects the sliders. I would like to make this change global, but I don't know where I should put it exactly, and that can be part of the other PR if you don't want any theme changes in this one.
There is a slight issue with using Escape to cancel, as the PointerLock api hardcodes this button to not allow a lock for 1 second after pressing escape, but I don't think it's a real problem. It just doesn't feel polished.
WIP commit for relative slider widgets. This makes sliders change from the current value towards the direction the mouse moves while dragging, instead of jumping to the value along the slider when clicking.
step
if an Int, or(step * 0.1)
for Floats. Will probably change this to(step * 0.01)
for Floats so it adjusts the same amount that the mouse does when adjusting the slider.Control + Scroll(Up/Down)
, this follows similar logic to the Ctrl snapping.Escape
orRight Clicking
, so the value returns to what it was before starting to change it.Bugs with implementation as of right now:
2*4
evaluating to 8 on confirm.Stuff that can be in another PR, but would be nice to implement now.
1.1
, or1.11
, or1.11
, etc. when being dragged.Notes: I did not add the theme changes to this, as you wanted them in a different PR. I think it would be okay to have a different commit in this one though, since they need to be edited to make the text for these easier to read. This does include the shadows, but it only effects the sliders. I would like to make this change global, but I don't know where I should put it exactly, and that can be part of the other PR if you don't want any theme changes in this one. There is a slight issue with using Escape to cancel, as the PointerLock api hardcodes this button to not allow a lock for 1 second after pressing escape, but I don't think it's a real problem. It just doesn't feel polished.