Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

#323: holding \ in a wipe shows the Before window everywhere

Nathaniel Ledford03249f461959
diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rs
index de2065827..4612281f9 100644
--- a/crates/ui-egui/src/headless.rs
+++ b/crates/ui-egui/src/headless.rs
@@ -114,7 +114,7 @@ pub struct Headless {
pub pixels_per_point: f32,
time: f64,
frames: u64,
- events: Vec<egui::Event>,
+ pub(crate) events: Vec<egui::Event>,
control: Sender<ControlRequest>,
quit: bool,
}
diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rs
index 0a080e07b..32bf919b6 100644
--- a/crates/ui-egui/src/panels/detail.rs
+++ b/crates/ui-egui/src/panels/detail.rs
@@ -602,7 +602,9 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {
// …and the window renders go over the whole-frame ones, all of them, where they belong in the
// frame (clipped to their pane, or their side of the line)
for (v, view) in &windows {
- let clip = crate::region::window_clip(app.ui.before_after, v.before, v.visible, canvas, img_rect);
+ // (holding `\` in a wipe shows the Before everywhere: it is the Before view alone then)
+ let mode = if show_before { BeforeAfter::Original } else { app.ui.before_after };
+ let clip = crate::region::window_clip(mode, v.before, v.visible, canvas, img_rect);
draw_window(&p.with_clip_rect(clip), app, &window_ctx, v, view);
}
// the line of a wipe over both
diff --git a/crates/ui-egui/src/tests_preview_limit.rs b/crates/ui-egui/src/tests_preview_limit.rs
index 8150fd4f0..a1bd224c1 100644
--- a/crates/ui-egui/src/tests_preview_limit.rs
+++ b/crates/ui-egui/src/tests_preview_limit.rs
@@ -578,6 +578,29 @@ mod in_the_loupe {
}
}
+ // Given `\` held in a wipe at 1:1, the Before is shown everywhere, so its window is painted
+ // everywhere (not only left of the line)
+ #[test]
+ fn holding_backslash_in_a_wipe_paints_the_before_window_across_the_canvas() {
+ let (mut h, _) = detail();
+ h.app.ui.before_after = crate::state::BeforeAfter::Split;
+ h.request("engine.execute", json!({"command": "view.zoom100"}), T);
+ h.settle(SETTLE);
+ h.events.push(egui::Event::Key {
+ key: egui::Key::Backslash,
+ physical_key: Some(egui::Key::Backslash),
+ pressed: true,
+ repeat: false,
+ modifiers: egui::Modifiers::NONE,
+ });
+ h.settle(SETTLE);
+ h.step();
+ let canvas = h.app.canvas_rect.unwrap();
+ let window = drawn(&h, Slot::RegionBefore);
+ assert!(!window.is_empty());
+ assert!(window[0].1.right() >= canvas.right() - 0.5, "the Before window stops at the wipe line: {:?}", window[0].1);
+ }
+
// Given Before and After side by side at 1:1, each window is painted inside its own pane: its
// margin (a window is wider than what its pane shows) does not spill into the neighbour
#[test]