Open crop properties from shortcuts for automatic fit layers

This commit is contained in:
Dandaedre 2026-11-19 07:58:25 +01:00
parent 6f777f7455
commit 46ace1fe25
5 changed files with 53 additions and 13 deletions

2
Cargo.lock generated
View File

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

View File

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

View File

@ -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)] {

View File

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

View File

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