Narrow the grid to several people at once, either way
"Show photos" could only ever mean one person. The two questions a photographer actually asks are "every picture of Anna or Bob" and "the pictures they are both in", and the second is not reachable by any sequence of single-person filters — no amount of switching between one person and another finds the frame they share. So the filter holds a *set* of people and a mode. `RatingFilter` was already the right home, as its own doc says: every query path threads it, so the count in the header and the cells in the grid are narrowed by the same thing, and this composes with stars, flags and the date range for free. The union is `EXISTS ... person_id IN (...)`. The intersection counts **distinct** people per image and compares against the size of the selection — one subquery rather than one per person, and it does not grow the statement with the selection. `DISTINCT` is what makes it correct: three faces of Anna in one frame must not satisfy a filter asking for Anna and Bob, and there is a test that says so. Any rather than All is the default. With one person the modes are the same filter, and adding a second to a union can only ever show more — so a user who has not noticed the toggle never ends up staring at an empty grid wondering what they broke. The toggle only appears at two people, because a control that demonstrably does nothing is a control that teaches the user to ignore it. Building the set needs no picker of its own: the Identity screen gains "And also…" beside "Show photos", offered only once the grid is already narrowed to somebody. Each person is a chip on the filter bar and each chip removes just that person, so a selection of three can be taken apart one at a time rather than only cleared wholesale. `RatingFilter` stops being `Copy`, since it now holds a `Vec`. Every query path already took it by reference; the casualties were two struct updates and one `Cell` that becomes a `RefCell`. 484 dr-ui tests pass, including the union, the intersection, that one person reads the same in both modes, and the repeated-faces trap. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-9
@@ -5,7 +5,7 @@ import { SpotHandle, SpotPanel, SpotRole } from "spots.slint";
|
||||
import { HistoryPanel, HistoryRow } from "history.slint";
|
||||
import { LaunchScreen } from "launch.slint";
|
||||
import { IdentityScreen, IdentityPerson, IdentityFace } from "identity.slint";
|
||||
import { LibraryGrid, LibraryCell, TimelineBar, PhotoRoll, KeywordRow } from "library.slint";
|
||||
import { LibraryGrid, LibraryCell, TimelineBar, PhotoRoll, KeywordRow, PersonChip } from "library.slint";
|
||||
import { Button, PanelHeading, Label, Value, Caption, Panel, EmptyState, ProgressBar, ActivityRow } from "widgets.slint";
|
||||
import { CollectionsPanel, CollectionRow, OfflinePrompt } from "collections.slint";
|
||||
import { HistogramPanel, HistogramView } from "histogram.slint";
|
||||
@@ -13,7 +13,7 @@ import { SettingsPage } from "settings.slint";
|
||||
import { ImportPage } from "import.slint";
|
||||
import { StatusBar, InfoPanel } from "develop.slint";
|
||||
|
||||
export { LibraryCell, TimelineBar, CollectionRow, ActivityRow, HistogramView }
|
||||
export { LibraryCell, TimelineBar, CollectionRow, ActivityRow, HistogramView, PersonChip }
|
||||
export { ViewMode, GradientHandle, HandleRole, SpotHandle, SpotRole }
|
||||
|
||||
export component AppWindow inherits Window {
|
||||
@@ -365,7 +365,7 @@ export component AppWindow inherits Window {
|
||||
in property <bool> identity-selected-ignored: false;
|
||||
callback identity-toggle-show-ignored();
|
||||
callback identity-ignore-person(int, bool);
|
||||
callback identity-show-photos(int);
|
||||
callback identity-show-photos(int, bool);
|
||||
callback identity-index();
|
||||
callback identity-stop-indexing();
|
||||
callback identity-check-coverage();
|
||||
@@ -541,9 +541,12 @@ export component AppWindow inherits Window {
|
||||
/// the two arguments is -1, saying which axis was *not* meant.
|
||||
callback library-judged(int, int);
|
||||
|
||||
/// Whose photographs the grid is narrowed to. Empty when it is not.
|
||||
in property <string> library-filter-person-name;
|
||||
callback library-filter-person-cleared();
|
||||
/// Whose photographs the grid is narrowed to, one entry each.
|
||||
in property <[PersonChip]> library-filter-people;
|
||||
/// Whether those people are an intersection rather than a union.
|
||||
in property <bool> library-filter-people-all: false;
|
||||
callback library-filter-person-cleared(int);
|
||||
callback library-filter-people-mode-toggled();
|
||||
in property <int> library-filter-min-rating: 0;
|
||||
in property <bool> library-filter-unjudged: false;
|
||||
in property <int> library-filter-flag: 0;
|
||||
@@ -1198,6 +1201,7 @@ in property <bool> panel-visible: true;
|
||||
confirm-all() => { root.identity-confirm-all(); }
|
||||
split-picked() => { root.identity-split-picked(); }
|
||||
compact: !root.expanded;
|
||||
photos-filtered: root.library-filter-people.length > 0;
|
||||
regrouping: root.identity-regrouping;
|
||||
regroup-status: root.identity-regroup-status;
|
||||
ignored-count: root.identity-ignored-count;
|
||||
@@ -1205,7 +1209,7 @@ in property <bool> panel-visible: true;
|
||||
selected-ignored: root.identity-selected-ignored;
|
||||
toggle-show-ignored() => { root.identity-toggle-show-ignored(); }
|
||||
ignore-person(id, on) => { root.identity-ignore-person(id, on); }
|
||||
show-photos(id) => { root.identity-show-photos(id); }
|
||||
show-photos(id, add) => { root.identity-show-photos(id, add); }
|
||||
recluster() => { root.identity-recluster(); }
|
||||
index-faces() => { root.identity-index(); }
|
||||
stop-indexing() => { root.identity-stop-indexing(); }
|
||||
@@ -1431,7 +1435,8 @@ in property <bool> panel-visible: true;
|
||||
root.library-remove-from-collection();
|
||||
}
|
||||
|
||||
filter-person-name: root.library-filter-person-name;
|
||||
filter-people: root.library-filter-people;
|
||||
filter-people-all: root.library-filter-people-all;
|
||||
filter-min-rating: root.library-filter-min-rating;
|
||||
filter-unjudged: root.library-filter-unjudged;
|
||||
filter-flag: root.library-filter-flag;
|
||||
@@ -1462,7 +1467,8 @@ in property <bool> panel-visible: true;
|
||||
root.library-filter-unjudged-changed(on);
|
||||
}
|
||||
filter-flag-changed(f) => { root.library-filter-flag-changed(f); }
|
||||
filter-person-cleared() => { root.library-filter-person-cleared(); }
|
||||
filter-person-cleared(id) => { root.library-filter-person-cleared(id); }
|
||||
filter-people-mode-toggled() => { root.library-filter-people-mode-toggled(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,14 @@ export component IdentityScreen inherits Rectangle {
|
||||
/// Set a person aside, or bring them back.
|
||||
callback ignore-person(int, bool);
|
||||
/// Show every photograph this person appears in, in the library grid.
|
||||
callback show-photos(int);
|
||||
///
|
||||
/// The flag is whether to *add* to whoever the grid is already narrowed
|
||||
/// to, rather than replace them — which is how a union or an intersection
|
||||
/// of several people gets built without a person-picker of its own.
|
||||
callback show-photos(int, bool);
|
||||
/// Whether the library grid is already narrowed to somebody, so the
|
||||
/// "and also" button only appears when there is something to add to.
|
||||
in property <bool> photos-filtered: false;
|
||||
callback recluster();
|
||||
callback index-faces();
|
||||
callback stop-indexing();
|
||||
@@ -479,7 +486,14 @@ export component IdentityScreen inherits Rectangle {
|
||||
// screen is a filing cabinet with no drawer handles.
|
||||
if root.selected-person >= 0: Button {
|
||||
text: "Show photos";
|
||||
clicked => { root.show-photos(root.selected-person); }
|
||||
clicked => { root.show-photos(root.selected-person, false); }
|
||||
}
|
||||
// Builds the union or intersection a person at a time. Only
|
||||
// offered once the grid is narrowed to somebody, because
|
||||
// "and also" with nothing to add to is just "Show photos".
|
||||
if root.selected-person >= 0 && root.photos-filtered: Button {
|
||||
text: "And also…";
|
||||
clicked => { root.show-photos(root.selected-person, true); }
|
||||
}
|
||||
// Most clusters in a real library are strangers — passers-by,
|
||||
// other people's guests, a face on a poster. Naming them is
|
||||
|
||||
@@ -414,6 +414,12 @@ export component Timeline inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
/// One person the grid is narrowed to, as drawn on the filter bar.
|
||||
export struct PersonChip {
|
||||
id: int,
|
||||
name: string,
|
||||
}
|
||||
|
||||
export struct LibraryCell {
|
||||
name: string,
|
||||
// Non-empty on the first cell of a new month, e.g. "August 2026". The grid
|
||||
@@ -1253,10 +1259,13 @@ export component LibraryGrid inherits Rectangle {
|
||||
/// grid reads as broken.
|
||||
in property <[int]> rating-counts;
|
||||
|
||||
/// Whose photographs the grid is narrowed to, for the chip that says so
|
||||
/// and clears it. Empty when no person filter is applied.
|
||||
in property <string> filter-person-name;
|
||||
callback filter-person-cleared();
|
||||
/// Whose photographs the grid is narrowed to — one chip each, so a
|
||||
/// selection of three can be taken apart one person at a time.
|
||||
in property <[PersonChip]> filter-people;
|
||||
/// Whether those people are an intersection rather than a union.
|
||||
in property <bool> filter-people-all: false;
|
||||
callback filter-person-cleared(int);
|
||||
callback filter-people-mode-toggled();
|
||||
callback filter-min-rating-changed(int);
|
||||
callback filter-unjudged-toggled(bool);
|
||||
callback filter-flag-changed(int);
|
||||
@@ -1817,7 +1826,7 @@ export component LibraryGrid inherits Rectangle {
|
||||
// Hidden while there is nothing to filter: an empty library offering
|
||||
// six rating buttons is chrome describing data that does not exist.
|
||||
if root.total > 0 || root.filter-min-rating > 0 || root.filter-unjudged
|
||||
|| root.filter-flag > 0 || root.filter-person-name != "": Rectangle {
|
||||
|| root.filter-flag > 0 || root.filter-people.length > 0: Rectangle {
|
||||
height: 34px;
|
||||
background: Theme.surface;
|
||||
|
||||
@@ -1859,12 +1868,22 @@ export component LibraryGrid inherits Rectangle {
|
||||
// that has to be the first thing read — a user who does not
|
||||
// find it is looking at a library that has apparently lost
|
||||
// most of its photographs.
|
||||
if root.filter-person-name != "": FilterChip {
|
||||
for p[i] in root.filter-people: FilterChip {
|
||||
icon: "cross";
|
||||
label: root.filter-person-name;
|
||||
label: p.name;
|
||||
active: true;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { root.filter-person-cleared(); }
|
||||
clicked => { root.filter-person-cleared(p.id); }
|
||||
}
|
||||
|
||||
// Only with two, because with one the modes are the same
|
||||
// filter and a toggle that changes nothing is a control that
|
||||
// teaches the user it does nothing.
|
||||
if root.filter-people.length > 1: FilterChip {
|
||||
label: root.filter-people-all ? "all of them" : "any of them";
|
||||
active: root.filter-people-all;
|
||||
y: (parent.height - self.height) / 2;
|
||||
clicked => { root.filter-people-mode-toggled(); }
|
||||
}
|
||||
|
||||
Caption {
|
||||
|
||||
Reference in New Issue
Block a user