Merge branch 'red/t8' into fw/mac1

This commit is contained in:
aiongg
2026-11-16 22:47:46 +00:00
2 changed files with 40 additions and 3 deletions
+6 -1
View File
@@ -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<Demosaic>,
history: EditHistory<RawDevelopSettings>,
@@ -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<Demosaic>) {
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<Self::Result> {
let _ = (ctx, source);
self.settings.validate().ok()?;
self.settings.validate_changes(&self.stored).ok()?;
Some(self.result(self.target.accept()))
}
}
+34 -2
View File
@@ -107,8 +107,9 @@ impl RawDevelopSource for Source {
None
}
fn sample(&self, _: [f64; 2], _: bool, _: bool) -> Option<ScopeReadout> {
None
fn sample(&self, _: [f64; 2], before: bool, _: bool) -> Option<ScopeReadout> {
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::<Hosted>(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 "))