Drags: added value ladder: stepped value editing with explicit magnit…#9464
Drags: added value ladder: stepped value editing with explicit magnit…#9464tksuoran wants to merge 4 commits into
Conversation
…ude selection (Houdini-style) (ocornut#9463) Hold middle mouse button over a DragXXX widget to open a vertical ladder of step magnitudes: drag vertically to select the step magnitude, horizontally to add/subtract steps of that size. Release middle mouse button to confirm, press Escape to cancel and revert to the initial value. - Enable globally with io.ConfigDragValueLadder or per-widget with ImGuiSliderFlags_ValueLadder. - Rungs are powers of ten, from the smallest step representable with the display format (1 for integers) up to 10000. For bounded widgets, rungs covering the whole range or more are dropped. - Unlike regular drag speed tweaks (Alt/Shift), the ladder makes the current step magnitude visible and exact, and any size of change is reachable without a range. - Min/max clamping, wrap-around and display format rounding behave the same as regular mouse drags (reuses the DragBehaviorT pipeline). - Multi-component widgets (DragFloat3 etc.) get a ladder per component. - Overlay is drawn on the viewport foreground draw list, so it cannot interfere with inputs and may spill outside the host window. - Not supported together with ImGuiSliderFlags_Logarithmic. - Demo: added dedicated Widgets->Value Ladder section, checkboxes in Configuration->Widgets and Widgets->Drag/Slider Flags. Addresses feature request ocornut#9463. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Please avoid the "not carefully reviewed" part as it means you are offloading more to me. 🙏 About your comment "maybe useful and it might fit into imgui. " : About Shouldn't the code support keyboard navigation (Space to edit with arrows) ? Does Houdini has it on a separate mouse button?
|
|
Apologies about my hasty intro wording. At this stage, I created the PR for:
If people show interest in this feature, I can put more effort into this, my intention was not to offload any more than you are comfortable with. Meanwhile, I'll start testing the PR in my use as is / with the improvements regarding DataTypeXXX API and small integers you suggested, and can I report if learn something. I think, The point about small integers is a good one, for integers with small range (around two digits) the ladder provides little to no value. Houdini has it in middle mouse, but it is a single app, and they are in full control of the UI bindings. The possibility of someone using middle button for something else is real. |
- Disable the ladder on integer ranges of 2 digits or less, where it provides little to no value. Added a demo widget showing this. - Added DataTypeAsDouble() to the DataTypeXXX API (replacing the local ValueLadderGetValueAsDouble() helper). Range span is now computed with DataTypeApplyOp() subtraction followed by DataTypeAsDouble(), which also clamps integer overflow. - Added keyboard/gamepad navigation support: activating the widget (Space) opens the ladder, Up/Down select the step magnitude, Left/Right add/subtract steps, Space confirms, Escape cancels and reverts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…cornut#9463) The ladder width was measured once at activation, so a value growing into larger magnitudes mid-drag could render outside the ladder. The overlay now grows (monotonically, staying centered and clamped into the viewport) whenever the formatted value is wider than the box. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…t#9463) - Rungs are now a full font height taller (FontSize * 3 + FramePadding.y * 2), making it harder to accidentally slip to a neighboring rung while dragging horizontally. - Replaced the integer-specific activation rule (range of 2 digits or less) with a generic one: the ladder is disabled when it would yield fewer than 3 rungs, whatever the data type. Extracted rung magnitude computation into ValueLadderCalcRungs(), shared by activation gating and ladder construction so the two can never disagree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
I have now implemented suggested improvements:
I haven't used keyboard much with imgui, but now that I added keyboard navigation support to the ladder, I think it might improve keyboard (and maybe gamepad) support since inputting for example larger floating point values precisely is easier with ladder (I think). Keyboard navigation with updated layout: |
NOTE: This is a proof of concept, implemented quickly with Claude. It might work, but it has not been through careful review at time of PR submission.
Hold middle mouse button over a DragXXX widget to open a vertical ladder of step magnitudes: drag vertically to select the step magnitude, horizontally to add/subtract steps of that size. Release middle mouse button to confirm, press Escape to cancel and revert to the initial value.
Proof of concept to address feature request #9463.
20260706-1410-15.8103262.mp4