Disable crop helper for automatic Centered and Cropped fit

This commit is contained in:
Dandaedre 2026-11-16 09:08:00 +01:00
parent 2a90330f7a
commit c9bb03c645
4 changed files with 47 additions and 10 deletions

View File

@ -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.");
}

View File

@ -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.",
)

View File

@ -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

View File

@ -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.