Add LevelsControl, a levels adjustment over a histogram - #536
Merged
Merged
Conversation
Also folds in: - Register the levels demo in the demo section registry Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HgjMCJ9MQRmUk6c8KABDYH
matt-edmondson
force-pushed
the
claude/project-thread-a7ic2a
branch
from
September 30, 2026 10:44
6cb9f33 to
9944b4e
Compare
matt-edmondson
changed the base branch from
main
to
claude/project-thread-wmrk2b
September 30, 2026 10:44
|
This was referenced Sep 30, 2026
This was referenced Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Requested by Matt · project thread
Closes #499
This PR is part of the widget stack: #567 → #536 → #539 → #540 → #542. It targets #567's branch, so its diff is the levels work alone. Merge #567 first.
Before: a levels control had to be built from
HistogramandHandleTrackby hand. The caller also had to derive gamma from a grey handle and write its own transfer function to apply to pixels. That transfer function could drift from what the handles showed.After:
ImGuiWidgets.LevelsControl(label, bins, seriesCount, ref levels, size, seriesColors)draws a histogram with black, grey and white input handles. Under it are an output ramp with black and white handles and a one-line readout. It edits a caller-ownedLevelsAdjustment.LevelsAdjustment.Applyis the same function the handles describe, so the curve on screen and the curve applied to an image cannot disagree. Grey point and gamma follow the Photoshop convention: the midpoint is gamma 1, and moving it toward black brightens.How:
LevelsAdjustmentis areadonly record structholding:Apply,Normalized,GammaFromGreyPointandGreyPointFromGamma, implemented as the issue specifies.WithInputHandlesandWithOutputHandles. When black and white stay put,WithInputHandlesreads the drag as a grey move and changes only gamma. When either one moves, gamma is kept and the grey handle follows.HandleTracks, so the handles stay ordered and one 8-bit step apart. The input range is kept two steps wide so the grey handle always has room.label/histogram,label/input,label/outputRampandlabel/output. All sit inside aScopedId(label).LevelsDemo.csis registered inDemoSections.AdvancedDemosafter ImageCanvas. It builds a luminance histogram of the ktsu logo, then redraws the logo throughApplywhenever the levels change.LevelsControltile in the data and signals sheet.Validation (Release):
ImGui.Widgets.Tests: 415/415 passed, including 22 newLevelsAdjustmentTests.ImGui.Widgets.UITests: 418/418 passed, including 7 newLevelsControlTests. One of these reads the ramp's pixels to confirm it runs dark to light.ImGuiWidgetsDemo.UITests: 36/36 passed, including the newLevelsDemo_DraggingTheBlackPointChangesTheLevels.WidgetGallery.UITests: 6/6 passed, including--checkand a full render.🤖 Generated with Claude Code
https://claude.ai/code/session_01LXUsRiHnKs6HCgLAbC1L6D