LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Fix #316: the section eye switches off Light, Color and Detail too
Claude9b4ba1aa8046
diff --git a/crates/develop/src/lib.rs b/crates/develop/src/lib.rsindex ff4daedd9..bfce1893e 100644--- a/crates/develop/src/lib.rs+++ b/crates/develop/src/lib.rs@@ -68,6 +68,32 @@ impl DevelopSettings {!self.disabled_sections.iter().any(|s| s == section)}+ /// The settings as rendered: an Edit-panel section whose eye is off contributes nothing (issue+ /// #316). Light (with its tone curve), Color (white balance, presence, the mixers, colour grading+ /// and point colour) and Detail are reset to their defaults here; Effects, Optics, Geometry and+ /// Calibration the pipeline switches off where it applies them. Borrowed when every section is on.+ pub fn effective(&self) -> std::borrow::Cow<'_, DevelopSettings> {+ let off = |section: &str| !self.section_enabled(section);+ if !(off("light") || off("color") || off("detail")) {+ return std::borrow::Cow::Borrowed(self);+ }+ let mut d = self.clone();+ if off("light") {+ d.reset_section(Section::Light);+ d.reset_section(Section::Curve);+ }+ if off("color") {+ for section in [Section::Color, Section::Mixer, Section::BwMix, Section::Grading, Section::PointColor] {+ d.reset_section(section);+ }+ d.point_colors.clear();+ }+ if off("detail") {+ d.reset_section(Section::Detail);+ }+ std::borrow::Cow::Owned(d)+ }+pub fn set_section_enabled(&mut self, section: &str, on: bool) {self.disabled_sections.retain(|s| s != section);if !on {diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rsindex 70d6246a7..5ef3011b7 100644--- a/crates/gpu/src/lib.rs+++ b/crates/gpu/src/lib.rs@@ -294,6 +294,9 @@ pub fn stage_bytes(stages: &StageCache) -> usize {pub fn render(src: &Arc<Rgb32f>, info: &SourceInfo, s: &DevelopSettings, req: &RenderRequest, stages: Option<&StageCache>) -> Option<Rendered> {#[cfg(not(target_arch = "wasm32"))]{+ // sections switched off with their eye render as if at their defaults (issue #316)+ let effective = s.effective();+ let s: &DevelopSettings = &effective;// the kernel writes 8-bit output: high-bit-depth exports (and soft proofs) render on the CPUif !enabled() || req.depth != lightcraft_pipeline::OutputDepth::U8 || req.proof.is_some() {return None;diff --git a/crates/pipeline/src/lib.rs b/crates/pipeline/src/lib.rsindex 15fbd7f33..3feaa153c 100644--- a/crates/pipeline/src/lib.rs+++ b/crates/pipeline/src/lib.rs@@ -365,6 +365,9 @@ enum Src<'a> {}fn render_impl(src: Src<'_>, info: &SourceInfo, s: &DevelopSettings, req: &RenderRequest, cache: Option<&StageCache>) -> Rendered {+ // sections switched off with their eye render as if at their defaults (issue #316)+ let effective = s.effective();+ let s: &DevelopSettings = &effective;// `Instant::now()` panics on wasm32-unknown-unknown: only read the clock when profiling.let lap = |what: &str, t: &mut Option<std::time::Instant>| {if let Some(t) = t {diff --git a/crates/pipeline/src/tests.rs b/crates/pipeline/src/tests.rsindex 61e0de7c1..00578bdaa 100644--- a/crates/pipeline/src/tests.rs+++ b/crates/pipeline/src/tests.rs@@ -237,6 +237,35 @@ fn exposure_after_spatial_filters_equals_exposing_the_source() {assert!(d <= 2, "max difference {d}");}+/// A section whose eye is off renders as if it were at its defaults (issue #316): Light, Color+/// and Detail, which the pipeline doesn't switch off where it applies them.+#[test]+fn sections_switched_off_render_as_defaults() {+ let src = Rgb32f::from_fn(32, 24, |x, y| [0.05 + x as f32 / 40.0, 0.1 + y as f32 / 30.0, 0.3]);+ let info = SourceInfo::default();+ let req = RenderRequest::fit(32, 24);+ let plain = render(&src, &info, &DevelopSettings::default(), &req).image;+ let mut s = DevelopSettings::default();+ s.light.exposure = 1.5;+ s.light.contrast = 40.0;+ s.color.saturation = -60.0;+ s.color.vibrance = 30.0;+ s.detail.sharpen_amount = 120.0;+ let edited = render(&src, &info, &s, &req).image;+ assert_ne!(edited.data, plain.data);+ for section in ["light", "color", "detail"] {+ s.set_section_enabled(section, false);+ }+ assert_eq!(render(&src, &info, &s, &req).image.data, plain.data, "every edited section off = the unedited photo");+ // one section back on brings back only its own adjustments+ s.set_section_enabled("light", true);+ let mut light_only = DevelopSettings::default();+ light_only.light.exposure = 1.5;+ light_only.light.contrast = 40.0;+ assert_eq!(render(&src, &info, &s, &req).image.data, render(&src, &info, &light_only, &req).image.data);+ assert!(matches!(DevelopSettings::default().effective(), std::borrow::Cow::Borrowed(_)), "nothing is copied when every section is on");+}+#[test]fn calibration_shifts_colours_but_keeps_greys() {let info = SourceInfo { raw: true, ..Default::default() };diff --git a/docs/parity.md b/docs/parity.mdindex d5a31ea9c..5aea3bea0 100644--- a/docs/parity.md+++ b/docs/parity.md@@ -263,7 +263,7 @@ under the UI command that wraps it (a no-op error); the UI command now wins.| LR-EDIT-GEOM-GRID | Grid while transforming | P2 | ✅ | `crates/ui-egui/src/panels/detail.rs` | a fine grid over the photo while a geometry slider is dragged || LR-EDIT-LENSBLUR | Lens blur | P2 | ⬜ | | settings field reserved, not rendered || LR-EDIT-CALIB | Calibration [Classic] | P1 | ✅ | `ctl:calibration.*` | shadows tint, red/green/blue primary hue and saturation; read/written in XMP |-| LR-EDIT-SECTION-TOGGLE | Section on/off | P1 | ✅ | `cmd:develop.sectionEnabled` | |+| LR-EDIT-SECTION-TOGGLE | Section on/off | P1 | ✅ | `cmd:develop.sectionEnabled`, `crates/develop/src/lib.rs` (`effective`) | the eye on a section header hides its adjustments: Light (with the curve), Color (white balance, presence, mixers, grading, point colour), Effects, Detail, Optics, Geometry, Calibration; masks stay on (issue #316 fixed Light, Color and Detail, which had no effect) || LR-EDIT-RESET | Reset all / section / slider | P0 | ✅ | `cmd:develop.reset`, `cmd:develop.resetSection`, `cmd:develop.resetControl`, `crates/ui-egui/src/widgets.rs` (double-click) | no "reset to open" || LR-EDIT-SHOWORIG | Show original | P0 | ✅ | `cmd:view.showOriginal` | |diff --git a/docs/whats-new.md b/docs/whats-new.mdindex ea0243f42..d70414fd8 100644--- a/docs/whats-new.md+++ b/docs/whats-new.md@@ -13,6 +13,10 @@with a counterpart here come along, the rest is listed.- 23 new built-in presets: Portrait, Landscape, Urban, Food, Seasons, Vintage and B&W toners.+### Editing+- The eye on the Light, Color and Detail section headers now hides their adjustments, as it already did for Effects,+ Optics, Geometry and Calibration (issue #316).+### Reliability- LightCraft no longer crashes at launch on Windows PCs whose Vulkan driver is broken (issue #136, e.g. some Intel UHD630 drivers): on Windows the window and GPU rendering use DirectX 12 only and never load the Vulkan driver unless