Skip to content

[minor] Add CropOverlay, a crop rectangle drawn over an ImageCanvas - #573

Merged
matt-edmondson merged 3 commits into
mainfrom
widget/stack-crop
Sep 30, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
widget/stack-crop

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Requested by Matt · project thread

Before: an ImageCanvas could display an image but had no crop tool.

After: ImGuiWidgets.CropOverlay draws a crop, measured in image pixels, over an ImageCanvas. It has a dimmed surround, rule-of-thirds guides, edge and corner handles, an optional aspect lock, and an optional rotate handle. The crop is always kept inside the image. Dragging outside the crop still pans the canvas, and the wheel zooms it once rather than twice.

How: CropOverlayState holds the geometry and drag rules and has no ImGui dependency. ImageCanvasState gains ImageToViewport, the inverse of ViewportToImage. The canvas now allows overlap, so an overlay submitted on top of it gets the hover. The overlay restores the cursor, the same way CurveTrack does, so the gallery tile submits a Dummy after it. The PR adds a demo section, an isolation suite, a gallery tile and docs entries.

Stacked PR. The base is #572 (ImageCompare). Merge order: #570 → #571 → #572 → this → PixelLoupe.

Validation, Release build: the solution builds clean, ImGuiWidgetsDemo.UITests passes 45/45, and WidgetGallery --check passes.

Closes #506

🤖 Generated with Claude Code

https://claude.ai/code/session_01LXUsRiHnKs6HCgLAbC1L6D


Generated by Claude Code

ImGuiWidgets.CropOverlay draws a crop in image pixels over an ImageCanvas, with
a dimmed surround, thirds guides, edge and corner handles, an optional aspect
lock and an optional rotate handle. The crop is kept inside the image. Dragging
outside it pans the canvas and the wheel zooms it once. CropOverlayState holds
the geometry and drag rules with no ImGui dependency.

ImageCanvasState gains ImageToViewport, the inverse of ViewportToImage, and the
canvas allows overlap so an overlay submitted over it takes the hover.

Closes #506

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXUsRiHnKs6HCgLAbC1L6D
Base automatically changed from widget/stack-compare to main September 30, 2026 12:35
@sonarqubecloud

Copy link
Copy Markdown

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.

Domain widgets Tier 2: add CropOverlay (crop rect, aspect lock, thirds guides, rotation) over ImageCanvas

2 participants