M1.7: a raw with its import settings is not 'edited' (grid badge, edited filter)
Photo::import_defaults moves into the catalog; is_edited compares against it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9886d49823
commit
3586c772cb
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)?
|
||||
|
|
|
|||
Loading…
Reference in New Issue