diff --git a/crates/canvas-pilot/src/format_ui.rs b/crates/canvas-pilot/src/format_ui.rs index 82c62b8..fb656d6 100644 --- a/crates/canvas-pilot/src/format_ui.rs +++ b/crates/canvas-pilot/src/format_ui.rs @@ -504,6 +504,8 @@ impl Editor { paint_layer_source(ui.painter(),fit_rect(area,[current.width,current.height]), &self.layout, i, self.layer_preview(i)); if current_fit == canvas_pilot::formats::LayerFit::OneToOne { ui.small("Drag the canvas helper's edges to crop without zooming. The retained picture stays centered. Corners trim two edges independently. Double-click a layer to toggle the helper; use viewport zoom to reach offscreen handles."); + } else if matches!(current_fit, canvas_pilot::formats::LayerFit::Centered | canvas_pilot::formats::LayerFit::Cropped) { + ui.small("This mode fits automatically. The canvas crop helper is disabled; numeric crop edges remain available here."); } else { ui.small("Edit crop edges here; visual zoom/drag controls are for normal crop mode."); } diff --git a/crates/canvas-pilot/src/gui.rs b/crates/canvas-pilot/src/gui.rs index fcdfe82..7768d32 100644 --- a/crates/canvas-pilot/src/gui.rs +++ b/crates/canvas-pilot/src/gui.rs @@ -370,7 +370,24 @@ fn bounds(g: Geometry) -> String { ) } impl Editor { + fn automatic_layer_fit(&self, i: usize) -> bool { + matches!( + self.layout.formats().layer_fit[i], + Some( + canvas_pilot::formats::LayerFit::Centered + | canvas_pilot::formats::LayerFit::Cropped + ) + ) + } fn toggle_crop_edit(&mut self) { + 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) @@ -1525,7 +1542,13 @@ impl Editor { "Adjust layer crop" }; let edit_width = if self.edit_content { w - 120.0 } else { w }; - ink.button(0.0, 275.0, edit_width, edit_label, self.edit_content); + let automatic_fit = self.automatic_layer_fit(i); + if automatic_fit { + ink.card(0.0, 275.0, edit_width, 34.0, palette.field, palette.line); + ink.text(12.0, 284.0, "Crop helper unavailable", 13.0, palette.muted); + } else { + ink.button(0.0, 275.0, edit_width, edit_label, self.edit_content); + } if self.edit_content { ink.button(w - 108.0, 275.0, 108.0, "Reset crop", false); if click( @@ -1547,18 +1570,22 @@ impl Editor { } } } - if click( - ui, - &ink, - [0.0, 275.0, edit_width, 34.0], - "edit-layer-content", - ) { + if !automatic_fit + && click( + ui, + &ink, + [0.0, 275.0, edit_width, 34.0], + "edit-layer-content", + ) + { self.toggle_crop_edit(); } ui.put( Rect::from_min_size(ink.point(0.0, 317.0), Vec2::new(w, 48.0)), egui::Label::new(egui::RichText::new( - if self.layout.formats().layer_fit[i] == Some(canvas_pilot::formats::LayerFit::OneToOne) { + if automatic_fit { + "Centered and Cropped fit automatically. Edit numeric crop edges in Crop properties if needed." + } else if self.layout.formats().layer_fit[i] == Some(canvas_pilot::formats::LayerFit::OneToOne) { "Drag helper edges to crop source pixels without zooming. The retained picture stays centered; the container stays fixed." } else if self.layout.formats().layer_fit[i].is_some() { "Opens advanced crop edges and fit mode. The rectangle defines the container." @@ -1940,7 +1967,8 @@ impl Editor { "Adjust layer crop" }; if ui - .button(crop_label) + .add_enabled(!self.automatic_layer_fit(i), egui::Button::new(crop_label)) + .on_disabled_hover_text("Centered and Cropped fit automatically; use Crop properties for numeric crop edges.") .on_hover_text( "Change crop zoom and offset inside the layer; keep its visible box fixed.", ) diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index f5778ee..f966b6b 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,10 @@ ## Unreleased +- Disable the crop helper button, context-menu action and double-click shortcut + for Centered/Cropped: those modes fit automatically. Keep numeric crop fields + available in Crop properties; normal crop and the 1:1 helper are unchanged. + - Add the double-click crop helper for advanced 1:1 fit: independent side/corner handles trim or restore source pixels while preserving pixel scale and the layer container. Show a faded source guide, synchronize crop fields, and keep diff --git a/docs/canvas-pilot/guide/formats-and-crop.md b/docs/canvas-pilot/guide/formats-and-crop.md index 638afcf..3d00350 100644 --- a/docs/canvas-pilot/guide/formats-and-crop.md +++ b/docs/canvas-pilot/guide/formats-and-crop.md @@ -178,7 +178,10 @@ The retained picture stays centered, so its outline contracts/expands symmetrica even though only the chosen source crop edge changes. The container stays fixed. 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. Other advanced modes still use the numeric crop controls. Unchecking +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 resets to normal centered cover framing. Input/global inheritance is intentionally omitted. Pending Source edits remain staged and require Apply as usual.