Enter layer crop adjustment on canvas double click
This commit is contained in:
parent
feb829ae02
commit
87daa7d8fa
|
|
@ -1181,6 +1181,9 @@ impl Editor {
|
|||
}
|
||||
} else {
|
||||
self.layout.select(hit);
|
||||
if response.double_clicked_by(egui::PointerButton::Primary) && hit.is_some() {
|
||||
self.edit_content = true;
|
||||
}
|
||||
}
|
||||
self.sync();
|
||||
ui.ctx().memory_mut(|m| {
|
||||
|
|
@ -1547,6 +1550,50 @@ mod tests {
|
|||
}
|
||||
}
|
||||
#[test]
|
||||
fn double_click_enters_crop_mode_without_changing_geometry() {
|
||||
for target in [Some(0), Some(1), None] {
|
||||
let mut app = Editor::default();
|
||||
let ctx = egui::Context::default();
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let before = *app.layout.layers();
|
||||
let formats = *app.layout.formats();
|
||||
let pos = target
|
||||
.map(|i| layer_rects(&output)[i].center())
|
||||
.unwrap_or(Pos2::new(500.0, 700.0));
|
||||
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, target.is_some());
|
||||
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);
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn double_click_does_not_edit_a_locked_layer() {
|
||||
let mut app = Editor::default();
|
||||
let ctx = egui::Context::default();
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let pos = layer_rects(&output)[1].center();
|
||||
app.layout.set_locked(1, true);
|
||||
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.edit_content);
|
||||
}
|
||||
#[test]
|
||||
fn content_mode_drags_only_crop_and_camera_zoom_keeps_document_unchanged() {
|
||||
let mut app = Editor {
|
||||
edit_content: true,
|
||||
|
|
|
|||
|
|
@ -254,7 +254,8 @@ Select one layer and click its **Layer resolution** card to open **Layer propert
|
|||
**Recenter** preserves zoom; **Reset crop** returns to the minimum centered
|
||||
cover crop. Invalid typed offsets show the permitted range and do not apply.
|
||||
5. Click **Adjust layer crop** in the selected layer’s parameters, below its format
|
||||
summary, to drag or arrow-nudge content inside the fixed box. The button
|
||||
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.
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue