Skip to content

Add ValueSlider, a slider whose number stays readable - #622

Merged
matt-edmondson merged 2 commits into
mainfrom
claude/project-thread-9lzc74
Oct 11, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
claude/project-thread-9lzc74

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: the only single-value slider was ImGui's own SliderFloat, whose grab rectangle sits over the number and hides it as you drag.

After: ImGuiWidgets.ValueSlider (float and int) draws a frame filled from the left up to the value, with the formatted value centered and nothing drawn over it. Drag anywhere to change it, Shift to go finely, Ctrl+click to type, and double-click to reset (or to type, when no reset value is set).

ValueSliderOptions adds a number format (by default chosen from the range), a unit suffix such as %, ° or px, a reset value, the fine-drag scale, and ValueSliderFill.FromZero for bipolar ranges such as -100..100. Text over the fill switches to a readable color when the theme's own text color would not read against it.

How: the frame and label are one ImGui item (ItemSize/ItemAdd/ButtonBehavior, as SliderFloat does it), and the widget calls MarkItemEdited, so a drop-in replacement for SliderFloat keeps working with IsItemActivated, IsItemDeactivatedAfterEdit and a probe mark taken straight after the call. Only the frame takes the pointer. Drags are relative, so a press never jumps the value. Typing opens an InputText with the slider's own id in the same place. Formatting, parsing, drag arithmetic and the fill span live in the ImGui-free ValueSliderState.

Added: a demo section, an 18-test isolation suite, 29 unit tests, a demo UI test and a gallery tile. Ran locally: widget unit tests (1074), widget UI tests (737), widgets demo UI tests (53) and gallery UI tests (6), all passing. I also checked it in both themes at 100% and 150%.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VX31mmLGVNK3y28fjKiFmB


Generated by Claude Code

ImGuiWidgets.ValueSlider (float and int) draws a frame filled up to the
value with the value centered and nothing drawn over it. Drags are
relative, Shift drags finely, Ctrl+click types, and a double-click resets
to ValueSliderOptions.ResetValue or types when there is none. Options add
a number format, a unit suffix and a bipolar fill from zero. The frame and
label are one item, as with ImGui.SliderFloat, so IsItemActivated and
IsItemDeactivatedAfterEdit work after it.

Adds a demo section, an isolation suite, unit tests for the ImGui-free
ValueSliderState, and a gallery tile.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VX31mmLGVNK3y28fjKiFmB
@matt-edmondson matt-edmondson self-assigned this Oct 11, 2026
Comment thread tests/ImGui.Widgets.UITests/ValueSliderTests.cs Fixed
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VX31mmLGVNK3y28fjKiFmB
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants