From b49daffe1216e122e826de9abf6496a5ceccf5ec Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 23:43:10 +0000 Subject: [PATCH] Camera Raw workspace: a held OK files its answer for the app (OK and Done); trial --- crates/imaging/src/ui/raw_develop/mod.rs | 19 ++++++++++++------- crates/imaging/tests/it/raw_develop.rs | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/crates/imaging/src/ui/raw_develop/mod.rs b/crates/imaging/src/ui/raw_develop/mod.rs index 02bf25af2..f002deed1 100644 --- a/crates/imaging/src/ui/raw_develop/mod.rs +++ b/crates/imaging/src/ui/raw_develop/mod.rs @@ -519,7 +519,7 @@ impl FullWindowWorkspace for RawDevelopWorkspace { const KEY: &'static str = "filter.cameraRaw"; fn show(&mut self, ui: &mut Ui, cx: WorkspaceCx<'_, Self::Source>) -> WorkspacePass { - let WorkspaceCx { source, revision, open, .. } = cx; + let WorkspaceCx { source, revision, open, hold_ok, ok_waits, .. } = cx; let env = Env::of(ui); let words = env.words::(); let common = env.words::(); @@ -529,9 +529,11 @@ impl FullWindowWorkspace for RawDevelopWorkspace { let name = if self.target == RawTarget::OpenRaw { words.name.clone() } else { words.name_filter.clone() }; let title: Label = FullWindowTitle::new(name).subject(self.subject.clone()).zoom(self.view.zoom_percent()).label(&env); - let mut plan = vec![(Footer::Finish(self.target.accept()), FooterButton::new(self.target_label(&words, &common), DialogRole::Accept))]; + // A held OK files its answer for the app and keeps the workspace open until the app answers; the buttons that finish wait meanwhile. + let finishing = |button: FooterButton| button.stays_open(hold_ok).enabled(!ok_waits); + let mut plan = vec![(Footer::Finish(self.target.accept()), finishing(FooterButton::new(self.target_label(&words, &common), DialogRole::Accept)))]; if self.target == RawTarget::OpenRaw { - plan.push((Footer::Finish(RawFinish::Done), FooterButton::new(words.done.clone(), DialogRole::Other))); + plan.push((Footer::Finish(RawFinish::Done), finishing(FooterButton::new(words.done.clone(), DialogRole::Other)))); } plan.push((Footer::Save, FooterButton::new(words.save_settings.clone(), DialogRole::Other).stays_open(true))); plan.push((Footer::Load, FooterButton::new(words.load_settings.clone(), DialogRole::Other).stays_open(true))); @@ -804,11 +806,14 @@ impl FullWindowWorkspace for RawDevelopWorkspace { Some(Footer::Finish(finish)) => finish, _ => self.target.accept(), }; - let result = match self.requested.take() { - Some(finish) => Some(DialogResult::Ok(self.result(finish))), - None => output.result(|| self.result(finish)), + let (result, held) = match (self.requested.take(), hold_ok) { + (Some(finish), true) => (None, Some(self.result(finish))), + (Some(finish), false) => (Some(DialogResult::Ok(self.result(finish))), None), + // Esc and Cancel close the workspace either way. + (None, true) => (output.closed.map(|_| DialogResult::Cancel), matches!(footer, Some(Footer::Finish(_))).then(|| self.result(finish))), + (None, false) => (output.result(|| self.result(finish)), None), }; - WorkspacePass::new(output.response, events).result(result) + WorkspacePass::new(output.response, events).held(held).result(result) } fn json_fields(&self, source: &Self::Source) -> Option { diff --git a/crates/imaging/tests/it/raw_develop.rs b/crates/imaging/tests/it/raw_develop.rs index dde506a0d..35ff3d2b0 100644 --- a/crates/imaging/tests/it/raw_develop.rs +++ b/crates/imaging/tests/it/raw_develop.rs @@ -218,6 +218,22 @@ fn raw_develop_switches_raws_and_finishes_with_each_footer_button() { assert_eq!(finish(&host), Some(RawFinish::Ok)); } +#[trial] +fn a_held_ok_files_its_answer_and_keeps_the_workspace_open_until_the_app_answers() { + 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::OpenRaw)), Source::new()).held_ok()); + fixture.idle(10); + let done = fixture.by_label("Done").expect("Done"); + fixture.click(&done).idle(4); + let held = host.borrow_mut().get_mut::().expect("Done keeps the workspace open").take_ok(); + assert_eq!(held.map(|result| result.finish), Some(RawFinish::Done), "Done files its answer for the app"); + + host.borrow_mut().get_mut::().expect("open").answer_ok(Ok(())); + fixture.idle(4); + assert_eq!(finish(&host), Some(RawFinish::Done), "the app's answer closes the workspace with the filed result"); +} + /// The key `key` going down or up, as a keyboard reports it. fn key_event(key: Key, pressed: bool) -> Event { Event::Key { key, physical_key: Some(key), pressed, repeat: false, modifiers: Modifiers::NONE }