diff --git a/crates/catalog/src/query.rs b/crates/catalog/src/query.rs index d4efb71bc0..2106204b19 100644 --- a/crates/catalog/src/query.rs +++ b/crates/catalog/src/query.rs @@ -36,6 +36,10 @@ pub struct Filter { /// Any of these labels (the filter bar's multi-select); empty = no constraint. #[serde(skip_serializing_if = "Vec::is_empty")] pub labels: Vec, + /// The photos without a colour label, as one more choice of the `labels` multi-select (the + /// filter bar's No label button): a photo passes with one of `labels` or with no label. + #[serde(skip_serializing_if = "std::ops::Not::not")] + pub unlabeled: bool, /// Any of these flags (the filter bar's multi-select: Picked and Unflagged hide only the /// rejects); empty = no constraint. #[serde(skip_serializing_if = "Vec::is_empty", deserialize_with = "null_as_empty")] @@ -274,17 +278,24 @@ fn has_person(p: &Photo, name: &str) -> bool { } impl Filter { - /// The labels that `label` and `labels` let through together (they AND), in `labels`' order; - /// `None` when neither is set, empty when they exclude each other. The chip and the filter + /// The labels that `label` and `labels` (with [`Filter::unlabeled`]) let through together (they + /// AND), in `labels`' order; `None` when neither is set, empty when they exclude each other or + /// only the photos without a label pass ([`Filter::unlabeled_shown`]). The chip and the filter /// bar's buttons show this, so they match what is filtered. pub fn labels_shown(&self) -> Option> { - match (self.label, self.labels.is_empty()) { + match (self.label, self.labels.is_empty() && !self.unlabeled) { (None, true) => None, (Some(l), true) => Some(vec![l]), (l, false) => Some(self.labels.iter().copied().filter(|x| l.is_none_or(|l| l == *x)).collect()), } } + /// Whether the photos without a label are let through by the label rules: [`Filter::unlabeled`] + /// is on and `label` (one colour) doesn't exclude them. The No label button is lit by this. + pub fn unlabeled_shown(&self) -> bool { + self.unlabeled && self.label.is_none() + } + /// Human-readable summary of the active rules (smart album tooltips, `album.list`). pub fn describe(&self) -> String { self.describe_in(None) @@ -331,8 +342,9 @@ impl Filter { if let Some(l) = self.label { v.push(format!("label {}", format!("{l:?}").to_lowercase())); } - if !self.labels.is_empty() { - v.push(format!("label {}", self.labels.iter().map(|l| format!("{l:?}").to_lowercase()).collect::>().join(" or "))); + if !self.labels.is_empty() || self.unlabeled { + let names = self.labels.iter().map(|l| format!("{l:?}").to_lowercase()).chain(self.unlabeled.then(|| "none".to_string())); + v.push(format!("label {}", names.collect::>().join(" or "))); } if let Some(k) = self.kind { v.push(format!("kind {}", format!("{k:?}").to_lowercase())); @@ -464,7 +476,7 @@ impl Filter { { return false; } - if !self.labels.is_empty() && !p.label.is_some_and(|l| self.labels.contains(&l)) { + if (!self.labels.is_empty() || self.unlabeled) && !p.label.map_or(self.unlabeled, |l| self.labels.contains(&l)) { return false; } if !self.flags.is_empty() && !self.flags.contains(&p.flag) { diff --git a/crates/engine/src/cmd/library/specs.rs b/crates/engine/src/cmd/library/specs.rs index 6db4fd0fcb..15955a79f5 100644 --- a/crates/engine/src/cmd/library/specs.rs +++ b/crates/engine/src/cmd/library/specs.rs @@ -172,7 +172,7 @@ pub fn specs() -> Vec { "Filter", [], None, - "partial Filter: {text?, rating?, ratingOp?: atLeast|exactly|atMost, flag?: pick|reject|none|null, flags?: [pick|reject|none] (any of them; [] = no constraint), label?, kind?, merged?: hdr|panorama|hdrPanorama|any, edited?, date?, libraryFolder?: a path from library.folders, keyword?, person?, camera?}", + "partial Filter: {text?, rating?, ratingOp?: atLeast|exactly|atMost, flag?: pick|reject|none|null, flags?: [pick|reject|none] (any of them; [] = no constraint), label?, labels?: [red|yellow|green|blue|purple] (any of them; [] = no constraint), unlabeled?: bool (the photos without a label, one more choice of `labels`), kind?, merged?: hdr|panorama|hdrPanorama|any, edited?, date?, libraryFolder?: a path from library.folders, keyword?, person?, camera?}", always, |s, p| { let mut v = serde_json::to_value(&s.filter).unwrap_or_default(); @@ -959,7 +959,7 @@ pub fn specs() -> Vec { "New Smart Album…", [], None, - "{name, rules?: partial Filter (rating, ratingOp, flag, flags, label, labels, kind, edited, keyword, camera, lens, dateFrom, dateTo, date, text, album, ruleSet: {match: all|any|none, rules: [{field, op, value} | {group: ruleSet}]} — see album.ruleFields), parent?: folderId} — without `rules`, saves the current view (source + filter)", + "{name, rules?: partial Filter (rating, ratingOp, flag, flags, label, labels, unlabeled, kind, edited, keyword, camera, lens, dateFrom, dateTo, date, text, album, ruleSet: {match: all|any|none, rules: [{field, op, value} | {group: ruleSet}]} — see album.ruleFields), parent?: folderId} — without `rules`, saves the current view (source + filter)", always, |s, p| { let name = str_param(p, "name").unwrap_or("Smart Album").trim().to_string(); diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 3fe68e9cf5..529303ef67 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -1633,6 +1633,46 @@ fn rating_exactly_or_at_most_zero_shows_the_unrated_photos() { } } +/// The filter bar's No label choice shows the photos without a colour label, alone or as one more choice next to the +/// colours, and its chip names it and clears it (#5028). +#[test] +fn no_label_shows_the_photos_without_a_colour_label() { + let mut s = demo(); + let ids: Vec = s.catalog.photos().map(|p| p.id.0).collect(); + assert!(ids.len() >= 3); + s.execute("photo.label", &json!({"label": null, "ids": ids})).unwrap(); + s.execute("photo.label", &json!({"label": "red", "ids": [ids[0]]})).unwrap(); + s.execute("photo.label", &json!({"label": "blue", "ids": [ids[1]]})).unwrap(); + let unlabeled = ids.len() - 2; + let label = |s: &crate::Session, id: lightcraft_catalog::PhotoId| s.catalog.photo(id).unwrap().label; + + s.execute("library.filter", &json!({"unlabeled": true})).unwrap(); + let shown = s.visible_cloned(); + assert_eq!(shown.len(), unlabeled); + assert!(shown.iter().all(|id| label(&s, *id).is_none()), "only the photos without a label"); + assert_eq!(s.catalog.count(&s.filter), unlabeled); + let chips = crate::filter_chips(&s.filter, &s.catalog); + assert_eq!(chips.iter().map(|c| c.label.as_str()).collect::>(), ["Label: No label"]); + + // with a colour, either passes + s.execute("library.filter", &json!({"labels": ["red"]})).unwrap(); + let shown = s.visible_cloned(); + assert_eq!(shown.len(), unlabeled + 1); + assert!(shown.contains(&lightcraft_catalog::PhotoId(ids[0])) && !shown.contains(&lightcraft_catalog::PhotoId(ids[1]))); + let chips = crate::filter_chips(&s.filter, &s.catalog); + assert_eq!(chips[0].label, "Label: Red or No label"); + + // the chip clears both + s.execute("library.filter", &chips[0].clear).unwrap(); + assert_eq!(s.filter, Default::default()); + assert_eq!(s.visible_cloned().len(), ids.len()); + + // one colour (`label`) and No label exclude each other: nothing passes, and the chip says why + s.execute("library.filter", &json!({"label": "red", "unlabeled": true})).unwrap(); + assert!(s.visible_cloned().is_empty()); + assert_eq!(crate::filter_chips(&s.filter, &s.catalog)[0].label, "Label: Red and No label"); +} + #[test] fn find_similar_values_stay_within_zero_and_one() { let mut s = demo(); diff --git a/crates/engine/src/view.rs b/crates/engine/src/view.rs index 3c56f27d3b..a7a1a7cf0d 100644 --- a/crates/engine/src/view.rs +++ b/crates/engine/src/view.rs @@ -174,16 +174,20 @@ pub fn filter_chips(f: &Filter, cat: &Catalog) -> Vec { add(format!("Flag: {names}"), json!({"flag": Null, "flags": []})); } if let Some(shown) = f.labels_shown() { - let or = |ls: &[lightcraft_catalog::ColorLabel]| ls.iter().map(|l| cat.label_name(*l)).collect::>().join(" or "); - // empty: `label` and `labels` exclude each other, so name both constraints - let names = if shown.is_empty() { + // the colours, then "No label" when the photos without one pass too + let or = |ls: &[lightcraft_catalog::ColorLabel], none: bool| { + ls.iter().map(|l| cat.label_name(*l)).chain(none.then(|| "No label".to_string())).collect::>().join(" or ") + }; + // empty and no unlabeled photos: `label` and `labels` exclude each other, so name both constraints + let names = if shown.is_empty() && !f.unlabeled_shown() { // parenthesised when plural, so "Red and Yellow or Green" cannot read as "(Red and Yellow) or Green" - let plural = if f.labels.len() > 1 { format!("({})", or(&f.labels)) } else { or(&f.labels) }; + let plural = + if f.labels.len() + usize::from(f.unlabeled) > 1 { format!("({})", or(&f.labels, f.unlabeled)) } else { or(&f.labels, f.unlabeled) }; format!("{} and {plural}", f.label.map(|l| cat.label_name(l)).unwrap_or_default()) } else { - or(&shown) + or(&shown, f.unlabeled_shown()) }; - add(format!("Label: {names}"), json!({"label": Null, "labels": []})); + add(format!("Label: {names}"), json!({"label": Null, "labels": [], "unlabeled": false})); } if let Some(k) = f.kind { let n = match k { diff --git a/crates/ui-egui/src/dialogs/confirm.rs b/crates/ui-egui/src/dialogs/confirm.rs index 5e343e993d..84f9f862df 100644 --- a/crates/ui-egui/src/dialogs/confirm.rs +++ b/crates/ui-egui/src/dialogs/confirm.rs @@ -29,6 +29,7 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result>().join(&format!(" {} ", tr("or"))); - if !shown.is_empty() { - return or(&shown); + // the colours, then "No label" when the photos without one pass too + let or = |labels: &[lightcraft_catalog::ColorLabel], none: bool| { + labels.iter().map(name).chain(none.then(|| tr("No label").to_string())).collect::>().join(&format!(" {} ", tr("or"))) + }; + if !shown.is_empty() || filter.unlabeled_shown() { + return or(&shown, filter.unlabeled_shown()); } - let plural = if filter.labels.len() > 1 { format!("({})", or(&filter.labels)) } else { or(&filter.labels) }; + let n = filter.labels.len() + usize::from(filter.unlabeled); + let plural = if n > 1 { format!("({})", or(&filter.labels, filter.unlabeled)) } else { or(&filter.labels, filter.unlabeled) }; format!("{} {} {plural}", filter.label.as_ref().map(name).unwrap_or_default(), tr("and")) } diff --git a/crates/ui-egui/src/panels/filterbar.rs b/crates/ui-egui/src/panels/filterbar.rs index 09cdb8dc68..1e3b466140 100644 --- a/crates/ui-egui/src/panels/filterbar.rs +++ b/crates/ui-egui/src/panels/filterbar.rs @@ -381,9 +381,21 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) { } next.sort(); let names: Vec = next.iter().map(|x| format!("{x:?}").to_lowercase()).collect(); - filter(app, json!({"label": Value::Null, "labels": names})); + filter(app, json!({"label": Value::Null, "labels": names, "unlabeled": f.unlabeled_shown()})); } } + // the photos without a label, one more choice of the same multi-select (#5028) + let none_on = f.unlabeled_shown(); + if toggle( + ui, + "label-none", + none_on, + "No label (click labels too to show any of them)", + FilterGlyph::Icon { icon: Icon::Circle, tint: Color32::TRANSPARENT }, + ) { + let names: Vec = chosen.iter().map(|x| format!("{x:?}").to_lowercase()).collect(); + filter(app, json!({"label": Value::Null, "labels": names, "unlabeled": !none_on})); + } ui.add_space(14.0); // The media-kind flow uses the SDK; all other filter controls keep their existing paths. diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 3cccf0a6fb..a73087bfc0 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -156,7 +156,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-FILT-SEARCH-AI | Natural-language search | P2 | ⬜ | | | | LR-FILT-RATING | Rating filter | P0 | ✅ | `cmd:library.filter` (`rating`, `ratingOp`), `crates/ui-egui/src/panels/filterbar.rs` | ≥ / = / ≤ stars in the filter bar (`cmd:view.filterBar`); = or ≤ no stars shows the unrated photos, as in Lightroom (issue #3417, `rating_exactly_or_at_most_zero_shows_the_unrated_photos`) | | LR-FILT-FLAG | Flag filter | P0 | ✅ | `cmd:library.filter` (`flag`, `flags`), `crates/ui-egui/src/panels/filterbar.rs` | picked / rejected / unflagged, toggled on and off like Classic's Attribute flag buttons: several at once show any of them (Picked + Unflagged hides only the rejects, issue #2588; `flags`, one chip); the single `flag` of saved filters, smart albums and agents still filters | -| LR-FILT-LABEL | Colour-label filter | P1 | ✅ | `cmd:library.filter` (`label`), `crates/ui-egui/src/panels/filterbar.rs` | one label at a time; no “no label” choice | +| LR-FILT-LABEL | Colour-label filter | P1 | ✅ | `cmd:library.filter` (`label`, `labels`, `unlabeled`), `crates/ui-egui/src/panels/filterbar.rs` | several labels at once (any of them matches); No label shows the photos without one, alone or next to the colours (issue #5028, `no_label_shows_the_photos_without_a_colour_label`) | | LR-FILT-TYPE | Type / edited filter | P1 | ✅ | `cmd:library.filter` (`kind`, `merged`, `edited`), `crates/ui-egui/src/panels/filterbar.rs`, `crates/catalog/src/query.rs` (`merged_kind`) | photos / raw / videos / HDR / panoramas / HDR panoramas (merge results by name), edited / unedited; no depth kind | | LR-FILT-KEYWORD | Keyword filter | P1 | ✅ | `cmd:library.filter` (`keyword`), `crates/ui-egui/src/panels/filterbar.rs` | keyword picker | | LR-FILT-CAMERA | Camera / lens filter | P1 | ✅ | `cmd:library.filter` (`camera`, `lens`), `crates/ui-egui/src/panels/filterbar.rs` | camera and lens pickers | @@ -810,6 +810,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| +| 2026-12-03 | patch | LR-FILT-LABEL: a No label choice in the filter bar shows the photos without a colour label (`library.filter` `unlabeled`, #5028); status unchanged | | 2026-12-01 | patch | MENU-VIEW-MAP ✅ → 🟡: the Map view's commands moved from View ▸ Map to Window ▸ Map, beside the Map panel toggles, because View is at the 40-row menu limit; Map View (⌘⌥3) is there too | | 2026-11-27 | minor | LR-IMP-ADD-DIALOG / LR-IMP-MOVE: an optional backup folder (Backup to, `library.import` `backup`) gets a verified copy of each copied or moved file under the same folders and names as the destination; a move keeps the original of a photo whose backup failed; counts unchanged | | 2026-12-02 | minor | LR-MASK-BRUSH: a stroke's edge is feathered as one dab's is (process V16); status unchanged | diff --git a/docs/whats-new.md b/docs/whats-new.md index 39d5cc7e92..6f88f7b841 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -2,6 +2,11 @@ ## Unreleased +### Filter for photos without a colour label +- The filter bar's Label group has a No label button after the colour swatches: on its own it shows the photos without + a colour label, and with colours on it shows those photos too, so you can find what you haven't labelled yet while + culling (issue #5028). + ### Apple ProRAW tone chain fitted to Lightroom (process 17) - On Apple ProRAW files with a profile tone curve, the Light sliders now run through a tone chain fitted to Lightroom Classic exports of an iPhone 12 Pro ProRAW, applying the profile curve to colour as well as brightness