LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
M1.7: a raw with its import settings is not 'edited' (grid badge, edited filter)
Brandon Thomas3586c772cb16
diff --git a/crates/catalog/src/model.rs b/crates/catalog/src/model.rsindex ad15b7ef7..7f145b967 100644--- a/crates/catalog/src/model.rs+++ b/crates/catalog/src/model.rs@@ -180,8 +180,21 @@ impl Photo {embedded_lens: None,}}+ /// The develop settings import gives this photo (raws: as-shot white balance and the raw+ /// defaults; embedded lens corrections on when the file has them).+ pub fn import_defaults(&self) -> DevelopSettings {+ let mut d = match self.as_shot_wb {+ Some((t, tint)) => DevelopSettings::for_raw(t, tint),+ None => DevelopSettings::default(),+ };+ if self.embedded_lens.is_some() {+ d.optics.lens_profile = true;+ }+ d+ }+ /// Edited by the user: settings differ from what import gave the photo.pub fn is_edited(&self) -> bool {- !self.develop.is_unedited()+ *self.develop != self.import_defaults() && !self.develop.is_unedited()}/// Capture time if known, else import time (sort key).pub fn date(&self) -> &str {@@ -204,3 +217,22 @@ pub struct Album {#[serde(default)]pub cover: Option<PhotoId>,}++#[cfg(test)]+mod edited_tests {+ use super::*;++ #[test]+ fn raw_with_import_settings_is_not_edited() {+ let mut p = Photo::new(PhotoId(1), Source::Demo { scene: 0 }, "a.arw", "ARW", 10, 10, "2026-10-01T00:00:00");+ p.as_shot_wb = Some((5200.0, 4.0));+ p.develop = Arc::new(p.import_defaults());+ assert!(!p.is_edited(), "import look counts as unedited");+ let mut d = (*p.develop).clone();+ d.light.exposure = 0.5;+ p.develop = Arc::new(d);+ assert!(p.is_edited());+ p.develop = Arc::new(DevelopSettings::default());+ assert!(!p.is_edited(), "a full reset is unedited too");+ }+}diff --git a/crates/engine/src/import.rs b/crates/engine/src/import.rsindex e3f69c015..e07199d68 100644--- a/crates/engine/src/import.rs+++ b/crates/engine/src/import.rs@@ -61,14 +61,7 @@ pub struct ImportReport {/// default sharpening / colour noise reduction, and file-embedded lens corrections on (as the/// camera intended).pub fn import_defaults(p: &Photo) -> lightcraft_develop::DevelopSettings {- let mut d = match p.as_shot_wb {- Some((t, tint)) => lightcraft_develop::DevelopSettings::for_raw(t, tint),- None => lightcraft_develop::DevelopSettings::default(),- };- if p.embedded_lens.is_some() {- d.optics.lens_profile = true;- }- d+ p.import_defaults()}/// Does the photo still look as imported (its embedded camera preview is then a fair stand-in)?