From 46ace1fe254fff2277e4009b17ce42b6e4037770 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 19 Nov 2026 07:58:25 +0100 Subject: [PATCH] Open crop properties from shortcuts for automatic fit layers --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/canvas-pilot/src/gui.rs | 48 +++++++++++++++++---- docs/canvas-pilot/changelog.md | 7 +++ docs/canvas-pilot/guide/formats-and-crop.md | 7 +-- 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d31d76e..ff98cc0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -602,7 +602,7 @@ dependencies = [ [[package]] name = "canvas-pilot" -version = "0.10.0-rc.11" +version = "0.10.0-rc.12" dependencies = [ "base64 0.22.1", "craft-dwg", diff --git a/Cargo.toml b/Cargo.toml index 63c5923..c66c25a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"] resolver = "3" [workspace.package] -version = "0.10.0-rc.11" +version = "0.10.0-rc.12" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot" diff --git a/crates/canvas-pilot/src/gui.rs b/crates/canvas-pilot/src/gui.rs index 2a1a68c..27b4f96 100644 --- a/crates/canvas-pilot/src/gui.rs +++ b/crates/canvas-pilot/src/gui.rs @@ -603,14 +603,6 @@ impl Editor { fn toggle_crop_edit(&mut self) { self.edit_mask = false; - if self - .layout - .selected() - .is_some_and(|i| self.automatic_layer_fit(i)) - { - self.edit_content = false; - return; - } if let Some(i) = self.layout.selected() && self.layout.formats().layer_fit[i] .is_some_and(|fit| fit != canvas_pilot::formats::LayerFit::OneToOne) @@ -6689,6 +6681,46 @@ mod tests { assert!(app.edit_content); } + #[test] + fn automatic_fit_shortcuts_open_crop_properties_without_changing_fit_or_geometry() { + use canvas_pilot::formats::LayerFit; + for fit in [LayerFit::Centered, LayerFit::Cropped, LayerFit::Fullscreen] { + for keyboard in [false, true] { + let ctx = egui::Context::default(); + let mut app = Editor::default(); + let output = frame(&mut app, &ctx, vec![]); + let pos = layer_rects(&output)[1].center(); + app.layout.select(Some(1)); + app.layout + .set_layer_fit(1, Some(fit), Default::default()) + .unwrap(); + let before = app.project(); + frame(&mut app, &ctx, vec![]); + if keyboard { + frame(&mut app, &ctx, vec![key(egui::Key::Enter)]); + } else { + 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!( + app.format_draft + .as_ref() + .is_some_and(|draft| draft.is_for(1)), + "{fit:?}, keyboard={keyboard}" + ); + assert!(matches!(app.property_tab, PropertyTab::Crop)); + assert!(!app.edit_content); + assert_eq!(app.project(), before); + } + } + } + #[test] fn enter_opens_crop_and_release_is_required_before_closing() { for fit in [None, Some(canvas_pilot::formats::LayerFit::OneToOne)] { diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index 70c6dbd..a5118ad 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,13 @@ ## Unreleased +### v0.10.0-rc.12 + +- Double-click and Enter open Crop properties for Centered/Cropped layers instead + of silently doing nothing. Preserve automatic fitting, geometry and crop; normal + crop and 1:1 still use their interactive helper. Regression tests cover both + shortcuts across all explicit fit modes. + ### v0.10.0-rc.11 - Review problematic transfers with explicit included/skipped layer lists and diff --git a/docs/canvas-pilot/guide/formats-and-crop.md b/docs/canvas-pilot/guide/formats-and-crop.md index 577ae95..c61fc6b 100644 --- a/docs/canvas-pilot/guide/formats-and-crop.md +++ b/docs/canvas-pilot/guide/formats-and-crop.md @@ -191,9 +191,10 @@ source pixel; Shift+arrows move by ten. The layer container stays in place. Use viewport zoom/pan to reach handles outside the screen. Each drag is one Undo step; Escape cancels an active drag and exits the helper. Numeric crop fields stay in sync. **Centered** and **Cropped** fit automatically, so their helper button -and context-menu action are disabled and double-click does not open a helper. -Their numeric crop edges remain editable in Crop properties. Fullscreen continues -to use the numeric crop controls. Unchecking +and context-menu helper action are disabled. Double-click or Enter opens their +**Crop properties** with editable numeric crop edges instead of the canvas helper. +Fullscreen uses those same numeric crop controls. These shortcuts preserve the +selected fit mode and do not change the document. Unchecking resets to normal centered cover framing. Input/global inheritance is intentionally omitted. Pending Source edits remain staged and require Apply as usual.