Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Open camera raws in Camera Raw first (Open / Cancel) (#1309)

Gert Pellin - GPE75b6931e713d
diff --git a/Cargo.lock b/Cargo.lock
index 86a22b278..bb980e6ee 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3868,6 +3868,7 @@ dependencies = [
"photocraft-plugins",
"photocraft-psd",
"photocraft-raster",
+ "photocraft-raw",
"photocraft-testkit",
"photocraft-text",
"photocraft-vector",
diff --git a/crates/algo/src/camera_raw.rs b/crates/algo/src/camera_raw.rs
index b4a6c6ac3..2c1b0c922 100644
--- a/crates/algo/src/camera_raw.rs
+++ b/crates/algo/src/camera_raw.rs
@@ -525,6 +525,17 @@ fn is_linear(c: &[[f32; 2]]) -> bool {
c.len() < 2 || c.iter().all(|p| (p[0] - p[1]).abs() < 1e-3)
}
+/// Camera Raw's white-balance channel gains for Temperature / Tint (−100…100), relative to the
+/// as-shot balance: warmer raises red and lowers blue (±35 % at the ends); a negative tint
+/// raises green, a positive one lowers it toward magenta (±25 %). An observed approximation of
+/// Adobe Camera Raw's sliders, not a colour-temperature model; shared by the filter (in linear
+/// RGB) and the raw open (on the camera's white-balance multipliers) so both agree.
+pub fn white_balance_gains(temperature: f32, tint: f32) -> [f32; 3] {
+ let t = temperature / 100.0;
+ let tn = tint / 100.0;
+ [1.0 + 0.35 * t, 1.0 - 0.25 * tn, 1.0 - 0.35 * t]
+}
+
/// Runs the Camera Raw pipeline on straight RGBA pixels (`w × h`, display-encoded RGB).
/// `float` keeps values above 1 (32-bit documents).
pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bool) {
@@ -535,9 +546,7 @@ pub fn develop(px: &mut [[f32; 4]], w: usize, h: usize, p: &CameraRaw, float: bo
let long = w.max(h) as f32;
// 1. White balance + exposure in linear light.
if !p.wb_neutral() {
- let t = p.temperature / 100.0;
- let tn = p.tint / 100.0;
- let mut g = [1.0 + 0.35 * t, 1.0 - 0.25 * tn, 1.0 - 0.35 * t];
+ let mut g = white_balance_gains(p.temperature, p.tint);
let norm = luma(g);
g = g.map(|v| v / norm * 2f32.powf(p.exposure));
par_rows(px, w, 1, |_, row| {
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs
index d19f4d652..81326e530 100644
--- a/crates/engine/src/prefs.rs
+++ b/crates/engine/src/prefs.rs
@@ -686,6 +686,10 @@ pub struct RawDefaults {
pub sharpen_for: RawSharpen,
pub open_as_smart_object: bool,
pub apply_auto_tone: bool,
+ /// Opening a raw file interactively shows the Camera Raw dialog first (Open / Cancel), as
+ /// Photoshop does; off develops it with the defaults straight away. Automation opens never
+ /// show the dialog.
+ pub open_in_camera_raw: bool,
}
impl Default for RawDefaults {
@@ -697,6 +701,7 @@ impl Default for RawDefaults {
sharpen_for: RawSharpen::None,
open_as_smart_object: false,
apply_auto_tone: false,
+ open_in_camera_raw: true,
}
}
}
diff --git a/crates/io/src/raw.rs b/crates/io/src/raw.rs
index 7d046d4fd..dc3299c51 100644
--- a/crates/io/src/raw.rs
+++ b/crates/io/src/raw.rs
@@ -6,7 +6,7 @@
use std::sync::Arc;
use photocraft_codecs::{self as codecs, ChannelLayout, Format, Image};
-use photocraft_raw::{DevelopOptions, Limits, RawError};
+use photocraft_raw::{DevelopOptions, Limits, RawError, WhiteBalance};
use crate::flat::image_to_document;
use crate::{ImportResult, IoError};
@@ -33,32 +33,99 @@ fn upright_preview(raw: &[u8], jpeg: &[u8]) -> Result<Image, IoError> {
Ok(img.oriented(o)?)
}
+/// Camera Raw's Temperature, Tint and Exposure, applied while developing the sensor data
+/// (the open-time Camera Raw dialog) instead of to the developed RGB pixels.
+#[derive(Clone, Copy, Debug, Default, PartialEq)]
+pub struct RawTuning {
+ /// −100…100, as `photocraft_algo::camera_raw::CameraRaw::temperature`.
+ pub temperature: f32,
+ /// −100…100, as `CameraRaw::tint`.
+ pub tint: f32,
+ /// EV, as `CameraRaw::exposure`.
+ pub exposure: f32,
+}
+
+/// Develops a raw file with `tuning` applied at the raw stage: Exposure as develop exposure,
+/// Temperature / Tint as gains on the camera's as-shot white-balance multipliers (the same
+/// gains the Camera Raw filter applies to RGB). The second value is `false` when the file has
+/// no as-shot white balance: Temperature / Tint were then not applied, and the caller keeps
+/// them as RGB adjustments.
+pub fn import_raw_tuned(name: &str, bytes: &[u8], tuning: &RawTuning) -> Result<(ImportResult, bool), IoError> {
+ let format = photocraft_raw::identify(bytes).map(|f| f.name()).unwrap_or("camera raw");
+ let exposure = f64::from(tuning.exposure);
+ if !exposure.is_finite() || !(-10.0..=10.0).contains(&exposure) {
+ return Err(IoError::Raw(RawError::Malformed(format!("exposure {} EV is out of range", tuning.exposure))));
+ }
+ let sensor = photocraft_raw::decode(bytes, &limits()).map_err(IoError::Raw)?;
+ let mut opts = DevelopOptions { limits: limits(), exposure, ..Default::default() };
+ let wb_applied = match sensor.camera_wb {
+ Some(m) => {
+ let g = wb_gains(tuning.temperature, tuning.tint);
+ opts.white_balance = WhiteBalance::Multipliers([m[0] * g[0], m[1] * g[1], m[2] * g[2]]);
+ true
+ }
+ None => false,
+ };
+ let dev = photocraft_raw::develop_sensor(&sensor, &opts).map_err(IoError::Raw)?;
+ let wb = if wb_applied {
+ format!("as-shot white balance, temperature {:+.0}, tint {:+.0}", tuning.temperature, tuning.tint)
+ } else {
+ "estimated white balance".into()
+ };
+ let summary = format!("developed in Camera Raw (exposure {:+.2} EV, {wb})", tuning.exposure);
+ Ok((developed_document(name, format, dev, &summary)?, wb_applied))
+}
+
+/// "Canon" + "Canon EOS 80D" and "NIKON CORPORATION" + "NIKON D3200" read as the model alone:
+/// the model already starts with the make's first word.
+fn camera_name(make: Option<&str>, model: Option<&str>) -> String {
+ match (make, model) {
+ (Some(make), Some(model))
+ if make.split_whitespace().next().is_some_and(|brand| model.to_ascii_lowercase().starts_with(&brand.to_ascii_lowercase())) =>
+ {
+ model.to_string()
+ }
+ (make, model) => [make, model].into_iter().flatten().collect::<Vec<_>>().join(" "),
+ }
+}
+
+/// Camera Raw's white-balance gains for Temperature / Tint (−100…100), the same the Camera
+/// Raw filter applies ([`photocraft_algo::camera_raw::white_balance_gains`]).
+fn wb_gains(temperature: f32, tint: f32) -> [f64; 3] {
+ photocraft_algo::camera_raw::white_balance_gains(temperature.clamp(-100.0, 100.0), tint.clamp(-100.0, 100.0)).map(f64::from)
+}
+
+/// A developed raw as a 16-bit ProPhoto document, with a note saying how it was developed.
+fn developed_document(name: &str, format: &str, dev: photocraft_raw::Developed, summary: &str) -> Result<ImportResult, IoError> {
+ let img = Image::from_u16(dev.width, dev.height, ChannelLayout::Rgb, &dev.rgb)?;
+ let mut r = image_to_document(name, &img)?;
+ r.document.icc_profile = Some(Arc::new(photocraft_cms::Builtin::ProPhotoCompat.profile().to_bytes().to_vec()));
+ let camera = camera_name(dev.info.make.as_deref(), dev.info.model.as_deref());
+ r.warnings.push(format!(
+ "{format}{} {summary} into 16-bit {}",
+ if camera.is_empty() { String::new() } else { format!(" from {camera}") },
+ photocraft_raw::OUTPUT_SPACE
+ ));
+ r.warnings.extend(dev.warnings);
+ Ok(r)
+}
+
/// Develops a raw file with the default settings.
pub fn import_raw(name: &str, bytes: &[u8]) -> Result<ImportResult, IoError> {
import_raw_with(name, bytes, &DevelopOptions { limits: limits(), ..Default::default() })
}
+/// In the import note of a raw developed from its sensor data with the default settings (not of
+/// a preview fallback): what the open-time Camera Raw dialog looks for.
+pub const DEVELOPED_NOTE: &str = "developed with default settings";
+
/// Develops a raw file with explicit settings.
pub fn import_raw_with(name: &str, bytes: &[u8], opts: &DevelopOptions) -> Result<ImportResult, IoError> {
let format = photocraft_raw::identify(bytes).map(|f| f.name()).unwrap_or("camera raw");
match photocraft_raw::develop(bytes, opts) {
Ok(dev) => {
- let img = Image::from_u16(dev.width, dev.height, ChannelLayout::Rgb, &dev.rgb)?;
- let mut r = image_to_document(name, &img)?;
- r.document.icc_profile = Some(Arc::new(photocraft_cms::Builtin::ProPhotoCompat.profile().to_bytes().to_vec()));
- // "Canon" + "Canon EOS 80D" reads as "Canon EOS 80D".
- let camera = match (dev.info.make.as_deref(), dev.info.model.as_deref()) {
- (Some(make), Some(model)) if model.to_ascii_lowercase().starts_with(&make.to_ascii_lowercase()) => model.to_string(),
- (make, model) => [make, model].into_iter().flatten().collect::<Vec<_>>().join(" "),
- };
- r.warnings.push(format!(
- "{format}{} developed with default settings ({} demosaic, as-shot white balance) into 16-bit {}",
- if camera.is_empty() { String::new() } else { format!(" from {camera}") },
- opts.demosaic.id(),
- photocraft_raw::OUTPUT_SPACE
- ));
- r.warnings.extend(dev.warnings);
- Ok(r)
+ let summary = format!("{DEVELOPED_NOTE} ({} demosaic, as-shot white balance)", opts.demosaic.id());
+ developed_document(name, format, dev, &summary)
}
Err(RawError::Unsupported(reason)) => match photocraft_raw::embedded_preview(bytes) {
Some(p) => {
@@ -78,3 +145,17 @@ pub fn import_raw_with(name: &str, bytes: &[u8], opts: &DevelopOptions) -> Resul
Err(e) => Err(IoError::Raw(e)),
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn camera_names_drop_a_repeated_make() {
+ assert_eq!(camera_name(Some("Canon"), Some("Canon EOS 80D")), "Canon EOS 80D");
+ assert_eq!(camera_name(Some("NIKON CORPORATION"), Some("NIKON D3200")), "NIKON D3200");
+ assert_eq!(camera_name(Some("SONY"), Some("ILCE-7M3")), "SONY ILCE-7M3");
+ assert_eq!(camera_name(None, Some("X")), "X");
+ assert_eq!(camera_name(Some("Panasonic"), Some("DC-G9")), "Panasonic DC-G9");
+ }
+}
diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml
index 18879cc8d..e4d8ebd6a 100644
--- a/crates/ui-egui/Cargo.toml
+++ b/crates/ui-egui/Cargo.toml
@@ -39,6 +39,8 @@ rayon = { workspace = true }
sys-locale = "=0.3.2"
[dev-dependencies]
+# Synthetic raw files for the open-time Camera Raw dialog tests.
+photocraft-raw = { workspace = true, features = ["testgen"] }
egui_kittest = { workspace = true, features = ["wgpu", "snapshot", "eframe"] }
# Benchmark helpers for the `--json` benches `cargo xtask perf` runs (in-process RSS, percentiles).
photocraft-testkit = { workspace = true }
diff --git a/crates/ui-egui/src/camera_raw_ui.rs b/crates/ui-egui/src/camera_raw_ui.rs
index 8ed65a25f..2fcc24c0e 100644
--- a/crates/ui-egui/src/camera_raw_ui.rs
+++ b/crates/ui-egui/src/camera_raw_ui.rs
@@ -60,6 +60,8 @@ pub struct CameraRawDialog {
pub show_before: bool,
mixer_tab: usize,
pub render_ms: f64,
+ /// Set for the open-time dialog ([`Target::OpenRaw`]).
+ raw_open: Option<RawOpen>,
}
impl CameraRawDialog {
@@ -72,8 +74,9 @@ impl CameraRawDialog {
"samples": h.samples, "transparent": h.transparent, "invalid": h.invalid, "underflow": h.underflow, "overflow": h.overflow, "shadows": h.shadows, "highlights": h.highlights}});
result["smartFilter"] = json!(match self.target {
Target::SmartFilter(index) => Some(index),
- Target::NewFilter => None,
+ Target::NewFilter | Target::OpenRaw => None,
});
+ result["openingRaw"] = json!(self.raw_open.as_ref().map(|r| json!({"name": r.name, "path": r.path})));
result["view"] = json!(navigation);
result["sourceSize"] = json!([self.full_w, self.full_h]);
result["previewApproximate"] = json!(!self.detail.ready && (self.pw != self.full_w || self.ph != self.full_h));
@@ -110,17 +113,7 @@ impl CameraRawDialog {
/// Params for the engine: only the settings that differ from the defaults.
pub fn command_params(&self) -> Value {
- let full = serde_json::to_value(&self.params).unwrap_or(json!({}));
- let def = serde_json::to_value(CameraRaw::default()).unwrap_or(json!({}));
- let mut out = serde_json::Map::new();
- if let (Value::Object(f), Value::Object(d)) = (full, def) {
- for (k, v) in f {
- if k != "pixelScale" && d.get(&k) != Some(&v) {
- out.insert(k, v);
- }
- }
- }
- Value::Object(out)
+ non_defaults(&self.params)
}
fn image(px: &[[f32; 4]], w: usize, h: usize) -> egui::ColorImage {
@@ -166,6 +159,272 @@ impl CameraRawDialog {
enum Target {
NewFilter,
SmartFilter(usize),
+ /// The open-time dialog of a raw file just opened (File › Open): OK is **Open**, Cancel
+ /// closes the document again. See [`RawOpen`].
+ OpenRaw,
+}
+
+/// A raw file opened interactively, shown in Camera Raw before it is kept (as Photoshop opens
+/// raws in Adobe Camera Raw first). The document is already developed with the defaults; Open
+/// re-develops it when Temperature, Tint or Exposure changed (those act on the sensor data, see
+/// [`photocraft_io::raw::import_raw_tuned`]) and applies the other settings as one Camera Raw
+/// step, then marks the document unmodified. Cancel closes it.
+#[derive(Clone, Debug)]
+pub struct RawOpen {
+ pub document: photocraft_doc::DocId,
+ pub name: String,
+ pub path: Option<String>,
+ /// The file, when it was opened from bytes (no path to read it again from).
+ pub bytes: Option<std::sync::Arc<Vec<u8>>>,
+}
+
+/// Should an interactive open of `name` show the open-time Camera Raw dialog? `warnings` are
+/// the import's: only a raw developed from its sensor data qualifies (not a preview fallback).
+pub fn wants_open_dialog(app: &PhotocraftApp, warnings: &[String]) -> bool {
+ app.session.prefs().raw_defaults.open_in_camera_raw && warnings.iter().any(|w| w.contains(photocraft_io::raw::DEVELOPED_NOTE))
+}
+
+/// `warnings` without the "developed with default settings" note: the open-time dialog shows
+/// how the raw is developed.
+pub fn without_develop_note(warnings: &[String]) -> Vec<String> {
+ warnings.iter().filter(|w| !w.contains(photocraft_io::raw::DEVELOPED_NOTE)).cloned().collect()
+}
+
+/// Queues the open-time dialog for the active document (shown on the next frame).
+pub fn queue_open_dialog(app: &mut PhotocraftApp, name: &str, path: Option<&str>, bytes: Option<&[u8]>) {
+ if let Some(st) = app.session.active() {
+ app.pending_raw_open = Some(RawOpen {
+ document: st.doc.id,
+ name: name.to_string(),
+ path: path.map(str::to_string),
+ bytes: bytes.map(|b| std::sync::Arc::new(b.to_vec())),
+ });
+ }
+}
+
+/// Opens the queued open-time dialog on its document's (only) layer.
+fn open_raw(app: &mut PhotocraftApp, ctx: &egui::Context, raw: RawOpen) -> Result<(), String> {
+ let index = document_index(app, raw.document).ok_or("the raw document was closed")?;
+ app.session.set_active(index);
+ let (layer, surf, _) = crate::distort_ui::active_pixels(app)?;
+ open_pixels(app, ctx, layer, surf, CameraRaw::default(), Coverage::None, Target::OpenRaw)?;
+ if let Some(d) = app.camera_raw.as_mut() {
+ d.layer_name = raw.name.clone();
+ d.raw_open = Some(raw);
+ }
+ Ok(())
+}
+
+fn document_index(app: &PhotocraftApp, id: photocraft_doc::DocId) -> Option<usize> {
+ app.session.documents().iter().position(|st| st.doc.id == id)
+}
+
+/// The non-default settings of `p` as engine params.
+fn non_defaults(p: &CameraRaw) -> Value {
+ let full = serde_json::to_value(p).unwrap_or(json!({}));
+ let def = serde_json::to_value(CameraRaw::default()).unwrap_or(json!({}));
+ let mut out = serde_json::Map::new();
+ if let (Value::Object(f), Value::Object(d)) = (full, def) {
+ for (k, v) in f {
+ if k != "pixelScale" && d.get(&k) != Some(&v) {
+ out.insert(k, v);
+ }
+ }
+ }
+ Value::Object(out)
+}
+
+/// The job id of an open-time re-develop (not an engine command: the shell starts it).
+pub const REDEVELOP_JOB: &str = "cameraRaw.redevelop";
+
+/// An open-time re-develop running in the background: what to finish with when it lands.
+#[derive(Clone, Debug)]
+pub struct Redevelop {
+ pub job: photocraft_engine::jobs::JobId,
+ params: CameraRaw,
+ raw: RawOpen,
+ /// The job is the final Camera Raw step (`filter.cameraRaw`), not the re-develop: when it
+ /// lands the document is marked unmodified.
+ filter_step: bool,
+}
+
+/// Open: re-develop for raw-stage settings, apply the rest, keep the document unmodified.
+///
+/// Re-developing reads and decodes the whole raw again, so in the desktop app (background jobs
+/// on) it runs as a job like the open itself: the reply is `{"job", "pending": true}`, the
+/// document is locked meanwhile, and [`on_redevelop_event`] finishes when it lands. Elsewhere
+/// (tests, the web) it runs inline.
+fn commit_open_raw(app: &mut PhotocraftApp, params: &CameraRaw, raw: &RawOpen) -> Result<Value, String> {
+ let index = document_index(app, raw.document).ok_or("the raw document was closed")?;
+ let tuning = photocraft_io::raw::RawTuning { temperature: params.temperature, tint: params.tint, exposure: params.exposure };
+ // Without the file the raw-stage settings stay RGB adjustments, like the filter's.
+ let source = match (&raw.bytes, &raw.path) {
+ (Some(b), _) => Some(photocraft_engine::jobs::OpenSource::Bytes(b.clone())),
+ #[cfg(not(target_arch = "wasm32"))]
+ (None, Some(p)) => Some(photocraft_engine::jobs::OpenSource::Path(p.clone())),
+ _ => None,
+ };
+ let Some(source) = source.filter(|_| tuning != photocraft_io::raw::RawTuning::default()) else {
+ return finish_open_raw(app, index, params.clone(), None, Some(raw));
+ };
+ app.session.set_active(index);
+ let (name, doc_id) = (raw.name.clone(), raw.document);
+ let work = move |ctx: &photocraft_engine::jobs::JobCtx| -> photocraft_engine::Result<(photocraft_io::ImportResult, bool)> {
+ ctx.progress(0.0, "Reading");
+ let bytes = match source {
+ photocraft_engine::jobs::OpenSource::Bytes(b) => b,
+ #[cfg(not(target_arch = "wasm32"))]
+ photocraft_engine::jobs::OpenSource::Path(p) => {
+ std::sync::Arc::new(std::fs::read(&p).map_err(|e| photocraft_engine::EngineError::Other(format!("{p}: {e}")))?)
+ }
+ #[cfg(target_arch = "wasm32")]
+ photocraft_engine::jobs::OpenSource::Path(p) => return Err(photocraft_engine::EngineError::Other(format!("{p}: cannot read files here"))),
+ };
+ ctx.check()?;
+ ctx.progress(0.05, "Developing");
+ photocraft_io::raw::import_raw_tuned(&name, &bytes, &tuning).map_err(|e| photocraft_engine::EngineError::Other(e.to_string()))
+ };
+ let apply = move |s: &mut photocraft_engine::Session, (r, wb): (photocraft_io::ImportResult, bool)| replace_raw_document(s, doc_id, r, wb);
+ let label = crate::i18n::fmt(tl!("Developing {name}"), &[("name", &raw.name)]);
+ let started = if app.background_jobs {
+ app.session.start_job(REDEVELOP_JOB, json!({"name": raw.name}), &label, true, work, apply).map_err(|e| e.to_string())?
+ } else {
+ let v = work(&photocraft_engine::jobs::JobCtx::new()).and_then(|t| apply(&mut app.session, t)).map_err(|e| e.to_string())?;
+ photocraft_engine::jobs::Started::Done(v)
+ };
+ match started {
+ photocraft_engine::jobs::Started::Done(v) => finish_redevelop(app, params, raw, &v),
+ photocraft_engine::jobs::Started::Job(job) => {
+ app.raw_redevelop = Some(Redevelop { job, params: params.clone(), raw: raw.clone(), filter_step: false });
+ app.ui.status = label;
+ app.ui.status_error = false;
+ Ok(json!({"job": job.0, "pending": true}))
+ }
+ }
+}
+
+/// Swap the default-developed document `doc_id` for the re-developed one, at the same tab
+/// position and with the same path. Returns `{document, previous, warnings, wb}`.
+fn replace_raw_document(
+ s: &mut photocraft_engine::Session,
+ doc_id: photocraft_doc::DocId,
+ r: photocraft_io::ImportResult,
+ wb: bool,
+) -> photocraft_engine::Result<Value> {
+ let index =
+ s.documents().iter().position(|st| st.doc.id == doc_id).ok_or_else(|| photocraft_engine::EngineError::Other("the raw document was closed".into()))?;
+ let path = s.documents().get(index).and_then(|st| st.path.clone());
+ s.close(index);
+ let (opened, _) = s.open_document(r.document, path);
+ let index = match s.execute("document.move", json!({"document": opened, "to": index})) {
+ Ok(moved) => moved.get("document").and_then(Value::as_u64).map_or(opened, |i| i as usize),
+ Err(_) => opened,
+ };
+ s.set_active(index);
+ Ok(json!({"document": index, "previous": doc_id.0, "warnings": r.warnings, "wb": wb}))
+}
+
+/// After the re-develop: keep the old document's view (zoom, scroll) on the new one, report
+/// the import's notes, then apply the remaining settings.
+fn finish_redevelop(app: &mut PhotocraftApp, params: &CameraRaw, raw: &RawOpen, v: &Value) -> Result<Value, String> {
+ let index = v.get("document").and_then(Value::as_u64).ok_or("the re-develop returned no document")? as usize;
+ if let Some(new_id) = app.session.documents().get(index).map(|st| st.doc.id) {
+ for id in app.view_docs.iter_mut().filter(|id| **id == raw.document) {
+ *id = new_id;
+ }
+ }
+ let warnings: Vec<String> =
+ v.get("warnings").and_then(Value::as_array).map(|a| a.iter().filter_map(|w| w.as_str().map(str::to_string)).collect()).unwrap_or_default();
+ crate::notices::io_warnings(app, &format!("Opened {}", raw.name), &without_develop_note(&warnings));
+ let mut rest = params.clone();
+ rest.exposure = 0.0;
+ if v.get("wb").and_then(Value::as_bool) == Some(true) {
+ rest.temperature = 0.0;
+ rest.tint = 0.0;
+ }
+ finish_open_raw(app, index, rest, Some(true), Some(raw))
+}
+
+/// The other settings as one Camera Raw step on document `index`, then the document is marked
+/// unmodified (developing is part of opening). The step runs like any filter (in the
+/// background in the desktop app); the document is marked unmodified when it lands.
+fn finish_open_raw(app: &mut PhotocraftApp, index: usize, rest: CameraRaw, redeveloped: Option<bool>, raw: Option<&RawOpen>) -> Result<Value, String> {
+ app.session.set_active(index);
+ app.sync_views();
+ let mut result = json!({"document": index, "redeveloped": redeveloped.unwrap_or(false)});
+ if !rest.is_identity() {
+ let layer = app.session.active().and_then(|st| st.active_layer).ok_or("no layer to develop")?;
+ let mut p = non_defaults(&rest);
+ p["layer"] = json!(layer.0);
+ let r = app.run("filter.cameraRaw", p)?;
+ if r.get("pending").and_then(Value::as_bool) == Some(true)
+ && let (Some(job), Some(raw)) = (r.get("job").and_then(Value::as_u64), raw)
+ {
+ app.raw_redevelop = Some(Redevelop { job: photocraft_engine::jobs::JobId(job), params: rest.clone(), raw: raw.clone(), filter_step: true });
+ }
+ result["filter"] = r;
+ }
+ mark_unmodified(app, index);
+ Ok(result)
+}
+
+fn mark_unmodified(app: &mut PhotocraftApp, index: usize) {
+ let active = app.session.active_index();
+ app.session.set_active(index);
+ if let Some(st) = app.session.active_mut() {
+ st.saved_revision = st.revision;
+ }
+ if let Some(i) = active {
+ app.session.set_active(i);
+ }
+ app.sync_views();
+}
+
+/// A finished background re-develop ([`REDEVELOP_JOB`]) or open-time Camera Raw step. `true`
+/// when the event was one of those (handled here).
+pub fn on_redevelop_event(app: &mut PhotocraftApp, e: &photocraft_engine::jobs::JobEvent) -> bool {
+ let Some(pending) = app.raw_redevelop.take_if(|r| r.job == e.id) else { return false };
+ if pending.filter_step {
+ if matches!(e.outcome, photocraft_engine::jobs::JobOutcome::Done(_))
+ && let Some(index) = e.document.and_then(|id| document_index(app, id))
+ {
+ mark_unmodified(app, index);
+ }
+ // The usual filter reporting still applies.
+ return false;
+ }
+ match &e.outcome {
+ photocraft_engine::jobs::JobOutcome::Done(v) => match finish_redevelop(app, &pending.params, &pending.raw, v) {
+ Ok(_) => {
+ app.ui.status = format!("Opened {}", pending.raw.name);
+ app.ui.status_error = false;
+ }
+ Err(err) => crate::notices::error(app, format!("{}: {err}", e.label)),
+ },
+ photocraft_engine::jobs::JobOutcome::Failed(err) => {
+ // The document stays open, developed with the defaults.
+ app.sync_views();
+ crate::notices::error(app, format!("{}: {err}", e.label));
+ }
+ photocraft_engine::jobs::JobOutcome::Cancelled => {
+ app.ui.status = crate::i18n::fmt(tl!("Cancelled {label}"), &[("label", &e.label)]);
+ app.ui.status_error = false;
+ }
+ }
+ true
+}
+
+/// Cancel: closes the dialog; for the open-time dialog also the document it was opening.
+fn cancel(app: &mut PhotocraftApp) {
+ let Some(d) = app.camera_raw.take() else { return };
+ if let (Target::OpenRaw, Some(raw)) = (d.target, &d.raw_open)
+ && let Some(index) = document_index(app, raw.document)
+ {
+ app.session.close(index);
+ app.sync_views();
+ app.ui.status = crate::i18n::fmt(tl!("Cancelled opening {name}"), &[("name", &raw.name)]);
+ app.ui.status_error = false;
+ }
}
/// What limits the preview: the document selection (a new filter applies through it, as the
@@ -320,6 +579,7 @@ fn open_pixels(
curve_state: Default::default(),
curve_rect: None,
render_ms: 0.0,
+ raw_open: None,
};
d.render(ctx);
app.camera_raw = Some(d);
@@ -446,7 +706,7 @@ fn menu_update(app: &mut PhotocraftApp, ctx: &egui::Context, ui: &Value) -> Opti
}
super::camera_raw_scope_ui::persist(app, ctx);
if ui.get("cancel").and_then(Value::as_bool) == Some(true) {
- app.camera_raw = None;
+ cancel(app);
return Some(Ok(json!({"cancelled": true})));
}
if ui.get("commit").and_then(Value::as_bool) == Some(true) {
@@ -473,6 +733,11 @@ fn commit(app: &mut PhotocraftApp) -> Result<Value, String> {
}
app.run("layer.smartFilter.setParams", json!({"layer": d.layer.0, "index": index, "params": params}))?
}
+ Target::OpenRaw => {
+ let raw = d.raw_open.clone().ok_or("no raw file is being opened")?;
+ let params = d.params.clone();
+ commit_open_raw(app, &params, &raw)?
+ }
};
app.camera_raw = None;
Ok(result)
@@ -562,6 +827,14 @@ fn curve_editor(ui: &mut egui::Ui, p: &mut CameraRaw, dirty: &mut bool, state: &
}
pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
+ if app.camera_raw.is_none()
+ && let Some(raw) = app.pending_raw_open.take()
+ && let Err(e) = open_raw(app, ctx, raw)
+ {
+ // The document stays open, developed with the defaults.
+ app.ui.status = e;
+ app.ui.status_error = true;
+ }
if app.camera_raw.is_none() {
return;
}
@@ -581,7 +854,12 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let title = ERect::from_min_size(full.min, vec2(full.width(), 30.0));
painter.rect_filled(title, 0.0, t.dock);
painter.line_segment([title.left_bottom(), title.right_bottom()], Stroke::new(1.0, t.separator));
- let window_title = crate::i18n::fmt(tl!("Camera Raw Filter ({layer})"), &[("layer", &d.layer_name)]);
+ let window_title = if d.target == Target::OpenRaw {
+ crate::i18n::fmt(tl!("Camera Raw ({name})"), &[("name", &d.layer_name)])
+ } else {
+ crate::i18n::fmt(tl!("Camera Raw Filter ({layer})"), &[("layer", &d.layer_name)])
+ };
+ let ok_label = if d.target == Target::OpenRaw { tl!("Open") } else { tl!("OK") };
painter.text(title.center(), Align2::CENTER_CENTER, window_title, FontId::proportional(13.0), t.text);
let footer_h = 48.0;
let body = ERect::from_min_max(pos2(full.left(), title.bottom()), pos2(full.right(), full.bottom() - footer_h));
@@ -751,7 +1029,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
if let Some(role) = widgets::dialog_buttons(
&mut fu,
&[
- widgets::DialogButton::new(widgets::ButtonRole::Default, tl!("OK"), 90.0),
+ widgets::DialogButton::new(widgets::ButtonRole::Default, ok_label, 90.0),
widgets::DialogButton::new(widgets::ButtonRole::Cancel, tl!("Cancel"), 90.0),
],
) {
@@ -776,7 +1054,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
app.ui.status = e;
}
}
- Some("cancel") => app.camera_raw = None,
+ Some("cancel") => cancel(app),
_ => {}
}
}
@@ -913,4 +1191,110 @@ mod tests {
assert_eq!(r["cancelled"], true);
assert!(menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"exposure": "x"}}})).unwrap().is_err());
}
+
+ /// An app whose importer is the real one, opening a synthetic DNG.
+ fn raw_app() -> (PhotocraftApp, Vec<u8>) {
+ use photocraft_raw::testgen::{DngSpec, mosaic, scene};
+ let services = crate::Services {
+ import: Some(Box::new(|name: &str, b: &[u8]| photocraft_io::import(name, b).map(|r| (r.document, r.warnings)).map_err(|e| e.to_string()))),
+ ..Default::default()
+ };
+ let (w, h) = (48, 32);
+ let mut spec = DngSpec::cfa(w, h, mosaic(&scene(w, h), w, [0, 1, 1, 2], 0, 30000));
+ spec.as_shot_neutral = Some([0.5, 1.0, 0.7]);
+ (PhotocraftApp::new(photocraft_engine::Session::new(), services), spec.build())
+ }
+
+ fn mean_red(app: &PhotocraftApp) -> f32 {
+ let st = app.session.active().unwrap();
+ let s = st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap();
+ (0..8).map(|i| s.rgba(4 + i * 4, 16)[0]).sum::<f32>() / 8.0
+ }
+
+ #[test]
+ fn raw_opens_in_camera_raw_and_open_redevelops() {
+ let (mut app, dng) = raw_app();
+ let ctx = egui::Context::default();
+ let warnings = app.open_bytes("IMG_0001.dng", &dng).unwrap();
+ assert!(warnings.iter().any(|w| w.contains(photocraft_io::raw::DEVELOPED_NOTE)), "{warnings:?}");
+ let raw = app.pending_raw_open.take().expect("a raw open queues the dialog");
+ open_raw(&mut app, &ctx, raw).unwrap();
+ let d = app.camera_raw.as_ref().unwrap();
+ assert_eq!(d.target, Target::OpenRaw);
+ assert_eq!(d.describe(&app.ui.camera_raw_scope, &app.ui.camera_raw_preview)["openingRaw"]["name"], "IMG_0001.dng");
+ let before = mean_red(&app);
+ menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"exposure": 1.0, "temperature": 30, "contrast": 20}}})).unwrap().unwrap();
+ let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap();
+ assert_eq!(r["redeveloped"], true, "{r}");
+ assert!(r.get("filter").is_some(), "contrast is applied as a Camera Raw step: {r}");
+ assert!(app.camera_raw.is_none());
+ assert_eq!(app.session.documents().len(), 1);
+ let st = app.session.active().unwrap();
+ assert_eq!(st.saved_revision, st.revision, "Open leaves the document unmodified");
+ assert_eq!(st.doc.depth, photocraft_color::SampleType::U16);
+ assert!(mean_red(&app) > before + 0.05, "{before} → {}", mean_red(&app));
+ }
+
+ #[test]
+ fn background_redevelop_keeps_the_tab_position_and_view() {
+ let (mut app, dng) = raw_app();
+ let ctx = egui::Context::default();
+ app.run("file.new", json!({"width": 10, "height": 10})).unwrap();
+ app.open_bytes("mid.dng", &dng).unwrap();
+ app.run("file.new", json!({"width": 12, "height": 12})).unwrap();
+ app.sync_views();
+ let raw = app.pending_raw_open.take().unwrap();
+ let old_id = raw.document;
+ assert_eq!(document_index(&app, old_id), Some(1));
+ app.ui.views[1].zoom = 3.0;
+ open_raw(&mut app, &ctx, raw).unwrap();
+ let before = mean_red(&app);
+ // The re-develop and the Camera Raw step run as jobs; the UI thread only polls.
+ app.background_jobs = true;
+ menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"set": {"exposure": 1.0, "contrast": 20}}})).unwrap().unwrap();
+ let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap();
+ assert_eq!(r["pending"], true, "{r}");
+ assert!(app.camera_raw.is_none());
+ for _ in 0..3000 {
+ crate::jobs_ui::tick(&mut app, &ctx);
+ if app.raw_redevelop.is_none() && !app.session.has_jobs() {
+ break;
+ }
+ std::thread::sleep(std::time::Duration::from_millis(5));
+ }
+ assert!(app.raw_redevelop.is_none() && !app.session.has_jobs(), "the jobs never finished");
+ let docs = app.session.documents();
+ assert_eq!(docs.len(), 3);
+ assert_eq!((docs[0].doc.size.width, docs[2].doc.size.width), (10, 12), "the other tabs keep their places");
+ assert_ne!(docs[1].doc.id, old_id, "re-developed");
+ assert_eq!(docs[1].doc.depth, photocraft_color::SampleType::U16);
+ assert_eq!(docs[1].saved_revision, docs[1].revision, "Open leaves the document unmodified");
+ assert_eq!(app.session.active_index(), Some(1));
+ assert_eq!(app.ui.views[1].zoom, 3.0, "the view carries over to the re-developed document");
+ assert!(mean_red(&app) > before + 0.05, "{before} → {}", mean_red(&app));
+ }
+
+ #[test]
+ fn cancel_closes_the_raw_and_the_preference_skips_the_dialog() {
+ let (mut app, dng) = raw_app();
+ let ctx = egui::Context::default();
+ app.open_bytes("a.dng", &dng).unwrap();
+ let raw = app.pending_raw_open.take().unwrap();
+ open_raw(&mut app, &ctx, raw).unwrap();
+ let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"cancel": true}})).unwrap().unwrap();
+ assert_eq!(r["cancelled"], true);
+ assert!(app.session.documents().is_empty(), "Cancel closes the raw being opened");
+ // Unchanged settings: Open keeps the default develop and adds no step.
+ app.open_bytes("b.dng", &dng).unwrap();
+ let raw = app.pending_raw_open.take().unwrap();
+ open_raw(&mut app, &ctx, raw).unwrap();
+ let r = menu(&mut app, &ctx, "filter.cameraRaw", &json!({"ui": {"commit": true}})).unwrap().unwrap();
+ assert_eq!(r, json!({"document": 0, "redeveloped": false}));
+ // Preference off: raws open straight away.
+ app.run("prefs.set", json!({"path": "rawDefaults.openInCameraRaw", "value": false})).unwrap();
+ app.open_bytes("c.dng", &dng).unwrap();
+ assert!(app.pending_raw_open.is_none());
+ // A non-raw never queues the dialog; a closed document is an error, not a panic.
+ assert!(open_raw(&mut app, &ctx, RawOpen { document: photocraft_doc::DocId(u64::MAX), name: "x".into(), path: None, bytes: None }).is_err());
+ }
}
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 7d4d8a842..b46ebcc3b 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -1823,6 +1823,7 @@
Never Nikdy
Normal tip Normální hrot
Open as smart object Otevřít jako chytrý objekt
+ Open in camera raw Otevírat v Camera Raw
Open documents as tabs Otevírat dokumenty jako záložky
Overscroll Posouvání za okraj
Performance Výkon
@@ -2021,6 +2022,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Není k dispozici žádná cesta, ze které by šlo vytvořit výběr: nakreslete ji nástrojem Pero nebo ji vyberte na panelu Cesty.
Cancel opening Zrušit otevírání
Cancelled opening {name} Otevírání {name} zrušeno
+ Developing {name} Vyvolávání {name}
Cancelled {label} Zrušeno: {label}
Esc to cancel Esc pro zrušení
Opening {name} Otevírání {name}
@@ -2059,6 +2061,7 @@
cameraRaw Light Světlo
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Filtr Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Red Červené
cameraRaw Orange Oranžové
cameraRaw Yellow Žluté
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 417f9ad98..3c9cb4b0c 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -1800,6 +1800,7 @@
Never Nie
Normal tip Normale Spitze
Open as smart object Als Smart-Objekt öffnen
+ Open in camera raw In Camera Raw öffnen
Open documents as tabs Dokumente als Registerkarten öffnen
Overscroll Überscrollen
Performance Leistung
@@ -1994,6 +1995,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Kein Pfad für eine Auswahl vorhanden: zeichne einen mit dem Stift-Werkzeug oder wähle einen im Pfade-Bedienfeld.
Cancel opening Öffnen abbrechen
Cancelled opening {name} Öffnen von {name} abgebrochen
+ Developing {name} {name} wird entwickelt
Cancelled {label} {label} abgebrochen
Esc to cancel Esc zum Abbrechen
Opening {name} Öffne {name}
@@ -2104,6 +2106,7 @@
4 x 4 4 x 4
5 x 5 5 x 5
Camera Raw Filter ({layer}) Camera-Raw-Filter ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
Edit Type Text bearbeiten
Grid: Raster:
Highlight Clipping Warning (O) Lichter-Abschneidewarnung (O)
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 500562e13..c7f3d1f48 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -1809,6 +1809,7 @@
Never Nunca
Normal tip Punta normal
Open as smart object Abrir como objeto inteligente
+ Open in camera raw Abrir en Camera Raw
Open documents as tabs Abrir los documentos como pestañas
Overscroll Sobredesplazamiento
Performance Rendimiento
@@ -2007,6 +2008,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. No hay ningún trazado para crear una selección: dibuje uno con la herramienta Pluma o seleccione uno en el panel Trazados.
Cancel opening Cancelar apertura
Cancelled opening {name} Se canceló la apertura de {name}
+ Developing {name} Revelando {name}
Cancelled {label} Se canceló {label}
Esc to cancel Esc para cancelar
Opening {name} Abriendo {name}
@@ -2131,6 +2133,7 @@
cameraRaw Light Luz
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Filtro Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights Tonos claros
cameraRaw Darks Tonos oscuros
cameraRaw Red Rojos
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index e561b3a04..58c8e6e66 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -1787,6 +1787,7 @@
Never Jamais
Normal tip Pointe normale
Open as smart object Ouvrir en tant qu'objet intelligent
+ Open in camera raw Ouvrir dans Camera Raw
Open documents as tabs Ouvrir les documents dans des onglets
Overscroll Défilement au-delà des bords
Performance Performances
@@ -1978,6 +1979,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Aucun tracé à partir duquel créer une sélection : dessinez-en un avec l'outil Plume ou sélectionnez-en un dans le panneau Tracés.
Cancel opening Annuler l'ouverture
Cancelled opening {name} Ouverture de {name} annulée
+ Developing {name} Développement de {name}
Cancelled {label} {label} : annulé
Esc to cancel Échap pour annuler
Opening {name} Ouverture de {name}
@@ -2491,6 +2493,7 @@
Show Selected Region Afficher la zone sélectionnée
cameraRaw Light Lumière
Camera Raw Filter ({layer}) Filtre Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights Tons clairs
cameraRaw Darks Tons sombres
cameraRaw Blacks Noirs
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index b74a9f08f..6e08d361b 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -1781,6 +1781,7 @@
Never Tidak pernah
Normal tip Ujung normal
Open as smart object Buka sebagai smart object
+ Open in camera raw Buka di Camera Raw
Open documents as tabs Buka dokumen sebagai tab
Overscroll Overscroll
Performance Performa
@@ -1971,6 +1972,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Tidak ada path untuk dibuat seleksi: gambar dengan alat Pen atau pilih salah satu di panel Path.
Cancel opening Batalkan pembukaan
Cancelled opening {name} Pembukaan {name} dibatalkan
+ Developing {name} Mengembangkan {name}
Cancelled {label} {label} dibatalkan
Esc to cancel Esc untuk batal
Opening {name} Membuka {name}
@@ -2465,6 +2467,7 @@
Show Selected Region Tampilkan Wilayah Terpilih
cameraRaw Light Cahaya
Camera Raw Filter ({layer}) Filter Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights Nada Terang
cameraRaw Darks Nada Gelap
cameraRaw Blacks Hitam
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 073fb4faa..d9d0d7917 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -1806,6 +1806,7 @@
Never Mai
Normal tip Punta normale
Open as smart object Apri come oggetto avanzato
+ Open in camera raw Apri in Camera Raw
Open documents as tabs Apri documenti come schede
Overscroll Overscroll
Performance Prestazioni
@@ -2004,6 +2005,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Nessun tracciato da cui creare selezione: disegnane uno con Penna o selezionane uno nel pannello Tracciati.
Cancel opening Annulla apertura
Cancelled opening {name} Apertura {name} annullata
+ Developing {name} Sviluppo di {name}
Cancelled {label} {label} annullato
Esc to cancel Esc per annullare
Opening {name} Apertura {name}
@@ -2136,6 +2138,7 @@ cameraRaw Light Luce
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Filtro Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights Toni chiari
cameraRaw Darks Toni scuri
cameraRaw Red Rossi
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 6e54a5c62..3dff04a9e 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -1814,6 +1814,7 @@
Never しない
Normal tip 通常の先端
Open as smart object スマートオブジェクトとして開く
+ Open in camera raw Camera Raw で開く
Open documents as tabs ドキュメントをタブで開く
Overscroll オーバースクロール
Performance パフォーマンス
@@ -2011,6 +2012,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. 選択範囲を作成するパスがありません。ペンツールで描くか、パスパネルでパスを選択してください。
Cancel opening 開くのをキャンセル
Cancelled opening {name} {name} を開くのをキャンセルしました
+ Developing {name} {name} を現像中
Cancelled {label} {label} をキャンセルしました
Esc to cancel Esc キーでキャンセル
Opening {name} {name} を開いています
@@ -2049,6 +2051,7 @@
cameraRaw Light ライト
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Camera Raw フィルター ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights 明部
cameraRaw Blending ブレンド
cameraRaw Blacks 黒レベル
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index e35929505..d04471c61 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -1782,6 +1782,7 @@
Never 안 함
Normal tip 표준 브러시 끝
Open as smart object 스마트 오브젝트로 열기
+ Open in camera raw Camera Raw에서 열기
Open documents as tabs 문서를 탭으로 열기
Overscroll 캔버스 밖으로 스크롤
Performance 성능
@@ -1972,6 +1973,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. 선택 영역으로 만들 패스가 없습니다: 펜 도구로 그리거나 패스 패널에서 선택하세요.
Cancel opening 열기 취소
Cancelled opening {name} {name} 열기를 취소했습니다
+ Developing {name} {name} 현상 중
Cancelled {label} {label} 작업을 취소했습니다
Esc to cancel Esc 키로 취소
Opening {name} {name} 여는 중
@@ -2020,6 +2022,7 @@
Show Selected Region 선택한 영역 표시
cameraRaw Light 밝게
Camera Raw Filter ({layer}) Camera Raw 필터 ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights 밝은 중간 영역
cameraRaw Blending 혼합
cameraRaw Blacks 검정 계열
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index b02fdfefd..f13ecedc6 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -1786,6 +1786,7 @@
Never Nunca
Normal tip Ponta normal
Open as smart object Abrir como objeto inteligente
+ Open in camera raw Abrir no Camera Raw
Open documents as tabs Abrir documentos como guias
Overscroll Rolagem além dos limites
Performance Desempenho
@@ -1977,6 +1978,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Nenhum demarcador para criar a seleção: desenhe um com a ferramenta Caneta ou selecione um no painel Demarcadores.
Cancel opening Cancelar abertura
Cancelled opening {name} Abertura de {name} cancelada
+ Developing {name} Revelando {name}
Cancelled {label} {label} cancelado
Esc to cancel Esc para cancelar
Opening {name} Abrindo {name}
@@ -2485,6 +2487,7 @@
Show Selected Region Mostrar região selecionada
cameraRaw Light Luz
Camera Raw Filter ({layer}) Filtro Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
cameraRaw Lights Claros
cameraRaw Darks Escuros
cameraRaw Blacks Pretos
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 069122307..ca2e5b34d 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -2207,6 +2207,7 @@
Never Никогда
Normal tip Контур кисти (50%)
Open as smart object Открывать как смарт-объект
+ Open in camera raw Открывать в Camera Raw
Open documents as tabs Открывать документы во вкладках
OpenGL OpenGL
Orange Оранжевая
@@ -2288,6 +2289,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. Нет контура для создания выделения: нарисуйте его инструментом «Перо» или выберите на панели «Контуры».
Cancel opening Отменить открытие
Cancelled opening {name} Открытие {name} отменено
+ Developing {name} Обработка {name}
Cancelled {label} {label}: отменено
Esc to cancel Esc — отмена
Opening {name} Открытие {name}
@@ -2326,6 +2328,7 @@
cameraRaw Light Свет
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Фильтр Camera Raw ({layer})
+ Camera Raw ({name}) Camera Raw ({name})
Aqua Голубой
cameraRaw Amount Интенсивность
cameraRaw Blacks Чёрные
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index d7ef31bc7..e93e49048 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -1816,6 +1816,7 @@
Never 从不
Normal tip 正常笔尖
Open as smart object 作为智能对象打开
+ Open in camera raw 在 Camera Raw 中打开
Open documents as tabs 以标签页打开文档
Overscroll 过度滚动
Performance 性能
@@ -1946,6 +1947,7 @@
cameraRaw Light 光线
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Camera Raw 滤镜({layer})
+ Camera Raw ({name}) Camera Raw({name})
cameraRaw Lights 亮调
cameraRaw Darks 暗调
cameraRaw Blacks 黑色色阶
@@ -2061,6 +2063,7 @@ cameraRaw Blending 混合
# Layer navigation, copy transforms and cancellable opening (labels added on main since this catalog).
Cancel opening 取消打开
Cancelled opening {name} 已取消打开 {name}
+ Developing {name} 正在处理 {name}
Cancelled {label} 已取消 {label}
Esc to cancel 按 Esc 取消
Opening {name} 正在打开 {name}
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 073072655..94dc73777 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -1809,6 +1809,7 @@
Never 永不
Normal tip 一般筆尖
Open as smart object 以智慧型物件開啟
+ Open in camera raw 在 Camera Raw 中開啟
Open documents as tabs 以索引標籤開啟文件
Overscroll 超出捲動
Performance 效能
@@ -2003,6 +2004,7 @@
No path to make a selection from: draw one with the Pen tool or select one in the Paths panel. 沒有可用來建立選取範圍的路徑:請使用鋼筆工具繪製,或在路徑面板中選取一個路徑。
Cancel opening 取消開啟
Cancelled opening {name} 已取消開啟 {name}
+ Developing {name} 正在處理 {name}
Cancelled {label} 已取消 {label}
Esc to cancel 按 Esc 取消
Opening {name} 正在開啟 {name}
@@ -2041,6 +2043,7 @@
cameraRaw Light 光線
# Camera Raw: contextual controls and window title
Camera Raw Filter ({layer}) Camera Raw 濾鏡({layer})
+ Camera Raw ({name}) Camera Raw({name})
cameraRaw Lights 亮調
cameraRaw Darks 暗調
cameraRaw Blacks 黑色色階
diff --git a/crates/ui-egui/src/jobs_ui.rs b/crates/ui-egui/src/jobs_ui.rs
index 57cb50ded..279b60a3c 100644
--- a/crates/ui-egui/src/jobs_ui.rs
+++ b/crates/ui-egui/src/jobs_ui.rs
@@ -147,6 +147,10 @@ fn on_event(app: &mut PhotocraftApp, e: JobEvent) {
true
}
});
+ // Camera Raw's open-time re-develop and its final step.
+ if crate::camera_raw_ui::on_redevelop_event(app, &e) {
+ return;
+ }
if e.command == OPEN_JOB {
let Some(i) = app.jobs.opens.iter().position(|o| o.job == e.id) else { return };
let tab = app.jobs.opens.remove(i);
@@ -207,7 +211,13 @@ fn finish_open(app: &mut PhotocraftApp, name: &str, path: Option<&str>, v: &Valu
app.sync_views();
app.ui.status = format!("Opened {name}");
app.ui.status_error = false;
- notices::io_warnings(app, &format!("Opened {name}"), &warnings);
+ // A raw opens in Camera Raw first; the dialog says how it was developed.
+ if crate::camera_raw_ui::wants_open_dialog(app, &warnings) {
+ crate::camera_raw_ui::queue_open_dialog(app, name, path, None);
+ notices::io_warnings(app, &format!("Opened {name}"), &crate::camera_raw_ui::without_develop_note(&warnings));
+ } else {
+ notices::io_warnings(app, &format!("Opened {name}"), &warnings);
+ }
// Script events bound to "Open Document".
photocraft_engine::automate_cmds::document_opened(&mut app.session);
app.sync_views();
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index ac44a5d3e..a015b2591 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -413,6 +413,11 @@ pub struct PhotocraftApp {
pub(crate) gradient: gradient_ui::LiveGradient,
/// Filter › Camera Raw Filter dialog (camera_raw_ui).
pub(crate) camera_raw: Option<camera_raw_ui::CameraRawDialog>,
+ /// A raw file just opened interactively, waiting for the open-time Camera Raw dialog (shown
+ /// on the next frame, which has the egui context).
+ pub(crate) pending_raw_open: Option<camera_raw_ui::RawOpen>,
+ /// The open-time re-develop (or its Camera Raw step) running in the background.
+ pub(crate) raw_redevelop: Option<camera_raw_ui::Redevelop>,
/// Filter › Adaptive Wide Angle dialog (wide_angle_ui).
pub(crate) wide_angle: Option<wide_angle_ui::WideAngleDialog>,
/// Signature of the image we last put on the OS clipboard (to tell ours from other apps').
@@ -536,6 +541,8 @@ impl PhotocraftApp {
distort: Default::default(),
gradient: Default::default(),
camera_raw: None,
+ pending_raw_open: None,
+ raw_redevelop: None,
wide_angle: None,
tone_hist: None,
doc_hist: None,
@@ -774,7 +781,12 @@ impl PhotocraftApp {
self.sync_views();
self.ui.status = format!("Opened {name}");
self.ui.status_error = false;
- notices::io_warnings(self, &format!("Opened {name}"), &warnings);
+ if camera_raw_ui::wants_open_dialog(self, &warnings) {
+ camera_raw_ui::queue_open_dialog(self, name, None, Some(bytes));
+ notices::io_warnings(self, &format!("Opened {name}"), &camera_raw_ui::without_develop_note(&warnings));
+ } else {
+ notices::io_warnings(self, &format!("Opened {name}"), &warnings);
+ }
// Script events bound to "Open Document".
photocraft_engine::automate_cmds::document_opened(&mut self.session);
self.sync_views();
diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs
index 56b58b28f..f225659a1 100644
--- a/crates/ui-egui/src/prefs_ui.rs
+++ b/crates/ui-egui/src/prefs_ui.rs
@@ -1798,9 +1798,12 @@ mod tests {
assert!(has_visible_fields(&values, "general"));
assert!(has_visible_fields(&values, "fileHandling"));
// Every setting of these sections is still unimplemented.
- for section in ["type", "enhancedControls", "rawDefaults", "integrations", "scratchDisks"] {
+ for section in ["type", "enhancedControls", "integrations", "scratchDisks"] {
assert!(!has_visible_fields(&values, section), "{section}");
}
+ // Camera Raw Defaults shows only "Open in Camera Raw" so far.
+ assert!(has_visible_fields(&values, "rawDefaults"));
+ assert!(!prefs::is_hidden("rawDefaults.openInCameraRaw"));
assert!(prefs::is_hidden("rawDefaults.applyAutoTone"));
assert!(!prefs::is_hidden("general.autoShowHomeScreen"));
assert!(!prefs::is_hidden("interface.uiScale"));
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index abc176f8c..42c3bbab0 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -317,6 +317,17 @@ opened). Unknown `ui` or settings properties, non-boolean `before` / `commit` /
least one level apart. Commit dispatches one `filter.cameraRaw` engine command; a failed commit
keeps the dialog open for correction. Nothing else writes document history.
+**Opening a raw file.** An interactive open (File › Open, Open Recent, drag and drop, the
+command line) of a camera raw developed from its sensor data shows this dialog first, titled
+"Camera Raw (name)", with **Open** and **Cancel**, as Photoshop opens raws in Adobe Camera Raw.
+`ui.inspect.cameraRaw.openingRaw` is then `{name, path}`. Commit (Open) re-develops the raw when
+Temperature, Tint or Exposure changed (as-shot white-balance gains and develop exposure on the
+sensor data; without an as-shot white balance, or without the file's bytes, they stay RGB
+adjustments), applies the remaining settings as one `filter.cameraRaw` step and leaves the
+document unmodified; its result is `{document, redeveloped, filter?}`. Cancel closes the
+document. `app.open` and other automation opens never show the dialog. The preference
+`rawDefaults.openInCameraRaw` (default `true`) turns it off.
+
Imported PSD Camera Raw filters whose processing settings are all mapped or neutral use this
same editor. `params.__cameraRawPsd` is reserved import/export metadata: preserve it when editing
stored parameters. Other processing fields or versions remain opaque Photoshop filters. See