Toggle visual crop editing on double-click

This commit is contained in:
Dandaedre 2026-11-14 19:49:42 +01:00
parent f4f1e44742
commit d21fb9cf2a
3 changed files with 34 additions and 3 deletions

View File

@ -2763,6 +2763,14 @@ impl Editor {
self.zoom_drag = None;
self.camera_before = None;
}
let finish_crop = self.edit_content
&& edit_pointer
&& pivot_hover.is_none()
&& !click_shift_modifier(ui)
&& response.double_clicked_by(egui::PointerButton::Primary);
if finish_crop {
self.edit_content = false;
}
if response.clicked()
&& edit_pointer
&& self.edit_content
@ -2781,6 +2789,7 @@ impl Editor {
if response.clicked()
&& edit_pointer
&& pivot_hover.is_none()
&& !finish_crop
&& !self.edit_content
&& let Some(p) = pointer
{
@ -3091,7 +3100,7 @@ impl Editor {
ink.text(
24.0,
r.height() - 40.0,
if move_pointer { "Move tool · Drag anywhere to move the current selection · V: Select · H: Pan" } else if self.navigation_tool == NavigationTool::Pan { "Pan tool · Drag to move the view · V: Select · Z: Zoom · Space/middle-drag pans from any tool" } else if self.navigation_tool == NavigationTool::Zoom { "Zoom tool · Click to zoom in · Alt-click to zoom out · Drag right/left to zoom · V: Select · H: Pan" } else if pivot_visible { "Pivot resize · Drag pivot to position · Double-click to center · Ctrl temporarily toggles pivot" } else if self.edit_content { "Crop mode · Drag crop handles to zoom content · Drag image to reposition · Click outside to finish" } else { match self.active_resize_mode() {
if move_pointer { "Move tool · Drag anywhere to move the current selection · V: Select · H: Pan" } else if self.navigation_tool == NavigationTool::Pan { "Pan tool · Drag to move the view · V: Select · Z: Zoom · Space/middle-drag pans from any tool" } else if self.navigation_tool == NavigationTool::Zoom { "Zoom tool · Click to zoom in · Alt-click to zoom out · Drag right/left to zoom · V: Select · H: Pan" } else if pivot_visible { "Pivot resize · Drag pivot to position · Double-click to center · Ctrl temporarily toggles pivot" } else if self.edit_content { "Crop mode · Drag crop handles to zoom content · Drag image to reposition · Double-click or click outside to finish" } else { match self.active_resize_mode() {
ResizeMode::Individual => "Corners resize · Side handles keep opposite edge fixed · Shift-click selects",
ResizeMode::Same => "Same handles · Matching handles scale selected layers proportionally · Escape cancels drag",
ResizeMode::Mirror => "Mirror horizontally · Left/right mirrored handles · Escape cancels drag",
@ -5177,7 +5186,7 @@ mod tests {
}
}
#[test]
fn double_click_enters_crop_mode_without_changing_geometry() {
fn double_click_toggles_crop_mode_without_changing_geometry() {
for target in [Some(0), Some(1), None] {
let mut app = Editor::default();
let ctx = egui::Context::default();
@ -5199,6 +5208,26 @@ mod tests {
assert_eq!(app.layout.selected(), target);
assert_eq!(*app.layout.layers(), before);
assert_eq!(*app.layout.formats(), formats);
if target.is_some() {
// Separate gestures, then double-click again to finish and again to reopen.
for expected in [false, true] {
for _ in 0..40 {
frame(&mut app, &ctx, vec![]);
}
for _ in 0..2 {
frame(
&mut app,
&ctx,
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
);
frame(&mut app, &ctx, vec![mouse(pos, false)]);
}
assert_eq!(app.edit_content, expected);
assert_eq!(app.layout.selected(), target);
assert_eq!(*app.layout.layers(), before);
assert_eq!(*app.layout.formats(), formats);
}
}
frame(&mut app, &ctx, vec![key(egui::Key::Escape)]);
assert!(!app.edit_content);
}

View File

@ -517,7 +517,7 @@ Select one layer and click its **Layer resolution** card to open **Layer propert
5. Click **Adjust layer crop** in the selected layer’s parameters, below its format
summary, or **double-click a layer on the canvas**, to drag or arrow-nudge
content inside the fixed box. The button
highlights while active; click **Done adjusting crop** to leave the mode.
highlights while active; double-click again or click **Done adjusting crop** to leave the mode.
Drags clamp at valid crop boundaries; Escape cancels a drag and leaves this
mode. Wheel zoom still controls the camera. A source-coordinate test pattern
illustrates framing; it is deliberately separate from the screen reference.

View File

@ -4,6 +4,8 @@
## Unreleased
- Double-click again in visual crop mode to finish editing; preserve selection and framing. Viewport regression coverage checks entering, exiting and reopening without geometry changes.
- Pool input captures across matching queued layers and automatic previews, including requests queued during a fetch. Share one decoded texture and consume matching requests on failure to avoid per-layer retries; preserve existing manual stills. Regression tests cover direct, automatic and import captures, failure handling and different-input isolation.
- Capture a first still automatically when selecting a preview input, in both pickers. Queue the latest choice behind the shared five-second throttle and active request, without waiting the auto-refresh cycle; retain explicit recapture/import. Regression tests cover throttling, coalescing and cancelling stale targets.