Exit crop editing when clicking outside editable content
This commit is contained in:
parent
35ceab2846
commit
02956594b2
|
|
@ -1558,6 +1558,12 @@ impl Editor {
|
|||
self.marquee = None;
|
||||
self.panning = false;
|
||||
}
|
||||
if response.clicked()
|
||||
&& self.edit_content
|
||||
&& pointer.is_some_and(|p| self.content_hit(p, origin, scale).is_none())
|
||||
{
|
||||
self.edit_content = false;
|
||||
}
|
||||
if response.clicked()
|
||||
&& !self.edit_content
|
||||
&& let Some(p) = pointer
|
||||
|
|
@ -2251,6 +2257,70 @@ mod tests {
|
|||
frame(&mut app, &ctx, vec![key(egui::Key::Escape)]);
|
||||
assert!(!app.edit_content);
|
||||
}
|
||||
#[test]
|
||||
fn clicking_outside_crop_exits_and_selects_normally_without_changing_geometry() {
|
||||
for target in [Some(0), None] {
|
||||
let mut app = Editor {
|
||||
edit_content: true,
|
||||
..Default::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));
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
assert!(!app.edit_content);
|
||||
assert_eq!(app.layout.selected(), target);
|
||||
assert_eq!(*app.layout.layers(), before);
|
||||
assert_eq!(*app.layout.formats(), formats);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clicking_visible_or_faded_crop_content_keeps_editing() {
|
||||
for outside_box in [false, true] {
|
||||
let mut app = Editor {
|
||||
edit_content: true,
|
||||
..Default::default()
|
||||
};
|
||||
app.layout
|
||||
.set_framing(
|
||||
1,
|
||||
midra_layout::formats::Framing {
|
||||
zoom: 2.0,
|
||||
offset: [0.0; 2],
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
let output = frame(&mut app, &ctx, vec![]);
|
||||
let rect = layer_rects(&output)[1];
|
||||
let pos = if outside_box {
|
||||
rect.center_top() - Vec2::new(0.0, 15.0)
|
||||
} else {
|
||||
rect.center()
|
||||
};
|
||||
let formats = *app.layout.formats();
|
||||
frame(
|
||||
&mut app,
|
||||
&ctx,
|
||||
vec![egui::Event::PointerMoved(pos), mouse(pos, true)],
|
||||
);
|
||||
frame(&mut app, &ctx, vec![mouse(pos, false)]);
|
||||
assert!(app.edit_content);
|
||||
assert_eq!(app.layout.selected(), Some(1));
|
||||
assert_eq!(*app.layout.formats(), formats);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn faded_content_can_be_grabbed_outside_box_at_different_camera_scales() {
|
||||
for zoom in [0.6, 1.0] {
|
||||
|
|
|
|||
|
|
@ -366,3 +366,8 @@ crop, **Layer** for the final visible box, and **Crop** for content zoom and off
|
|||
The three right-click properties entries open their matching tab directly.
|
||||
Switching tabs retains pending edits. Source and Layer changes still apply together
|
||||
with their shared Apply button; Crop has its own Apply button.
|
||||
|
||||
While adjusting a layer crop, click empty canvas or another layer to leave crop
|
||||
mode and select normally. Clicking or dragging the visible image or its faded
|
||||
outside preview keeps crop mode active. Property controls remain usable while
|
||||
editing the crop.
|
||||
|
|
|
|||
Loading…
Reference in New Issue