From bcdfd861b3f83af94ef69489991d89ac4a5bf677 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 23:39:06 +0000 Subject: [PATCH] Camera Raw: the sampler readouts follow Before; the workspace's automation fields carry the pointer and sampler readouts (json_fields takes the source) --- crates/imaging/src/ui/fill/mod.rs | 2 +- crates/imaging/src/ui/filter_gallery/mod.rs | 2 +- crates/imaging/src/ui/liquify/mod.rs | 2 +- crates/imaging/src/ui/raw_develop/mod.rs | 6 +++++- crates/imaging/src/ui/raw_develop/preview.rs | 17 ++++++++++++++--- crates/imaging/src/ui/select_mask/mod.rs | 2 +- crates/imaging/src/ui/vanishing_point/mod.rs | 2 +- crates/imaging/src/ui/wide_angle/mod.rs | 2 +- crates/imaging/tests/it/raw_develop.rs | 2 +- .../ui-canvas/src/canvas/full_window/hosted.rs | 8 +++++--- .../ui-canvas/src/canvas/full_window/stories.rs | 2 +- 11 files changed, 32 insertions(+), 15 deletions(-) diff --git a/crates/imaging/src/ui/fill/mod.rs b/crates/imaging/src/ui/fill/mod.rs index a2582c524..878cf50f3 100644 --- a/crates/imaging/src/ui/fill/mod.rs +++ b/crates/imaging/src/ui/fill/mod.rs @@ -916,7 +916,7 @@ impl FullWindowWorkspace for ContentAwareFillWorkspace { /// The settings, and the bar's `tool`, `brushSize`, `brushMode` (`"add"`, `"subtract"`), `lassoMode` (`"new"`, /// `"add"`, `"subtract"`, `"intersect"`) and `expandBy`. - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { let mut fields = serde_fields(&self.settings)?; let bar = fields.as_object_mut()?; let brush_mode = if self.options.brush_add { "add" } else { "subtract" }; diff --git a/crates/imaging/src/ui/filter_gallery/mod.rs b/crates/imaging/src/ui/filter_gallery/mod.rs index 4ad13d448..3cb77eea5 100644 --- a/crates/imaging/src/ui/filter_gallery/mod.rs +++ b/crates/imaging/src/ui/filter_gallery/mod.rs @@ -436,7 +436,7 @@ impl FullWindowWorkspace for FilterGalleryWorkspace { WorkspacePass::new(dialog.output.response, events).result(result) } - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { let zoom = if self.view.is_fit() { json!("fit") } else { json!(self.view.device_zoom()) }; let effects = serde_json::to_value(&self.session.effects).unwrap_or_default(); Some(json!({ "effects": effects, "select": self.clamped_selection(), "zoom": zoom })) diff --git a/crates/imaging/src/ui/liquify/mod.rs b/crates/imaging/src/ui/liquify/mod.rs index 1200701a5..e8a6225b4 100644 --- a/crates/imaging/src/ui/liquify/mod.rs +++ b/crates/imaging/src/ui/liquify/mod.rs @@ -737,7 +737,7 @@ impl FullWindowWorkspace for LiquifyWorkspace { } /// The settings (the brush keys at the top level) and `preview`. - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { let mut fields = serde_fields(&self.edit.settings)?; fields.as_object_mut()?.insert("preview".to_owned(), serde_json::Value::Bool(self.preview)); Some(fields) diff --git a/crates/imaging/src/ui/raw_develop/mod.rs b/crates/imaging/src/ui/raw_develop/mod.rs index a935ed8c6..02bf25af2 100644 --- a/crates/imaging/src/ui/raw_develop/mod.rs +++ b/crates/imaging/src/ui/raw_develop/mod.rs @@ -811,7 +811,7 @@ impl FullWindowWorkspace for RawDevelopWorkspace { WorkspacePass::new(output.response, events).result(result) } - fn json_fields(&self) -> Option { + fn json_fields(&self, source: &Self::Source) -> Option { let mut fields = serde_fields(&self.settings)?; if let serde_json::Value::Object(map) = &mut fields { map.insert("before".to_owned(), serde_json::Value::Bool(self.before)); @@ -819,7 +819,11 @@ impl FullWindowWorkspace for RawDevelopWorkspace { let view = if self.view.is_fit() { serde_json::Value::from("fit") } else { serde_json::Value::from(self.view.zoom_percent()) }; map.insert("view".to_owned(), view); let scope = self.scope.as_ref().map(|state| state.settings.clone()).unwrap_or_default(); + let lab = scope.lab_readouts; map.insert("scope".to_owned(), serde_json::to_value(scope).unwrap_or(serde_json::Value::Null)); + let read = |at: [f64; 2]| preview::readout_json(source, at, self.before, lab); + map.insert("pointerReadout".to_owned(), self.hover.map_or(serde_json::Value::Null, read)); + map.insert("samplerReadouts".to_owned(), self.samplers.points().iter().copied().map(read).collect()); } Some(fields) } diff --git a/crates/imaging/src/ui/raw_develop/preview.rs b/crates/imaging/src/ui/raw_develop/preview.rs index 6adde51c2..5e6e5a9ff 100644 --- a/crates/imaging/src/ui/raw_develop/preview.rs +++ b/crates/imaging/src/ui/raw_develop/preview.rs @@ -12,8 +12,8 @@ use super::source::RawDevelopSource; use crate::scopes::ClippingMask; use crate::ui::scopes::{ClippingMode, ClippingOverlay, ScopeReadout}; -/// The readouts of `samplers` over the picture `before` or after, from `cache` while `revision` and the points are -/// unchanged. The samplers ask in RGB; with `lab` (Show Lab Color Readouts) each readout also carries its Lab value, +/// The readouts of `samplers` over the picture `before` or after, from `cache` while `revision`, the picture shown and the +/// points are unchanged. The samplers ask in RGB; with `lab` (Show Lab Color Readouts) each readout also carries its Lab value, /// asked of the source again for the few points. pub(super) fn sampler_readouts( samplers: &ColorSamplers, @@ -27,7 +27,7 @@ pub(super) fn sampler_readouts( Some(ScopeReadout::Rgb([r, g, b])) => Srgba { r, g, b, a: 1.0 }, _ => Srgba { r: 0.0, g: 0.0, b: 0.0, a: 0.0 }, }; - let readouts = SamplerReadouts::new(samplers, read).revision(revision).get(cache); + let readouts = SamplerReadouts::new(samplers, read).revision(revision).document(before).get(cache); if !lab { return readouts; } @@ -44,6 +44,17 @@ pub(super) fn sampler_readouts( Arc::new(with_lab) } +/// The readout under `at` as the automation surface lists it: its `position`, `space` (`rgb` in 0..=255, or `lab` +/// when `lab` asks for the Lab value) and `values`; `null` where the source reads no pixel. +pub(super) fn readout_json(source: &dyn RawDevelopSource, at: [f64; 2], before: bool, lab: bool) -> serde_json::Value { + let (space, values) = match source.sample(at, before, lab) { + Some(ScopeReadout::Rgb(rgb)) => ("rgb", rgb.map(|v| v * 255.0)), + Some(ScopeReadout::Lab(lab)) => ("lab", lab), + _ => return serde_json::Value::Null, + }; + serde_json::json!({ "position": at, "space": space, "values": values }) +} + /// The source's clipping mask and its revision while a warning is on; nothing when `mode` shows none. pub(super) fn clipping_state(source: &dyn RawDevelopSource, mode: ClippingMode) -> Option<(Arc, Revision)> { if matches!(mode, ClippingMode::None) { None } else { source.clipping() } diff --git a/crates/imaging/src/ui/select_mask/mod.rs b/crates/imaging/src/ui/select_mask/mod.rs index b2079f213..d53267345 100644 --- a/crates/imaging/src/ui/select_mask/mod.rs +++ b/crates/imaging/src/ui/select_mask/mod.rs @@ -915,7 +915,7 @@ impl FullWindowWorkspace for SelectMaskWorkspace { /// The settings, and the bar's `tool`, `mode` (`"add"`, `"subtract"`), `size` (of the current tool), `hardness`, /// `sampleAllLayers`, and `hideView`. - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { let mut fields = serde_fields(&self.settings)?; let bar = fields.as_object_mut()?; let mode = if self.options.add { "add" } else { "subtract" }; diff --git a/crates/imaging/src/ui/vanishing_point/mod.rs b/crates/imaging/src/ui/vanishing_point/mod.rs index 54b75e361..56711c5f9 100644 --- a/crates/imaging/src/ui/vanishing_point/mod.rs +++ b/crates/imaging/src/ui/vanishing_point/mod.rs @@ -514,7 +514,7 @@ impl FullWindowWorkspace for VanishingPointWorkspace { WorkspacePass::new(shown.output.response.clone(), events).result(result) } - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { let mut fields = serde_fields(&self.settings)?; let map = fields.as_object_mut()?; let selected = self.editor.selected().map_or(Value::Null, Value::from); diff --git a/crates/imaging/src/ui/wide_angle/mod.rs b/crates/imaging/src/ui/wide_angle/mod.rs index 5995509e9..a9ac5220a 100644 --- a/crates/imaging/src/ui/wide_angle/mod.rs +++ b/crates/imaging/src/ui/wide_angle/mod.rs @@ -507,7 +507,7 @@ impl FullWindowWorkspace for WideAngleWorkspace { WorkspacePass::new(shown.output.response.clone(), events).result(result) } - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { let mut fields = serde_fields(&self.session)?; fields.as_object_mut()?.insert("preview".to_owned(), Value::Bool(self.preview_on)); Some(fields) diff --git a/crates/imaging/tests/it/raw_develop.rs b/crates/imaging/tests/it/raw_develop.rs index cd732da5c..dde506a0d 100644 --- a/crates/imaging/tests/it/raw_develop.rs +++ b/crates/imaging/tests/it/raw_develop.rs @@ -284,7 +284,7 @@ fn readout_shown(fixture: &Fixture) -> bool { } fn scope_json(host: &Rc>) -> serde_json::Value { - let fields = host.borrow_mut().get_mut::().and_then(|hosted| hosted.workspace().json_fields()); + let fields = host.borrow_mut().get_mut::().and_then(|hosted| hosted.workspace().json_fields(&**hosted.source())); fields.and_then(|fields| fields.get("scope").cloned()).unwrap_or_default() } diff --git a/crates/ui-canvas/src/canvas/full_window/hosted.rs b/crates/ui-canvas/src/canvas/full_window/hosted.rs index 6c9a6428f..bbcc33b31 100644 --- a/crates/ui-canvas/src/canvas/full_window/hosted.rs +++ b/crates/ui-canvas/src/canvas/full_window/hosted.rs @@ -39,8 +39,10 @@ pub trait FullWindowWorkspace: Send + 'static { /// it binds to `open` ([`opened`](crate::dialog::FullWindowDialog::opened)). fn show(&mut self, ui: &mut Ui, cx: WorkspaceCx<'_, Self::Source>) -> WorkspacePass; - /// The workspace's fields as JSON for the automation surface; `None` when it has none. - fn json_fields(&self) -> Option { + /// The workspace's fields as JSON for the automation surface; `None` when it has none. `source` is what the app + /// shows the workspace, for the fields that read it (the readout under the pointer). + fn json_fields(&self, source: &Self::Source) -> Option { + let _ = source; None } @@ -321,7 +323,7 @@ impl StackDialog for HostedWorkspace { } fn json_fields(&self) -> Option { - self.workspace.json_fields() + self.workspace.json_fields(&*self.source) } fn set_json_field(&mut self, ctx: &Context, field: &str, value: serde_json::Value) -> Result<(), String> { diff --git a/crates/ui-canvas/src/canvas/full_window/stories.rs b/crates/ui-canvas/src/canvas/full_window/stories.rs index 870604803..4c52972af 100644 --- a/crates/ui-canvas/src/canvas/full_window/stories.rs +++ b/crates/ui-canvas/src/canvas/full_window/stories.rs @@ -153,7 +153,7 @@ impl FullWindowWorkspace for BrushWorkspace { WorkspacePass::new(shown.output.response, events).result(result).held(held) } - fn json_fields(&self) -> Option { + fn json_fields(&self, _source: &Self::Source) -> Option { Some(serde_json::json!({ "brush": self.brush })) }