Camera Raw: the sampler readouts follow Before; the workspace's automation fields carry the pointer and sampler readouts (json_fields takes the source)

This commit is contained in:
aiongg
2026-11-16 23:39:06 +00:00
parent 79a5564061
commit bcdfd861b3
11 changed files with 32 additions and 15 deletions
+1 -1
View File
@@ -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<serde_json::Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<serde_json::Value> {
let mut fields = serde_fields(&self.settings)?;
let bar = fields.as_object_mut()?;
let brush_mode = if self.options.brush_add { "add" } else { "subtract" };
+1 -1
View File
@@ -436,7 +436,7 @@ impl FullWindowWorkspace for FilterGalleryWorkspace {
WorkspacePass::new(dialog.output.response, events).result(result)
}
fn json_fields(&self) -> Option<Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<Value> {
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 }))
+1 -1
View File
@@ -737,7 +737,7 @@ impl FullWindowWorkspace for LiquifyWorkspace {
}
/// The settings (the brush keys at the top level) and `preview`.
fn json_fields(&self) -> Option<serde_json::Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<serde_json::Value> {
let mut fields = serde_fields(&self.edit.settings)?;
fields.as_object_mut()?.insert("preview".to_owned(), serde_json::Value::Bool(self.preview));
Some(fields)
+5 -1
View File
@@ -811,7 +811,7 @@ impl FullWindowWorkspace for RawDevelopWorkspace {
WorkspacePass::new(output.response, events).result(result)
}
fn json_fields(&self) -> Option<serde_json::Value> {
fn json_fields(&self, source: &Self::Source) -> Option<serde_json::Value> {
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)
}
+14 -3
View File
@@ -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<ClippingMask>, Revision)> {
if matches!(mode, ClippingMode::None) { None } else { source.clipping() }
+1 -1
View File
@@ -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<serde_json::Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<serde_json::Value> {
let mut fields = serde_fields(&self.settings)?;
let bar = fields.as_object_mut()?;
let mode = if self.options.add { "add" } else { "subtract" };
+1 -1
View File
@@ -514,7 +514,7 @@ impl FullWindowWorkspace for VanishingPointWorkspace {
WorkspacePass::new(shown.output.response.clone(), events).result(result)
}
fn json_fields(&self) -> Option<Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<Value> {
let mut fields = serde_fields(&self.settings)?;
let map = fields.as_object_mut()?;
let selected = self.editor.selected().map_or(Value::Null, Value::from);
+1 -1
View File
@@ -507,7 +507,7 @@ impl FullWindowWorkspace for WideAngleWorkspace {
WorkspacePass::new(shown.output.response.clone(), events).result(result)
}
fn json_fields(&self) -> Option<Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<Value> {
let mut fields = serde_fields(&self.session)?;
fields.as_object_mut()?.insert("preview".to_owned(), Value::Bool(self.preview_on));
Some(fields)
+1 -1
View File
@@ -284,7 +284,7 @@ fn readout_shown(fixture: &Fixture) -> bool {
}
fn scope_json(host: &Rc<RefCell<DialogHost>>) -> serde_json::Value {
let fields = host.borrow_mut().get_mut::<Hosted>().and_then(|hosted| hosted.workspace().json_fields());
let fields = host.borrow_mut().get_mut::<Hosted>().and_then(|hosted| hosted.workspace().json_fields(&**hosted.source()));
fields.and_then(|fields| fields.get("scope").cloned()).unwrap_or_default()
}
@@ -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<Self::Event, Self::Result>;
/// The workspace's fields as JSON for the automation surface; `None` when it has none.
fn json_fields(&self) -> Option<serde_json::Value> {
/// 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<serde_json::Value> {
let _ = source;
None
}
@@ -321,7 +323,7 @@ impl<W: FullWindowWorkspace> StackDialog for HostedWorkspace<W> {
}
fn json_fields(&self) -> Option<serde_json::Value> {
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> {
@@ -153,7 +153,7 @@ impl FullWindowWorkspace for BrushWorkspace {
WorkspacePass::new(shown.output.response, events).result(result).held(held)
}
fn json_fields(&self) -> Option<serde_json::Value> {
fn json_fields(&self, _source: &Self::Source) -> Option<serde_json::Value> {
Some(serde_json::json!({ "brush": self.brush }))
}