mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-04 01:08:27 +00:00
LR-FILT-LABEL: a No label choice in the filter bar shows the photos without a colour label (#5028)
* LR-FILT-LABEL: a No label choice in the filter bar shows the photos without a colour label (#5028) The Label group of the filter bar gets a No label button after the colour swatches: alone it shows the photos without a colour label, with colours on it shows those photos too. library.filter gains `unlabeled`, one more choice of the `labels` multi-select; the chip names it and clears it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mj2w3LwYjFhMHALZuFp2rU * LR-FILT-LABEL: review: the filter bar keeps No label with the swatches (headless test), the Lightroom result's reset clears it (test), agents find unlabeled - filter_bar_no_label_combines_with_the_swatches: No label, then Red keeps both, then No label again leaves Red. - lightroom_result_stays_readable_and_shows_photos_hidden_by_a_filter sets unlabeled, so the reset line is covered. - library.filter lists labels and unlabeled; album.createSmart lists unlabeled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mj2w3LwYjFhMHALZuFp2rU --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
41bba7b486
commit
6c54433175
11 files changed
+120
-20
No files matched your search
@@ -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<ColorLabel>,
|
||||
/// 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<Vec<ColorLabel>> {
|
||||
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::<Vec<_>>().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::<Vec<_>>().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) {
|
||||
|
||||
@@ -172,7 +172,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"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<CommandSpec> {
|
||||
"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();
|
||||
|
||||
@@ -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<u64> = 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::<Vec<_>>(), ["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();
|
||||
|
||||
@@ -174,16 +174,20 @@ pub fn filter_chips(f: &Filter, cat: &Catalog) -> Vec<FilterChip> {
|
||||
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::<Vec<_>>().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::<Vec<_>>().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 {
|
||||
|
||||
@@ -29,6 +29,7 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result<serde_jso
|
||||
// The filter command merges a patch; these defaults are omitted by serde.
|
||||
filter["only"] = json!([]);
|
||||
filter["labels"] = json!([]);
|
||||
filter["unlabeled"] = json!(false);
|
||||
filter["flags"] = json!([]);
|
||||
filter["ruleSet"] = serde_json::Value::Null;
|
||||
app.run("library.filter", filter)?;
|
||||
|
||||
@@ -1618,6 +1618,26 @@ fn filter_bar_labels_from_label_and_labels() {
|
||||
h.settle(SETTLE);
|
||||
}
|
||||
|
||||
/// No label is one more choice of the label multi-select: a swatch clicked after it keeps it on, and clicking it again
|
||||
/// leaves the swatches as they were (#5028).
|
||||
#[test]
|
||||
fn filter_bar_no_label_combines_with_the_swatches() {
|
||||
use lightcraft_catalog::ColorLabel;
|
||||
let mut h = demo([1400.0, 800.0]);
|
||||
let t = Duration::from_secs(10);
|
||||
h.request("engine.execute", json!({"command": "view.filterBar"}), t);
|
||||
for (w, labels, unlabeled) in
|
||||
[("filter:label-none", vec![], true), ("filter:label-red", vec![ColorLabel::Red], true), ("filter:label-none", vec![ColorLabel::Red], false)]
|
||||
{
|
||||
h.step();
|
||||
let r = h.request("ui.clickWidget", json!({"id": w}), t);
|
||||
assert_eq!(r["ok"], true, "{w}: {r}");
|
||||
let f = h.app.session.filter.clone();
|
||||
assert_eq!((f.label, f.labels, f.unlabeled), (None, labels, unlabeled), "after {w}");
|
||||
}
|
||||
h.settle(SETTLE);
|
||||
}
|
||||
|
||||
/// The filter bar drives `library.filter` and saves the view as a smart album.
|
||||
#[test]
|
||||
fn filter_bar_filters_and_saves_a_smart_album() {
|
||||
|
||||
@@ -658,6 +658,7 @@ mod tests {
|
||||
h.app.session.filter.text = "no-photo-has-this-name".into();
|
||||
h.app.session.filter.only = vec![lightcraft_catalog::PhotoId(u64::MAX)];
|
||||
h.app.session.filter.labels = vec![lightcraft_catalog::ColorLabel::Red];
|
||||
h.app.session.filter.unlabeled = true;
|
||||
h.app.session.filter.flags = vec![lightcraft_catalog::Flag::Reject];
|
||||
h.app.session.filter.rule_set = Some(lightcraft_catalog::RuleSet {
|
||||
mode: lightcraft_catalog::rules::Match::All,
|
||||
|
||||
@@ -37,11 +37,15 @@ fn label_names(filter: &lightcraft_catalog::Filter, catalog: &lightcraft_catalog
|
||||
use crate::i18n::tr;
|
||||
let shown = filter.labels_shown().unwrap_or_default();
|
||||
let name = |label: &lightcraft_catalog::ColorLabel| crate::i18n::color_label(catalog, *label);
|
||||
let or = |labels: &[lightcraft_catalog::ColorLabel]| labels.iter().map(name).collect::<Vec<_>>().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::<Vec<_>>().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"))
|
||||
}
|
||||
|
||||
|
||||
@@ -381,9 +381,21 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
next.sort();
|
||||
let names: Vec<String> = 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<String> = 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.
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user