diff --git a/crates/imaging/src/ui/raw_develop/mod.rs b/crates/imaging/src/ui/raw_develop/mod.rs index 8198f2c23..a935ed8c6 100644 --- a/crates/imaging/src/ui/raw_develop/mod.rs +++ b/crates/imaging/src/ui/raw_develop/mod.rs @@ -249,6 +249,9 @@ pub struct RawDevelopWorkspace { size: PixelSize, target: RawTarget, settings: RawDevelopSettings, + /// The settings the workspace, or the raw now shown, started from: a curve left as stored passes OK, so an older + /// Smart Filter stays editable. + stored: RawDevelopSettings, original: RawDevelopSettings, demosaic: Option, history: EditHistory, @@ -287,6 +290,7 @@ impl RawDevelopWorkspace { size: open.size, target: open.target, history: EditHistory::new(&open.settings), + stored: open.settings.clone(), settings: open.settings, original: open.original, demosaic: open.demosaic, @@ -329,6 +333,7 @@ impl RawDevelopWorkspace { /// over. pub fn show_item(&mut self, current: usize, settings: RawDevelopSettings, original: RawDevelopSettings, demosaic: Option) { self.history = EditHistory::new(&settings); + self.stored = settings.clone(); self.settings = settings; self.original = original; self.demosaic = demosaic; @@ -886,7 +891,7 @@ impl FullWindowWorkspace for RawDevelopWorkspace { fn confirm(&mut self, ctx: &Context, source: &Self::Source) -> Option { let _ = (ctx, source); - self.settings.validate().ok()?; + self.settings.validate_changes(&self.stored).ok()?; Some(self.result(self.target.accept())) } } diff --git a/crates/imaging/tests/it/raw_develop.rs b/crates/imaging/tests/it/raw_develop.rs index ca755ce1f..cd732da5c 100644 --- a/crates/imaging/tests/it/raw_develop.rs +++ b/crates/imaging/tests/it/raw_develop.rs @@ -107,8 +107,9 @@ impl RawDevelopSource for Source { None } - fn sample(&self, _: [f64; 2], _: bool, _: bool) -> Option { - None + fn sample(&self, _: [f64; 2], before: bool, _: bool) -> Option { + let level = f32::from(if before { self.before.level } else { self.after.level }) / 255.0; + Some(ScopeReadout::Rgb([level; 3])) } fn has_selection(&self) -> bool { @@ -222,6 +223,18 @@ fn key_event(key: Key, pressed: bool) -> Event { Event::Key { key, physical_key: Some(key), pressed, repeat: false, modifiers: Modifiers::NONE } } +#[trial] +fn ok_accepts_a_curve_left_as_stored() { + let stacked = vec![[0.0, 0.0], [60.0, 40.0], [60.0, 200.0], [255.0, 255.0]]; + let stored = RawDevelopSettings { point_curve: stacked.clone(), ..RawDevelopSettings::default() }; + let host = Rc::new(RefCell::new(DialogHost::new())); + let fixture = fixture(&host, &Rc::new(Cell::new(false))); + let open = RawDevelopOpen::new("IMG_0001.CR3", PixelSize::new(IMAGE[0], IMAGE[1]), RawTarget::SmartFilter, stored); + host.borrow_mut().open(HostedWorkspace::new(RawDevelopWorkspace::new(open), Source::new())); + assert!(host.borrow_mut().confirm::(fixture.ctx()), "an older Smart Filter's curve left as stored passes OK"); + assert!(finish(&host).is_some()); +} + #[trial] fn before_shows_the_before_picture_and_edits_nothing() { let host = Rc::new(RefCell::new(DialogHost::new())); @@ -246,6 +259,25 @@ fn before_shows_the_before_picture_and_edits_nothing() { assert_eq!(exposure(&host), 0.0, "Before records no history step"); } +#[trial] +fn a_sampler_reads_the_picture_on_show() { + let host = Rc::new(RefCell::new(DialogHost::new())); + let mut fixture = fixture(&host, &Rc::new(Cell::new(false))); + host.borrow_mut().open(HostedWorkspace::new(RawDevelopWorkspace::new(open(RawTarget::Filter)), Source::new())); + fixture.idle(10); + let canvas = focus_canvas(&mut fixture); + fixture.key(Key::S, Modifiers::NONE).idle(2); + fixture.click(&canvas).idle(4); + let reading = |fixture: &Fixture| fixture.texts().iter().find(|run| run.text.starts_with("#1 ")).map(|run| run.text.to_string()); + let developed = reading(&fixture).expect("a click of the Color Sampler tool adds a sampler"); + + fixture.frame(vec![key_event(Key::Y, true)]).idle(6); + let before = reading(&fixture).expect("the sampler keeps reading while Before shows"); + assert_ne!(before, developed, "Before reads the undeveloped pixel"); + fixture.frame(vec![key_event(Key::Y, false)]).idle(4); + assert_eq!(reading(&fixture), Some(developed), "releasing Y reads the developed pixel again"); +} + /// A color sampler's readout shows under the zoom bar. fn readout_shown(fixture: &Fixture) -> bool { fixture.texts().iter().any(|run| run.text.starts_with("#1 "))