Widgets: Added SliderFloatRange2(), SliderIntRange2() for range selection (#76)#9164
Widgets: Added SliderFloatRange2(), SliderIntRange2() for range selection (#76)#9164Entrpi wants to merge 3 commits intoocornut:masterfrom
Conversation
…tion. (ocornut#76) - Two-handle slider for selecting a min/max range - Middle bar dragging to move both handles together while maintaining range - Hover highlighting to show which handle will be selected on click - Ctrl+Click text input with "XXX...YYYY" parsing to set both values - Per-handle format strings for different precision on each handle - Optional step parameter for snapping
d2ddb97 to
5743047
Compare
|
Thanks, wonderful. Further feedback:
What's your opinion on those?
|
|
I was having a bad day so the swift and unusually quality updates in this PR are very comforting! Thank you! |
d08ba62 to
f998eae
Compare
- Single format string API: removed format_max parameter, format can be "%.3f" (same for both) or "%.3f...%.3f" (different for min/max) - Accept any number of dots (.., ..., ....) as separator when parsing - Accept " - " as separator in addition to dots - Ctrl+Click shows "min...max" format for editing both values - Unknown state (-2) when handles overlap: drag direction determines which handle to use - Display uses " - " separator by default (customizable via format)
f998eae to
94d0184
Compare
Tests for the new SliderRange2 widgets (ocornut/imgui#9164): - Overlapping handles resolution by drag direction - Ctrl+Click text input with "..." separator - Ctrl+Click text input with " - " separator - Handles can't cross constraint - Integer range slider text input
|
That means a lot to hear, glad I could brighten your day a bit! Hope things turn around for you. Addressed the feedback: API changes:
Behavior:
Tests: ocornut/imgui_test_engine#88 All 5 tests pass:
Let me know if you'd like any adjustments! |
Alternative API: SliderFloat2(label, v, min, max, fmt, ImGuiSliderFlags_Range) renders as a range slider instead of two separate sliders. This minimizes API surface by reusing existing SliderScalarN functions.
Tests for the new SliderRange2 widgets (ocornut/imgui#9164): - Overlapping handles resolution by drag direction - Ctrl+Click text input with "..." separator - Ctrl+Click text input with " - " separator - Handles can't cross constraint - Integer range slider text input
|
Also implemented the moonshot: added Now you can do either: // Dedicated function
SliderFloatRange2("range", &min, &max, 0.0f, 1.0f);
// Or use SliderFloat2 with flag
float v[2] = { min, max };
SliderFloat2("range", v, 0.0f, 1.0f, "%.3f", ImGuiSliderFlags_Range);Both approaches work identically. The flag version routes through |
|
Thanks, please give me some time to digest all that and get through all details.
|
|
I'll try work on this on wednesday, please avoid further force-pushing to the branch. 🙏 |
|
Sounds good, look forward to seeing where you take it! Yes, I agree re: the API choice. Personally I prefer the "feel" of breaking it out into new functions, but not a strong preference. I wasn't entirely sure about your intended approach with multi-format strings and just thought through the first thing that made some sense to me. I like your idea, so happy if that's the approach! I do need the step feature, but it doesn't need to be done as I have. |

Summary
This PR implements range sliders as discussed in #76.
Features:
API
Changes
SliderRangeActiveHandlecontext fieldTest Plan