From d6a7b1992d5a2e62872031920cdf5503912e6b30 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 17 Oct 2026 09:32:11 -0400 Subject: [PATCH 01/15] LR-VIEW-FILMSTRIP: filmstrip and grid thumbnails share one overlay, and it degrades on narrow tiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The grid and the filmstrip drew their marks with separate code, so the filmstrip had no virtual-copy tag, a stack badge that could not be clicked, no placeholder and no failure mark, and the grid's marks ran over a narrow photo's edge. One painter now draws all three surfaces. - crates/ui-egui/src/thumb.rs (new): the overlay (stack badge, copy tag, failure mark, preview pill, marks row) and the pure layouts that decide what a narrow tile keeps: the copy tag drops its name and then hides before it meets the stack badge; the marks row drops the edited mark, then shows the stars as a star and the number, then keeps only what fits whole (flag, rating, label) - the failure mark is a drawn icon registered as `badge:failed:` / `film:failed:`; its tooltip says why and where to go (Locate Missing File… or Reload from Disk) - a colour label is the dot in the marks row on every surface; the justified grid's tinted footer band over the photo is gone - the stack badge tooltips are translated; the screen-reader rating is ", rating N of 5", with no English plural suffix - crates/ui-egui/src/panels/grid.rs, panels/detail.rs: `cell` and `filmstrip` call the overlay; `film_badges`, the filmstrip's inline stack badge and the grid's `stack_badge` and inline copy tag are removed - crates/ui-egui/src/icons.rs: Warning and VirtualCopy icons - crates/ui-egui/locales: the new strings in all 13 catalogs - crates/ui-egui/src/tests_thumb.rs, tests_labels.rs: headless tests of the above - docs/parity-checklist.md, docs/whats-new.md Co-Authored-By: Claude --- crates/ui-egui/locales/cs-formats.json | 4 +- crates/ui-egui/locales/cs.json | 7 +- crates/ui-egui/locales/de-formats.json | 4 +- crates/ui-egui/locales/de.json | 7 +- crates/ui-egui/locales/es-formats.json | 4 +- crates/ui-egui/locales/es.json | 7 +- crates/ui-egui/locales/fr-formats.json | 4 +- crates/ui-egui/locales/fr.json | 7 +- crates/ui-egui/locales/it-formats.json | 4 +- crates/ui-egui/locales/it.json | 7 +- crates/ui-egui/locales/ja-formats.json | 4 +- crates/ui-egui/locales/ja.json | 7 +- crates/ui-egui/locales/ka-formats.json | 4 +- crates/ui-egui/locales/ka.json | 7 +- crates/ui-egui/locales/pl-formats.json | 4 +- crates/ui-egui/locales/pl.json | 7 +- crates/ui-egui/locales/pt-br-formats.json | 4 +- crates/ui-egui/locales/pt-br.json | 7 +- crates/ui-egui/locales/ru-formats.json | 4 +- crates/ui-egui/locales/ru.json | 7 +- crates/ui-egui/locales/uk-formats.json | 4 +- crates/ui-egui/locales/uk.json | 7 +- crates/ui-egui/locales/zh-hans-formats.json | 4 +- crates/ui-egui/locales/zh-hans.json | 7 +- crates/ui-egui/locales/zh-hant-formats.json | 4 +- crates/ui-egui/locales/zh-hant.json | 7 +- crates/ui-egui/src/icons.rs | 14 + crates/ui-egui/src/lib.rs | 1 + crates/ui-egui/src/panels/detail/filmstrip.rs | 65 +- crates/ui-egui/src/panels/grid.rs | 181 ++--- crates/ui-egui/src/tests.rs | 1 + crates/ui-egui/src/tests/filmstrip.rs | 2 +- crates/ui-egui/src/tests/labels.rs | 13 +- crates/ui-egui/src/tests/thumb.rs | 164 +++++ crates/ui-egui/src/thumb.rs | 650 ++++++++++++++++++ docs/parity-checklist.md | 11 +- docs/whats-new.md | 12 + 37 files changed, 1039 insertions(+), 218 deletions(-) create mode 100644 crates/ui-egui/src/tests/thumb.rs create mode 100644 crates/ui-egui/src/thumb.rs diff --git a/crates/ui-egui/locales/cs-formats.json b/crates/ui-egui/locales/cs-formats.json index e0ec9f1baa..afcc68e06f 100644 --- a/crates/ui-egui/locales/cs-formats.json +++ b/crates/ui-egui/locales/cs-formats.json @@ -18,7 +18,6 @@ "+{} more": "+{} dalších", ", {failed} file{} not readable": ", nečitelné soubory: {failed}{:.0}", ", {} label": ", štítek: {}", - ", {} star{}": ", hvězdičky: {}{:.0}", "1 task is still running: {names}. Quitting stops it.": "Stále běží 1 úloha: {names}. Ukončení aplikace ji zastaví.", "; {kept} already had a location": "; {kept} již mělo polohu", "; {n} gained synonyms": "; {n} získalo synonyma", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Rozložení panelů se nepodařilo obnovit: {error}", "Panel move was not applied: {error}": "Přesun panelu nebyl použit: {error}", "{name} is installed": "{name} je nainstalován", - "{name} is installed and in use: face recognition is on": "{name} je nainstalován a používán: rozpoznávání obličejů je zapnuto" + "{name} is installed and in use: face recognition is on": "{name} je nainstalován a používán: rozpoznávání obličejů je zapnuto", + ", rating {} of 5": ", hodnocení: {} z 5" } diff --git a/crates/ui-egui/locales/cs.json b/crates/ui-egui/locales/cs.json index 6a056bbfb9..32c94e100d 100644 --- a/crates/ui-egui/locales/cs.json +++ b/crates/ui-egui/locales/cs.json @@ -2438,5 +2438,10 @@ "Set up name suggestions…": "Nastavit návrhy jmen…", "Top bar": "Horní lišta", "Tool strip": "Pruh nástrojů", - "Bottom bar": "Dolní lišta" + "Bottom bar": "Dolní lišta", + "Stack — click to expand (S)": "Sada — kliknutím rozbalíte (S)", + "Stack — click to collapse (S)": "Sada — kliknutím sbalíte (S)", + "Virtual copy": "Virtuální kopie", + "Right-click ▸ Locate Missing File… to find it again.": "Klikněte pravým tlačítkem → Najít chybějící soubor… a najděte jej znovu.", + "Right-click ▸ Reload from Disk to try again.": "Klikněte pravým tlačítkem → Znovu načíst z disku a zkuste to znovu." } diff --git a/crates/ui-egui/locales/de-formats.json b/crates/ui-egui/locales/de-formats.json index 782886be84..b9c7b9b925 100644 --- a/crates/ui-egui/locales/de-formats.json +++ b/crates/ui-egui/locales/de-formats.json @@ -201,7 +201,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "Ähnliche Fotos: {n}{:.0} · Ansicht → Filter löschen zeigt alle Fotos", "Moved; {} photo(s) relinked": "Verschoben; {} Foto(s) neu verknüpft", "{} label (click more labels to show any of them)": "Farbmarkierung {} (weitere Farbmarkierungen auswählen, um alle passenden Fotos zu zeigen)", - ", {} star{}": ", Sterne: {}{:.0}", ", {} label": ", Farbmarkierung: {}", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Lädt von {host} herunter. Sobald es angekommen und geprüft ist, installiert LightCraft es und {after}.", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Die Bereichsanordnung konnte nicht wiederhergestellt werden: {error}", "Panel move was not applied: {error}": "Das Verschieben des Bereichs wurde nicht ausgeführt: {error}", "{name} is installed": "{name} ist installiert", - "{name} is installed and in use: face recognition is on": "{name} ist installiert und in Gebrauch: Gesichtserkennung ist eingeschaltet" + "{name} is installed and in use: face recognition is on": "{name} ist installiert und in Gebrauch: Gesichtserkennung ist eingeschaltet", + ", rating {} of 5": ", Bewertung: {} von 5" } diff --git a/crates/ui-egui/locales/de.json b/crates/ui-egui/locales/de.json index 405c54a464..0567d2169f 100644 --- a/crates/ui-egui/locales/de.json +++ b/crates/ui-egui/locales/de.json @@ -3470,5 +3470,10 @@ "Top bar": "Obere Leiste", "Tool strip": "Werkzeugleiste", "Bottom bar": "Untere Leiste", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "G-SYNC-/FreeSync-Flimmern verhindern (gilt ab dem nächsten Start)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "G-SYNC-/FreeSync-Flimmern verhindern (gilt ab dem nächsten Start)", + "Stack — click to expand (S)": "Stapel — Klicken zum Aufklappen (S)", + "Stack — click to collapse (S)": "Stapel — Klicken zum Zuklappen (S)", + "Virtual copy": "Virtuelle Kopie", + "Right-click ▸ Locate Missing File… to find it again.": "Rechtsklick → Fehlende Datei suchen…, um sie wiederzufinden.", + "Right-click ▸ Reload from Disk to try again.": "Rechtsklick → Vom Datenträger neu laden, um es erneut zu versuchen." } diff --git a/crates/ui-egui/locales/es-formats.json b/crates/ui-egui/locales/es-formats.json index 41ae09d66e..caa0f4d747 100644 --- a/crates/ui-egui/locales/es-formats.json +++ b/crates/ui-egui/locales/es-formats.json @@ -202,7 +202,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "Fotos similares: {n}{:.0} · Vista → Borrar filtros para ver todas", "Moved; {} photo(s) relinked": "Movida; {} foto(s) vinculada(s) de nuevo", "{} label (click more labels to show any of them)": "Etiqueta {} (hacer clic en más etiquetas para mostrar cualquiera de ellas)", - ", {} star{}": ", {} estrella{}", ", {} label": ", etiqueta {}", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Se descarga desde {host}. Cuando llega y se comprueba, LightCraft lo instala y {after}.", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "No se pudo restablecer la disposición de paneles: {error}", "Panel move was not applied: {error}": "No se aplicó el movimiento del panel: {error}", "{name} is installed": "{name} está instalado", - "{name} is installed and in use: face recognition is on": "{name} está instalado y en uso: el reconocimiento facial está activado" + "{name} is installed and in use: face recognition is on": "{name} está instalado y en uso: el reconocimiento facial está activado", + ", rating {} of 5": ", valoración: {} de 5" } diff --git a/crates/ui-egui/locales/es.json b/crates/ui-egui/locales/es.json index e43ae8c49b..a9082f96a4 100644 --- a/crates/ui-egui/locales/es.json +++ b/crates/ui-egui/locales/es.json @@ -2390,5 +2390,10 @@ "Top bar": "Barra superior", "Tool strip": "Barra de herramientas", "Bottom bar": "Barra inferior", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Evitar el parpadeo de G-SYNC/FreeSync (se aplica al reiniciar)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Evitar el parpadeo de G-SYNC/FreeSync (se aplica al reiniciar)", + "Stack — click to expand (S)": "Pila — clic para expandir (S)", + "Stack — click to collapse (S)": "Pila — clic para contraer (S)", + "Virtual copy": "Copia virtual", + "Right-click ▸ Locate Missing File… to find it again.": "Clic derecho → Localizar archivo que falta… para encontrarlo de nuevo.", + "Right-click ▸ Reload from Disk to try again.": "Clic derecho → Recargar desde el disco para intentarlo de nuevo." } diff --git a/crates/ui-egui/locales/fr-formats.json b/crates/ui-egui/locales/fr-formats.json index fc46d653c6..5b4f872722 100644 --- a/crates/ui-egui/locales/fr-formats.json +++ b/crates/ui-egui/locales/fr-formats.json @@ -202,7 +202,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "{n} photo{} similaire(s) · Affichage → Effacer les filtres pour tout voir", "Moved; {} photo(s) relinked": "Déplacé ; {} photo(s) de nouveau associée(s)", "{} label (click more labels to show any of them)": "Étiquette {} (cliquez sur « autres étiquettes » pour afficher celles de votre choix)", - ", {} star{}": ", {} étoile{}", ", {} label": ", étiquette {}", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Téléchargement depuis {host}. Une fois le téléchargement terminé et vérifié, LightCraft l’installe, {after}.", "{:.1} MB": "{:.1} Mo", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "La disposition des panneaux n'a pas pu être restaurée : {error}", "Panel move was not applied: {error}": "Le déplacement du panneau n'a pas été appliqué : {error}", "{name} is installed": "{name} est installé", - "{name} is installed and in use: face recognition is on": "{name} est installé et utilisé : la reconnaissance des visages est activée" + "{name} is installed and in use: face recognition is on": "{name} est installé et utilisé : la reconnaissance des visages est activée", + ", rating {} of 5": ", note : {} sur 5" } diff --git a/crates/ui-egui/locales/fr.json b/crates/ui-egui/locales/fr.json index e032cf52f3..33007258e9 100644 --- a/crates/ui-egui/locales/fr.json +++ b/crates/ui-egui/locales/fr.json @@ -3573,5 +3573,10 @@ "Top bar": "Barre supérieure", "Tool strip": "Barre d’outils", "Bottom bar": "Barre inférieure", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Empêcher le scintillement G-SYNC/FreeSync (au prochain démarrage)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Empêcher le scintillement G-SYNC/FreeSync (au prochain démarrage)", + "Stack — click to expand (S)": "Pile — cliquer pour déplier (S)", + "Stack — click to collapse (S)": "Pile — cliquer pour replier (S)", + "Virtual copy": "Copie virtuelle", + "Right-click ▸ Locate Missing File… to find it again.": "Clic droit → Localiser le fichier manquant… pour le retrouver.", + "Right-click ▸ Reload from Disk to try again.": "Clic droit → Recharger depuis le disque pour réessayer." } diff --git a/crates/ui-egui/locales/it-formats.json b/crates/ui-egui/locales/it-formats.json index 4437aa644d..2b3eccaae9 100644 --- a/crates/ui-egui/locales/it-formats.json +++ b/crates/ui-egui/locales/it-formats.json @@ -199,7 +199,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "Foto simili: {n}{:.0} · Visualizza → Cancella filtri per vederle tutte", "Moved; {} photo(s) relinked": "Spostata; foto ricollegate: {}", "{} label (click more labels to show any of them)": "Etichetta {} (fai clic su altre etichette per mostrarne una qualsiasi)", - ", {} star{}": ", stelle: {}{:.0}", ", {} label": ", etichetta {}", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Scaricato da {host}. Quando è arrivato ed è stato verificato, LightCraft lo installa e {after}.", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Non è stato possibile ripristinare la disposizione dei pannelli: {error}", "Panel move was not applied: {error}": "Lo spostamento del pannello non è stato applicato: {error}", "{name} is installed": "{name} è installato", - "{name} is installed and in use: face recognition is on": "{name} è installato e in uso: il riconoscimento dei volti è attivo" + "{name} is installed and in use: face recognition is on": "{name} è installato e in uso: il riconoscimento dei volti è attivo", + ", rating {} of 5": ", valutazione: {} su 5" } diff --git a/crates/ui-egui/locales/it.json b/crates/ui-egui/locales/it.json index a0d39d0610..6756fc586d 100644 --- a/crates/ui-egui/locales/it.json +++ b/crates/ui-egui/locales/it.json @@ -2556,5 +2556,10 @@ "Unit": "Unità", "Top bar": "Barra superiore", "Tool strip": "Barra degli strumenti", - "Bottom bar": "Barra inferiore" + "Bottom bar": "Barra inferiore", + "Stack — click to expand (S)": "Pila — clic per espandere (S)", + "Stack — click to collapse (S)": "Pila — clic per comprimere (S)", + "Virtual copy": "Copia virtuale", + "Right-click ▸ Locate Missing File… to find it again.": "Clic destro → Trova file mancante… per ritrovarlo.", + "Right-click ▸ Reload from Disk to try again.": "Clic destro → Ricarica dal disco per riprovare." } diff --git a/crates/ui-egui/locales/ja-formats.json b/crates/ui-egui/locales/ja-formats.json index 2fb625ff6a..4cde42faf2 100644 --- a/crates/ui-egui/locales/ja-formats.json +++ b/crates/ui-egui/locales/ja-formats.json @@ -206,7 +206,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "似た写真{n}枚{:.0}・すべて表示するには「表示 → フィルターを解除」", "Moved; {} photo(s) relinked": "移動しました。{}枚の写真の参照先を更新しました", "{} label (click more labels to show any of them)": "{}ラベル(ほかのラベルもクリックすると、いずれかに一致する写真を表示)", - ", {} star{}": "、星{}つ{:.0}", ", {} label": "、{}ラベル", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "{host} からダウンロードします。届いて確認が済むと、LightCraft がインストールし、{after}。", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "パネル配置を復元できませんでした:{error}", "Panel move was not applied: {error}": "パネルの移動は適用されませんでした:{error}", "{name} is installed": "{name} をインストールしました", - "{name} is installed and in use: face recognition is on": "{name} をインストールして使用中です:顔認識はオンです" + "{name} is installed and in use: face recognition is on": "{name} をインストールして使用中です:顔認識はオンです", + ", rating {} of 5": "、評価: 5段階中{}" } diff --git a/crates/ui-egui/locales/ja.json b/crates/ui-egui/locales/ja.json index 5f80d7896b..20f8ec9936 100644 --- a/crates/ui-egui/locales/ja.json +++ b/crates/ui-egui/locales/ja.json @@ -2388,5 +2388,10 @@ "Top bar": "上部バー", "Tool strip": "ツールバー", "Bottom bar": "下部バー", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "G-SYNC/FreeSyncのちらつきを防ぐ(次回起動時に適用)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "G-SYNC/FreeSyncのちらつきを防ぐ(次回起動時に適用)", + "Stack — click to expand (S)": "スタック — クリックして展開 (S)", + "Stack — click to collapse (S)": "スタック — クリックして折りたたむ (S)", + "Virtual copy": "仮想コピー", + "Right-click ▸ Locate Missing File… to find it again.": "右クリック → 見つからないファイルを指定… で、ファイルをもう一度指定できます。", + "Right-click ▸ Reload from Disk to try again.": "右クリック → ディスクから再読み込み で、もう一度試せます。" } diff --git a/crates/ui-egui/locales/ka-formats.json b/crates/ui-egui/locales/ka-formats.json index 329662ac1b..416f4f8a47 100644 --- a/crates/ui-egui/locales/ka-formats.json +++ b/crates/ui-egui/locales/ka-formats.json @@ -18,7 +18,6 @@ "+{} more": "+ კიდევ {}", ", {failed} file{} not readable": ", ვერ იკითხება ფაილი: {failed}{:.0}", ", {} label": ", იარლიყი: {}", - ", {} star{}": ", ვარსკვლავი: {}{:.0}", "1 task is still running: {names}. Quitting stops it.": "ჯერ კიდევ მიმდინარეობს 1 ამოცანა: {names}. გასვლა მას შეწყვეტს.", "; {kept} already had a location": "; მდებარეობა უკვე ჰქონდა: {kept}", "; {n} gained synonyms": "; სინონიმები დაემატა: {n}", @@ -320,5 +319,6 @@ "Panel layout could not be restored: {error}": "პანელების განლაგების აღდგენა ვერ მოხერხდა: {error}", "Panel move was not applied: {error}": "პანელის გადატანა არ შესრულდა: {error}", "{name} is installed": "{name} დაინსტალირებულია", - "{name} is installed and in use: face recognition is on": "{name} დაინსტალირებულია და გამოიყენება: სახეების ამოცნობა ჩართულია" + "{name} is installed and in use: face recognition is on": "{name} დაინსტალირებულია და გამოიყენება: სახეების ამოცნობა ჩართულია", + ", rating {} of 5": ", შეფასება: {} 5-დან" } diff --git a/crates/ui-egui/locales/ka.json b/crates/ui-egui/locales/ka.json index 0ea7d3d805..88cacae7c0 100644 --- a/crates/ui-egui/locales/ka.json +++ b/crates/ui-egui/locales/ka.json @@ -3659,5 +3659,10 @@ "Top bar": "ზედა ზოლი", "Tool strip": "ხელსაწყოების ზოლი", "Bottom bar": "ქვედა ზოლი", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "G-SYNC/FreeSync-ის ციმციმის თავიდან აცილება (ამოქმედდება შემდეგი გაშვებისას)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "G-SYNC/FreeSync-ის ციმციმის თავიდან აცილება (ამოქმედდება შემდეგი გაშვებისას)", + "Stack — click to expand (S)": "დასტა — დააწკაპუნეთ გასაშლელად (S)", + "Stack — click to collapse (S)": "დასტა — დააწკაპუნეთ ჩასაკეცად (S)", + "Virtual copy": "ვირტუალური ასლი", + "Right-click ▸ Locate Missing File… to find it again.": "მარჯვენა დაწკაპუნება → დაკარგული ფაილის მოძებნა… ფაილის ხელახლა საპოვნელად.", + "Right-click ▸ Reload from Disk to try again.": "მარჯვენა დაწკაპუნება → დისკიდან ხელახლა ჩატვირთვა, ხელახლა საცდელად." } diff --git a/crates/ui-egui/locales/pl-formats.json b/crates/ui-egui/locales/pl-formats.json index 3f0fd43a22..d375275acb 100644 --- a/crates/ui-egui/locales/pl-formats.json +++ b/crates/ui-egui/locales/pl-formats.json @@ -190,7 +190,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "Podobne zdjęcia: {n}{:.0} · Widok → Wyczyść filtry, aby zobaczyć wszystkie", "Moved; {} photo(s) relinked": "Przeniesiono; ponownie powiązane zdjęcia: {}", "{} label (click more labels to show any of them)": "{} etykieta (kliknij kolejne etykiety, aby wyświetlić dowolną z nich)", - ", {} star{}": ", gwiazdki: {}{:.0}", ", {} label": ", {} etykieta", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Pobieranie z {host}. Po pobraniu i weryfikacji LightCraft zainstaluje plik, {after}.", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Nie udało się przywrócić układu paneli: {error}", "Panel move was not applied: {error}": "Przeniesienie panelu nie zostało zastosowane: {error}", "{name} is installed": "{name} jest zainstalowany", - "{name} is installed and in use: face recognition is on": "{name} jest zainstalowany i używany: rozpoznawanie twarzy jest włączone" + "{name} is installed and in use: face recognition is on": "{name} jest zainstalowany i używany: rozpoznawanie twarzy jest włączone", + ", rating {} of 5": ", ocena: {} na 5" } diff --git a/crates/ui-egui/locales/pl.json b/crates/ui-egui/locales/pl.json index bb3729a5b6..a70269d298 100644 --- a/crates/ui-egui/locales/pl.json +++ b/crates/ui-egui/locales/pl.json @@ -2315,5 +2315,10 @@ "Set up name suggestions…": "Skonfiguruj propozycje imion…", "Top bar": "Górny pasek", "Tool strip": "Pasek narzędzi", - "Bottom bar": "Dolny pasek" + "Bottom bar": "Dolny pasek", + "Stack — click to expand (S)": "Stos — kliknij, aby rozwinąć (S)", + "Stack — click to collapse (S)": "Stos — kliknij, aby zwinąć (S)", + "Virtual copy": "Kopia wirtualna", + "Right-click ▸ Locate Missing File… to find it again.": "Kliknij prawym przyciskiem → Znajdź brakujący plik…, aby go odnaleźć ponownie.", + "Right-click ▸ Reload from Disk to try again.": "Kliknij prawym przyciskiem → Wczytaj ponownie z dysku, aby spróbować jeszcze raz." } diff --git a/crates/ui-egui/locales/pt-br-formats.json b/crates/ui-egui/locales/pt-br-formats.json index c26b2e281e..a64fea970b 100644 --- a/crates/ui-egui/locales/pt-br-formats.json +++ b/crates/ui-egui/locales/pt-br-formats.json @@ -206,7 +206,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "{n} foto{0} semelhante{0} · Exibir → Limpar filtros para ver todas", "Moved; {} photo(s) relinked": "Movida; {} foto(s) vinculada(s) novamente", "{} label (click more labels to show any of them)": "Rótulo {} (clique em mais rótulos para mostrar qualquer um deles)", - ", {} star{}": ", {} estrela{}", ", {} label": ", rótulo {}", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Faz o download de {host}. Depois que chegar e for verificado, o LightCraft o instala e {after}.", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Não foi possível restaurar a disposição dos painéis: {error}", "Panel move was not applied: {error}": "A movimentação do painel não foi aplicada: {error}", "{name} is installed": "{name} está instalado", - "{name} is installed and in use: face recognition is on": "{name} está instalado e em uso: o reconhecimento facial está ativado" + "{name} is installed and in use: face recognition is on": "{name} está instalado e em uso: o reconhecimento facial está ativado", + ", rating {} of 5": ", avaliação: {} de 5" } diff --git a/crates/ui-egui/locales/pt-br.json b/crates/ui-egui/locales/pt-br.json index a0884dc56a..cc5c2d9fe0 100644 --- a/crates/ui-egui/locales/pt-br.json +++ b/crates/ui-egui/locales/pt-br.json @@ -2234,5 +2234,10 @@ "Top bar": "Barra superior", "Tool strip": "Barra de ferramentas", "Bottom bar": "Barra inferior", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Evitar cintilação de G-SYNC/FreeSync (no próximo início)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Evitar cintilação de G-SYNC/FreeSync (no próximo início)", + "Stack — click to expand (S)": "Pilha — clique para expandir (S)", + "Stack — click to collapse (S)": "Pilha — clique para recolher (S)", + "Virtual copy": "Cópia virtual", + "Right-click ▸ Locate Missing File… to find it again.": "Clique com o botão direito → Localizar arquivo ausente… para encontrá-lo de novo.", + "Right-click ▸ Reload from Disk to try again.": "Clique com o botão direito → Recarregar do disco para tentar de novo." } diff --git a/crates/ui-egui/locales/ru-formats.json b/crates/ui-egui/locales/ru-formats.json index 4be240ec5b..514c39f2ba 100644 --- a/crates/ui-egui/locales/ru-formats.json +++ b/crates/ui-egui/locales/ru-formats.json @@ -14,7 +14,6 @@ "+{} more": "+{} ещё", ", {failed} file{} not readable": ", не читается файлов: {failed}{:.0}", ", {} label": ", метка: {}", - ", {} star{}": ", звёзд: {}{:.0}", "; {kept} already had a location": "; уже имели местоположение: {kept}", "; {outside} outside its time range": "; вне временного диапазона трека: {outside}", "@{}: {} PRs, {} commits, +{} / −{} lines (Δ {}), +{} / −{} binary assets, {} – {}": "@{}: PR: {}, коммитов: {}, строк: +{} / −{} (Δ {}), бинарных файлов: +{} / −{}, {} – {}", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Не удалось восстановить расположение панелей: {error}", "Panel move was not applied: {error}": "Перемещение панели не применено: {error}", "{name} is installed": "Модель {name} установлена", - "{name} is installed and in use: face recognition is on": "Модель {name} установлена и используется: распознавание лиц включено" + "{name} is installed and in use: face recognition is on": "Модель {name} установлена и используется: распознавание лиц включено", + ", rating {} of 5": ", оценка: {} из 5" } diff --git a/crates/ui-egui/locales/ru.json b/crates/ui-egui/locales/ru.json index 598893c3bc..493c224fcf 100644 --- a/crates/ui-egui/locales/ru.json +++ b/crates/ui-egui/locales/ru.json @@ -2596,5 +2596,10 @@ "Top bar": "Верхняя панель", "Tool strip": "Панель инструментов", "Bottom bar": "Нижняя панель", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Предотвращать мерцание G-SYNC/FreeSync (после перезапуска)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Предотвращать мерцание G-SYNC/FreeSync (после перезапуска)", + "Stack — click to expand (S)": "Стопка — щёлкните, чтобы развернуть (S)", + "Stack — click to collapse (S)": "Стопка — щёлкните, чтобы свернуть (S)", + "Virtual copy": "Виртуальная копия", + "Right-click ▸ Locate Missing File… to find it again.": "Щёлкните правой кнопкой → Указать отсутствующий файл…, чтобы найти его снова.", + "Right-click ▸ Reload from Disk to try again.": "Щёлкните правой кнопкой → Перезагрузить с диска, чтобы повторить попытку." } diff --git a/crates/ui-egui/locales/uk-formats.json b/crates/ui-egui/locales/uk-formats.json index e87bd03749..7190a50dae 100644 --- a/crates/ui-egui/locales/uk-formats.json +++ b/crates/ui-egui/locales/uk-formats.json @@ -202,7 +202,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "Подібних фото: {n}{:.0} · Вигляд → Скинути фільтри, щоб побачити всі", "Moved; {} photo(s) relinked": "Переміщено; повторно пов’язано фото: {}", "{} label (click more labels to show any of them)": "Мітка «{}» (клацніть інші мітки, щоб показати фото з будь-якою з них)", - ", {} star{}": ", зірок: {}{:.0}", ", {} label": ", мітка: {}", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Завантажується з {host}. Після отримання й перевірки LightCraft установлює модель, {after}.", "{:.1} MB": "{:.1} МБ", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "Не вдалося відновити розташування панелей: {error}", "Panel move was not applied: {error}": "Переміщення панелі не застосовано: {error}", "{name} is installed": "{name} установлено", - "{name} is installed and in use: face recognition is on": "{name} установлено й використовується: розпізнавання облич увімкнено" + "{name} is installed and in use: face recognition is on": "{name} установлено й використовується: розпізнавання облич увімкнено", + ", rating {} of 5": ", оцінка: {} з 5" } diff --git a/crates/ui-egui/locales/uk.json b/crates/ui-egui/locales/uk.json index a4efe34a60..b9fe09de85 100644 --- a/crates/ui-egui/locales/uk.json +++ b/crates/ui-egui/locales/uk.json @@ -2386,5 +2386,10 @@ "Top bar": "Верхня панель", "Tool strip": "Панель інструментів", "Bottom bar": "Нижня панель", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Запобігати мерехтінню G-SYNC/FreeSync (після перезапуску)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "Запобігати мерехтінню G-SYNC/FreeSync (після перезапуску)", + "Stack — click to expand (S)": "Стос — клацніть, щоб розгорнути (S)", + "Stack — click to collapse (S)": "Стос — клацніть, щоб згорнути (S)", + "Virtual copy": "Віртуальна копія", + "Right-click ▸ Locate Missing File… to find it again.": "Клацніть правою кнопкою → Знайти відсутній файл…, щоб знайти його знову.", + "Right-click ▸ Reload from Disk to try again.": "Клацніть правою кнопкою → Перезавантажити з диска, щоб спробувати ще раз." } diff --git a/crates/ui-egui/locales/zh-hans-formats.json b/crates/ui-egui/locales/zh-hans-formats.json index 0a8b94115f..255284b181 100644 --- a/crates/ui-egui/locales/zh-hans-formats.json +++ b/crates/ui-egui/locales/zh-hans-formats.json @@ -206,7 +206,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "{n} 张相似照片{0:.0} · 选择“视图 → 清除过滤器”可查看全部", "Moved; {} photo(s) relinked": "已移动;已重新链接 {0} 张照片", "{} label (click more labels to show any of them)": "{0}标签(单击更多标签可显示符合其中任一标签的照片)", - ", {} star{}": ",{0} 星{1:.0}", ", {} label": ",{0}标签", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "从 {host} 下载。下载完成并通过校验后,LightCraft 会进行安装,{after}。", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "无法恢复面板布局:{error}", "Panel move was not applied: {error}": "面板移动未应用:{error}", "{name} is installed": "{name} 已安装", - "{name} is installed and in use: face recognition is on": "{name} 已安装并在使用:人脸识别已开启" + "{name} is installed and in use: face recognition is on": "{name} 已安装并在使用:人脸识别已开启", + ", rating {} of 5": ",评分:{}/5" } diff --git a/crates/ui-egui/locales/zh-hans.json b/crates/ui-egui/locales/zh-hans.json index ea867f35e6..d1117147ba 100644 --- a/crates/ui-egui/locales/zh-hans.json +++ b/crates/ui-egui/locales/zh-hans.json @@ -2389,5 +2389,10 @@ "Set up name suggestions…": "设置姓名建议…", "Top bar": "顶部栏", "Tool strip": "工具栏", - "Bottom bar": "底部栏" + "Bottom bar": "底部栏", + "Stack — click to expand (S)": "堆叠 — 单击展开 (S)", + "Stack — click to collapse (S)": "堆叠 — 单击折叠 (S)", + "Virtual copy": "虚拟副本", + "Right-click ▸ Locate Missing File… to find it again.": "右键单击 → 定位缺失的文件…,即可重新找到它。", + "Right-click ▸ Reload from Disk to try again.": "右键单击 → 从磁盘重新读取,即可重试。" } diff --git a/crates/ui-egui/locales/zh-hant-formats.json b/crates/ui-egui/locales/zh-hant-formats.json index 178cd55a03..aeadee4469 100644 --- a/crates/ui-egui/locales/zh-hant-formats.json +++ b/crates/ui-egui/locales/zh-hant-formats.json @@ -206,7 +206,6 @@ "{n} similar photo{} · View ▸ Clear Filters to see all": "{n} 張相似照片{:.0} · 選擇「檢視 → 清除篩選條件」可查看全部", "Moved; {} photo(s) relinked": "已移動;已重新連結 {} 張照片", "{} label (click more labels to show any of them)": "{}標籤(點擊更多標籤可顯示符合其中任一標籤的照片)", - ", {} star{}": ",{} 顆星{:.0}", ", {} label": ",{}標籤", "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.": "Downloads from {host}. Once it has arrived and checked out, LightCraft installs it, {after}.", "{:.1} MB": "{:.1} MB", @@ -317,5 +316,6 @@ "Panel layout could not be restored: {error}": "無法還原面板配置:{error}", "Panel move was not applied: {error}": "面板移動未套用:{error}", "{name} is installed": "{name} 已安裝", - "{name} is installed and in use: face recognition is on": "{name} 已安裝並在使用中:臉部辨識已開啟" + "{name} is installed and in use: face recognition is on": "{name} 已安裝並在使用中:臉部辨識已開啟", + ", rating {} of 5": ",評分:{}/5" } diff --git a/crates/ui-egui/locales/zh-hant.json b/crates/ui-egui/locales/zh-hant.json index 90b3670ec3..db58b148f5 100644 --- a/crates/ui-egui/locales/zh-hant.json +++ b/crates/ui-egui/locales/zh-hant.json @@ -2389,5 +2389,10 @@ "Top bar": "頂部列", "Tool strip": "工具列", "Bottom bar": "底部列", - "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "防止 G-SYNC/FreeSync 閃爍(下次啟動時生效)" + "Prevent G-SYNC/FreeSync flicker (applies at next launch)": "防止 G-SYNC/FreeSync 閃爍(下次啟動時生效)", + "Stack — click to expand (S)": "堆疊 — 按一下以展開 (S)", + "Stack — click to collapse (S)": "堆疊 — 按一下以收合 (S)", + "Virtual copy": "虛擬副本", + "Right-click ▸ Locate Missing File… to find it again.": "按右鍵 → 尋找遺失的檔案…,即可重新找到它。", + "Right-click ▸ Reload from Disk to try again.": "按右鍵 → 從磁碟重新載入,即可重試。" } diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index 0ef3e04483..a06184f2af 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -106,6 +106,10 @@ pub enum Icon { Sun, /// Appearance Mode ▸ Dark: a crescent moon. Moon, + /// A render failed: a triangle with an exclamation mark. + Warning, + /// A virtual copy: a page with a folded corner. + VirtualCopy, } struct Pen<'a> { @@ -347,6 +351,16 @@ fn paint_with(p: &Painter, rect: Rect, icon: Icon, color: Color32, turn: Option< pen.line(&[(10.0, 9.0), (10.0, 14.0)]); pen.dot(10.0, 6.3, 0.9); } + Warning => { + pen.closed(&[(10.0, 3.0), (17.5, 16.5), (2.5, 16.5)]); + pen.line(&[(10.0, 8.0), (10.0, 11.8)]); + pen.dot(10.0, 14.1, 0.9); + } + VirtualCopy => { + // a page whose top right corner is folded down + pen.line(&[(11.0, 3.0), (5.0, 3.0), (5.0, 17.0), (15.0, 17.0), (15.0, 7.0)]); + pen.line(&[(11.0, 3.0), (15.0, 7.0), (11.0, 7.0), (11.0, 3.0)]); + } GridPhoto => { pen.rect_fill(3.0, 4.0, 10.0, 9.5, 0.5); pen.rect_fill(11.0, 4.0, 17.0, 9.5, 0.5); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 7a67d87109..e411d2c431 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -48,6 +48,7 @@ pub mod state; pub mod sync; pub mod tasks; pub mod theme; +mod thumb; pub mod widgets; pub mod window_place; diff --git a/crates/ui-egui/src/panels/detail/filmstrip.rs b/crates/ui-egui/src/panels/detail/filmstrip.rs index 52e9c8b25a..36506dc2da 100644 --- a/crates/ui-egui/src/panels/detail/filmstrip.rs +++ b/crates/ui-egui/src/panels/detail/filmstrip.rs @@ -120,47 +120,32 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) { } let img_area = Rect::from_min_max(cr.min + vec2(10.0, 22.0), cr.max - vec2(10.0, 8.0)); crate::panels::grid::request_thumb(app, *id, (256.0 * ppp.min(2.0) / 2.0) as usize * 2, 8); - let thumb = app.renderer.thumb(*id); - if thumb.is_none() { - p.rect_filled(img_area, 0.0, t.skeleton); - if failed { - p.text(img_area.center(), Align2::CENTER_CENTER, "!", t.semibold(14.0), t.text); - } - } - if let Some(tex) = thumb { - let [tw, th] = tex.size; - let s = (img_area.width() / tw as f32).min(img_area.height() / th as f32); - let fr = Rect::from_center_size(img_area.center(), vec2(tw as f32 * s, th as f32 * s)); - p.image(tex.tex.id(), fr, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE); - crate::panels::grid::selection_ring(p, &t, fr, state); - if app.ui.settings.film_badges - && let Some(ph) = app.session.catalog.photo(*id) - { - film_badges(p, &t, fr, ph); - } - if let Some(st) = app.session.catalog.stack_of(*id) { - let collapsed = st.collapsed; - let text = - if collapsed { st.photos.len().to_string() } else { format!("{}/{}", st.position(*id).unwrap_or(0) + 1, st.photos.len()) }; - let g = p.layout_no_wrap(text, t.semibold(9.5), Color32::WHITE); - let br = Rect::from_min_size(fr.min + vec2(3.0, 3.0), vec2(g.size().x + 22.0, 15.0)); - // like the grid's badge: a click expands / collapses the stack - let badge = ui.interact(br, egui::Id::unique(("film-stack-badge", id.0)), Sense::click()).on_hover_text(if collapsed { - "Stack — click to expand" - } else { - "Stack — click to collapse" - }); - crate::widgets::announce(&badge, crate::i18n::tr(if collapsed { "Expand Stack" } else { "Collapse Stack" })); - register(ui, format!("filmstack:{}", id.0), br); - let p = ui.painter(); - let fill = if badge.hovered() { Color32::from_black_alpha(230) } else { Color32::from_black_alpha(170) }; - p.rect_filled(br, 7.5, fill); - crate::icons::paint(p, Rect::from_min_size(br.min + vec2(4.0, 2.0), vec2(11.0, 11.0)), crate::icons::Icon::Stack, Color32::WHITE); - p.galley(pos2(br.min.x + 17.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); - if badge.clicked() { - crate::panels::grid::toggle_stack(app, ui.ctx(), *id); + if let Some(photo) = app.session.catalog.photo(*id).cloned() { + let (photo_rect, failure) = if let Some(tex) = app.renderer.thumb(*id) { + let [tw, th] = tex.size; + let s = (img_area.width() / tw as f32).min(img_area.height() / th as f32); + let fr = Rect::from_center_size(img_area.center(), vec2(tw as f32 * s, th as f32 * s)); + p.image(tex.tex.id(), fr, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE); + crate::panels::grid::selection_ring(p, &t, fr, state); } - } + (fr, None) + } else { + let ph = crate::thumb::placeholder_rect(img_area, crate::panels::grid::photo_aspect(Some(&*photo))); + crate::thumb::paint_placeholder(p, ph, &t); + crate::panels::grid::selection_ring(p, &t, ph, state); + (ph, app.renderer.failure(crate::render::Slot::Thumb(*id)).map(str::to_owned)) + }; + let stack = app.session.catalog.stack_of(*id).map(|st| (st.id, st.position(*id).unwrap_or(0))); + let overlay = crate::thumb::Thumb { + surface: crate::thumb::Surface::Film, + photo: &photo, + rect: photo_rect, + stack, + marks: app.ui.settings.film_badges, + hot: false, + failure, + }; + crate::thumb::overlay(app, ui, &overlay); } if resp.clicked() { let m = ui.input(|i| i.modifiers); diff --git a/crates/ui-egui/src/panels/grid.rs b/crates/ui-egui/src/panels/grid.rs index 29579a01fb..8a46174315 100644 --- a/crates/ui-egui/src/panels/grid.rs +++ b/crates/ui-egui/src/panels/grid.rs @@ -271,9 +271,13 @@ pub(crate) fn import_way_in(keymap: &crate::shortcuts::Keymap, mac: bool) -> (&' (way, crate::shortcuts::shortcut_of(keymap, "file.addPhotos").map(|sc| crate::menubar::shortcut_text(sc, mac))) } -/// Width / height of a photo's cell: its cropped, oriented shape. +/// [`photo_aspect`] of photo `id` of the catalog. pub(crate) fn shape_of(cat: &Catalog, id: PhotoId) -> f32 { - let p = cat.photo(id); + photo_aspect(cat.photo(id).map(|p| &**p)) +} + +/// Width / height of a photo's cell: its cropped, oriented shape. +pub(crate) fn photo_aspect(p: Option<&lightcraft_catalog::Photo>) -> f32 { let (w, h) = p.map(|p| (p.width.max(1) as f32, p.height.max(1) as f32)).unwrap_or((3.0, 2.0)); let swap = p.is_some_and(|p| p.develop.orientation.swaps_axes()); let crop = p.map(|p| p.develop.crop.geometry.rect).unwrap_or(lightcraft_geom::Rect::UNIT); @@ -426,10 +430,7 @@ fn show_inner(app: &mut LightcraftApp, ui: &mut egui::Ui) { visible_ids.insert(id); let r = rect.translate(origin.to_vec2()); let onscreen = rect.intersects(viewport); - cell(app, ui, id, r, square, onscreen, ppp); - if let Some((sid, pos)) = stacks.get(&id) { - stack_badge(app, ui, id, *sid, *pos, r, square); - } + cell(app, ui, id, r, CellView { square, onscreen, ppp, stack: stacks.get(&id).copied() }); } } // date headers (top to bottom); the current group's header sticks to the top while its @@ -789,7 +790,8 @@ pub(crate) fn skips_the_real_render(embedded_is_final: bool, from_embedded: bool /// Rendered thumbnails replacing embedded previews: after everything on screen. pub const BACKGROUND_THUMB_PRIORITY: u32 = 3; -fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, square: bool, onscreen: bool, ppp: f32) { +fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, view: CellView) { + let CellView { square, onscreen, ppp, stack } = view; let t = Tokens::get(ui.ctx()); let Some(photo) = app.session.catalog.photo(id).cloned() else { return }; let resp = ui.interact(r, egui::Id::unique(("cell", id.0)), Sense::click_and_drag()); @@ -806,26 +808,32 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, square } else { r }; - paint_cell_thumbnail(app, p, &t, id, img_rect, ThumbFlags { square, state, onscreen, ppp }); + let flags = ThumbFlags { square, state, onscreen, ppp, aspect: photo_aspect(Some(&*photo)) }; + let (photo_rect, failure) = paint_cell_thumbnail(app, p, &t, id, img_rect, flags); // labels and badges paint_cell_caption(app, p, &t, &photo, r, square); - paint_cell_badges(app, p, &t, &photo, img_rect, BadgeFlags { square, selected, hovered: resp.hovered() }); - if let Some(name) = &photo.copy_name { - paint_copy_tag(p, &t, name, img_rect, square); - } - if let Some(why) = &photo.preview_only { - paint_preview_pill(ui, p, &t, id, why, img_rect); - } - if photo.flag == Flag::Reject { - p.rect_filled(img_rect, 0.0, Color32::from_black_alpha(110)); - } + let show_badges = match app.ui.settings.grid_badges { + crate::state::GridBadges::Auto => resp.hovered() || selected || photo.rating > 0 || photo.flag != Flag::None || photo.label.is_some(), + crate::state::GridBadges::Always => true, + crate::state::GridBadges::Never => false, + }; + let overlay = crate::thumb::Thumb { + surface: crate::thumb::Surface::Grid, + photo: &photo, + rect: photo_rect, + stack, + marks: show_badges, + hot: resp.hovered() || selected, + failure, + }; + crate::thumb::overlay(app, ui, &overlay); cell_interaction(app, ui, &resp, id, &photo); } pub(crate) fn cell_description(app: &LightcraftApp, photo: &lightcraft_catalog::Photo) -> String { let mut spoken = photo.file_name.clone(); if photo.rating > 0 { - spoken.push_str(&crate::i18n::tr_format!(", {} star{}", photo.rating, if photo.rating == 1 { "" } else { "s" })); + spoken.push_str(&crate::thumb::spoken_rating(photo.rating)); } match photo.flag { lightcraft_catalog::Flag::Pick => spoken.push_str(crate::i18n::tr(", picked")), @@ -838,26 +846,32 @@ pub(crate) fn cell_description(app: &LightcraftApp, photo: &lightcraft_catalog:: spoken } -fn paint_cell_thumbnail(app: &mut LightcraftApp, p: &egui::Painter, t: &Tokens, id: PhotoId, img_rect: Rect, flags: ThumbFlags) { - let ThumbFlags { square, state, onscreen, ppp } = flags; +fn paint_cell_thumbnail( + app: &mut LightcraftApp, + p: &egui::Painter, + t: &Tokens, + id: PhotoId, + img_rect: Rect, + flags: ThumbFlags, +) -> (Rect, Option) { + let ThumbFlags { square: _, state, onscreen, ppp, aspect } = flags; let size = thumb_px(img_rect.width().max(img_rect.height()), ppp); request_thumb(app, id, size, if onscreen { 10 } else { 5 }); - if let Some(tex) = app.renderer.thumb(id) { + let (photo_rect, failure) = if let Some(tex) = app.renderer.thumb(id) { let [tw, th] = tex.size; // Preserve the decoded preview's ratio when it differs from the catalog dimensions. let fit = super::detail::fit_texture_rect(img_rect, [tw, th]); p.image(tex.tex.id(), fit, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::WHITE); selection_ring(p, t, fit, state); + (fit, None) } else { - let ph = img_rect.shrink(if square { 20.0 } else { 0.0 }); - p.rect_filled(ph, 0.0, t.skeleton); + let ph = crate::thumb::placeholder_rect(img_rect, aspect); + crate::thumb::paint_placeholder(p, ph, t); // not drawn yet (or unreadable): the selection is still visible selection_ring(p, t, ph, state); - if app.renderer.failure(Slot::Thumb(id)).is_some() { - // unreadable / missing file - p.text(ph.center(), Align2::CENTER_CENTER, "!", t.semibold(18.0), t.text); - } - } + (ph, app.renderer.failure(Slot::Thumb(id)).map(str::to_owned)) + }; + (photo_rect, failure) } fn paint_cell_caption(app: &LightcraftApp, p: &egui::Painter, t: &Tokens, photo: &lightcraft_catalog::Photo, r: Rect, square: bool) { @@ -890,74 +904,6 @@ fn paint_cell_caption(app: &LightcraftApp, p: &egui::Painter, t: &Tokens, photo: } } -fn paint_cell_badges(app: &LightcraftApp, p: &egui::Painter, t: &Tokens, photo: &lightcraft_catalog::Photo, img_rect: Rect, flags: BadgeFlags) { - let BadgeFlags { square, selected, hovered } = flags; - let show_badges = match app.ui.settings.grid_badges { - crate::state::GridBadges::Auto => hovered || selected || photo.rating > 0 || photo.flag != Flag::None || photo.label.is_some(), - crate::state::GridBadges::Always => true, - crate::state::GridBadges::Never => false, - }; - let badge_bar = Rect::from_min_max(pos2(img_rect.left(), img_rect.bottom() - 24.0), img_rect.right_bottom()); - if !square && photo.label.is_some() { - // Justified photos fill the whole cell, so the label shows as a translucent tinted footer - // over the photo's bottom edge (opaque, it would hide 24 px of every labelled photo). - p.rect_filled(badge_bar, 0.0, crate::theme::label_background(t.cell, photo.label, selected).gamma_multiply(0.7)); - } - if show_badges { - let bar = badge_bar; - if (hovered || selected) && (square || photo.label.is_none()) { - p.rect_filled(bar, 0.0, Color32::from_black_alpha(120)); - } - let mut x = bar.left() + 6.0; - x += crate::rating::paint_rating(p, pos2(x, bar.center().y), photo.rating, crate::rating::RatingSize::Medium, t.star) + 4.0; - match photo.flag { - Flag::Pick => paint(p, Rect::from_min_size(pos2(x, bar.center().y - 7.0), vec2(14.0, 14.0)), Icon::FlagPickFilled, t.pick), - Flag::Reject => paint(p, Rect::from_min_size(pos2(x, bar.center().y - 7.0), vec2(14.0, 14.0)), Icon::FlagReject, t.reject), - Flag::None => {} - } - let mut right = bar.right(); - if photo.is_edited() { - paint(p, Rect::from_min_size(pos2(right - 20.0, bar.center().y - 7.0), vec2(14.0, 14.0)), Icon::Sliders, t.text_label); - right -= 20.0; - } - if let Some(l) = photo.label { - p.circle(pos2(right - 12.0, bar.center().y), 5.0, label_color(l), Stroke::new(1.0, Color32::from_black_alpha(120))); - } - } -} - -fn paint_copy_tag(p: &egui::Painter, t: &Tokens, name: &str, img_rect: Rect, square: bool) { - // virtual copy: a folded-corner tag at the top right - let g = p.layout_no_wrap(name.to_string(), t.semibold(10.5), Color32::WHITE); - let tr = if square { img_rect.right_top() + vec2(-6.0, 6.0) } else { img_rect.right_top() + vec2(-5.0, 5.0) }; - let br = Rect::from_min_max(pos2(tr.x - g.size().x - 26.0, tr.y), pos2(tr.x, tr.y + 20.0)); - p.rect_filled(br, 10.0, Color32::from_black_alpha(165)); - let c = pos2(br.left() + 13.0, br.center().y); - let s = 5.0; - p.add(egui::Shape::convex_polygon( - vec![c + vec2(-s, -s), c + vec2(s * 0.3, -s), c + vec2(s, -s * 0.3), c + vec2(s, s), c + vec2(-s, s)], - Color32::TRANSPARENT, - Stroke::new(1.2, Color32::WHITE), - )); - p.line_segment([c + vec2(s * 0.3, -s), c + vec2(s * 0.3, -s * 0.3)], Stroke::new(1.2, Color32::WHITE)); - p.line_segment([c + vec2(s * 0.3, -s * 0.3), c + vec2(s, -s * 0.3)], Stroke::new(1.2, Color32::WHITE)); - p.galley(pos2(br.left() + 22.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); -} - -fn paint_preview_pill(ui: &egui::Ui, p: &egui::Painter, t: &Tokens, id: PhotoId, why: &str, img_rect: Rect) { - // a raw shown from its embedded JPEG: a small amber "Preview" pill at the image's bottom - // left, above the badge bar (always shown: it changes what editing does) - let g = p.layout_no_wrap(crate::i18n::tr("Preview").into(), t.semibold(9.5), Color32::WHITE); - let at = pos2(img_rect.left() + 6.0, img_rect.bottom() - 30.0 - 16.0); - let br = Rect::from_min_size(at, vec2(g.size().x + 24.0, 16.0)); - p.rect_filled(br, 8.0, Color32::from_black_alpha(170)); - paint(p, Rect::from_center_size(pos2(br.left() + 9.0, br.center().y), vec2(12.0, 12.0)), Icon::Info, t.caution); - p.galley(pos2(br.left() + 17.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); - register(ui, format!("badge:previewOnly:{}", id.0), br); - ui.interact(br, egui::Id::unique(("preview-only-badge", id.0)), Sense::hover()) - .on_hover_text(crate::i18n::tr_format!("Preview only — {}", crate::widgets::preview_only_explanation(why))); -} - fn cell_interaction(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Response, id: PhotoId, photo: &lightcraft_catalog::Photo) { if let Some(k) = app.ui.keyword_painter.clone() { // painting: a click toggles the keyword on this photo @@ -998,12 +944,15 @@ struct ThumbFlags { state: lightcraft_engine::SelectionState, onscreen: bool, ppp: f32, + aspect: f32, } -struct BadgeFlags { +/// How `cell` is drawn: the layout, whether it is on screen, the pixel scale, and the photo's stack position. +struct CellView { square: bool, - selected: bool, - hovered: bool, + onscreen: bool, + ppp: f32, + stack: Option<(lightcraft_catalog::StackId, usize)>, } /// The header of a Local folder view: the path as a breadcrumb (each part opens that folder), @@ -1236,38 +1185,6 @@ pub fn label_param(l: Option) -> String { l.map_or_else(|| "none".to_string(), |l| format!("{l:?}").to_lowercase()) } -/// Stack badge at the cell's top-left: the photo count on a collapsed stack's top, `i/n` on the -/// members of an expanded stack. Clicking or double-clicking it expands/collapses the stack. -pub fn stack_badge(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, sid: lightcraft_catalog::StackId, pos: usize, r: Rect, square: bool) { - let t = Tokens::get(ui.ctx()); - let Some(st) = app.session.catalog.stack(sid) else { return }; - let n = st.photos.len(); - let collapsed = st.collapsed; - let text = if collapsed { n.to_string() } else { format!("{}/{n}", pos + 1) }; - let p = ui.painter(); - let g = p.layout_no_wrap(text, t.semibold(11.0), Color32::WHITE); - let origin = if square { r.min + vec2(10.0, 26.0) } else { r.min + vec2(5.0, 5.0) }; - let br = Rect::from_min_size(origin, vec2(g.size().x + 30.0, 20.0)); - let resp = ui.interact(br, egui::Id::unique(("stack-badge", id.0)), Sense::click()).on_hover_text(if collapsed { - "Stack — click to expand (S)" - } else { - "Stack — click to collapse (S)" - }); - crate::widgets::announce(&resp, crate::i18n::tr(if collapsed { "Expand Stack" } else { "Collapse Stack" })); - register(ui, format!("stack:{}", id.0), br); - let fill = if resp.hovered() { Color32::from_black_alpha(220) } else { Color32::from_black_alpha(165) }; - p.rect_filled(br, 10.0, fill); - if pos == 0 && !collapsed { - p.rect_stroke(br, 10.0, Stroke::new(1.0, t.accent), StrokeKind::Inside); - } - paint(p, Rect::from_min_size(br.min + vec2(6.0, 3.0), vec2(14.0, 14.0)), Icon::Stack, Color32::WHITE); - p.galley(pos2(br.min.x + 24.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); - // a double-click (Lightroom's way) toggles once: its second click would undo the first - if resp.clicked() && !resp.double_clicked() { - toggle_stack(app, ui.ctx(), id); - } -} - /// A click on a stack badge (grid or filmstrip): expand / collapse that photo's stack, selected or /// not. The selection stays as it is (Compare keeps its pair). pub fn toggle_stack(app: &mut LightcraftApp, ctx: &egui::Context, id: PhotoId) { diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 09e7703d77..72a52f00ad 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -87,6 +87,7 @@ mod sync; mod tallies; mod temp_slider; mod text_prompt; +mod thumb; mod titlebar; mod tool_overlay; mod unsaved; diff --git a/crates/ui-egui/src/tests/filmstrip.rs b/crates/ui-egui/src/tests/filmstrip.rs index de05996d1e..3dd01ec049 100644 --- a/crates/ui-egui/src/tests/filmstrip.rs +++ b/crates/ui-egui/src/tests/filmstrip.rs @@ -46,7 +46,7 @@ fn filmstrip_stack_badge_expands_and_collapses_the_stack() { assert_eq!(r["ok"], true, "{r}"); assert!(h.settle(SETTLE), "the filmstrip settles before clicking its stack badge"); assert!(!h.app.session.visible_cloned().contains(&member), "collapsed: only the top shows"); - let badge = format!("filmstack:{}", top.0); + let badge = format!("film:stack:{}", top.0); let r = h.request("ui.clickWidget", json!({"id": badge}), T); assert_eq!(r["ok"], true, "{r}"); assert!(h.settle(SETTLE), "the expanded stack settles"); diff --git a/crates/ui-egui/src/tests/labels.rs b/crates/ui-egui/src/tests/labels.rs index 9325ab77e0..5a49635f85 100644 --- a/crates/ui-egui/src/tests/labels.rs +++ b/crates/ui-egui/src/tests/labels.rs @@ -45,8 +45,19 @@ fn label_tints_grid_and_filmstrip_chrome_without_changing_photo_pixels() { let mut h = app(view); let widget = if view == ViewMode::Detail { "film:1" } else { "thumb:1" }; let cell = rect(&h, widget); + // (the photo grid's label is the dot in the marks row: no band is laid over its pixels; the + // square grid and the filmstrip also tint their surround) let sample = if view == ViewMode::PhotoGrid { - egui::pos2(cell.right() - 40.0, cell.bottom() - 8.0) + h.app.run("photo.label", json!({"label": "red"})).unwrap(); + h.step(); + let red = crate::theme::label_color(lightcraft_catalog::ColorLabel::Red); + let dot = h.view.painted_shapes().into_iter().find_map(|s| match s { + egui::epaint::Shape::Circle(c) if c.fill == red && cell.contains(c.center) => Some(c.center), + _ => None, + }); + h.app.run("photo.label", json!({"label": "none"})).unwrap(); + h.step(); + dot.expect("the label dot") } else { egui::pos2(cell.left() + 4.0, cell.center().y) }; diff --git a/crates/ui-egui/src/tests/thumb.rs b/crates/ui-egui/src/tests/thumb.rs new file mode 100644 index 0000000000..c4847365e0 --- /dev/null +++ b/crates/ui-egui/src/tests/thumb.rs @@ -0,0 +1,164 @@ +//! Headless tests of the thumbnail overlay the grid (justified and square) and the filmstrip share: +//! the virtual-copy tag, the stack badge, the placeholder and the failure mark, and the one way a +//! colour label shows. + +use std::{cell::Cell, rc::Rc, time::Duration}; + +use egui::epaint::Shape; +use egui::{Color32, Rect}; +use lightcraft_catalog::{ColorLabel, PhotoId}; +use serde_json::json; + +use crate::headless::{Headless, RenderGate}; +use crate::i18n::Locale; +use crate::render::Slot; +use crate::state::ViewMode; +use crate::{LightcraftApp, Services}; + +const T: Duration = Duration::from_secs(20); +const SETTLE: Duration = Duration::from_secs(120); + +fn demo() -> Headless { + let mut app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }); + app.ui.view = ViewMode::PhotoGrid; + Headless::new(app, [1400.0, 900.0], 1.0) +} + +fn run(h: &mut Headless, command: &str, params: serde_json::Value) { + let r = h.request("engine.execute", json!({"command": command, "params": params}), T); + assert_eq!(r["ok"], true, "{command}: {r}"); +} + +fn widget(h: &Headless, id: &str) -> Option { + h.app.widgets.iter().find(|(w, _)| w == id).map(|(_, r)| *r) +} + +fn first_photos(h: &mut Headless, n: usize) -> Vec { + h.app.session.visible_cloned().into_iter().take(n).collect() +} + +/// Hover `id` and wait for a tooltip text that satisfies `says`. +fn hover_says(h: &mut Headless, id: &str, says: impl Fn(&str) -> bool) -> bool { + let r = h.request("ui.hoverWidget", json!({"id": id}), T); + assert_eq!(r["ok"], true, "{r}"); + h.step_until(Duration::from_secs(5), |h| h.painted_text().iter().any(|t| says(t))) +} + +#[test] +fn a_virtual_copy_is_tagged_in_the_filmstrip_as_it_is_in_the_grid() { + let mut h = demo(); + let master = first_photos(&mut h, 1)[0]; + run(&mut h, "photo.virtualCopy", json!({"ids": [master.0]})); + let copy = h.app.session.catalog.photos().find(|p| p.copy_name.is_some()).map(|p| p.id).expect("a virtual copy"); + h.settle(SETTLE); + assert!(widget(&h, &format!("copy:{}", copy.0)).is_some(), "the grid tags the copy"); + assert!(widget(&h, &format!("copy:{}", master.0)).is_none(), "the master is not tagged"); + let r = h.request("ui.set", json!({"view": "detail"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + assert!(widget(&h, &format!("film:copy:{}", copy.0)).is_some(), "the filmstrip tags the copy too"); + assert!(widget(&h, &format!("film:copy:{}", master.0)).is_none(), "and not the master"); +} + +#[test] +fn the_filmstrip_stack_badge_toggles_its_stack_like_the_grid_s() { + let mut h = demo(); + let ids = first_photos(&mut h, 2); + run(&mut h, "stack.group", json!({"ids": [ids[0].0, ids[1].0], "collapsed": false})); + h.request("ui.set", json!({"view": "detail"}), T); + h.settle(SETTLE); + let collapsed = |h: &Headless| h.app.session.catalog.stack_of(ids[0]).map(|s| s.collapsed); + assert_eq!(collapsed(&h), Some(false)); + let r = h.request("ui.clickWidget", json!({"id": format!("film:stack:{}", ids[0].0)}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + assert_eq!(collapsed(&h), Some(true), "a click on the filmstrip's badge collapses the stack"); +} + +#[test] +fn the_stack_badge_tooltip_is_translated_in_the_grid_and_the_filmstrip() { + let mut h = demo(); + let ids = first_photos(&mut h, 2); + run(&mut h, "stack.group", json!({"ids": [ids[0].0, ids[1].0], "collapsed": false})); + h.settle(SETTLE); + let r = h.request("ui.set", json!({"language": "de"}), T); + assert_eq!(r["ok"], true, "{r}"); + let german = Locale::De.tr("Stack — click to collapse (S)"); + let said = |t: &str| t == german; + assert!(hover_says(&mut h, &format!("stack:{}", ids[0].0), said), "{:?}", h.painted_text()); + h.request("ui.move", json!({"x": 1, "y": 1}), T); + h.request("ui.set", json!({"view": "detail"}), T); + h.settle(SETTLE); + assert!(hover_says(&mut h, &format!("film:stack:{}", ids[0].0), said), "{:?}", h.painted_text()); + crate::i18n::set_language(Locale::En); +} + +fn placeholder_in(h: &Headless, cell: Rect) -> bool { + h.view.painted_shapes().iter().any(|s| matches!(s, Shape::Rect(r) if r.fill == Color32::from_gray(38) && cell.expand(1.0).contains_rect(r.rect))) +} + +#[test] +fn a_thumbnail_that_is_not_drawn_yet_has_the_same_placeholder_in_the_filmstrip_and_the_grid() { + let mut h = demo(); + // renders wait: no thumbnail exists + h.app.renderer.set_offload(Box::new(RenderGate::new(Rc::new(Cell::new(false))))); + let id = first_photos(&mut h, 1)[0]; + for _ in 0..10 { + h.step(); + } + let grid = widget(&h, &format!("thumb:{}", id.0)).expect("grid cell"); + assert!(placeholder_in(&h, grid), "the grid's placeholder"); + h.request("ui.set", json!({"view": "detail"}), T); + for _ in 0..10 { + h.step(); + } + let film = widget(&h, &format!("film:{}", id.0)).expect("filmstrip cell"); + assert!(placeholder_in(&h, film), "the filmstrip draws the grid's placeholder too"); +} + +#[test] +fn a_failed_thumbnail_shows_a_mark_that_explains_itself_in_the_grid_and_the_filmstrip() { + let mut h = demo(); + h.app.renderer.set_offload(Box::new(RenderGate::failing(Rc::new(Cell::new(true)), |s| matches!(s, Slot::Thumb(_))))); + let id = first_photos(&mut h, 1)[0]; + let (grid_mark, film_mark) = (format!("badge:failed:{}", id.0), format!("film:failed:{}", id.0)); + assert!(h.step_until(SETTLE, |h| widget(h, &grid_mark).is_some()), "the grid's mark is a widget"); + assert!(!h.painted_text().iter().any(|t| t == "!"), "drawn as an icon, not a glyph"); + let says = |t: &str| t.contains("This photo can't be opened") && t.contains("no decoder for this raw") && t.contains("Reload from Disk"); + assert!(hover_says(&mut h, &grid_mark, says), "{:?}", h.painted_text()); + h.request("ui.move", json!({"x": 1, "y": 1}), T); + h.request("ui.set", json!({"view": "detail"}), T); + assert!(h.step_until(SETTLE, |h| widget(h, &film_mark).is_some()), "the filmstrip draws the mark"); + assert!(hover_says(&mut h, &film_mark, says), "{:?}", h.painted_text()); +} + +fn label_dot_in(h: &Headless, cell: Rect) -> bool { + let red = crate::theme::label_color(ColorLabel::Red); + h.view.painted_shapes().iter().any(|s| matches!(s, Shape::Circle(c) if c.fill == red && cell.contains(c.center))) +} + +/// A band along a cell's lower edge the width of the cell: the footer a label once tinted over +/// the justified grid's photo. +fn footer_band_in(h: &Headless, cell: Rect) -> bool { + h.view.painted_shapes().iter().any(|s| { + matches!(s, Shape::Rect(r) if (r.rect.width() - cell.width()).abs() < 0.5 && (r.rect.height() - 24.0).abs() < 0.5 && (r.rect.bottom() - cell.bottom()).abs() < 0.5 && r.fill.a() > 0 && r.fill != Color32::from_black_alpha(120)) + }) +} + +#[test] +fn a_label_is_the_dot_in_the_marks_row_on_every_surface_and_no_footer_covers_the_photo() { + let mut h = demo(); + let id = first_photos(&mut h, 1)[0]; + run(&mut h, "photo.label", json!({"ids": [id.0], "label": "red"})); + // not selected, not hovered: the footer would show on its own + let other = first_photos(&mut h, 2)[1]; + run(&mut h, "library.select", json!({"ids": [other.0]})); + h.step(); + for (view, cell) in [(ViewMode::PhotoGrid, "thumb"), (ViewMode::SquareGrid, "thumb"), (ViewMode::Detail, "film")] { + h.app.ui.view = view; + h.settle(SETTLE); + let r = widget(&h, &format!("{cell}:{}", id.0)).unwrap_or_else(|| panic!("{view:?}: the photo's cell")); + assert!(label_dot_in(&h, r), "{view:?}: the label dot"); + assert!(!footer_band_in(&h, r), "{view:?}: no tinted footer over the photo"); + } +} diff --git a/crates/ui-egui/src/thumb.rs b/crates/ui-egui/src/thumb.rs new file mode 100644 index 0000000000..baadbd62ac --- /dev/null +++ b/crates/ui-egui/src/thumb.rs @@ -0,0 +1,650 @@ +//! The overlay a thumbnail wears, drawn the same way in the justified grid, the square grid and the +//! filmstrip: the stack badge (top left), the virtual-copy tag (top right), the failure mark, the +//! preview-only pill and the marks row along the photo's lower edge (rating, flag, edited, colour +//! label). +//! +//! Everything is laid out against the picture itself, not its cell: on a narrow tile (a portrait +//! photo at the smallest thumbnail size) the marks degrade instead of running over the photo's +//! edge (see [`bar_layout`] and [`copy_tag_layout`], pure functions of the width on offer). + +use egui::{Align2, Color32, Painter, Rect, Sense, Stroke, pos2, vec2}; +use lightcraft_catalog::{Flag, Photo, PhotoId, StackId}; + +use crate::{ + LightcraftApp, + icons::{Icon, paint}, + theme::Tokens, + widgets::register, +}; + +/// Where a thumbnail is drawn: its marks keep the proportions of the surface. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +pub(crate) enum Surface { + /// The justified and the square grid. + Grid, + /// The strip under the loupe. + Film, +} + +/// The sizes, in points, of a surface's marks. +#[derive(Clone, Copy, Debug)] +pub(crate) struct Metrics { + /// A star's side and the distance between two, and the shared rating drawing of that size (its + /// side and step are the same numbers). + star: f32, + star_pitch: f32, + rating: crate::rating::RatingSize, + /// The room a digit takes in a compact rating. + digit: f32, + /// The flag's icon, and the room it takes (a gap to what is left of it included). + flag_icon: f32, + flag: f32, + /// The edited mark's icon and room. + edited_icon: f32, + edited: f32, + /// The label dot's radius and room. + dot: f32, + label: f32, + /// The marks row's height, its padding at each end and the gap between its two groups. + bar: f32, + pad: f32, + gap: f32, + /// How far the corner badges sit from the photo's corner, and how high they are. + inset: f32, + badge: f32, + /// What a stack badge adds to its text (icon and padding), and what a copy tag adds to its + /// name; a copy tag without its name is `copy_icon` wide. + stack_extra: f32, + copy_extra: f32, + copy_icon: f32, + /// What the preview pill adds to its text; without its text it is `pill_icon` wide. + pill_extra: f32, + pill_icon: f32, + font: f32, + micro: f32, + /// Whether a band darkens the row under any marks (the filmstrip's), not only under the pointer + /// and on a chosen photo (the grid's). + band: bool, +} + +impl Surface { + pub(crate) fn metrics(self) -> Metrics { + match self { + Surface::Grid => Metrics { + star: 12.0, + star_pitch: 13.0, + rating: crate::rating::RatingSize::Medium, + digit: 7.0, + flag_icon: 14.0, + flag: 18.0, + edited_icon: 14.0, + edited: 20.0, + dot: 5.0, + label: 14.0, + bar: 24.0, + pad: 4.0, + gap: 6.0, + inset: 5.0, + badge: 20.0, + stack_extra: 30.0, + copy_extra: 26.0, + copy_icon: 20.0, + pill_extra: 24.0, + pill_icon: 16.0, + font: 11.0, + micro: 9.5, + band: false, + }, + Surface::Film => Metrics { + star: 8.0, + star_pitch: 9.0, + rating: crate::rating::RatingSize::Small, + digit: 5.0, + flag_icon: 10.0, + flag: 12.0, + edited_icon: 10.0, + edited: 14.0, + dot: 3.5, + label: 10.0, + bar: 15.0, + pad: 3.0, + gap: 4.0, + inset: 3.0, + badge: 15.0, + stack_extra: 22.0, + copy_extra: 20.0, + copy_icon: 16.0, + pill_extra: 20.0, + pill_icon: 14.0, + font: 9.5, + micro: 8.5, + band: true, + }, + } + } + + /// The widget ids of a surface: the grid's keep their names, the filmstrip's start with `film:`. + fn widget(self, kind: Mark, id: PhotoId) -> String { + let (grid, film) = match kind { + Mark::Stack => ("stack", "film:stack"), + Mark::Copy => ("copy", "film:copy"), + Mark::Preview => ("badge:previewOnly", "film:previewOnly"), + Mark::Failed => ("badge:failed", "film:failed"), + }; + format!("{}:{}", if self == Surface::Grid { grid } else { film }, id.0) + } +} + +#[derive(Clone, Copy)] +enum Mark { + Stack, + Copy, + Preview, + Failed, +} + +// ------------------------------------------------------------------------ the marks row + +/// What a photo carries along its lower edge. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(crate) struct Marks { + pub rating: u8, + pub flag: bool, + pub edited: bool, + pub label: bool, +} + +impl Marks { + pub(crate) fn of(photo: &Photo) -> Self { + Marks { rating: photo.rating.min(5), flag: photo.flag != Flag::None, edited: photo.is_edited(), label: photo.label.is_some() } + } +} + +/// How the rating is drawn. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(crate) enum Stars { + #[default] + None, + /// One star per point of the rating. + Row(u8), + /// One star and the number: "★3". + Compact(u8), +} + +/// Which marks a row draws. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(crate) struct BarLayout { + pub stars: Stars, + pub flag: bool, + pub edited: bool, + pub label: bool, +} + +impl BarLayout { + pub(crate) fn is_empty(&self) -> bool { + *self == BarLayout::default() + } + + /// The width the row takes, its padding included; 0 for an empty row. + pub(crate) fn width(&self, m: &Metrics) -> f32 { + let stars = match self.stars { + Stars::None => 0.0, + Stars::Row(n) => f32::from(n) * m.star_pitch, + Stars::Compact(_) => m.star + 1.0 + m.digit, + }; + let left = stars + if self.flag { m.flag } else { 0.0 }; + let right = if self.edited { m.edited } else { 0.0 } + if self.label { m.label } else { 0.0 }; + if left + right == 0.0 { + return 0.0; + } + left + right + if left > 0.0 && right > 0.0 { m.gap } else { 0.0 } + 2.0 * m.pad + } + + fn fits(&self, width: f32, m: &Metrics) -> bool { + self.width(m) <= width + } +} + +/// The marks a photo `width` points wide has room for, as the tile narrows: first all of them; +/// then without the edited mark; then the stars as one star and the number; then only what fits +/// whole, by importance: the flag, the rating, the label. +pub(crate) fn bar_layout(width: f32, marks: Marks, m: &Metrics) -> BarLayout { + let stars = if marks.rating > 0 { Stars::Row(marks.rating) } else { Stars::None }; + let full = BarLayout { stars, flag: marks.flag, edited: marks.edited, label: marks.label }; + if full.fits(width, m) { + return full; + } + let plain = BarLayout { edited: false, ..full }; + if plain.fits(width, m) { + return plain; + } + // (one star is already as small as a rating gets) + let compact = if marks.rating > 1 { Stars::Compact(marks.rating) } else { stars }; + let squeezed = BarLayout { stars: compact, ..plain }; + if squeezed.fits(width, m) { + return squeezed; + } + let mut out = BarLayout::default(); + for trial in [BarLayout { flag: marks.flag, ..out }, BarLayout { stars: compact, ..out }, BarLayout { label: marks.label, ..out }] { + let next = BarLayout { + stars: if trial.stars == Stars::None { out.stars } else { trial.stars }, + flag: out.flag || trial.flag, + edited: false, + label: out.label || trial.label, + }; + if next != out && next.fits(width, m) { + out = next; + } + } + out +} + +// ------------------------------------------------------------------------ the corner badges + +/// How the virtual-copy tag is drawn. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum CopyTag { + /// The icon and the copy's name. + Full, + /// The icon alone. + IconOnly, + /// No room: the stack badge, or the photo's edge, is in the way. + Hidden, +} + +/// The copy tag for a photo `width` wide whose name is `name_w` wide, next to a stack badge +/// `stack_w` wide (if it has one): the tag gives up its name before it would run into the badge +/// or over the photo's edge, and then gives up its icon. +pub(crate) fn copy_tag_layout(width: f32, stack_w: Option, name_w: f32, m: &Metrics) -> CopyTag { + let room = width - 2.0 * m.inset - stack_w.map_or(0.0, |w| w + m.gap); + if name_w + m.copy_extra <= room { + CopyTag::Full + } else if m.copy_icon <= room { + CopyTag::IconOnly + } else { + CopyTag::Hidden + } +} + +/// Whether the preview-only pill has room for its word (else it is the icon alone). +pub(crate) fn preview_pill_full(width: f32, text_w: f32, m: &Metrics) -> bool { + text_w + m.pill_extra + 2.0 * m.inset <= width +} + +// ------------------------------------------------------------------------ texts + +/// What a screen reader says of a rating: the number follows its label, so that it reads right in +/// every language whatever its plural forms (no "star"/"stars" suffix to pick). +pub(crate) fn spoken_rating(rating: u8) -> String { + crate::i18n::tr_format!(", rating {} of 5", rating) +} + +/// What the failure mark says on hover: why the photo has no thumbnail, in plain words, where to +/// go from there, and the error itself. (The loupe's pill uses the same two headlines.) +pub(crate) fn failure_text(offline: bool, error: &str) -> String { + let (head, hint) = if offline { + (crate::i18n::tr("Original offline · no smart preview"), crate::i18n::tr("Right-click ▸ Locate Missing File… to find it again.")) + } else { + (crate::i18n::tr("This photo can't be opened"), crate::i18n::tr("Right-click ▸ Reload from Disk to try again.")) + }; + format!("{head}\n{hint}\n{error}") +} + +fn stack_tip(collapsed: bool) -> &'static str { + crate::i18n::tr(if collapsed { "Stack — click to expand (S)" } else { "Stack — click to collapse (S)" }) +} + +// ------------------------------------------------------------------------ placeholder + +/// Where a photo of `aspect` (width / height) sits in `area`, when its thumbnail is not drawn yet. +pub(crate) fn placeholder_rect(area: Rect, aspect: f32) -> Rect { + let aspect = if aspect.is_finite() && aspect > 0.0 { aspect } else { 1.5 }; + let (w, h) = if area.width() / aspect <= area.height() { (area.width(), area.width() / aspect) } else { (area.height() * aspect, area.height()) }; + Rect::from_center_size(area.center(), vec2(w, h)) +} + +/// The picture's stand-in: the theme's skeleton color (firmer than the cell on the light themes). +pub(crate) fn paint_placeholder(p: &Painter, rect: Rect, t: &Tokens) { + p.rect_filled(rect, 0.0, t.skeleton); +} + +// ------------------------------------------------------------------------ the overlay + +/// One thumbnail to put the overlay on. +pub(crate) struct Thumb<'a> { + pub surface: Surface, + pub photo: &'a Photo, + /// The picture (or the placeholder standing for it) on screen. + pub rect: Rect, + /// The photo's stack and its place in it. + pub stack: Option<(StackId, usize)>, + /// Whether the marks row is drawn (Settings → Interface). + pub marks: bool, + /// The pointer is over the cell, or it is chosen: the row's band shows even without marks. + pub hot: bool, + /// Why the thumbnail could not be drawn, when it could not. + pub failure: Option, +} + +pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) { + let t = Tokens::get(ui.ctx()); + let m = th.surface.metrics(); + let (photo, rect, id) = (th.photo, th.rect, th.photo.id); + let p = ui.painter().clone(); + // (a rejected photo is dimmed under its marks, not over them) + if photo.flag == Flag::Reject { + p.rect_filled(rect, 0.0, Color32::from_black_alpha(110)); + } + if let Some(error) = &th.failure { + failure_mark(app, ui, th, &t, error); + } + if th.marks { + marks_row(&p, &t, &m, th); + } + let stack_w = th.stack.and_then(|(sid, pos)| stack_badge(app, ui, th, &t, sid, pos)); + if let Some(name) = &photo.copy_name { + copy_tag(ui, th, &t, name, stack_w); + } + if let Some(why) = &photo.preview_only { + preview_pill(ui, th, &t, why); + } + let _ = (&p, id); +} + +fn failure_mark(app: &LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, error: &str) { + let id = th.photo.id; + let side = (th.rect.width().min(th.rect.height()) * 0.4).clamp(12.0, 22.0); + let icon = Rect::from_center_size(th.rect.center(), vec2(side, side)); + paint(ui.painter(), icon, Icon::Warning, t.caution); + let target = icon.expand(4.0); + register(ui, th.surface.widget(Mark::Failed, id), target); + let offline = matches!(&th.photo.source, lightcraft_catalog::Source::File { path } if app.session.media.availability.is_offline(path)); + let text = failure_text(offline, error); + let resp = ui.interact(target, egui::Id::unique((th.surface, "thumb-failed", id.0)), Sense::hover()).on_hover_text(&text); + resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, text.replace('\n', ": "))); +} + +fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb) { + let (photo, rect) = (th.photo, th.rect); + let layout = bar_layout(rect.width(), Marks::of(photo), m); + if layout.is_empty() && !th.hot { + return; + } + let bar = Rect::from_min_max(pos2(rect.left(), (rect.bottom() - m.bar).max(rect.top())), rect.right_bottom()); + if th.hot || m.band { + p.rect_filled(bar, 0.0, Color32::from_black_alpha(120)); + } + let y = bar.center().y; + let mut x = bar.left() + m.pad; + match layout.stars { + Stars::None => {} + Stars::Row(n) => { + x += crate::rating::paint_rating(p, pos2(x, y), n, m.rating, t.star); + } + Stars::Compact(n) => { + paint(p, Rect::from_min_size(pos2(x, y - m.star / 2.0), vec2(m.star, m.star)), Icon::StarFilled, t.star); + p.text(pos2(x + m.star + 1.0, y), Align2::LEFT_CENTER, n.to_string(), t.semibold(m.font), t.star); + x += m.star + 1.0 + m.digit; + } + } + if layout.flag { + let at = Rect::from_min_size(pos2(x + m.flag - m.flag_icon, y - m.flag_icon / 2.0), vec2(m.flag_icon, m.flag_icon)); + match photo.flag { + Flag::Pick => paint(p, at, Icon::FlagPickFilled, t.pick), + Flag::Reject => paint(p, at, Icon::FlagReject, t.reject), + Flag::None => {} + } + } + let mut right = bar.right() - m.pad; + if layout.label + && let Some(l) = photo.label + { + p.circle(pos2(right - m.label / 2.0, y), m.dot, crate::theme::label_color(l), Stroke::new(1.0, Color32::from_black_alpha(120))); + right -= m.label; + } + if layout.edited { + let at = Rect::from_center_size(pos2(right - m.edited / 2.0, y), vec2(m.edited_icon, m.edited_icon)); + paint(p, at, Icon::Sliders, t.text_label); + } +} + +/// The stack badge at the photo's top left: the number of photos on a collapsed stack's top, +/// `i/n` on the members of an expanded one; a click collapses or expands the stack. Returns its +/// width. +fn stack_badge(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, sid: StackId, pos: usize) -> Option { + let m = th.surface.metrics(); + let st = app.session.catalog.stack(sid)?; + let (n, collapsed) = (st.photos.len(), st.collapsed); + let id = th.photo.id; + let text = if collapsed { n.to_string() } else { format!("{}/{n}", pos + 1) }; + let p = ui.painter().clone(); + let g = p.layout_no_wrap(text, t.semibold(m.font), Color32::WHITE); + let br = Rect::from_min_size(th.rect.min + vec2(m.inset, m.inset), vec2(g.size().x + m.stack_extra, m.badge)); + let resp = ui.interact(br, egui::Id::unique((th.surface, "stack-badge", id.0)), Sense::click()).on_hover_text(stack_tip(collapsed)); + register(ui, th.surface.widget(Mark::Stack, id), br); + let fill = if resp.hovered() { Color32::from_black_alpha(220) } else { Color32::from_black_alpha(165) }; + p.rect_filled(br, m.badge / 2.0, fill); + if pos == 0 && !collapsed { + p.rect_stroke(br, m.badge / 2.0, Stroke::new(1.0, t.accent), egui::StrokeKind::Inside); + } + let icon = m.badge - 6.0; + paint(&p, Rect::from_min_size(br.min + vec2(m.badge * 0.3, 3.0), vec2(icon, icon)), Icon::Stack, Color32::WHITE); + p.galley(pos2(br.min.x + m.stack_extra - 6.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); + let width = br.width(); + // a double-click (Lightroom's way) toggles once: its second click would undo the first + if resp.clicked() && !resp.double_clicked() { + crate::panels::grid::toggle_stack(app, ui.ctx(), id); + } + Some(width) +} + +/// The virtual-copy tag at the photo's top right, so that a copy and its master tell apart. +fn copy_tag(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, name: &str, stack_w: Option) { + let m = th.surface.metrics(); + let p = ui.painter().clone(); + let g = p.layout_no_wrap(name.to_string(), t.semibold(m.micro + 1.0), Color32::WHITE); + let mode = copy_tag_layout(th.rect.width(), stack_w, g.size().x, &m); + let w = match mode { + CopyTag::Full => g.size().x + m.copy_extra, + CopyTag::IconOnly => m.copy_icon, + CopyTag::Hidden => return, + }; + let br = Rect::from_min_size(pos2(th.rect.right() - m.inset - w, th.rect.top() + m.inset), vec2(w, m.badge)); + p.rect_filled(br, m.badge / 2.0, Color32::from_black_alpha(165)); + let icon = m.badge * 0.55; + let at = if mode == CopyTag::Full { pos2(br.left() + m.badge * 0.65, br.center().y) } else { br.center() }; + paint(&p, Rect::from_center_size(at, vec2(icon, icon)), Icon::VirtualCopy, Color32::WHITE); + if mode == CopyTag::Full { + p.galley(pos2(br.left() + m.copy_extra - 4.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); + } + let id = th.photo.id; + register(ui, th.surface.widget(Mark::Copy, id), br); + let tip = format!("{}: {name}", crate::i18n::tr("Virtual copy")); + ui.interact(br, egui::Id::unique((th.surface, "copy-tag", id.0)), Sense::hover()) + .on_hover_text(&tip) + .widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, &tip)); +} + +/// A raw shown from its embedded JPEG: a small amber "Preview" pill above the marks row, always +/// shown (it changes what editing does). +fn preview_pill(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, why: &str) { + let m = th.surface.metrics(); + let p = ui.painter().clone(); + let g = p.layout_no_wrap(crate::i18n::tr("Preview").into(), t.semibold(m.micro), Color32::WHITE); + let full = preview_pill_full(th.rect.width(), g.size().x, &m); + let (w, h) = (if full { g.size().x + m.pill_extra } else { m.pill_icon }, m.pill_icon); + let top = (th.rect.bottom() - m.bar - 4.0 - h).max(th.rect.top() + m.inset); + let br = Rect::from_min_size(pos2(th.rect.left() + m.inset, top), vec2(w, h)); + p.rect_filled(br, h / 2.0, Color32::from_black_alpha(170)); + let icon = h - 4.0; + let centre = if full { pos2(br.left() + h * 0.55, br.center().y) } else { br.center() }; + paint(&p, Rect::from_center_size(centre, vec2(icon, icon)), Icon::Info, t.caution); + if full { + p.galley(pos2(br.left() + h * 0.55 + icon / 2.0 + 2.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); + } + let id = th.photo.id; + register(ui, th.surface.widget(Mark::Preview, id), br); + ui.interact(br, egui::Id::unique((th.surface, "preview-only-badge", id.0)), Sense::hover()) + .on_hover_text(crate::i18n::tr_format!("Preview only — {}", crate::widgets::preview_only_explanation(why))); +} + +#[cfg(test)] +mod tests { + use super::*; + + fn all_marks() -> Vec { + let mut out = Vec::new(); + for rating in 0..=5 { + for bits in 0..8u8 { + out.push(Marks { rating, flag: bits & 1 != 0, edited: bits & 2 != 0, label: bits & 4 != 0 }); + } + } + out + } + + #[test] + fn a_wide_tile_draws_every_mark() { + let m = Surface::Grid.metrics(); + let marks = Marks { rating: 5, flag: true, edited: true, label: true }; + let l = bar_layout(300.0, marks, &m); + assert_eq!(l, BarLayout { stars: Stars::Row(5), flag: true, edited: true, label: true }); + } + + /// As the photo narrows, the edited mark goes first, then the stars shrink to one star and the + /// number, and the rest is kept only as far as it fits whole. + #[test] + fn marks_degrade_in_order_as_the_tile_narrows() { + for surface in [Surface::Grid, Surface::Film] { + let m = surface.metrics(); + let marks = Marks { rating: 5, flag: true, edited: true, label: true }; + let full = bar_layout(1000.0, marks, &m); + let w_full = full.width(&m); + let no_edit = bar_layout(w_full - 0.5, marks, &m); + assert_eq!(no_edit, BarLayout { edited: false, ..full }, "{surface:?}: the edited mark goes first"); + let w_plain = no_edit.width(&m); + let compact = bar_layout(w_plain - 0.5, marks, &m); + assert_eq!(compact.stars, Stars::Compact(5), "{surface:?}: then the stars collapse"); + assert!(compact.flag && compact.label && !compact.edited, "{surface:?}: and nothing else is lost yet: {compact:?}"); + let w_compact = compact.width(&m); + let fewer = bar_layout(w_compact - 0.5, marks, &m); + assert!(fewer.width(&m) <= w_compact - 0.5, "{surface:?}: what is drawn fits"); + assert!(fewer.flag, "{surface:?}: the flag outlasts the label: {fewer:?}"); + assert!(!fewer.label, "{surface:?}: the label is the first to go: {fewer:?}"); + } + } + + /// Whatever is drawn is drawn whole: the row never needs more than the photo's width. + #[test] + fn the_marks_row_never_outgrows_the_photo() { + for surface in [Surface::Grid, Surface::Film] { + let m = surface.metrics(); + for marks in all_marks() { + for w in 0..400 { + let l = bar_layout(w as f32, marks, &m); + assert!(l.width(&m) <= w as f32, "{surface:?} {marks:?} at {w}: {l:?} needs {}", l.width(&m)); + if l.edited { + assert!(marks.edited && l == bar_layout(1000.0, marks, &m), "the edited mark only shows alongside all the others"); + } + } + } + } + } + + /// A portrait photo at the smallest thumbnail size with five stars and a flag: the case that + /// ran over the photo's edge. + #[test] + fn a_narrow_portrait_with_five_stars_and_a_flag_keeps_what_fits() { + let m = Surface::Grid.metrics(); + let marks = Marks { rating: 5, flag: true, edited: false, label: false }; + // justified rows 90 pt high: a 2:3 portrait is 60 wide + let l = bar_layout(60.0, marks, &m); + assert_eq!(l, BarLayout { stars: Stars::Compact(5), flag: true, edited: false, label: false }); + // a square cell 90 pt wide leaves a 70 × 56 area for the photo: 37 wide + let narrow = bar_layout(56.0 * 2.0 / 3.0, marks, &m); + assert!(narrow.width(&m) <= 56.0 * 2.0 / 3.0 && narrow.flag, "{narrow:?}"); + assert_ne!(narrow.stars, Stars::Row(5), "five whole stars (65 pt) cannot fit 37"); + } + + #[test] + fn one_star_stays_one_star() { + let m = Surface::Grid.metrics(); + let marks = Marks { rating: 1, flag: false, edited: false, label: false }; + assert_eq!(bar_layout(m.star_pitch + 2.0 * m.pad, marks, &m).stars, Stars::Row(1)); + } + + #[test] + fn the_copy_tag_gives_up_its_name_then_its_icon_before_it_meets_the_stack_badge() { + for surface in [Surface::Grid, Surface::Film] { + let m = surface.metrics(); + let (stack_w, name_w) = (44.0, 50.0); + let mut seen = Vec::new(); + for w in (0..300).step_by(1) { + let width = w as f32; + let mode = copy_tag_layout(width, Some(stack_w), name_w, &m); + let tag_w = match mode { + CopyTag::Full => name_w + m.copy_extra, + CopyTag::IconOnly => m.copy_icon, + CopyTag::Hidden => 0.0, + }; + if mode != CopyTag::Hidden { + // stack badge from the left inset, the tag to the right inset: they leave a gap + let (stack_right, tag_left) = (m.inset + stack_w, width - m.inset - tag_w); + assert!(stack_right < tag_left, "{surface:?} at {width}: {mode:?} meets the badge"); + assert!(tag_left >= m.inset, "{surface:?} at {width}: {mode:?} leaves the photo"); + } + if seen.last() != Some(&mode) { + seen.push(mode); + } + } + assert_eq!(seen, [CopyTag::Hidden, CopyTag::IconOnly, CopyTag::Full], "{surface:?}: as the tile widens"); + } + } + + #[test] + fn without_a_stack_badge_the_copy_tag_keeps_its_name_longer() { + let m = Surface::Grid.metrics(); + let width = 2.0 * m.inset + 50.0 + m.copy_extra + 1.0; + assert_eq!(copy_tag_layout(width, None, 50.0, &m), CopyTag::Full); + assert_eq!(copy_tag_layout(width, Some(30.0), 50.0, &m), CopyTag::IconOnly); + } + + #[test] + fn the_preview_pill_shrinks_to_its_icon_on_a_narrow_tile() { + let m = Surface::Grid.metrics(); + assert!(preview_pill_full(120.0, 40.0, &m)); + assert!(!preview_pill_full(60.0, 40.0, &m)); + } + + #[test] + fn the_placeholder_has_the_photo_s_shape() { + let area = Rect::from_min_size(pos2(10.0, 10.0), vec2(70.0, 56.0)); + let portrait = placeholder_rect(area, 2.0 / 3.0); + assert!( + (portrait.width() / portrait.height() - 2.0 / 3.0).abs() < 1e-4 && area.contains_rect(portrait) && portrait.center() == area.center() + ); + let wide = placeholder_rect(area, 3.0); + assert!((wide.width() - 70.0).abs() < 1e-4 && wide.height() < 56.0); + let unknown = placeholder_rect(area, f32::NAN); + assert!((unknown.width() / unknown.height() - 1.5).abs() < 1e-4); + } + + /// Italian says "valutazione: 1 su 5", "valutazione: 2 su 5"…: no English plural suffix to + /// pick, so no number reads wrong. + #[test] + fn a_spoken_rating_needs_no_plural_suffix() { + crate::i18n::set_language(crate::i18n::Locale::It); + let said: Vec = (1..=5).map(spoken_rating).collect(); + crate::i18n::set_language(crate::i18n::Locale::En); + assert!(said.iter().all(|s| !s.contains("star")), "{said:?}"); + assert_eq!(said[1], said[0].replacen('1', "2", 1), "only the number changes: {said:?}"); + assert_eq!(spoken_rating(1), ", rating 1 of 5"); + } + + #[test] + fn a_missing_original_points_at_locate_and_anything_else_at_reload() { + let missing = failure_text(true, "No such file"); + assert!(missing.contains("Original offline") && missing.contains("Locate Missing File") && missing.ends_with("No such file"), "{missing}"); + let broken = failure_text(false, "bad header"); + assert!(broken.contains("can't be opened") && broken.contains("Reload from Disk") && !broken.contains("Locate"), "{broken}"); + } +} diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 46aabad737..232d43ca10 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -102,10 +102,10 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-LIB-TARGET | Target album | P2 | ✅ | `cmd:album.setTarget`, `cmd:album.toggleTarget` | see LRC-LIB-COLLECTIONS | | LR-LIB-RATING | Star ratings | P0 | ✅ | `cmd:photo.rate` (`advance`), `cmd:photo.decreaseRating`, `cmd:photo.increaseRating`, `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/widgets/rating.rs` | one shared star row in the bottom bar, Info panel and filter bar (hover previews, ←/→ on a focused star) and one painter for badges (grid cells, filmstrip, Compare caption); menu rows with star text (Photo ▸ Set Rating, Select By Rating, the grid context menu) are separate menu items, unchanged; 0 clears; 1–5 set; Shift+0–5 applies and advances once, including with Auto Advance. A rating, flag or label that takes the active photo out of the view (filter bar, Picks, smart album) makes the photo after it active (the one before at the end), and Shift / Auto Advance doesn't step past it (#2312). Default grid brackets adjust each photo by one, clamped to 0–5; one batch undo and AutoWrite. Batch grid and undo/redo regressions; macOS native ownership corrected (PR #261) | | LR-LIB-FLAG | Pick / reject flags | P0 | ✅ | `cmd:photo.pick`, `cmd:photo.reject`, `cmd:photo.unflag`, `cmd:photo.flag` | P pick, X reject, U clear; Shift+P picks and advances in both grids (Presets elsewhere); Shift+X/U and legacy Shift+Z advance; no flag cycle; rejection does not delete the file; a pick shows as a filled flag on thumbnails, in Compare, in the loupe and on the Pick button, a reject outlined (#1013) | -| LR-LIB-LABEL | Colour labels | P1 | ✅ | `cmd:photo.label`, `cmd:photo.clearLabel`, `cmd:label.setNames`, `cmd:label.names`, `cmd:dialog.labelNames`, keys 6–9 in `crates/ui-egui/src/shortcuts.rs` | Photo menu and grid context menu (coloured, named), Info-panel swatches, label dot plus translucent colour on square-grid/filmstrip surrounds and photo-grid footers (photo pixels unchanged); colour-label toasts have pale matching backgrounds; setting/clearing through keys (including Shift), menus or Info swatches shows the same bottom toast as ratings, with the colour/custom name; editable label names (undoable, journaled); no purple key (as in Lightroom), Clear Color Label (`photo.clearLabel`) has no key until one is given in Help → Keyboard Shortcuts, no custom extra labels | +| LR-LIB-LABEL | Colour labels | P1 | ✅ | `cmd:photo.label`, `cmd:photo.clearLabel`, `cmd:label.setNames`, `cmd:label.names`, `cmd:dialog.labelNames`, keys 6–9 in `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/thumb.rs` | Photo menu and grid context menu (coloured, named), Info-panel swatches, the label is a dot in the marks row on every surface (justified grid, square grid, filmstrip) plus translucent colour on the square-grid and filmstrip surrounds; nothing is laid over the photo's pixels (the justified grid's tinted footer band is gone); colour-label toasts have pale matching backgrounds; setting/clearing through keys (including Shift), menus or Info swatches shows the same bottom toast as ratings, with the colour/custom name; editable label names (undoable, journaled); no purple key (as in Lightroom), Clear Color Label (`photo.clearLabel`) has no key until one is given in Help → Keyboard Shortcuts, no custom extra labels | | LR-LIB-KEYWORD | Keywords | P0 | ✅ | `cmd:panel.keywords`, `cmd:photo.setMeta` (`addKeywords`/`removeKeywords`), `cmd:keyword.list`, `cmd:keyword.rename`, `cmd:keyword.delete`, `cmd:keyword.merge`, `cmd:keyword.suggest`, `crates/catalog/src/keywords.rs`, `crates/ui-egui/src/panels/left.rs` | left-panel keyword tree with counts (click filters, children included; context menu rename / merge / delete / add / remove); library-wide ops are one undo step and replay from the op log; suggestions (co-occurring / most used / completions) in the Keywords panel; keywords reorganize by drag and drop in the Keyword List (LRC-LIB-KEYWORDS) | | LR-LIB-PEOPLE | People / faces | P2 | 🟡 | `cmd:faces.detect`, `cmd:view.people`, `cmd:view.faceBoxes`, `cmd:photo.removeRegion`, `cmd:photo.setRegion`, `cmd:library.filter`, `crates/ui-egui/src/panels/people.rs`, `crates/catalog/src/query.rs` (`people`), `crates/engine/src/media.rs` (`face_job`), `crates/meta/src/xmp.rs` | MVP: named face regions read from XMP (MWG-RS, read-only, see `docs/xmp-interop.md`; clipped to the photo; Lightroom's `Rotation` of ±π/2 and π handled, mirrored orientations taken as written; boxes follow Rotate Left/Right and flips; a sidecar stating `mwg-rs:Regions`, even empty, replaces the photo's on re-read, one without leaves them) become cards in the People view (View ▸ People, or the People button in the toolbar): a close-up of the person's largest face, name and photo count; a click filters the grid (`person` in `library.filter`, `person:` search token, filter chip). Face boxes in the loupe can be switched off (View ▸ Face Boxes, toolbar) resized with eight drag handles and removed with the × shown on hover (catalog-only and undoable, one undo step per drag; the sidecar is never rewritten for either); no moving a box by dragging it yet. Photo ▸ Detect Faces (`cmd:faces.detect`) finds faces with the YuNet detector (pure Rust, about 200 ms a photo, matches OpenCV's own YuNet on a 45-photo test set; the 232 KB model is a one-time download offered in the same step, never part of LightCraft) and adds them as unnamed boxes; names are suggested from the faces already named (recognition models are opt-in downloads, run on the CPU in a background thread; a face is named only when you confirm it); a person's page shows their cropped faces and the unnamed faces that look like them (LRC-LIB-PEOPLE), with a user-triggered ↑ action or targeted A key to name all shown suggestions at or above one score in one undo step; with recognition on, a background scan finds faces in photos that have none and embeds every face (one to three worker threads, raws through their embedded preview); an Unnamed faces section orders faces by likeness and names a selected group at once; no separated clusters, no manual tagging, no writing regions back | -| LR-LIB-STACK | Stacks | P1 | ✅ | `cmd:stack.group`, `cmd:stack.ungroup`, `cmd:stack.toggle`, `cmd:stack.setTop`, `cmd:stack.remove`, `cmd:stack.auto`, `cmd:photo.delete`, `crates/catalog/src/stacks.rs` | grid/filmstrip count badges (a click expands / collapses the stack, selected or not), expand/collapse (a click or double-click on a grid badge toggles the stack once, #2233), auto-stack by capture time; delete / remove folder drop the photo from the stack so `i/n` updates (#1493); no visual-similarity auto-stack | +| LR-LIB-STACK | Stacks | P1 | ✅ | `cmd:stack.group`, `cmd:stack.ungroup`, `cmd:stack.toggle`, `cmd:stack.setTop`, `cmd:stack.remove`, `cmd:stack.auto`, `cmd:photo.delete`, `crates/catalog/src/stacks.rs`, `crates/ui-egui/src/thumb.rs` | grid/filmstrip count badges (the same badge on both, a click expands or collapses the stack, selected or not, one translated tooltip; widgets `stack:`, `film:stack:`), expand/collapse (a click or double-click on a grid badge toggles the stack once, #2233), auto-stack by capture time; delete / remove folder drop the photo from the stack so `i/n` updates (#1493); no visual-similarity auto-stack | | LR-LIB-VERSIONS | Versions | P1 | ✅ | `cmd:version.create` | see section M | | LR-LIB-DELETE | Delete / Recently Deleted | P0 | ✅ | `cmd:photo.delete`, `cmd:photo.restore`, `cmd:photo.deletePermanently` | Delete and Delete Permanently retain surviving selected photos; if none remain, select the next visible survivor (previous at the end) in the current source/filter/sort; permanent deletion removes catalog records, not files on disk; Restore and Delete Permanently in the Photo menu and the photo context menus for photos in Recently Deleted (before, the UI had no way to restore); importing a file that is in Recently Deleted again restores the photo with its edits, rating and albums (issues #298, #706: before, the import skipped it as "already in the library" while the grid showed it deleted) — the review dialog checks it, badges it "Will be restored", counts it as "in Recently Deleted" rather than "already in the library", and its choice Restore them / Import as new / Leave them starts on Restore; with Leave them such a file starts unchecked and Check All and the file-type toggles leave it out, but a click still checks it and it is restored (issue #1285: before, the click did nothing and the "In Recently Deleted" badge was drawn over the checkbox, which now sits above it); dropped files restore too ("Restored 1 photo from Recently Deleted"); a deleted photo matched by content whose file is gone is relinked to the imported file; Photo ▸ Empty Recently Deleted (`cmd:library.emptyRecentlyDeleted`, one undo step, shown while the trash is the source); import takes `onDeleted` restore (default) / skip / fresh for files in the trash (`cmd:library.import`; the report lists `restored`, and with skip flags the duplicate `existingDeleted`); browsing a folder in Local (`cmd:library.browse`), Auto Import and a Lightroom catalog import never restore a deleted photo; no confirmation dialog, no auto-purge after N days (needs a deleted-at date in the catalog); Delete asks first ("Move this photo to Recently Deleted?") from the key, the Photo menu and the photo context menu, on by default and switched off in Settings ▸ General (#1239: before, it was off by default and the context menu never asked); no auto-purge after N days (needs a deleted-at date in the catalog) | | LR-LIB-REMOVE-ALBUM | Remove from album | P0 | ✅ | `cmd:album.removePhotos`, `crates/engine/src/tests/album_remove.rs`, `crates/ui-egui/src/tests/album_remove.rs` | changes the album only: the photos stay in the library, their library folder and their folder on disk (issue #1805); `id` defaults to the album on screen; returns `{removed, album}`. In a normal album ⌫ removes from the album (as in Lightroom; no confirmation, one undo step), in a smart album it changes nothing and says to edit its rules | @@ -117,7 +117,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-LIB-CULL | Assisted culling | P2 | 🟡 | `cmd:photo.analyze`, `cmd:dialog.cull`, `crates/pipeline/src/cull.rs` | Photo ▸ Assisted Culling…: focus score (0–100), clipping, burst grouping (look-alike shots within 10 s, both limits adjustable in the dialog and as `burstGap` / `similarity`, #2275) with the sharpest marked; reject below a focus score, pick each burst's best; classical measures — no eyes-closed / expression detection | | LR-LIB-ACTIVITY | Comments & likes | OOS | 🚫 | | | | LR-LIB-QUICKCOLL | Quick collection [Classic] | P2 | ✅ | `cmd:album.toggleTarget`, `cmd:album.clearQuick` | B in the grids | -| LR-LIB-VIRTUALCOPY | Virtual copies [Classic] | P1 | ✅ | `cmd:photo.virtualCopy`, `cmd:photo.delete`, `crates/engine/src/cmd/organize.rs` | “Copy N” badge, stacked with the original, same albums, no XMP writes; default numbers are checked across the batch before copies are created, while explicit names bypass the counter; deleting a copy dissolves or renumbers the stack (#1493); no “Set Copy as Master” | +| LR-LIB-VIRTUALCOPY | Virtual copies [Classic] | P1 | ✅ | `cmd:photo.virtualCopy`, `cmd:photo.delete`, `crates/engine/src/cmd/organize.rs`, `crates/ui-egui/src/thumb.rs` | “Copy N” tag on the grid and on the filmstrip (widgets `copy:`, `film:copy:`; on a narrow thumbnail it drops its name and then hides rather than meet the stack badge), stacked with the original, same albums, no XMP writes; default numbers are checked across the batch before copies are created, while explicit names bypass the counter; deleting a copy dissolves or renumbers the stack (#1493); no “Set Copy as Master” | ## C. Views & navigation (VIEW) @@ -128,7 +128,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-VIEW-DETAIL | Single-photo view | P0 | ✅ | `cmd:view.detail`, `crates/ui-egui/src/panels/detail.rs` | a “Rendering…” pill at the bottom of the photo (widget `loupe:rendering`; above the Navigator when that is in the way) once a render has been on its way for 0.5 s with nothing new on screen: over a stand-in (the raw's embedded JPEG, a thumbnail), the previous render after an edit, or, zoomed in, the magnified frame waiting for its window; Before views watch their own renders. Always on (Lightroom Classic makes it a View Options choice). When the render fails behind a stand-in, a caution pill says “This photo can't be opened” (“Original offline · no smart preview” when that is why) with the reason on hover and for screen readers (widget `loupe:renderFailed`; `ui.inspect` → `loupe.failed`) | | LR-VIEW-EDIT | Edit view | P0 | ✅ | `cmd:panel.edit` | | | LR-VIEW-FULLSCREEN | Full-screen preview | P1 | ✅ | `cmd:view.fullScreenPreview`, `cmd:view.enterFullScreen` | photo on black, arrows step, Esc exits; ⇧⌘F window full screen | -| LR-VIEW-FILMSTRIP | Filmstrip | P0 | ✅ | `cmd:view.filmstrip`, `crates/ui-egui/src/panels/detail.rs` | the photo context menu on right-click; the mouse wheel scrolls it sideways, a third of its width per notch as in Lightroom Classic (trackpads scroll the points they report); it follows the active photo only when that changes (centred if off screen), so a scrolled strip stays put; every selected photo has the selected background; selected photos with a loaded thumbnail also show a ring, the active one in the heavier two-tone ring and the others in the lighter one, in the theme's colours, as in the grid (a selected cell with no thumbnail, still loading or failed, has the background and no ring); a drag from a cell carries the selection (a photo outside it drags alone and replaces it; in Compare it drags alone and leaves the selection, the active photo and the pair as they are) to the same sidebar rows as a drag from the grid, and a click without movement works as before (it selects the photo; in Compare it goes to the active side, see LR-VIEW-COMPARE) | +| LR-VIEW-FILMSTRIP | Filmstrip | P0 | ✅ | `cmd:view.filmstrip`, `crates/ui-egui/src/panels/detail.rs`, `crates/ui-egui/src/thumb.rs` | its thumbnails wear the overlay of the grid's (one painter, `thumb.rs`): the virtual-copy tag, a clickable stack badge with the grid's tooltip, the label dot, the grid's placeholder until the picture is drawn, and a failure mark that says why on hover (`film:failed:`); on a narrow thumbnail the marks degrade (edited mark, then the stars as ★ and the number, then what does not fit) instead of running over the photo's edge; the photo context menu on right-click; the mouse wheel scrolls it sideways, a third of its width per notch as in Lightroom Classic (trackpads scroll the points they report); it follows the active photo only when that changes (centred if off screen), so a scrolled strip stays put; every selected photo has the selected background; selected photos with a loaded thumbnail also show a ring, the active one in the heavier two-tone ring and the others in the lighter one, in the theme's colours, as in the grid (a selected cell with no thumbnail, still loading or failed, has the background and no ring); a drag from a cell carries the selection (a photo outside it drags alone and replaces it; in Compare it drags alone and leaves the selection, the active photo and the pair as they are) to the same sidebar rows as a drag from the grid, and a click without movement works as before (it selects the photo; in Compare it goes to the active side, see LR-VIEW-COMPARE) | | LR-VIEW-ZOOM | Zoom & pan | P0 | ✅ | `cmd:view.zoomFit`, `cmd:view.zoom100`, `cmd:view.zoomIn`, `cmd:view.zoomOut`, `cmd:view.zoomToggle`, `cmd:view.clickZoom`, `cmd:view.navigate`, `crates/ui-egui/src/panels/detail.rs`, `crates/ui-egui/src/headless.rs` | continuous native pinch / modifier-wheel zoom (Fit–800%, anchored under the pointer), two-finger scroll / touch pan with edge limits; in Detail a middle-button drag (the wheel pressed) pans with a hand cursor whatever tool is active, so Remove / Heal / Clone, mask brushes and Crop don't paint or move meanwhile (`middle_pan`, `tests_canvas_pan.rs`); in Detail a middle-button drag (the wheel pressed) pans with a hand cursor whatever tool is active, so Remove / Heal / Clone, mask brushes and Crop don't paint or move meanwhile (`middle_pan`, `tests_canvas_pan.rs`); Detail (including tools, Before/After and full-screen preview), Compare and Reference; fractional percentages preserve small gestures; image, picker and targeted-adjustment cursors stay steady between gesture events; keyboard steps 25–800 % (not 6–1600 %); Fill in the bottom bar; click / Z / Space eases to the chosen ratio (1:1 default, 2:1, 3:1, 4:1, 8:1). The loupe's cost follows the canvas, not the zoom (issue #323): the whole frame is rendered at about canvas size (at most the 2560 px preview source level unless a larger Preview size is chosen, and never above the GPU's texture side), and once the view is zoomed well past that (more than 25 %) the window on screen is rendered too, cut from a frame of at most the photo's own pixels, so beyond 100 % the GPU magnifies it (`region::plan`, `RenderRequest::window`, `Session::region_job`, `crates/ui-egui/src/region.rs`); 1:1 and 2:1–8:1 are sharp at any photo size. A slider tick takes 7–12 ms on a 1400 × 900 canvas and 11–25 ms on a 2800 × 1700 one at 100 % and 400 % of a 24 MP photo (M1 Max, GPU, `profile_slider_drag`); about 20–25 ms at 100 % on the big canvas is over a 16 ms frame. A slider drag renders the whole frame at full size where the GPU draws the view, so the fit view stays sharp while dragging, and at 0.6 of it where that would be too slow: on the CPU, with an output-device profile proof or the HDR range shown, or for a control whose full-size drafts on this photo went clearly over the 16 ms slider budget (more than 20 ms) in two drags in a row (a LUT profile or refined mask the CPU renders, a photo past a GPU limit, a slow GPU); a draft's time is its render plus the frame that uploads and shows it, and a host frame time over 1 s (a hidden or stalled window) counts as unknown. A slow verdict is per photo and control (the same control on another photo, or another control on this one, is timed afresh) and expires: after 30 s a drag tries full size again, the wait doubling after each slow retry up to 240 s. Only a drag timed at full size changes it: one whose full-size drafts' median time (leaving out the first) is at most 20 ms forgets it; a drag that drafts small from its start (while the verdict holds, or where the GPU does not draw the view) or times fewer than two full-size drafts leaves it unchanged. At most 256 (photo, control) pairs are remembered, the oldest forgotten first. The size is chosen when a drag starts and kept until it ends, unless its full-size drafts take more than twice the budget, when it drops to 0.6 after three of them (`region::DragScale`, issue #330). Zoomed in, the whole-frame draft under the window is the 0.6 one (only the histogram and the window's stand-in use it). Render workers convert the pixels for their textures, not the UI thread. Handing GPU renders to egui without a CPU readback is #1228. A continuous pinch holds the render sizes (and the windows there are) and the size the fit view is shrunk to until it is quiet. A fit view on a canvas up to about 3200 px (a Retina Mac) never decodes the original; larger displays get a window at fit, which does. Diagnostic overlays (Visualize Spots, Point Color range, HDR range) get windows too, tested equal to the whole-frame render's pixels. Photos whose spots or Auto Mask strokes read too far for one window (only photos longer than 8192 px) render the whole frame at the size it is drawn, as before windows; while a preset or profile is hovered, or over a picture that is not the frame (an unsupported raw's embedded JPEG), the whole frame stays canvas-sized. Before/After (side by side, stacked, `\\` and both wipes) gets the same windows on both sides, clipped to their pane or side of the line. Windows render on the GPU like whole frames (equivalence-tested against the CPU), in the browser build too (windows no wider than its GPU's texture side, at most 3072 px), and are not made while hovering a look, nor over a picture that is not the frame (an unsupported raw's embedded JPEG with another crop). No texture is larger than the GPU allows. Spots and Auto Mask brushes work while what a window reads fits one render (8192 px along an axis, 4096 in the browser): the window grows to hold the spot and its source patch, or the dabs near it, and if that would take more (a clone from far away at 8:1) the loupe keeps the whole-frame render instead, and spots with an automatic source pick it from a fixed-size render of the whole frame (so a window's choice can differ from a whole-frame render's, which picks at its own resolution). The wide stages (dehaze, clarity, highlights/shadows base) and Refine Edges on masks read a window margin capped at 768 px; measured on hard-edged blocks that costs at most a few levels at 8:1. the histogram and Navigator come from the whole-frame render. Compare and Reference get the same windows, one per pane (`Slot::CompareRegion`, `panels/compare.rs`), over each pane's whole-frame render (at most 2560 px); while either view is open two originals stay decoded (`MediaCache::set_full_capacity`), so one pane's window does not evict the other's source; a pinch, or a slider drag on the active photo in Reference, keeps the windows there are until it ends. Mask overlays and soft proofing get the same windows (the window carries the overlay or the proof; only an output-device-profile proof renders on the CPU, where a tick at 100 % on a 1400 × 900 canvas takes about 36 ms instead of a full-size 24 MP proof). Verified: a 1:1 window of a 24 MP photo with tone and colour edits is the full-size export to within one level (`one_to_one_window_pixels_are_export_pixels`). Measured on Linux (Ryzen AI Max+ 395, Radeon 8060S, GPU, `profile_slider_drag`): median tick→shown 7 ms at fit, 33 ms at 100 % and 6 ms at 400 % on 1400 × 900; 21 ms at 100 % and 9 ms at 400 % on 2800 × 1700; 36 ms at 100 % with an output-device-profile soft proof (the CPU path) | | LR-VIEW-FOCUSPOINT | Camera focus point overlay and zoom (beyond Lightroom) | P2 | 🟡 | `cmd:view.focusPoint`, `cmd:view.zoomToFocus`, `cmd:view.zoomToggle`, `cmd:photo.reload`, `cmd:photo.readFocusPoints`, `cmd:focus.pump`, `crates/meta/src/focus.rs`, `crates/meta/src/focus_read.rs`, `crates/engine/src/focus_scan.rs`, `crates/engine/src/tests/focus_scan.rs`, `crates/ui-egui/src/panels/detail.rs` (`focus_box`, `draw_focus_point`), `crates/ui-egui/src/panels/compare.rs`, `crates/ui-egui/src/tests/focus_point.rs`, `docs/focus-points.md` | an extra (Lightroom shows no focus points): the AF frame read from the file at import; photos imported earlier get it in the background from a header-only read of each file (about 32 KB, ~100 photos/s from a spinning disk; activity row, cancellable, resumable; Photo ▸ Read Focus Points) as a box on the upright photo, drawn in Detail, Compare and Survey through rotation and crop (View ▸ Focus Point, ⌥F); Toggle Zoom centres on it (View ▸ Zoom to Focus Point, on by default); Info panel row `AF-C · Wide · Animal Eye Tracking`; `meta.focus` in `photo.inspect`. Partial: Sony ILCE-1 and ILCE-7SM3 only (layout checked against 333 files); other Sony bodies and other makers not yet; manual focus and centre-only Wide reports show nothing; Compare panes share one pan, so Z centres on the active photo's point only | | LR-VIEW-NAVIGATOR | Navigator mini map | P1 | ✅ | `cmd:view.navigator`, `crates/ui-egui/src/panels/detail.rs` | shown while zoomed (bottom right); click/drag pans | @@ -717,7 +717,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06- | LRC-LIB-PEOPLE | People view | P2 | 🟡 | `cmd:view.people`, `cmd:view.person`, `cmd:faces.person`, `cmd:faces.unnamed`, `cmd:faces.nameFaces`, `crates/ui-egui/src/panels/people.rs`, `crates/ui-egui/src/panels/person.rs`, `crates/ui-egui/src/panels/unnamed.rs`, `crates/engine/src/face_tiles.rs` | Named People cards (face close-up, the photo count on the picture, name) for the photos the active filters let through, with the filter chips shown above them, sized by the thumbnail slider. Below them the **Unnamed faces**: every face nobody has named as a cropped picture, look-alikes next to each other once recognition has looked at them, a suggested name on a face the named ones recognise; click or Shift-click to select, type a name, Enter names the whole group in one undo step. A click on a person opens their page: only cropped faces, then **More** (unnamed faces that look like them, best first; click to confirm one, × to hide for the session, or ↑ / hovered-or-focused A key to confirm all currently shown non-hidden suggestions at or above that face's score, including ties, in one undo step). Every face is shown by the detector's box where the scan has one, so faces are equally close. Until recognition is set up a line at the top offers the next step (Settings ▸ Faces, or Turn on), as does the loupe's name box. Face pictures of unedited raws are cut from the largest embedded preview (planned read: header and JPEG only, never the sensor data) when it holds at least ¾ of the tile's pixels across the face, else developed as before; all are kept in the thumbnail disk cache at 16 px size steps, so a later launch shows them without reading the originals (#1440, `docs/faces.md`). No clusters with separators between groups, no persistent reject, no merge of two people | LRC-LIB-COMMENTS | Comments panel | P2 | ⬜ | | | | LRC-LIB-VISUALSEARCH | Find similar photos | P2 | ✅ | `cmd:library.findSimilar`, `crates/pipeline/src/cull.rs` (`signature`) | photo menu / Photo ▸ Find Similar Photos: look-alike photos (composition and tones), most similar first, as a filter (`only`) | -| LRC-LIB-MISSING | Missing files & relink | P1 | ✅ | `cmd:library.missing`, `cmd:photo.relink`, `cmd:library.findMissing`, `cmd:file.findMissing`, `cmd:photo.locate`, `crates/engine/src/cmd/missing.rs` (`checked_path`), `crates/ui-egui/src/missing_sweep.rs`, `crates/ui-egui/src/panels/left.rs` (`locate_missing_item`) | File → Find Missing Photos… (anywhere in a folder: same name, size and content hash; renamed files by size + content hash; same name and size alone only when unambiguous — look-alikes are skipped and reported; searched on a worker thread, one undo step), photo menu → Locate Missing File…; a folder or disk row's Locate Missing Files… chooses its new location and scopes the same recursive background finder to that folder and its subfolders. Unreadable files show "!" in the grid and a reason in the loupe; undo never moves files. Missing Photos in the sidebar (counted on a worker thread; the view, the Info panel, the grid's context menu and thumbnails read file availability from a cache a worker thread fills, so an offline NAS never stalls a frame); it covers library photos only — Local browse records are never checked, for the count, the view, `library.missing` and Find Missing alike; `library.missing` from the control channel or `mcp --connect` checks the files on a worker thread (a "Missing Photos" row in the activity stack, ✕ stops it) and answers when it ends, so a large library on a network share never stalls the window; the same request meanwhile shares the running check | +| LRC-LIB-MISSING | Missing files & relink | P1 | ✅ | `cmd:library.missing`, `cmd:photo.relink`, `cmd:library.findMissing`, `cmd:file.findMissing`, `cmd:photo.locate`, `crates/engine/src/cmd/missing.rs` (`checked_path`), `crates/ui-egui/src/missing_sweep.rs`, `crates/ui-egui/src/panels/left.rs` (`locate_missing_item`), `crates/ui-egui/src/thumb.rs` | File → Find Missing Photos… (anywhere in a folder: same name, size and content hash; renamed files by size + content hash; same name and size alone only when unambiguous — look-alikes are skipped and reported; searched on a worker thread, one undo step), photo menu → Locate Missing File…; a folder or disk row's Locate Missing Files… chooses its new location and scopes the same recursive background finder to that folder and its subfolders. Unreadable files show a warning icon in the grid and the filmstrip (widgets `badge:failed:`, `film:failed:`) whose tooltip says why and where to go (Locate Missing File… for a missing original, else Reload from Disk), and a reason in the loupe; undo never moves files. Missing Photos in the sidebar (counted on a worker thread; the view, the Info panel, the grid's context menu and thumbnails read file availability from a cache a worker thread fills, so an offline NAS never stalls a frame); it covers library photos only — Local browse records are never checked, for the count, the view, `library.missing` and Find Missing alike; `library.missing` from the control channel or `mcp --connect` checks the files on a worker thread (a "Missing Photos" row in the activity stack, ✕ stops it) and answers when it ends, so a large library on a network share never stalls the window; the same request meanwhile shares the running check | | LRC-LIB-CONVERT | Convert to DNG | P2 | ✅ | `cmd:photo.convertToDng`, `crates/engine/src/cmd/convert.rs` | Photo ▸ Convert to DNG: lossless DNG next to the raw with the settings embedded, photo (and its virtual copies) relinked; originals kept; undoable; the DNG is decoded and compared with the raw data, written to a temp file, synced, read back and only then given a free name (never replacing a file) — a failed write leaves no DNG and the photo on its raw (issue #106) | | LRC-LIB-PREVIEWS | Build / discard previews | P1 | ✅ | `cmd:library.buildPreviews`, `cmd:library.previewProgress`, `cmd:library.cancelPreviews`, `cmd:library.clearPreviews`, `crates/engine/src/cmd/previews.rs`, `crates/preview/src/lib.rs` | File ▸ Previews: build standard-sized (Settings → Performance size) or 1:1 previews of the selected / visible photos in the background (a row in the activity stack, ✕ to stop), discard the cache; disk thumbnail + view cache; no smart previews (offline proxies) | | LRC-LIB-SLIDESHOW-IMPROMPTU | Impromptu slideshow | P2 | ✅ | `cmd:view.slideshow` | see LR-VIEW-SLIDESHOW | @@ -1026,3 +1026,4 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | 2026-10-29 | patch | LR-BEHAV-TITLEBAR: a dialog's backdrop leaves the integrated title bar undimmed, as a macOS sheet does (the bar's controls stay inactive, a click on it is not a click outside the dialog, dragging its empty space still moves the window); status unchanged (🟡) | | 2026-10-29 | minor | LR-MASK-OBJECTS: an Object / Describe selection's stored grid is enlarged along the photo's edges (fast guided filter of its logits by log luminance, a 1.5-cell window), so a raised Exposure no longer draws an outline around the subject (#3272); existing AI masks are 1–2 px tighter at edges; status unchanged (🟡) | | 2026-10-30 | patch | LR-MASK-COLORRANGE: a colour-range mask keeps its first 64 samples however it is loaded (sidecar `lc:settings`, presets, `develop.merge`, `render --settings`, catalog and history), not only through `mask.add` / `mask.update`, so a document with thousands can't stall a render or lose the GPU device (issue #2556); status unchanged (✅) | +| 2026-10-17 | minor | LR-VIEW-FILMSTRIP, LR-LIB-VIRTUALCOPY, LR-LIB-STACK, LR-LIB-LABEL, LRC-LIB-MISSING: one thumbnail overlay for the justified grid, the square grid and the filmstrip (`thumb.rs`): the filmstrip gains the copy tag, a clickable stack badge, the placeholder, the failure mark and the label dot; the failure mark explains itself on hover; the justified grid's tinted label footer is gone; marks degrade on narrow thumbnails; the rating is read out without an English plural; statuses unchanged (✅) | diff --git a/docs/whats-new.md b/docs/whats-new.md index 98a0ac7157..ef2c1e398d 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -627,6 +627,18 @@ in Recently Deleted apart, since they are restored and their files stay where they are: "Move 2 Photos · Restore 1 Photo". +### The same marks on every thumbnail +- The filmstrip's thumbnails now carry what the grid's do: a virtual copy has its "Copy N" tag, so a copy and its + master tell apart; the stack badge can be clicked to expand or collapse the stack, with the same tooltip (now + translated); the colour label is a dot, and a grey placeholder stands in until the picture is drawn. +- A thumbnail that can't be drawn shows a warning icon instead of a bare "!". Hover it to read why, and where to go: + right-click ▸ Locate Missing File… when the original is gone, Reload from Disk otherwise. +- In the Photo Grid a colour label is no longer a tinted band over the bottom of the picture; it is the dot in the + row of marks, as in the Square Grid and the filmstrip. +- On a narrow thumbnail (a portrait photo at the smallest size) the marks no longer run over the photo's edge: the + copy tag drops its name, the edited mark goes, five stars become one star and the number, and what still doesn't fit is left out. + The Preview pill sits above the marks on the filmstrip too. +- Screen readers say "rating 3 of 5" in every language, instead of building "stars" from an English plural. ### Sharper resampling in HDR and panorama merges - Merged photos (HDR and panorama) are resampled with a sharper filter (Lanczos-3 instead of bilinear). Moving a From 09caa395668f96d21ce2b018acd1374e0cff829d Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 17 Oct 2026 09:46:30 -0400 Subject: [PATCH 02/15] LR-VIEW-FILMSTRIP: thumbnail overlay review fixes: label kept on narrow justified tiles, nothing painted outside the photo Fixes found reviewing the shared thumbnail overlay. - the justified grid has no tinted surround, so its label dot now outlasts the stars and flag on a narrow photo, and stays when Ratings & flags is Never (`Thumb::surround`, `bar_layout`'s `label_first`) - the preview pill is placed clear of the stack badge, the copy tag and the marks row (below the badge, or beside it as the icon alone, or hidden): `preview_pill_place` - the stack badge sheds its icon, then the `i/`, on a narrow photo (`stack_layout`); the whole overlay is painted clipped to the photo's rectangle - right-clicking the stack badge opens the photo's context menu in the grid and the filmstrip (`overlay` returns the badge's response) - removed the dead binding in `overlay`; fixed the label test's message - docs: rejected photos are dimmed on the filmstrip and under the marks in the grid; the label, flag and filmstrip rows and whats-new say what is true - tests: thumb.rs (label first, pill placement, stack badge degrade), tests_thumb.rs (label with ratings off, right-click on the filmstrip badge) Co-Authored-By: Claude --- crates/ui-egui/src/panels/detail/filmstrip.rs | 7 +- crates/ui-egui/src/panels/grid.rs | 18 +- crates/ui-egui/src/tests/labels.rs | 2 +- crates/ui-egui/src/tests/thumb.rs | 26 ++ crates/ui-egui/src/thumb.rs | 289 ++++++++++++++---- docs/parity-checklist.md | 4 +- docs/whats-new.md | 8 +- 7 files changed, 280 insertions(+), 74 deletions(-) diff --git a/crates/ui-egui/src/panels/detail/filmstrip.rs b/crates/ui-egui/src/panels/detail/filmstrip.rs index 36506dc2da..a599acf823 100644 --- a/crates/ui-egui/src/panels/detail/filmstrip.rs +++ b/crates/ui-egui/src/panels/detail/filmstrip.rs @@ -120,6 +120,7 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) { } let img_area = Rect::from_min_max(cr.min + vec2(10.0, 22.0), cr.max - vec2(10.0, 8.0)); crate::panels::grid::request_thumb(app, *id, (256.0 * ppp.min(2.0) / 2.0) as usize * 2, 8); + let mut badge = None; if let Some(photo) = app.session.catalog.photo(*id).cloned() { let (photo_rect, failure) = if let Some(tex) = app.renderer.thumb(*id) { let [tw, th] = tex.size; @@ -144,8 +145,9 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) { marks: app.ui.settings.film_badges, hot: false, failure, + surround: true, }; - crate::thumb::overlay(app, ui, &overlay); + badge = crate::thumb::overlay(app, ui, &overlay); } if resp.clicked() { let m = ui.input(|i| i.modifiers); @@ -182,6 +184,9 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) { } // the same photo actions as the grid and loupe (Restore / Delete Permanently in Recently Deleted) crate::widgets::context_menu(&resp, |ui| crate::panels::grid::context_menu(app, ui, *id)); + if let Some(badge) = badge { + crate::widgets::context_menu(&badge, |ui| crate::panels::grid::context_menu(app, ui, *id)); + } } }); } diff --git a/crates/ui-egui/src/panels/grid.rs b/crates/ui-egui/src/panels/grid.rs index 8a46174315..09fe9c185b 100644 --- a/crates/ui-egui/src/panels/grid.rs +++ b/crates/ui-egui/src/panels/grid.rs @@ -825,9 +825,10 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, view: marks: show_badges, hot: resp.hovered() || selected, failure, + surround: square, }; - crate::thumb::overlay(app, ui, &overlay); - cell_interaction(app, ui, &resp, id, &photo); + let badge = crate::thumb::overlay(app, ui, &overlay); + cell_interaction(app, ui, &resp, id, &photo, badge); } pub(crate) fn cell_description(app: &LightcraftApp, photo: &lightcraft_catalog::Photo) -> String { @@ -904,7 +905,14 @@ fn paint_cell_caption(app: &LightcraftApp, p: &egui::Painter, t: &Tokens, photo: } } -fn cell_interaction(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Response, id: PhotoId, photo: &lightcraft_catalog::Photo) { +fn cell_interaction( + app: &mut LightcraftApp, + ui: &mut egui::Ui, + resp: &egui::Response, + id: PhotoId, + photo: &lightcraft_catalog::Photo, + badge: Option, +) { if let Some(k) = app.ui.keyword_painter.clone() { // painting: a click toggles the keyword on this photo if resp.hovered() { @@ -937,6 +945,10 @@ fn cell_interaction(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Res begin_photo_drag(app, id); } crate::widgets::context_menu(resp, |ui| context_menu(app, ui, id)); + // (the stack badge covers part of the cell: it opens the same menu) + if let Some(badge) = badge { + crate::widgets::context_menu(&badge, |ui| context_menu(app, ui, id)); + } } struct ThumbFlags { diff --git a/crates/ui-egui/src/tests/labels.rs b/crates/ui-egui/src/tests/labels.rs index 5a49635f85..4ae1977b4a 100644 --- a/crates/ui-egui/src/tests/labels.rs +++ b/crates/ui-egui/src/tests/labels.rs @@ -70,7 +70,7 @@ fn label_tints_grid_and_filmstrip_chrome_without_changing_photo_pixels() { h.step(); let image = h.paint(); let c = pixel(&image, sample); - assert_ne!(c, pixel(&neutral, sample), "{view:?} {label} must tint the thumbnail surround/footer"); + assert_ne!(c, pixel(&neutral, sample), "{view:?} {label} must tint the thumbnail surround/label dot"); assert!(!colours.contains(&c), "each label has a distinct tint: {view:?} {label}"); colours.push(c); assert_eq!(pixel(&image, cell.center()), centre, "{view:?} {label} must not tint image pixels"); diff --git a/crates/ui-egui/src/tests/thumb.rs b/crates/ui-egui/src/tests/thumb.rs index c4847365e0..de49c50e19 100644 --- a/crates/ui-egui/src/tests/thumb.rs +++ b/crates/ui-egui/src/tests/thumb.rs @@ -162,3 +162,29 @@ fn a_label_is_the_dot_in_the_marks_row_on_every_surface_and_no_footer_covers_the assert!(!footer_band_in(&h, r), "{view:?}: no tinted footer over the photo"); } } + +#[test] +fn with_ratings_and_flags_off_the_justified_grid_still_shows_the_label() { + let mut h = demo(); + let ids = first_photos(&mut h, 2); + run(&mut h, "photo.label", json!({"ids": [ids[0].0], "label": "red"})); + run(&mut h, "library.select", json!({"ids": [ids[1].0]})); + h.app.ui.settings.grid_badges = crate::state::GridBadges::Never; + h.settle(SETTLE); + let cell = widget(&h, &format!("thumb:{}", ids[0].0)).expect("the photo's cell"); + assert!(label_dot_in(&h, cell), "the label is not a rating or a flag: it stays, the grid has no surround to tint"); +} + +#[test] +fn right_clicking_the_filmstrips_stack_badge_opens_the_photo_menu() { + let mut h = demo(); + let ids = first_photos(&mut h, 2); + run(&mut h, "stack.group", json!({"ids": [ids[0].0, ids[1].0], "collapsed": false})); + h.request("ui.set", json!({"view": "detail"}), T); + h.settle(SETTLE); + assert!(!egui::Popup::is_any_open(&h.view.ctx)); + let r = h.request("ui.clickWidget", json!({"id": format!("film:stack:{}", ids[0].0), "button": "right"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + assert!(egui::Popup::is_any_open(&h.view.ctx), "the photo's menu, as on the rest of the cell"); +} diff --git a/crates/ui-egui/src/thumb.rs b/crates/ui-egui/src/thumb.rs index baadbd62ac..fe95742224 100644 --- a/crates/ui-egui/src/thumb.rs +++ b/crates/ui-egui/src/thumb.rs @@ -3,9 +3,10 @@ //! preview-only pill and the marks row along the photo's lower edge (rating, flag, edited, colour //! label). //! -//! Everything is laid out against the picture itself, not its cell: on a narrow tile (a portrait -//! photo at the smallest thumbnail size) the marks degrade instead of running over the photo's -//! edge (see [`bar_layout`] and [`copy_tag_layout`], pure functions of the width on offer). +//! Everything is laid out against the picture itself, not its cell, and painted clipped to it: on +//! a narrow tile (a portrait photo at the smallest thumbnail size) the marks degrade instead of +//! running over the photo's edge (see [`bar_layout`], [`copy_tag_layout`], [`stack_layout`] and +//! [`preview_pill_place`], pure functions of the room on offer). use egui::{Align2, Color32, Painter, Rect, Sense, Stroke, pos2, vec2}; use lightcraft_catalog::{Flag, Photo, PhotoId, StackId}; @@ -207,8 +208,9 @@ impl BarLayout { /// The marks a photo `width` points wide has room for, as the tile narrows: first all of them; /// then without the edited mark; then the stars as one star and the number; then only what fits -/// whole, by importance: the flag, the rating, the label. -pub(crate) fn bar_layout(width: f32, marks: Marks, m: &Metrics) -> BarLayout { +/// whole, by importance: the flag, the rating, the label. Where the surface has no surround to +/// tint (`label_first`) the label is the only sign of the label, so it comes first. +pub(crate) fn bar_layout(width: f32, marks: Marks, m: &Metrics, label_first: bool) -> BarLayout { let stars = if marks.rating > 0 { Stars::Row(marks.rating) } else { Stars::None }; let full = BarLayout { stars, flag: marks.flag, edited: marks.edited, label: marks.label }; if full.fits(width, m) { @@ -224,15 +226,22 @@ pub(crate) fn bar_layout(width: f32, marks: Marks, m: &Metrics) -> BarLayout { if squeezed.fits(width, m) { return squeezed; } + #[derive(Clone, Copy)] + enum Item { + Flag, + Stars, + Label, + } + let order = if label_first { [Item::Label, Item::Flag, Item::Stars] } else { [Item::Flag, Item::Stars, Item::Label] }; let mut out = BarLayout::default(); - for trial in [BarLayout { flag: marks.flag, ..out }, BarLayout { stars: compact, ..out }, BarLayout { label: marks.label, ..out }] { - let next = BarLayout { - stars: if trial.stars == Stars::None { out.stars } else { trial.stars }, - flag: out.flag || trial.flag, - edited: false, - label: out.label || trial.label, + for item in order { + let next = match item { + Item::Flag if marks.flag => BarLayout { flag: true, ..out }, + Item::Stars if compact != Stars::None => BarLayout { stars: compact, ..out }, + Item::Label if marks.label => BarLayout { label: true, ..out }, + _ => continue, }; - if next != out && next.fits(width, m) { + if next.fits(width, m) { out = next; } } @@ -266,9 +275,71 @@ pub(crate) fn copy_tag_layout(width: f32, stack_w: Option, name_w: f32, m: } } -/// Whether the preview-only pill has room for its word (else it is the icon alone). -pub(crate) fn preview_pill_full(width: f32, text_w: f32, m: &Metrics) -> bool { - text_w + m.pill_extra + 2.0 * m.inset <= width +/// Where the preview-only pill goes. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct PillPlace { + pub rect: Rect, + /// With its word, else the icon alone. + pub full: bool, +} + +/// Where the preview-only pill goes on `photo`, clear of `obstacles` (the marks row, the copy tag +/// and the stack badge `stack`): above the marks row if it is free, else below the stack badge, +/// else beside it as the icon alone; `None` when there is no room. The word goes before the icon. +pub(crate) fn preview_pill_place(photo: Rect, text_w: f32, stack: Option, obstacles: &[Rect], m: &Metrics) -> Option { + let h = m.pill_icon; + let x = photo.left() + m.inset; + let above = (photo.bottom() - m.bar - 4.0 - h).max(photo.top() + m.inset); + let mut tries = vec![(pos2(x, above), true), (pos2(x, above), false)]; + if let Some(s) = stack { + let below = s.bottom() + 3.0; + tries.extend([(pos2(x, below), true), (pos2(x, below), false), (pos2(s.right() + 3.0, s.top()), false)]); + } + let overlap = |a: Rect, b: Rect| a.min.x < b.max.x && b.min.x < a.max.x && a.min.y < b.max.y && b.min.y < a.max.y; + tries.into_iter().find_map(|(at, full)| { + let rect = Rect::from_min_size(at, vec2(if full { text_w + m.pill_extra } else { h }, h)); + let inside = + rect.left() >= photo.left() && rect.right() <= photo.right() - m.inset && rect.top() >= photo.top() && rect.bottom() <= photo.bottom(); + (inside && !obstacles.iter().any(|o| overlap(rect, *o))).then_some(PillPlace { rect, full }) + }) +} + +/// How the stack badge is drawn. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) enum StackShape { + /// Icon and `i/n` (or the count on a collapsed stack's top). + Full, + /// `i/n` without the icon. + NoIcon, + /// The count alone. + CountOnly, +} + +/// The stack badge for `room` points (the photo's width less its two insets), whose text is +/// `full_w` wide and its count alone `count_w`: the shape and the width. The count alone is the +/// last shape; when even it is wider than the room the badge is drawn clipped to the photo. +pub(crate) fn stack_layout(room: f32, full_w: f32, count_w: f32, m: &Metrics) -> (StackShape, f32) { + let pad = 2.0 * m.pad + 2.0; + let full = full_w + m.stack_extra; + let bare = full_w + pad; + if full <= room { + (StackShape::Full, full) + } else if bare <= room { + (StackShape::NoIcon, bare) + } else { + (StackShape::CountOnly, count_w + pad) + } +} + +/// The marks row's strip along the photo's lower edge. +fn marks_bar(rect: Rect, m: &Metrics) -> Rect { + Rect::from_min_max(pos2(rect.left(), (rect.bottom() - m.bar).max(rect.top())), rect.right_bottom()) +} + +/// The overlay's painter: nothing is painted outside the photo. +fn clipped(ui: &egui::Ui, th: &Thumb) -> Painter { + let p = ui.painter(); + p.with_clip_rect(th.rect.intersect(p.clip_rect())) } // ------------------------------------------------------------------------ texts @@ -324,13 +395,19 @@ pub(crate) struct Thumb<'a> { pub hot: bool, /// Why the thumbnail could not be drawn, when it could not. pub failure: Option, + /// Whether the surface tints the cell around the photo with its colour label (the square grid + /// and the filmstrip do; the justified grid has no surround). + pub surround: bool, } -pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) { +/// Draws the overlay; returns the stack badge's response, which covers part of the cell, so that +/// its caller can give it the cell's context menu. +pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) -> Option { let t = Tokens::get(ui.ctx()); let m = th.surface.metrics(); - let (photo, rect, id) = (th.photo, th.rect, th.photo.id); - let p = ui.painter().clone(); + let photo = th.photo; + let p = clipped(ui, th); + let rect = th.rect; // (a rejected photo is dimmed under its marks, not over them) if photo.flag == Flag::Reject { p.rect_filled(rect, 0.0, Color32::from_black_alpha(110)); @@ -338,25 +415,32 @@ pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) { if let Some(error) = &th.failure { failure_mark(app, ui, th, &t, error); } + let bar = marks_bar(th.rect, &m); if th.marks { - marks_row(&p, &t, &m, th); + marks_row(&p, &t, &m, th, false); + } else if !th.surround && photo.label.is_some() { + // the setting is about ratings and flags: where no tinted surround says the label, its dot stays + marks_row(&p, &t, &m, th, true); } - let stack_w = th.stack.and_then(|(sid, pos)| stack_badge(app, ui, th, &t, sid, pos)); + let stack = th.stack.and_then(|(sid, pos)| stack_badge(app, ui, th, &t, sid, pos)); + let stack_rect = stack.as_ref().map(|(r, _)| *r); + let mut obstacles = vec![bar]; + obstacles.extend(stack_rect); if let Some(name) = &photo.copy_name { - copy_tag(ui, th, &t, name, stack_w); + obstacles.extend(copy_tag(ui, th, &t, name, stack_rect.map(|r| r.width()))); } if let Some(why) = &photo.preview_only { - preview_pill(ui, th, &t, why); + preview_pill(ui, th, &t, why, stack_rect, &obstacles); } - let _ = (&p, id); + stack.map(|(_, r)| r) } fn failure_mark(app: &LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, error: &str) { let id = th.photo.id; let side = (th.rect.width().min(th.rect.height()) * 0.4).clamp(12.0, 22.0); let icon = Rect::from_center_size(th.rect.center(), vec2(side, side)); - paint(ui.painter(), icon, Icon::Warning, t.caution); - let target = icon.expand(4.0); + paint(&clipped(ui, th), icon, Icon::Warning, t.caution); + let target = icon.expand(4.0).intersect(th.rect); register(ui, th.surface.widget(Mark::Failed, id), target); let offline = matches!(&th.photo.source, lightcraft_catalog::Source::File { path } if app.session.media.availability.is_offline(path)); let text = failure_text(offline, error); @@ -364,14 +448,15 @@ fn failure_mark(app: &LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, text.replace('\n', ": "))); } -fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb) { +fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) { let (photo, rect) = (th.photo, th.rect); - let layout = bar_layout(rect.width(), Marks::of(photo), m); - if layout.is_empty() && !th.hot { + let marks = if only_label { Marks { label: true, ..Marks::default() } } else { Marks::of(photo) }; + let layout = bar_layout(rect.width(), marks, m, !th.surround); + if layout.is_empty() && (only_label || !th.hot) { return; } - let bar = Rect::from_min_max(pos2(rect.left(), (rect.bottom() - m.bar).max(rect.top())), rect.right_bottom()); - if th.hot || m.band { + let bar = marks_bar(rect, m); + if !only_label && (th.hot || m.band) { p.rect_filled(bar, 0.0, Color32::from_black_alpha(120)); } let y = bar.center().y; @@ -409,45 +494,56 @@ fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb) { } /// The stack badge at the photo's top left: the number of photos on a collapsed stack's top, -/// `i/n` on the members of an expanded one; a click collapses or expands the stack. Returns its -/// width. -fn stack_badge(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, sid: StackId, pos: usize) -> Option { +/// `i/n` on the members of an expanded one; a click collapses or expands the stack. It gives up +/// its icon, then the `i/` of `i/n`, on a narrow photo, and is never painted outside the photo. +/// Returns the badge's rectangle (as laid out, before clipping) and its response. +fn stack_badge(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, sid: StackId, pos: usize) -> Option<(Rect, egui::Response)> { let m = th.surface.metrics(); let st = app.session.catalog.stack(sid)?; let (n, collapsed) = (st.photos.len(), st.collapsed); let id = th.photo.id; - let text = if collapsed { n.to_string() } else { format!("{}/{n}", pos + 1) }; - let p = ui.painter().clone(); - let g = p.layout_no_wrap(text, t.semibold(m.font), Color32::WHITE); - let br = Rect::from_min_size(th.rect.min + vec2(m.inset, m.inset), vec2(g.size().x + m.stack_extra, m.badge)); - let resp = ui.interact(br, egui::Id::unique((th.surface, "stack-badge", id.0)), Sense::click()).on_hover_text(stack_tip(collapsed)); - register(ui, th.surface.widget(Mark::Stack, id), br); + let p = clipped(ui, th); + let count = p.layout_no_wrap(n.to_string(), t.semibold(m.font), Color32::WHITE); + let full = if collapsed { count.clone() } else { p.layout_no_wrap(format!("{}/{n}", pos + 1), t.semibold(m.font), Color32::WHITE) }; + let (shape, w) = stack_layout(th.rect.width() - 2.0 * m.inset, full.size().x, count.size().x, &m); + let br = Rect::from_min_size(th.rect.min + vec2(m.inset, m.inset), vec2(w, m.badge)); + let hit = br.intersect(th.rect); + let resp = ui.interact(hit, egui::Id::unique((th.surface, "stack-badge", id.0)), Sense::click()).on_hover_text(stack_tip(collapsed)); + register(ui, th.surface.widget(Mark::Stack, id), hit); let fill = if resp.hovered() { Color32::from_black_alpha(220) } else { Color32::from_black_alpha(165) }; p.rect_filled(br, m.badge / 2.0, fill); if pos == 0 && !collapsed { p.rect_stroke(br, m.badge / 2.0, Stroke::new(1.0, t.accent), egui::StrokeKind::Inside); } - let icon = m.badge - 6.0; - paint(&p, Rect::from_min_size(br.min + vec2(m.badge * 0.3, 3.0), vec2(icon, icon)), Icon::Stack, Color32::WHITE); - p.galley(pos2(br.min.x + m.stack_extra - 6.0, br.center().y - g.size().y / 2.0), g, Color32::WHITE); - let width = br.width(); + let text = if shape == StackShape::CountOnly { count } else { full }; + match shape { + StackShape::Full => { + let icon = m.badge - 6.0; + paint(&p, Rect::from_min_size(br.min + vec2(m.badge * 0.3, 3.0), vec2(icon, icon)), Icon::Stack, Color32::WHITE); + p.galley(pos2(br.min.x + m.stack_extra - 6.0, br.center().y - text.size().y / 2.0), text, Color32::WHITE); + } + StackShape::NoIcon | StackShape::CountOnly => { + p.galley(br.center() - text.size() / 2.0, text, Color32::WHITE); + } + } // a double-click (Lightroom's way) toggles once: its second click would undo the first if resp.clicked() && !resp.double_clicked() { crate::panels::grid::toggle_stack(app, ui.ctx(), id); } - Some(width) + Some((br, resp)) } /// The virtual-copy tag at the photo's top right, so that a copy and its master tell apart. -fn copy_tag(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, name: &str, stack_w: Option) { +/// Returns where it is, when it is drawn. +fn copy_tag(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, name: &str, stack_w: Option) -> Option { let m = th.surface.metrics(); - let p = ui.painter().clone(); + let p = clipped(ui, th); let g = p.layout_no_wrap(name.to_string(), t.semibold(m.micro + 1.0), Color32::WHITE); let mode = copy_tag_layout(th.rect.width(), stack_w, g.size().x, &m); let w = match mode { CopyTag::Full => g.size().x + m.copy_extra, CopyTag::IconOnly => m.copy_icon, - CopyTag::Hidden => return, + CopyTag::Hidden => return None, }; let br = Rect::from_min_size(pos2(th.rect.right() - m.inset - w, th.rect.top() + m.inset), vec2(w, m.badge)); p.rect_filled(br, m.badge / 2.0, Color32::from_black_alpha(165)); @@ -463,18 +559,17 @@ fn copy_tag(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, name: &str, stack_w: Opti ui.interact(br, egui::Id::unique((th.surface, "copy-tag", id.0)), Sense::hover()) .on_hover_text(&tip) .widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, &tip)); + Some(br) } /// A raw shown from its embedded JPEG: a small amber "Preview" pill above the marks row, always -/// shown (it changes what editing does). -fn preview_pill(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, why: &str) { +/// shown (it changes what editing does) wherever it fits clear of the other marks. +fn preview_pill(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, why: &str, stack: Option, obstacles: &[Rect]) { let m = th.surface.metrics(); - let p = ui.painter().clone(); + let p = clipped(ui, th); let g = p.layout_no_wrap(crate::i18n::tr("Preview").into(), t.semibold(m.micro), Color32::WHITE); - let full = preview_pill_full(th.rect.width(), g.size().x, &m); - let (w, h) = (if full { g.size().x + m.pill_extra } else { m.pill_icon }, m.pill_icon); - let top = (th.rect.bottom() - m.bar - 4.0 - h).max(th.rect.top() + m.inset); - let br = Rect::from_min_size(pos2(th.rect.left() + m.inset, top), vec2(w, h)); + let Some(place) = preview_pill_place(th.rect, g.size().x, stack, obstacles, &m) else { return }; + let (br, full, h) = (place.rect, place.full, place.rect.height()); p.rect_filled(br, h / 2.0, Color32::from_black_alpha(170)); let icon = h - 4.0; let centre = if full { pos2(br.left() + h * 0.55, br.center().y) } else { br.center() }; @@ -506,7 +601,7 @@ mod tests { fn a_wide_tile_draws_every_mark() { let m = Surface::Grid.metrics(); let marks = Marks { rating: 5, flag: true, edited: true, label: true }; - let l = bar_layout(300.0, marks, &m); + let l = bar_layout(300.0, marks, &m, false); assert_eq!(l, BarLayout { stars: Stars::Row(5), flag: true, edited: true, label: true }); } @@ -517,16 +612,16 @@ mod tests { for surface in [Surface::Grid, Surface::Film] { let m = surface.metrics(); let marks = Marks { rating: 5, flag: true, edited: true, label: true }; - let full = bar_layout(1000.0, marks, &m); + let full = bar_layout(1000.0, marks, &m, false); let w_full = full.width(&m); - let no_edit = bar_layout(w_full - 0.5, marks, &m); + let no_edit = bar_layout(w_full - 0.5, marks, &m, false); assert_eq!(no_edit, BarLayout { edited: false, ..full }, "{surface:?}: the edited mark goes first"); let w_plain = no_edit.width(&m); - let compact = bar_layout(w_plain - 0.5, marks, &m); + let compact = bar_layout(w_plain - 0.5, marks, &m, false); assert_eq!(compact.stars, Stars::Compact(5), "{surface:?}: then the stars collapse"); assert!(compact.flag && compact.label && !compact.edited, "{surface:?}: and nothing else is lost yet: {compact:?}"); let w_compact = compact.width(&m); - let fewer = bar_layout(w_compact - 0.5, marks, &m); + let fewer = bar_layout(w_compact - 0.5, marks, &m, false); assert!(fewer.width(&m) <= w_compact - 0.5, "{surface:?}: what is drawn fits"); assert!(fewer.flag, "{surface:?}: the flag outlasts the label: {fewer:?}"); assert!(!fewer.label, "{surface:?}: the label is the first to go: {fewer:?}"); @@ -540,10 +635,10 @@ mod tests { let m = surface.metrics(); for marks in all_marks() { for w in 0..400 { - let l = bar_layout(w as f32, marks, &m); + let l = bar_layout(w as f32, marks, &m, false); assert!(l.width(&m) <= w as f32, "{surface:?} {marks:?} at {w}: {l:?} needs {}", l.width(&m)); if l.edited { - assert!(marks.edited && l == bar_layout(1000.0, marks, &m), "the edited mark only shows alongside all the others"); + assert!(marks.edited && l == bar_layout(1000.0, marks, &m, false), "the edited mark only shows alongside all the others"); } } } @@ -557,10 +652,10 @@ mod tests { let m = Surface::Grid.metrics(); let marks = Marks { rating: 5, flag: true, edited: false, label: false }; // justified rows 90 pt high: a 2:3 portrait is 60 wide - let l = bar_layout(60.0, marks, &m); + let l = bar_layout(60.0, marks, &m, false); assert_eq!(l, BarLayout { stars: Stars::Compact(5), flag: true, edited: false, label: false }); // a square cell 90 pt wide leaves a 70 × 56 area for the photo: 37 wide - let narrow = bar_layout(56.0 * 2.0 / 3.0, marks, &m); + let narrow = bar_layout(56.0 * 2.0 / 3.0, marks, &m, false); assert!(narrow.width(&m) <= 56.0 * 2.0 / 3.0 && narrow.flag, "{narrow:?}"); assert_ne!(narrow.stars, Stars::Row(5), "five whole stars (65 pt) cannot fit 37"); } @@ -569,7 +664,7 @@ mod tests { fn one_star_stays_one_star() { let m = Surface::Grid.metrics(); let marks = Marks { rating: 1, flag: false, edited: false, label: false }; - assert_eq!(bar_layout(m.star_pitch + 2.0 * m.pad, marks, &m).stars, Stars::Row(1)); + assert_eq!(bar_layout(m.star_pitch + 2.0 * m.pad, marks, &m, false).stars, Stars::Row(1)); } #[test] @@ -611,8 +706,70 @@ mod tests { #[test] fn the_preview_pill_shrinks_to_its_icon_on_a_narrow_tile() { let m = Surface::Grid.metrics(); - assert!(preview_pill_full(120.0, 40.0, &m)); - assert!(!preview_pill_full(60.0, 40.0, &m)); + let photo = |w: f32| Rect::from_min_size(pos2(0.0, 0.0), vec2(w, 80.0)); + assert!(preview_pill_place(photo(120.0), 40.0, None, &[], &m).is_some_and(|p| p.full)); + let narrow = preview_pill_place(photo(60.0), 40.0, None, &[], &m).expect("the icon fits"); + assert!(!narrow.full); + } + + /// A wide stacked photo in the filmstrip, a 3:2 one in the square grid at 90 pt: the pill's + /// usual place meets the stack badge, so it moves below it, beside it, or goes. + #[test] + fn the_preview_pill_keeps_clear_of_the_stack_badge() { + for (surface, w, h, badge_w) in [(Surface::Film, 100.0, 50.0, 30.0), (Surface::Grid, 70.0, 47.0, 40.0)] { + let m = surface.metrics(); + let photo = Rect::from_min_size(pos2(0.0, 0.0), vec2(w, h)); + let badge = Rect::from_min_size(pos2(m.inset, m.inset), vec2(badge_w, m.badge)); + let bar = marks_bar(photo, &m); + let place = preview_pill_place(photo, 30.0, Some(badge), &[bar, badge], &m); + let free = |r: Rect| !(r.min.x < badge.max.x && badge.min.x < r.max.x && r.min.y < badge.max.y && badge.min.y < r.max.y); + if let Some(p) = place { + assert!( + free(p.rect) && photo.contains_rect(p.rect) && p.rect.bottom() <= bar.top() + 0.01, + "{surface:?}: {p:?} meets the badge {badge:?}" + ); + } + // without the badge it sits where it always did + let alone = preview_pill_place(photo, 30.0, None, &[bar], &m).expect("room"); + assert_eq!(alone.rect.top(), (h - m.bar - 4.0 - m.pill_icon).max(m.inset), "{surface:?}"); + } + // a photo too small for the pill beside the badge has none + let m = Surface::Film.metrics(); + let tiny = Rect::from_min_size(pos2(0.0, 0.0), vec2(40.0, 30.0)); + let badge = Rect::from_min_size(pos2(m.inset, m.inset), vec2(34.0, m.badge)); + assert_eq!(preview_pill_place(tiny, 30.0, Some(badge), &[marks_bar(tiny, &m), badge], &m), None); + } + + /// "12/120" on a 60 pt photo, "3/12" on a 42 pt filmstrip photo: the badge sheds its icon, then + /// the `i/`, and what is left is drawn clipped to the photo rather than onto its neighbour. + #[test] + fn the_stack_badge_degrades_on_a_narrow_photo() { + for surface in [Surface::Grid, Surface::Film] { + let m = surface.metrics(); + let (full_w, count_w) = (34.0, 20.0); + let room = |w: f32| w - 2.0 * m.inset; + let (s, w) = stack_layout(room(300.0), full_w, count_w, &m); + assert_eq!((s, w), (StackShape::Full, full_w + m.stack_extra)); + let (s, w) = stack_layout(room(full_w + m.stack_extra + 2.0 * m.inset - 1.0), full_w, count_w, &m); + assert_eq!(s, StackShape::NoIcon, "{surface:?}: the icon goes first"); + assert!(w <= full_w + m.stack_extra); + let (s, w) = stack_layout(room(w + 2.0 * m.inset - 1.0), full_w, count_w, &m); + assert_eq!(s, StackShape::CountOnly, "{surface:?}: then the i/"); + assert!(w < full_w); + // nothing fits: still the count, and the caller clips it + assert_eq!(stack_layout(0.0, full_w, count_w, &m).0, StackShape::CountOnly); + } + } + + /// Where the label has no surround to say it, it outlasts the stars and the flag. + #[test] + fn on_a_surfaceless_tile_the_label_is_kept_before_the_stars() { + let m = Surface::Grid.metrics(); + let marks = Marks { rating: 5, flag: true, edited: false, label: true }; + let with_surround = bar_layout(60.0, marks, &m, false); + assert!(!with_surround.label, "{with_surround:?}"); + let without = bar_layout(60.0, marks, &m, true); + assert!(without.label && without.width(&m) <= 60.0, "{without:?}"); } #[test] diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 232d43ca10..c3f8829185 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -101,6 +101,8 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-LIB-OFFLINE | Keep album offline | P2 | 🚫 | | not applicable: local-first library | | LR-LIB-TARGET | Target album | P2 | ✅ | `cmd:album.setTarget`, `cmd:album.toggleTarget` | see LRC-LIB-COLLECTIONS | | LR-LIB-RATING | Star ratings | P0 | ✅ | `cmd:photo.rate` (`advance`), `cmd:photo.decreaseRating`, `cmd:photo.increaseRating`, `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/widgets/rating.rs` | one shared star row in the bottom bar, Info panel and filter bar (hover previews, ←/→ on a focused star) and one painter for badges (grid cells, filmstrip, Compare caption); menu rows with star text (Photo ▸ Set Rating, Select By Rating, the grid context menu) are separate menu items, unchanged; 0 clears; 1–5 set; Shift+0–5 applies and advances once, including with Auto Advance. A rating, flag or label that takes the active photo out of the view (filter bar, Picks, smart album) makes the photo after it active (the one before at the end), and Shift / Auto Advance doesn't step past it (#2312). Default grid brackets adjust each photo by one, clamped to 0–5; one batch undo and AutoWrite. Batch grid and undo/redo regressions; macOS native ownership corrected (PR #261) | +| LR-LIB-FLAG | Pick / reject flags | P0 | ✅ | `cmd:photo.pick`, `cmd:photo.reject`, `cmd:photo.unflag`, `cmd:photo.flag`, `crates/ui-egui/src/thumb.rs` | a rejected photo is dimmed on the grids and on the filmstrip, under its marks (the flag keeps its red); P pick, X reject, U clear; Shift+P picks and advances in both grids (Presets elsewhere); Shift+X/U and legacy Shift+Z advance; no flag cycle; rejection does not delete the file | +| LR-LIB-LABEL | Colour labels | P1 | ✅ | `cmd:photo.label`, `cmd:label.setNames`, `cmd:label.names`, `cmd:dialog.labelNames`, keys 6–9 in `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/thumb.rs` | Photo menu and grid context menu (coloured, named), Info-panel swatches, the label is a dot in the marks row on every surface (justified grid, square grid, filmstrip) plus translucent colour on the square-grid and filmstrip surrounds; nothing is laid over the photo's pixels (the justified grid's tinted footer band is gone). On the justified grid, which has no surround, the dot is kept before the stars and flag on a narrow photo and stays when Ratings & flags is Never; elsewhere the surround says the label; colour-label toasts have pale matching backgrounds; setting/clearing through keys (including Shift), menus or Info swatches shows the same bottom toast as ratings, with the colour/custom name; editable label names (undoable, journaled); no purple key (as in Lightroom), no custom extra labels | | LR-LIB-FLAG | Pick / reject flags | P0 | ✅ | `cmd:photo.pick`, `cmd:photo.reject`, `cmd:photo.unflag`, `cmd:photo.flag` | P pick, X reject, U clear; Shift+P picks and advances in both grids (Presets elsewhere); Shift+X/U and legacy Shift+Z advance; no flag cycle; rejection does not delete the file; a pick shows as a filled flag on thumbnails, in Compare, in the loupe and on the Pick button, a reject outlined (#1013) | | LR-LIB-LABEL | Colour labels | P1 | ✅ | `cmd:photo.label`, `cmd:photo.clearLabel`, `cmd:label.setNames`, `cmd:label.names`, `cmd:dialog.labelNames`, keys 6–9 in `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/thumb.rs` | Photo menu and grid context menu (coloured, named), Info-panel swatches, the label is a dot in the marks row on every surface (justified grid, square grid, filmstrip) plus translucent colour on the square-grid and filmstrip surrounds; nothing is laid over the photo's pixels (the justified grid's tinted footer band is gone); colour-label toasts have pale matching backgrounds; setting/clearing through keys (including Shift), menus or Info swatches shows the same bottom toast as ratings, with the colour/custom name; editable label names (undoable, journaled); no purple key (as in Lightroom), Clear Color Label (`photo.clearLabel`) has no key until one is given in Help → Keyboard Shortcuts, no custom extra labels | | LR-LIB-KEYWORD | Keywords | P0 | ✅ | `cmd:panel.keywords`, `cmd:photo.setMeta` (`addKeywords`/`removeKeywords`), `cmd:keyword.list`, `cmd:keyword.rename`, `cmd:keyword.delete`, `cmd:keyword.merge`, `cmd:keyword.suggest`, `crates/catalog/src/keywords.rs`, `crates/ui-egui/src/panels/left.rs` | left-panel keyword tree with counts (click filters, children included; context menu rename / merge / delete / add / remove); library-wide ops are one undo step and replay from the op log; suggestions (co-occurring / most used / completions) in the Keywords panel; keywords reorganize by drag and drop in the Keyword List (LRC-LIB-KEYWORDS) | @@ -128,7 +130,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-VIEW-DETAIL | Single-photo view | P0 | ✅ | `cmd:view.detail`, `crates/ui-egui/src/panels/detail.rs` | a “Rendering…” pill at the bottom of the photo (widget `loupe:rendering`; above the Navigator when that is in the way) once a render has been on its way for 0.5 s with nothing new on screen: over a stand-in (the raw's embedded JPEG, a thumbnail), the previous render after an edit, or, zoomed in, the magnified frame waiting for its window; Before views watch their own renders. Always on (Lightroom Classic makes it a View Options choice). When the render fails behind a stand-in, a caution pill says “This photo can't be opened” (“Original offline · no smart preview” when that is why) with the reason on hover and for screen readers (widget `loupe:renderFailed`; `ui.inspect` → `loupe.failed`) | | LR-VIEW-EDIT | Edit view | P0 | ✅ | `cmd:panel.edit` | | | LR-VIEW-FULLSCREEN | Full-screen preview | P1 | ✅ | `cmd:view.fullScreenPreview`, `cmd:view.enterFullScreen` | photo on black, arrows step, Esc exits; ⇧⌘F window full screen | -| LR-VIEW-FILMSTRIP | Filmstrip | P0 | ✅ | `cmd:view.filmstrip`, `crates/ui-egui/src/panels/detail.rs`, `crates/ui-egui/src/thumb.rs` | its thumbnails wear the overlay of the grid's (one painter, `thumb.rs`): the virtual-copy tag, a clickable stack badge with the grid's tooltip, the label dot, the grid's placeholder until the picture is drawn, and a failure mark that says why on hover (`film:failed:`); on a narrow thumbnail the marks degrade (edited mark, then the stars as ★ and the number, then what does not fit) instead of running over the photo's edge; the photo context menu on right-click; the mouse wheel scrolls it sideways, a third of its width per notch as in Lightroom Classic (trackpads scroll the points they report); it follows the active photo only when that changes (centred if off screen), so a scrolled strip stays put; every selected photo has the selected background; selected photos with a loaded thumbnail also show a ring, the active one in the heavier two-tone ring and the others in the lighter one, in the theme's colours, as in the grid (a selected cell with no thumbnail, still loading or failed, has the background and no ring); a drag from a cell carries the selection (a photo outside it drags alone and replaces it; in Compare it drags alone and leaves the selection, the active photo and the pair as they are) to the same sidebar rows as a drag from the grid, and a click without movement works as before (it selects the photo; in Compare it goes to the active side, see LR-VIEW-COMPARE) | +| LR-VIEW-FILMSTRIP | Filmstrip | P0 | ✅ | `cmd:view.filmstrip`, `crates/ui-egui/src/panels/detail.rs`, `crates/ui-egui/src/thumb.rs` | its thumbnails wear the overlay of the grid's (one painter, `thumb.rs`): the virtual-copy tag, a clickable stack badge with the grid's tooltip, the label dot, the grid's placeholder until the picture is drawn, a rejected photo dimmed as in the grid, and a failure mark that says why on hover (`film:failed:`); on a narrow thumbnail the marks degrade (edited mark, then the stars as ★ and the number, then what does not fit); the stack badge sheds its icon, then the `i/n`) and nothing is painted outside the photo; the preview pill keeps clear of the stack badge; right-click on the stack badge opens the photo menu; the photo context menu on right-click; the mouse wheel scrolls it sideways, a third of its width per notch as in Lightroom Classic (trackpads scroll the points they report); it follows the active photo only when that changes (centred if off screen), so a scrolled strip stays put; every selected photo has the selected background; selected photos with a loaded thumbnail also show a ring, the active one in the heavier two-tone ring and the others in the lighter one, in the theme's colours, as in the grid (a selected cell with no thumbnail, still loading or failed, has the background and no ring); a drag from a cell carries the selection (a photo outside it drags alone and replaces it; in Compare it drags alone and leaves the selection, the active photo and the pair as they are) to the same sidebar rows as a drag from the grid, and a click without movement works as before (it selects the photo; in Compare it goes to the active side, see LR-VIEW-COMPARE) | | LR-VIEW-ZOOM | Zoom & pan | P0 | ✅ | `cmd:view.zoomFit`, `cmd:view.zoom100`, `cmd:view.zoomIn`, `cmd:view.zoomOut`, `cmd:view.zoomToggle`, `cmd:view.clickZoom`, `cmd:view.navigate`, `crates/ui-egui/src/panels/detail.rs`, `crates/ui-egui/src/headless.rs` | continuous native pinch / modifier-wheel zoom (Fit–800%, anchored under the pointer), two-finger scroll / touch pan with edge limits; in Detail a middle-button drag (the wheel pressed) pans with a hand cursor whatever tool is active, so Remove / Heal / Clone, mask brushes and Crop don't paint or move meanwhile (`middle_pan`, `tests_canvas_pan.rs`); in Detail a middle-button drag (the wheel pressed) pans with a hand cursor whatever tool is active, so Remove / Heal / Clone, mask brushes and Crop don't paint or move meanwhile (`middle_pan`, `tests_canvas_pan.rs`); Detail (including tools, Before/After and full-screen preview), Compare and Reference; fractional percentages preserve small gestures; image, picker and targeted-adjustment cursors stay steady between gesture events; keyboard steps 25–800 % (not 6–1600 %); Fill in the bottom bar; click / Z / Space eases to the chosen ratio (1:1 default, 2:1, 3:1, 4:1, 8:1). The loupe's cost follows the canvas, not the zoom (issue #323): the whole frame is rendered at about canvas size (at most the 2560 px preview source level unless a larger Preview size is chosen, and never above the GPU's texture side), and once the view is zoomed well past that (more than 25 %) the window on screen is rendered too, cut from a frame of at most the photo's own pixels, so beyond 100 % the GPU magnifies it (`region::plan`, `RenderRequest::window`, `Session::region_job`, `crates/ui-egui/src/region.rs`); 1:1 and 2:1–8:1 are sharp at any photo size. A slider tick takes 7–12 ms on a 1400 × 900 canvas and 11–25 ms on a 2800 × 1700 one at 100 % and 400 % of a 24 MP photo (M1 Max, GPU, `profile_slider_drag`); about 20–25 ms at 100 % on the big canvas is over a 16 ms frame. A slider drag renders the whole frame at full size where the GPU draws the view, so the fit view stays sharp while dragging, and at 0.6 of it where that would be too slow: on the CPU, with an output-device profile proof or the HDR range shown, or for a control whose full-size drafts on this photo went clearly over the 16 ms slider budget (more than 20 ms) in two drags in a row (a LUT profile or refined mask the CPU renders, a photo past a GPU limit, a slow GPU); a draft's time is its render plus the frame that uploads and shows it, and a host frame time over 1 s (a hidden or stalled window) counts as unknown. A slow verdict is per photo and control (the same control on another photo, or another control on this one, is timed afresh) and expires: after 30 s a drag tries full size again, the wait doubling after each slow retry up to 240 s. Only a drag timed at full size changes it: one whose full-size drafts' median time (leaving out the first) is at most 20 ms forgets it; a drag that drafts small from its start (while the verdict holds, or where the GPU does not draw the view) or times fewer than two full-size drafts leaves it unchanged. At most 256 (photo, control) pairs are remembered, the oldest forgotten first. The size is chosen when a drag starts and kept until it ends, unless its full-size drafts take more than twice the budget, when it drops to 0.6 after three of them (`region::DragScale`, issue #330). Zoomed in, the whole-frame draft under the window is the 0.6 one (only the histogram and the window's stand-in use it). Render workers convert the pixels for their textures, not the UI thread. Handing GPU renders to egui without a CPU readback is #1228. A continuous pinch holds the render sizes (and the windows there are) and the size the fit view is shrunk to until it is quiet. A fit view on a canvas up to about 3200 px (a Retina Mac) never decodes the original; larger displays get a window at fit, which does. Diagnostic overlays (Visualize Spots, Point Color range, HDR range) get windows too, tested equal to the whole-frame render's pixels. Photos whose spots or Auto Mask strokes read too far for one window (only photos longer than 8192 px) render the whole frame at the size it is drawn, as before windows; while a preset or profile is hovered, or over a picture that is not the frame (an unsupported raw's embedded JPEG), the whole frame stays canvas-sized. Before/After (side by side, stacked, `\\` and both wipes) gets the same windows on both sides, clipped to their pane or side of the line. Windows render on the GPU like whole frames (equivalence-tested against the CPU), in the browser build too (windows no wider than its GPU's texture side, at most 3072 px), and are not made while hovering a look, nor over a picture that is not the frame (an unsupported raw's embedded JPEG with another crop). No texture is larger than the GPU allows. Spots and Auto Mask brushes work while what a window reads fits one render (8192 px along an axis, 4096 in the browser): the window grows to hold the spot and its source patch, or the dabs near it, and if that would take more (a clone from far away at 8:1) the loupe keeps the whole-frame render instead, and spots with an automatic source pick it from a fixed-size render of the whole frame (so a window's choice can differ from a whole-frame render's, which picks at its own resolution). The wide stages (dehaze, clarity, highlights/shadows base) and Refine Edges on masks read a window margin capped at 768 px; measured on hard-edged blocks that costs at most a few levels at 8:1. the histogram and Navigator come from the whole-frame render. Compare and Reference get the same windows, one per pane (`Slot::CompareRegion`, `panels/compare.rs`), over each pane's whole-frame render (at most 2560 px); while either view is open two originals stay decoded (`MediaCache::set_full_capacity`), so one pane's window does not evict the other's source; a pinch, or a slider drag on the active photo in Reference, keeps the windows there are until it ends. Mask overlays and soft proofing get the same windows (the window carries the overlay or the proof; only an output-device-profile proof renders on the CPU, where a tick at 100 % on a 1400 × 900 canvas takes about 36 ms instead of a full-size 24 MP proof). Verified: a 1:1 window of a 24 MP photo with tone and colour edits is the full-size export to within one level (`one_to_one_window_pixels_are_export_pixels`). Measured on Linux (Ryzen AI Max+ 395, Radeon 8060S, GPU, `profile_slider_drag`): median tick→shown 7 ms at fit, 33 ms at 100 % and 6 ms at 400 % on 1400 × 900; 21 ms at 100 % and 9 ms at 400 % on 2800 × 1700; 36 ms at 100 % with an output-device-profile soft proof (the CPU path) | | LR-VIEW-FOCUSPOINT | Camera focus point overlay and zoom (beyond Lightroom) | P2 | 🟡 | `cmd:view.focusPoint`, `cmd:view.zoomToFocus`, `cmd:view.zoomToggle`, `cmd:photo.reload`, `cmd:photo.readFocusPoints`, `cmd:focus.pump`, `crates/meta/src/focus.rs`, `crates/meta/src/focus_read.rs`, `crates/engine/src/focus_scan.rs`, `crates/engine/src/tests/focus_scan.rs`, `crates/ui-egui/src/panels/detail.rs` (`focus_box`, `draw_focus_point`), `crates/ui-egui/src/panels/compare.rs`, `crates/ui-egui/src/tests/focus_point.rs`, `docs/focus-points.md` | an extra (Lightroom shows no focus points): the AF frame read from the file at import; photos imported earlier get it in the background from a header-only read of each file (about 32 KB, ~100 photos/s from a spinning disk; activity row, cancellable, resumable; Photo ▸ Read Focus Points) as a box on the upright photo, drawn in Detail, Compare and Survey through rotation and crop (View ▸ Focus Point, ⌥F); Toggle Zoom centres on it (View ▸ Zoom to Focus Point, on by default); Info panel row `AF-C · Wide · Animal Eye Tracking`; `meta.focus` in `photo.inspect`. Partial: Sony ILCE-1 and ILCE-7SM3 only (layout checked against 333 files); other Sony bodies and other makers not yet; manual focus and centre-only Wide reports show nothing; Compare panes share one pan, so Z centres on the active photo's point only | | LR-VIEW-NAVIGATOR | Navigator mini map | P1 | ✅ | `cmd:view.navigator`, `crates/ui-egui/src/panels/detail.rs` | shown while zoomed (bottom right); click/drag pans | diff --git a/docs/whats-new.md b/docs/whats-new.md index ef2c1e398d..1fdf43191c 100644 --- a/docs/whats-new.md +++ b/docs/whats-new.md @@ -636,8 +636,12 @@ - In the Photo Grid a colour label is no longer a tinted band over the bottom of the picture; it is the dot in the row of marks, as in the Square Grid and the filmstrip. - On a narrow thumbnail (a portrait photo at the smallest size) the marks no longer run over the photo's edge: the - copy tag drops its name, the edited mark goes, five stars become one star and the number, and what still doesn't fit is left out. - The Preview pill sits above the marks on the filmstrip too. + copy tag drops its name, the edited mark goes, five stars become one star and the number, and what still doesn't fit is left out; + the stack badge sheds its icon and then the "1/" of "1/12". Nothing is painted outside the photo. The Preview pill sits + above the marks on the filmstrip too, and steps aside for the stack badge. In the Photo Grid, which has no tinted + surround, the label dot is kept before the stars on a narrow photo and stays when ratings and flags are turned off. +- The filmstrip now dims rejected photos as the grid does, and in the grid the dim sits under the marks, so the red + reject flag stays clear. Right-clicking the stack badge opens the photo's menu. - Screen readers say "rating 3 of 5" in every language, instead of building "stars" from an English plural. ### Sharper resampling in HDR and panorama merges From baa35a798f278459f5ffea21125ab69c253f8cdf Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 17 Oct 2026 09:57:17 -0400 Subject: [PATCH 03/15] LR-VIEW-FILMSTRIP: the Preview pill is never hidden, and avoids only the marks that are drawn The pill dodged the whole marks strip even when no marks were drawn, so it vanished on short photos (a 16:9 photo in the square grid at 90 pt, a wide panorama in the filmstrip). - crates/ui-egui/src/thumb.rs: `marks_extent` / `marks_row` report the strip actually covered, and only that is an obstacle; `preview_pill_place` falls back to the icon at its first spot - tests: a short photo without marks keeps the pill; the pill is always placed; the "never outgrows the photo" test also runs with the label first; right-clicking the grid's stack badge opens the photo menu Co-Authored-By: Claude --- crates/ui-egui/src/tests/thumb.rs | 13 ++++++ crates/ui-egui/src/thumb.rs | 68 ++++++++++++++++++++++--------- 2 files changed, 61 insertions(+), 20 deletions(-) diff --git a/crates/ui-egui/src/tests/thumb.rs b/crates/ui-egui/src/tests/thumb.rs index de49c50e19..65cc6d9783 100644 --- a/crates/ui-egui/src/tests/thumb.rs +++ b/crates/ui-egui/src/tests/thumb.rs @@ -188,3 +188,16 @@ fn right_clicking_the_filmstrips_stack_badge_opens_the_photo_menu() { h.settle(SETTLE); assert!(egui::Popup::is_any_open(&h.view.ctx), "the photo's menu, as on the rest of the cell"); } + +#[test] +fn right_clicking_the_grids_stack_badge_opens_the_photo_menu() { + let mut h = demo(); + let ids = first_photos(&mut h, 2); + run(&mut h, "stack.group", json!({"ids": [ids[0].0, ids[1].0], "collapsed": false})); + h.settle(SETTLE); + assert!(!egui::Popup::is_any_open(&h.view.ctx)); + let r = h.request("ui.clickWidget", json!({"id": format!("stack:{}", ids[0].0), "button": "right"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + assert!(egui::Popup::is_any_open(&h.view.ctx), "the photo's menu, as on the rest of the cell"); +} diff --git a/crates/ui-egui/src/thumb.rs b/crates/ui-egui/src/thumb.rs index fe95742224..d3c9629d2f 100644 --- a/crates/ui-egui/src/thumb.rs +++ b/crates/ui-egui/src/thumb.rs @@ -296,12 +296,21 @@ pub(crate) fn preview_pill_place(photo: Rect, text_w: f32, stack: Option, tries.extend([(pos2(x, below), true), (pos2(x, below), false), (pos2(s.right() + 3.0, s.top()), false)]); } let overlap = |a: Rect, b: Rect| a.min.x < b.max.x && b.min.x < a.max.x && a.min.y < b.max.y && b.min.y < a.max.y; - tries.into_iter().find_map(|(at, full)| { + let free = tries.into_iter().find_map(|(at, full)| { let rect = Rect::from_min_size(at, vec2(if full { text_w + m.pill_extra } else { h }, h)); let inside = rect.left() >= photo.left() && rect.right() <= photo.right() - m.inset && rect.top() >= photo.top() && rect.bottom() <= photo.bottom(); (inside && !obstacles.iter().any(|o| overlap(rect, *o))).then_some(PillPlace { rect, full }) - }) + }); + // it changes what editing does: when nowhere is clear it is still there, as the icon at its first spot + Some(free.unwrap_or(PillPlace { rect: Rect::from_min_size(pos2(x, above), vec2(h, h)), full: false })) +} + +/// The strip the marks row covers: `None` when it draws nothing (no marks that fit, and no band +/// under the pointer or on a chosen photo), so that nothing else keeps clear of it. +pub(crate) fn marks_extent(rect: Rect, marks: Marks, hot: bool, only_label: bool, label_first: bool, m: &Metrics) -> Option { + let layout = bar_layout(rect.width(), marks, m, label_first); + (!layout.is_empty() || (!only_label && hot)).then(|| marks_bar(rect, m)) } /// How the stack badge is drawn. @@ -415,16 +424,17 @@ pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) -> if let Some(error) = &th.failure { failure_mark(app, ui, th, &t, error); } - let bar = marks_bar(th.rect, &m); - if th.marks { - marks_row(&p, &t, &m, th, false); + let bar = if th.marks { + marks_row(&p, &t, &m, th, false) } else if !th.surround && photo.label.is_some() { // the setting is about ratings and flags: where no tinted surround says the label, its dot stays - marks_row(&p, &t, &m, th, true); - } + marks_row(&p, &t, &m, th, true) + } else { + None + }; let stack = th.stack.and_then(|(sid, pos)| stack_badge(app, ui, th, &t, sid, pos)); let stack_rect = stack.as_ref().map(|(r, _)| *r); - let mut obstacles = vec![bar]; + let mut obstacles: Vec = bar.into_iter().collect(); obstacles.extend(stack_rect); if let Some(name) = &photo.copy_name { obstacles.extend(copy_tag(ui, th, &t, name, stack_rect.map(|r| r.width()))); @@ -448,14 +458,12 @@ fn failure_mark(app: &LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, text.replace('\n', ": "))); } -fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) { +/// Draws the marks row; returns the strip it covers, if it drew anything. +fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) -> Option { let (photo, rect) = (th.photo, th.rect); let marks = if only_label { Marks { label: true, ..Marks::default() } } else { Marks::of(photo) }; let layout = bar_layout(rect.width(), marks, m, !th.surround); - if layout.is_empty() && (only_label || !th.hot) { - return; - } - let bar = marks_bar(rect, m); + let bar = marks_extent(rect, marks, th.hot, only_label, !th.surround, m)?; if !only_label && (th.hot || m.band) { p.rect_filled(bar, 0.0, Color32::from_black_alpha(120)); } @@ -491,6 +499,7 @@ fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) let at = Rect::from_center_size(pos2(right - m.edited / 2.0, y), vec2(m.edited_icon, m.edited_icon)); paint(p, at, Icon::Sliders, t.text_label); } + Some(bar) } /// The stack badge at the photo's top left: the number of photos on a collapsed stack's top, @@ -635,6 +644,8 @@ mod tests { let m = surface.metrics(); for marks in all_marks() { for w in 0..400 { + let first = bar_layout(w as f32, marks, &m, true); + assert!(first.width(&m) <= w as f32, "{surface:?} {marks:?} at {w} (label first): {first:?}"); let l = bar_layout(w as f32, marks, &m, false); assert!(l.width(&m) <= w as f32, "{surface:?} {marks:?} at {w}: {l:?} needs {}", l.width(&m)); if l.edited { @@ -723,12 +734,11 @@ mod tests { let bar = marks_bar(photo, &m); let place = preview_pill_place(photo, 30.0, Some(badge), &[bar, badge], &m); let free = |r: Rect| !(r.min.x < badge.max.x && badge.min.x < r.max.x && r.min.y < badge.max.y && badge.min.y < r.max.y); - if let Some(p) = place { - assert!( - free(p.rect) && photo.contains_rect(p.rect) && p.rect.bottom() <= bar.top() + 0.01, - "{surface:?}: {p:?} meets the badge {badge:?}" - ); - } + let p = place.expect("the pill is always placed"); + assert!( + free(p.rect) && photo.contains_rect(p.rect) && p.rect.bottom() <= bar.top() + 0.01, + "{surface:?}: {p:?} meets the badge {badge:?}" + ); // without the badge it sits where it always did let alone = preview_pill_place(photo, 30.0, None, &[bar], &m).expect("room"); assert_eq!(alone.rect.top(), (h - m.bar - 4.0 - m.pill_icon).max(m.inset), "{surface:?}"); @@ -737,7 +747,25 @@ mod tests { let m = Surface::Film.metrics(); let tiny = Rect::from_min_size(pos2(0.0, 0.0), vec2(40.0, 30.0)); let badge = Rect::from_min_size(pos2(m.inset, m.inset), vec2(34.0, m.badge)); - assert_eq!(preview_pill_place(tiny, 30.0, Some(badge), &[marks_bar(tiny, &m), badge], &m), None); + let last = preview_pill_place(tiny, 30.0, Some(badge), &[marks_bar(tiny, &m), badge], &m).expect("never hidden"); + assert!(!last.full, "the icon alone, at its first spot"); + } + + /// A square-grid 16:9 photo at 90 pt is 70 x 39: with no marks to draw the row covers nothing, + /// and the pill sits where it always did instead of dodging a strip that is not there. + #[test] + fn a_short_photo_without_marks_leaves_the_pill_its_place() { + for (surface, w, h) in [(Surface::Grid, 70.0, 39.0), (Surface::Film, 100.0, 30.0)] { + let m = surface.metrics(); + let photo = Rect::from_min_size(pos2(0.0, 0.0), vec2(w, h)); + let bar = marks_extent(photo, Marks::default(), false, false, false, &m); + assert_eq!(bar, None, "{surface:?}: nothing drawn, nothing to avoid"); + let obstacles: Vec = bar.into_iter().collect(); + let place = preview_pill_place(photo, 30.0, None, &obstacles, &m).expect("placed"); + assert!(photo.contains_rect(place.rect) && place.full, "{surface:?}: {place:?}"); + // under the pointer the band is there, and the row covers its strip + assert_eq!(marks_extent(photo, Marks::default(), true, false, false, &m), Some(marks_bar(photo, &m))); + } } /// "12/120" on a 60 pt photo, "3/12" on a 42 pt filmstrip photo: the badge sheds its icon, then From 7857822ebbc082a83a2afbce4ed7a50ccbc87238 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 17 Oct 2026 10:10:20 -0400 Subject: [PATCH 04/15] LR-VIEW-FILMSTRIP: the Preview pill may sit over the marks band but never over the stack badge The pill treated the marks strip as hard an obstacle as the stack badge, so on a short hovered or rated photo (square grid at 90 pt, 16:9) the spot beside the badge was refused for touching the band and the icon landed on the badge. - crates/ui-egui/src/thumb.rs: `preview_pill_place` takes hard obstacles (stack badge, copy tag) and soft ones (the marks strip) and tries a spot clear of both, then one clear of the hard ones, then the icon at its first spot - tests: the pill beside the badge over the band; the tiny case says what it does; a headless test of `overlay`'s wiring (no marks, 70 x 39 cell: the pill keeps its word) Co-Authored-By: Claude --- crates/ui-egui/src/tests/thumb.rs | 33 +++++++++++++ crates/ui-egui/src/thumb.rs | 81 ++++++++++++++++++++----------- 2 files changed, 87 insertions(+), 27 deletions(-) diff --git a/crates/ui-egui/src/tests/thumb.rs b/crates/ui-egui/src/tests/thumb.rs index 65cc6d9783..00fc3345a6 100644 --- a/crates/ui-egui/src/tests/thumb.rs +++ b/crates/ui-egui/src/tests/thumb.rs @@ -201,3 +201,36 @@ fn right_clicking_the_grids_stack_badge_opens_the_photo_menu() { h.settle(SETTLE); assert!(egui::Popup::is_any_open(&h.view.ctx), "the photo's menu, as on the rest of the cell"); } + +/// The overlay's wiring: a photo with no marks drawn has nothing for the pill to dodge, so on a +/// short 16:9 cell of the square grid at 90 pt (70 x 39) the pill keeps its word. +#[test] +fn the_preview_pill_keeps_its_word_on_a_short_photo_with_no_marks() { + let mut h = demo(); + let id = first_photos(&mut h, 1)[0]; + run(&mut h, "photo.rate", json!({"ids": [id.0], "rating": 0})); + run(&mut h, "photo.flag", json!({"ids": [id.0], "flag": "none"})); + run(&mut h, "photo.label", json!({"ids": [id.0], "label": "none"})); + let other = first_photos(&mut h, 2)[1]; + run(&mut h, "library.select", json!({"ids": [other.0]})); + let p = h.app.session.catalog.photo(id).expect("photo").clone(); + let op = lightcraft_catalog::Op::SetContent { + id, + width: 1600, + height: 900, + file_size: p.file_size, + content_hash: p.content_hash.clone(), + preview_only: Some("Cr3 files are not decoded yet".into()), + preview_checked: "0.5.0".into(), + }; + h.app.session.catalog.apply(op).unwrap(); + // no thumbnail yet: the photo is its placeholder, 16:9 + h.app.renderer.set_offload(Box::new(RenderGate::new(Rc::new(Cell::new(false))))); + h.app.ui.view = ViewMode::SquareGrid; + h.app.ui.thumb_size = 90.0; + for _ in 0..10 { + h.step(); + } + let pill = widget(&h, &format!("badge:previewOnly:{}", id.0)).expect("the pill is drawn"); + assert!(pill.width() > 30.0, "its word is there, not the icon alone: {pill:?}"); +} diff --git a/crates/ui-egui/src/thumb.rs b/crates/ui-egui/src/thumb.rs index d3c9629d2f..330cbfac9c 100644 --- a/crates/ui-egui/src/thumb.rs +++ b/crates/ui-egui/src/thumb.rs @@ -283,10 +283,13 @@ pub(crate) struct PillPlace { pub full: bool, } -/// Where the preview-only pill goes on `photo`, clear of `obstacles` (the marks row, the copy tag -/// and the stack badge `stack`): above the marks row if it is free, else below the stack badge, -/// else beside it as the icon alone; `None` when there is no room. The word goes before the icon. -pub(crate) fn preview_pill_place(photo: Rect, text_w: f32, stack: Option, obstacles: &[Rect], m: &Metrics) -> Option { +/// Where the preview-only pill goes on `photo`: above the marks row if that is clear, else below +/// the stack badge `stack`, else beside it as the icon alone. `hard` are what it must never cover +/// (the stack badge, the copy tag), `soft` what it may sit over when nothing else is clear (the +/// marks strip, whose marks are drawn at its ends). Order: a spot clear of both, then one clear of +/// `hard`, then, as it changes what editing does and so is never hidden, the icon at the first +/// spot. The word goes before the icon. +pub(crate) fn preview_pill_place(photo: Rect, text_w: f32, stack: Option, hard: &[Rect], soft: &[Rect], m: &Metrics) -> PillPlace { let h = m.pill_icon; let x = photo.left() + m.inset; let above = (photo.bottom() - m.bar - 4.0 - h).max(photo.top() + m.inset); @@ -296,14 +299,21 @@ pub(crate) fn preview_pill_place(photo: Rect, text_w: f32, stack: Option, tries.extend([(pos2(x, below), true), (pos2(x, below), false), (pos2(s.right() + 3.0, s.top()), false)]); } let overlap = |a: Rect, b: Rect| a.min.x < b.max.x && b.min.x < a.max.x && a.min.y < b.max.y && b.min.y < a.max.y; - let free = tries.into_iter().find_map(|(at, full)| { - let rect = Rect::from_min_size(at, vec2(if full { text_w + m.pill_extra } else { h }, h)); - let inside = - rect.left() >= photo.left() && rect.right() <= photo.right() - m.inset && rect.top() >= photo.top() && rect.bottom() <= photo.bottom(); - (inside && !obstacles.iter().any(|o| overlap(rect, *o))).then_some(PillPlace { rect, full }) - }); - // it changes what editing does: when nowhere is clear it is still there, as the icon at its first spot - Some(free.unwrap_or(PillPlace { rect: Rect::from_min_size(pos2(x, above), vec2(h, h)), full: false })) + let spots: Vec = tries + .into_iter() + .map(|(at, full)| PillPlace { rect: Rect::from_min_size(at, vec2(if full { text_w + m.pill_extra } else { h }, h)), full }) + .filter(|p| { + let r = p.rect; + r.left() >= photo.left() && r.right() <= photo.right() - m.inset && r.top() >= photo.top() && r.bottom() <= photo.bottom() + }) + .collect(); + let clear = |p: &&PillPlace, of: &[&[Rect]]| !of.iter().any(|set| set.iter().any(|o| overlap(p.rect, *o))); + spots + .iter() + .find(|p| clear(p, &[hard, soft])) + .or_else(|| spots.iter().find(|p| clear(p, &[hard]))) + .copied() + .unwrap_or(PillPlace { rect: Rect::from_min_size(pos2(x, above), vec2(h, h)), full: false }) } /// The strip the marks row covers: `None` when it draws nothing (no marks that fit, and no band @@ -434,13 +444,12 @@ pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) -> }; let stack = th.stack.and_then(|(sid, pos)| stack_badge(app, ui, th, &t, sid, pos)); let stack_rect = stack.as_ref().map(|(r, _)| *r); - let mut obstacles: Vec = bar.into_iter().collect(); - obstacles.extend(stack_rect); + let mut hard: Vec = stack_rect.into_iter().collect(); if let Some(name) = &photo.copy_name { - obstacles.extend(copy_tag(ui, th, &t, name, stack_rect.map(|r| r.width()))); + hard.extend(copy_tag(ui, th, &t, name, stack_rect.map(|r| r.width()))); } if let Some(why) = &photo.preview_only { - preview_pill(ui, th, &t, why, stack_rect, &obstacles); + preview_pill(ui, th, &t, why, stack_rect, &hard, bar.as_slice()); } stack.map(|(_, r)| r) } @@ -573,11 +582,11 @@ fn copy_tag(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, name: &str, stack_w: Opti /// A raw shown from its embedded JPEG: a small amber "Preview" pill above the marks row, always /// shown (it changes what editing does) wherever it fits clear of the other marks. -fn preview_pill(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, why: &str, stack: Option, obstacles: &[Rect]) { +fn preview_pill(ui: &mut egui::Ui, th: &Thumb, t: &Tokens, why: &str, stack: Option, hard: &[Rect], soft: &[Rect]) { let m = th.surface.metrics(); let p = clipped(ui, th); let g = p.layout_no_wrap(crate::i18n::tr("Preview").into(), t.semibold(m.micro), Color32::WHITE); - let Some(place) = preview_pill_place(th.rect, g.size().x, stack, obstacles, &m) else { return }; + let place = preview_pill_place(th.rect, g.size().x, stack, hard, soft, &m); let (br, full, h) = (place.rect, place.full, place.rect.height()); p.rect_filled(br, h / 2.0, Color32::from_black_alpha(170)); let icon = h - 4.0; @@ -718,8 +727,8 @@ mod tests { fn the_preview_pill_shrinks_to_its_icon_on_a_narrow_tile() { let m = Surface::Grid.metrics(); let photo = |w: f32| Rect::from_min_size(pos2(0.0, 0.0), vec2(w, 80.0)); - assert!(preview_pill_place(photo(120.0), 40.0, None, &[], &m).is_some_and(|p| p.full)); - let narrow = preview_pill_place(photo(60.0), 40.0, None, &[], &m).expect("the icon fits"); + assert!(preview_pill_place(photo(120.0), 40.0, None, &[], &[], &m).full); + let narrow = preview_pill_place(photo(60.0), 40.0, None, &[], &[], &m); assert!(!narrow.full); } @@ -732,23 +741,41 @@ mod tests { let photo = Rect::from_min_size(pos2(0.0, 0.0), vec2(w, h)); let badge = Rect::from_min_size(pos2(m.inset, m.inset), vec2(badge_w, m.badge)); let bar = marks_bar(photo, &m); - let place = preview_pill_place(photo, 30.0, Some(badge), &[bar, badge], &m); + let p = preview_pill_place(photo, 30.0, Some(badge), &[badge], &[bar], &m); let free = |r: Rect| !(r.min.x < badge.max.x && badge.min.x < r.max.x && r.min.y < badge.max.y && badge.min.y < r.max.y); - let p = place.expect("the pill is always placed"); assert!( free(p.rect) && photo.contains_rect(p.rect) && p.rect.bottom() <= bar.top() + 0.01, "{surface:?}: {p:?} meets the badge {badge:?}" ); // without the badge it sits where it always did - let alone = preview_pill_place(photo, 30.0, None, &[bar], &m).expect("room"); + let alone = preview_pill_place(photo, 30.0, None, &[], &[bar], &m); assert_eq!(alone.rect.top(), (h - m.bar - 4.0 - m.pill_icon).max(m.inset), "{surface:?}"); } - // a photo too small for the pill beside the badge has none + // a photo too small for the pill anywhere clear of the badge: nothing else fits, so the + // icon is drawn at its first spot, over the badge, rather than not at all let m = Surface::Film.metrics(); let tiny = Rect::from_min_size(pos2(0.0, 0.0), vec2(40.0, 30.0)); let badge = Rect::from_min_size(pos2(m.inset, m.inset), vec2(34.0, m.badge)); - let last = preview_pill_place(tiny, 30.0, Some(badge), &[marks_bar(tiny, &m), badge], &m).expect("never hidden"); - assert!(!last.full, "the icon alone, at its first spot"); + let last = preview_pill_place(tiny, 30.0, Some(badge), &[badge], &[marks_bar(tiny, &m)], &m); + assert!(!last.full, "the icon alone"); + assert_eq!(last.rect.min, pos2(m.inset, (tiny.bottom() - m.bar - 4.0 - m.pill_icon).max(m.inset)), "at its first spot"); + assert!(last.rect.intersects(badge), "over the badge: the last resort"); + } + + /// A short photo with a collapsed stack's badge and a marks band (hovered, or rated): the spot + /// beside the badge overlaps the band, which is allowed (its marks sit at its ends), the badge + /// is not. + #[test] + fn the_pill_may_sit_over_the_marks_band_but_never_over_the_badge() { + let m = Surface::Grid.metrics(); + let photo = Rect::from_min_size(pos2(0.0, 0.0), vec2(70.0, 39.0)); + let badge = Rect::from_min_size(pos2(m.inset, m.inset), vec2(34.0, m.badge)); + let band = marks_bar(photo, &m); + let p = preview_pill_place(photo, 30.0, Some(badge), &[badge], &[band], &m); + let overlap = |a: Rect, b: Rect| a.min.x < b.max.x && b.min.x < a.max.x && a.min.y < b.max.y && b.min.y < a.max.y; + assert!(!overlap(p.rect, badge), "{p:?} is over the badge {badge:?}"); + assert!(photo.contains_rect(p.rect), "{p:?}"); + assert!(p.rect.left() >= badge.right(), "beside the badge: {p:?}"); } /// A square-grid 16:9 photo at 90 pt is 70 x 39: with no marks to draw the row covers nothing, @@ -761,7 +788,7 @@ mod tests { let bar = marks_extent(photo, Marks::default(), false, false, false, &m); assert_eq!(bar, None, "{surface:?}: nothing drawn, nothing to avoid"); let obstacles: Vec = bar.into_iter().collect(); - let place = preview_pill_place(photo, 30.0, None, &obstacles, &m).expect("placed"); + let place = preview_pill_place(photo, 30.0, None, &[], &obstacles, &m); assert!(photo.contains_rect(place.rect) && place.full, "{surface:?}: {place:?}"); // under the pointer the band is there, and the row covers its strip assert_eq!(marks_extent(photo, Marks::default(), true, false, false, &m), Some(marks_bar(photo, &m))); From 8f665149a02a21f3321e0301ebf542edf9838ac1 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 17 Oct 2026 10:30:04 -0400 Subject: [PATCH 05/15] LR-VIEW-FILMSTRIP: the copy tag keeps its name when it clears the stack badge by 4 pt The tag asked for the surface's 6 pt mark gap beside the stack badge, so on a 124 pt justified tile ("Copy 1" beside "2/2") it fell to the icon where main fit both. - crates/ui-egui/src/thumb.rs: `copy_tag_layout` keeps the full tag while it clears the badge by `COPY_GAP` (4 pt); test with the case's widths Co-Authored-By: Claude --- crates/ui-egui/src/thumb.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/thumb.rs b/crates/ui-egui/src/thumb.rs index 330cbfac9c..171665fad5 100644 --- a/crates/ui-egui/src/thumb.rs +++ b/crates/ui-egui/src/thumb.rs @@ -261,11 +261,14 @@ pub(crate) enum CopyTag { Hidden, } +/// The least clear space between the stack badge and the copy tag. +const COPY_GAP: f32 = 4.0; + /// The copy tag for a photo `width` wide whose name is `name_w` wide, next to a stack badge /// `stack_w` wide (if it has one): the tag gives up its name before it would run into the badge /// or over the photo's edge, and then gives up its icon. pub(crate) fn copy_tag_layout(width: f32, stack_w: Option, name_w: f32, m: &Metrics) -> CopyTag { - let room = width - 2.0 * m.inset - stack_w.map_or(0.0, |w| w + m.gap); + let room = width - 2.0 * m.inset - stack_w.map_or(0.0, |w| w + COPY_GAP); if name_w + m.copy_extra <= room { CopyTag::Full } else if m.copy_icon <= room { @@ -715,6 +718,19 @@ mod tests { } } + /// The real case: "Copy 1" (34 pt of text) beside a "2/2" badge (18 pt of text) on a 124 pt + /// justified tile fitted with 2 pt to spare on main. The tag keeps its name while it clears the + /// badge by 4 pt, and is the icon alone just below that. + #[test] + fn the_copy_tag_keeps_its_name_when_it_clears_the_badge_by_four_points() { + let m = Surface::Grid.metrics(); + let (name_w, stack_w) = (34.0, 18.0 + m.stack_extra); + let edge = 2.0 * m.inset + stack_w + 4.0 + name_w + m.copy_extra; + assert_eq!(copy_tag_layout(124.0, Some(stack_w), name_w, &m), CopyTag::Full); + assert_eq!(copy_tag_layout(edge, Some(stack_w), name_w, &m), CopyTag::Full); + assert_eq!(copy_tag_layout(edge - 0.5, Some(stack_w), name_w, &m), CopyTag::IconOnly); + } + #[test] fn without_a_stack_badge_the_copy_tag_keeps_its_name_longer() { let m = Surface::Grid.metrics(); From cf454ffd0d510ea5c89718c92a25778a836f5a94 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sat, 17 Oct 2026 11:30:30 -0400 Subject: [PATCH 06/15] LR-VIEW-FILMSTRIP: the Preview pill test drops a thumbnail rendered before it, so it always sees the placeholder The test could find the photo's thumbnail already rendered by the demo (a portrait one in the integration build's demo library) and then read a pill sized for that shape, failing about one run in three there. Co-Authored-By: Claude --- crates/ui-egui/src/tests/thumb.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/tests/thumb.rs b/crates/ui-egui/src/tests/thumb.rs index 00fc3345a6..24a6d81307 100644 --- a/crates/ui-egui/src/tests/thumb.rs +++ b/crates/ui-egui/src/tests/thumb.rs @@ -224,13 +224,24 @@ fn the_preview_pill_keeps_its_word_on_a_short_photo_with_no_marks() { preview_checked: "0.5.0".into(), }; h.app.session.catalog.apply(op).unwrap(); - // no thumbnail yet: the photo is its placeholder, 16:9 + // no thumbnail: the photo is its placeholder, 16:9. A thumbnail the demo already rendered + // would be drawn at the picture's own shape instead (a portrait one leaves the pill no room). h.app.renderer.set_offload(Box::new(RenderGate::new(Rc::new(Cell::new(false))))); + h.app.renderer.textures.remove(&Slot::Thumb(id)); + h.app.renderer.textures.remove(&Slot::ThumbQuick(id)); h.app.ui.view = ViewMode::SquareGrid; h.app.ui.thumb_size = 90.0; - for _ in 0..10 { - h.step(); + for round in 0..2 { + for _ in 0..10 { + h.step(); + } + // (a render already under way before the gate lands in the first round: drop it too) + if round == 0 { + h.app.renderer.textures.remove(&Slot::Thumb(id)); + h.app.renderer.textures.remove(&Slot::ThumbQuick(id)); + } } + assert!(h.app.renderer.thumb(id).is_none(), "the photo is still its placeholder"); let pill = widget(&h, &format!("badge:previewOnly:{}", id.0)).expect("the pill is drawn"); assert!(pill.width() > 30.0, "its word is there, not the icon alone: {pill:?}"); } From cbc387e8ec9dd685899ca2f6172dd96c59b7ba18 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sun, 18 Oct 2026 13:14:28 -0400 Subject: [PATCH 07/15] LR-PREF-INTERFACE: grid badges set to Stars on hover keep flags and labels on every tile, stars and the edited mark only on hover or selection (folded in from #2163) Under Settings > Interface > Grid > Ratings & flags, the default is renamed from "When rated or hovered" to "Stars on hover" (all 13 catalogs, with a hint line): the flag and the colour label show on every thumbnail, the stars and the edited mark only on the hovered or selected photo. Always and Never are unchanged (Never keeps the label dot on the justified grid, which has no tinted surround). The shared thumbnail overlay (thumb.rs) gains `Thumb::extras` for this, and registers each mark it draws as `badge:{stars,flag,label,edited}:{id}` (filmstrip `film:badge:...`). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/locales/cs.json | 3 +- crates/ui-egui/locales/de.json | 3 +- crates/ui-egui/locales/es.json | 3 +- crates/ui-egui/locales/fr.json | 3 +- crates/ui-egui/locales/it.json | 3 +- crates/ui-egui/locales/ja.json | 3 +- crates/ui-egui/locales/ka.json | 3 +- crates/ui-egui/locales/pl.json | 3 +- crates/ui-egui/locales/pt-br.json | 3 +- crates/ui-egui/locales/ru.json | 3 +- crates/ui-egui/locales/uk.json | 3 +- crates/ui-egui/locales/zh-hans.json | 3 +- crates/ui-egui/locales/zh-hant.json | 3 +- .../ui-egui/src/dialogs/settings/display.rs | 3 +- crates/ui-egui/src/panels/detail/filmstrip.rs | 1 + crates/ui-egui/src/panels/grid.rs | 16 +- crates/ui-egui/src/state/settings.rs | 2 +- crates/ui-egui/src/tests.rs | 1 + crates/ui-egui/src/tests/grid_badges.rs | 165 ++++++++++++++++++ crates/ui-egui/src/tests/thumb.rs | 7 +- crates/ui-egui/src/thumb.rs | 31 +++- 21 files changed, 238 insertions(+), 27 deletions(-) create mode 100644 crates/ui-egui/src/tests/grid_badges.rs diff --git a/crates/ui-egui/locales/cs.json b/crates/ui-egui/locales/cs.json index 32c94e100d..a639b4c807 100644 --- a/crates/ui-egui/locales/cs.json +++ b/crates/ui-egui/locales/cs.json @@ -2052,7 +2052,8 @@ "We": "St", "Wednesday": "Středa", "What's New": "Co je nového", - "When rated or hovered": "Při hodnocení nebo najetí myší", + "Stars on hover": "Hvězdy při najetí", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Hvězdy při najetí: vlajky a barevné štítky jsou vidět vždy; hvězdy a značka úprav se zobrazí, když je fotka pod myší nebo vybraná.", "White Balance": "Vyvážení bílé", "White Balance Selector": "Kapátko vyvážení bílé", "White Balance Selector (W)": "Kapátko vyvážení bílé (W)", diff --git a/crates/ui-egui/locales/de.json b/crates/ui-egui/locales/de.json index 0567d2169f..957a668306 100644 --- a/crates/ui-egui/locales/de.json +++ b/crates/ui-egui/locales/de.json @@ -1647,7 +1647,8 @@ "Watermark": "Wasserzeichen", "Wednesday": "Mittwoch", "What's New": "Neuigkeiten", - "When rated or hovered": "Bei Bewertung oder unter dem Mauszeiger", + "Stars on hover": "Sterne beim Überfahren", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Sterne beim Überfahren: Flaggen und Farbmarkierungen sind immer sichtbar; die Sterne und das Bearbeitet-Zeichen erscheinen, solange ein Foto überfahren oder ausgewählt ist.", "White Balance": "Weißabgleich", "White Balance Selector": "Weißabgleich-Pipette", "White Balance Selector (W)": "Weißabgleich-Pipette (W)", diff --git a/crates/ui-egui/locales/es.json b/crates/ui-egui/locales/es.json index a9082f96a4..0c5e172243 100644 --- a/crates/ui-egui/locales/es.json +++ b/crates/ui-egui/locales/es.json @@ -1757,7 +1757,8 @@ "Watermark": "Marca de agua", "Wednesday": "Miércoles", "What's New": "Novedades", - "When rated or hovered": "Al valorar o pasar el puntero", + "Stars on hover": "Estrellas al pasar el puntero", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Estrellas al pasar el puntero: las marcas y las etiquetas de color se ven siempre; las estrellas y la marca de edición aparecen mientras una foto está bajo el puntero o seleccionada.", "White Balance": "Balance de blancos", "White Balance Selector": "Selector de balance de blancos", "White Balance Selector (W)": "Selector de balance de blancos (W)", diff --git a/crates/ui-egui/locales/fr.json b/crates/ui-egui/locales/fr.json index 33007258e9..95eeadbdcb 100644 --- a/crates/ui-egui/locales/fr.json +++ b/crates/ui-egui/locales/fr.json @@ -1576,7 +1576,8 @@ "Watermark": "Filigrane", "Wednesday": "Mercredi", "What's New": "Nouveautés", - "When rated or hovered": "Lors de la notation ou du survol", + "Stars on hover": "Étoiles au survol", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Étoiles au survol : les drapeaux et les étiquettes de couleur sont toujours visibles ; les étoiles et la marque de retouche apparaissent quand une photo est survolée ou sélectionnée.", "White Balance": "Balance des blancs", "White Balance Selector": "Sélecteur de balance des blancs", "White Balance Selector (W)": "Sélecteur de balance des blancs (W)", diff --git a/crates/ui-egui/locales/it.json b/crates/ui-egui/locales/it.json index 6756fc586d..a0a96e10a3 100644 --- a/crates/ui-egui/locales/it.json +++ b/crates/ui-egui/locales/it.json @@ -1606,7 +1606,8 @@ "Watermark": "Filigrana", "Wednesday": "Mercoledì", "What's New": "Novità", - "When rated or hovered": "Quando ha una valutazione o è sotto il puntatore", + "Stars on hover": "Stelle al passaggio", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Stelle al passaggio: i contrassegni e le etichette colore sono sempre visibili; le stelle e il segno di modifica compaiono quando la foto è sotto il puntatore o selezionata.", "White Balance": "Bilanciamento del bianco", "White Balance Selector": "Selettore del bilanciamento del bianco", "White Balance Selector (W)": "Selettore del bilanciamento del bianco (W)", diff --git a/crates/ui-egui/locales/ja.json b/crates/ui-egui/locales/ja.json index 20f8ec9936..a2eae54dd0 100644 --- a/crates/ui-egui/locales/ja.json +++ b/crates/ui-egui/locales/ja.json @@ -1503,7 +1503,8 @@ "Watched folder": "監視フォルダ", "Watermark": "透かし", "What's New": "新着情報", - "When rated or hovered": "評価時またはカーソルを合わせたとき", + "Stars on hover": "星はカーソルを合わせたとき", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "星はカーソルを合わせたとき:フラグとカラーラベルは常に表示され、星と編集済みマークは写真にカーソルを合わせたか選択したときに表示されます。", "White Balance": "ホワイトバランス", "White Balance Selector": "ホワイトバランス選択", "White Balance Selector (W)": "ホワイトバランス選択(W)", diff --git a/crates/ui-egui/locales/ka.json b/crates/ui-egui/locales/ka.json index 88cacae7c0..6c5e526f09 100644 --- a/crates/ui-egui/locales/ka.json +++ b/crates/ui-egui/locales/ka.json @@ -2269,7 +2269,8 @@ "What's New": "რა არის ახალი", "When GPU rendering is on but no graphics processor can be found, LightCraft now says so once at start-up instead": "როცა GPU რენდერი ჩართულია, მაგრამ გრაფიკული პროცესორი ვერ მოიძებნა, LightCraft ახლა ამას გაშვებისას ერთხელ გეუბნებათ, ნაცვლად იმისა,", "When a folder holds several file types, the Import Photos review has a toggle per type (`ARW · 120`, `JPG · 120`):": "როცა საქაღალდეში რამდენიმე ტიპის ფაილია, ფოტოების იმპორტის მიმოხილვას თითო ტიპზე გადამრთველი აქვს (`ARW · 120`, `JPG · 120`):", - "When rated or hovered": "შეფასებისას ან კურსორის მიტანისას", + "Stars on hover": "ვარსკვლავები კურსორის მიტანისას", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "ვარსკვლავები კურსორის მიტანისას: დროშები და ფერადი ჭდეები ყოველთვის ჩანს; ვარსკვლავები და რედაქტირების ნიშანი ჩნდება, როცა ფოტო კურსორის ქვეშაა ან მონიშნულია.", "White Balance": "თეთრის ბალანსი", "White Balance Selector": "თეთრის ბალანსის ამრჩევი", "White Balance Selector (W)": "თეთრის ბალანსის ამრჩევი (W)", diff --git a/crates/ui-egui/locales/pl.json b/crates/ui-egui/locales/pl.json index a70269d298..5a6bad5bbf 100644 --- a/crates/ui-egui/locales/pl.json +++ b/crates/ui-egui/locales/pl.json @@ -1541,7 +1541,8 @@ "Watermark": "Znak wodny", "Wednesday": "Środa", "What's New": "Co nowego", - "When rated or hovered": "Po ocenieniu lub wskazaniu kursorem", + "Stars on hover": "Gwiazdki po wskazaniu", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Gwiazdki po wskazaniu: flagi i kolorowe etykiety są widoczne zawsze; gwiazdki i znak edycji pojawiają się, gdy zdjęcie jest wskazane kursorem lub zaznaczone.", "White Balance": "Balans bieli", "White Balance Selector": "Próbnik balansu bieli", "White Balance Selector (W)": "Próbnik balansu bieli (W)", diff --git a/crates/ui-egui/locales/pt-br.json b/crates/ui-egui/locales/pt-br.json index cc5c2d9fe0..87a9f9713d 100644 --- a/crates/ui-egui/locales/pt-br.json +++ b/crates/ui-egui/locales/pt-br.json @@ -1600,7 +1600,8 @@ "Watermark": "Marca d'água", "Wednesday": "Quarta-feira", "What's New": "Novidades", - "When rated or hovered": "Ao avaliar ou passar o mouse", + "Stars on hover": "Estrelas ao passar o mouse", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Estrelas ao passar o mouse: sinalizadores e etiquetas de cor sempre aparecem; as estrelas e a marca de edição aparecem enquanto a foto está sob o mouse ou selecionada.", "White Balance": "Balanço de branco", "White Balance Selector": "Seletor de balanço de branco", "White Balance Selector (W)": "Seletor de balanço de branco (W)", diff --git a/crates/ui-egui/locales/ru.json b/crates/ui-egui/locales/ru.json index 493c224fcf..7409dce4ad 100644 --- a/crates/ui-egui/locales/ru.json +++ b/crates/ui-egui/locales/ru.json @@ -1556,7 +1556,8 @@ "Watermark": "Водяной знак", "Wednesday": "Среда", "What's New": "Что нового", - "When rated or hovered": "При оценке или наведении", + "Stars on hover": "Звёзды при наведении", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Звёзды при наведении: флаги и цветные метки видны всегда; звёзды и значок правки появляются, пока фото под курсором или выбрано.", "White Balance": "Баланс белого", "White Balance Selector": "Пипетка баланса белого", "White Balance Selector (W)": "Пипетка баланса белого (W)", diff --git a/crates/ui-egui/locales/uk.json b/crates/ui-egui/locales/uk.json index b9fe09de85..a5c4668350 100644 --- a/crates/ui-egui/locales/uk.json +++ b/crates/ui-egui/locales/uk.json @@ -1533,7 +1533,8 @@ "Watched folder": "Відстежувана тека", "Watermark": "Водяний знак", "What's New": "Що нового", - "When rated or hovered": "Після оцінювання або наведення", + "Stars on hover": "Зірки при наведенні", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "Зірки при наведенні: прапорці й кольорові мітки видно завжди; зірки та позначка редагування з’являються, поки фото під курсором або вибране.", "White Balance": "Баланс білого", "White Balance Selector": "Вибір балансу білого", "White Balance Selector (W)": "Вибір балансу білого (W)", diff --git a/crates/ui-egui/locales/zh-hans.json b/crates/ui-egui/locales/zh-hans.json index d1117147ba..e14283daeb 100644 --- a/crates/ui-egui/locales/zh-hans.json +++ b/crates/ui-egui/locales/zh-hans.json @@ -1576,7 +1576,8 @@ "Watermark": "水印", "Wednesday": "星期三", "What's New": "新功能", - "When rated or hovered": "评级或悬停时", + "Stars on hover": "悬停时显示星级", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "悬停时显示星级:旗标和颜色标签始终显示;星级和已编辑标记在照片被悬停或选中时显示。", "White Balance": "白平衡", "White Balance Selector": "白平衡选择器", "White Balance Selector (W)": "白平衡选择器 (W)", diff --git a/crates/ui-egui/locales/zh-hant.json b/crates/ui-egui/locales/zh-hant.json index db58b148f5..7b52c7dc08 100644 --- a/crates/ui-egui/locales/zh-hant.json +++ b/crates/ui-egui/locales/zh-hant.json @@ -1582,7 +1582,8 @@ "Watermark": "浮水印", "Wednesday": "星期三", "What's New": "新增功能", - "When rated or hovered": "評分或游標停留時", + "Stars on hover": "游標停留時顯示星級", + "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected.": "游標停留時顯示星級:旗標和顏色標籤一律顯示;星級和已編輯標記在照片被游標停留或選取時顯示。", "White Balance": "白平衡", "White Balance Selector": "白平衡選取器", "White Balance Selector (W)": "白平衡選取器(W)", diff --git a/crates/ui-egui/src/dialogs/settings/display.rs b/crates/ui-egui/src/dialogs/settings/display.rs index a5b1974d21..31248e87ef 100644 --- a/crates/ui-egui/src/dialogs/settings/display.rs +++ b/crates/ui-egui/src/dialogs/settings/display.rs @@ -86,10 +86,11 @@ pub(super) fn interface_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Toke choices( ui, "settingsGridBadges", - &[(GridBadges::Auto, "When rated or hovered"), (GridBadges::Always, "Always"), (GridBadges::Never, "Never")], + &[(GridBadges::Auto, "Stars on hover"), (GridBadges::Always, "Always"), (GridBadges::Never, "Never")], &mut app.ui.settings.grid_badges, ); }); + hint(ui, t, "Stars on hover: flags and colour labels always show; the stars and the edited mark appear while a photo is hovered or selected."); check(ui, "settings.showFilenames", &mut app.ui.show_filenames, "Square Grid: show file names and formats"); heading(ui, t, crate::i18n::tr("Keywords")); row(ui, t, crate::i18n::tr("Keywords of the selection"), |ui| { diff --git a/crates/ui-egui/src/panels/detail/filmstrip.rs b/crates/ui-egui/src/panels/detail/filmstrip.rs index a599acf823..e6aa0d4e14 100644 --- a/crates/ui-egui/src/panels/detail/filmstrip.rs +++ b/crates/ui-egui/src/panels/detail/filmstrip.rs @@ -143,6 +143,7 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) { rect: photo_rect, stack, marks: app.ui.settings.film_badges, + extras: app.ui.settings.film_badges, hot: false, failure, surround: true, diff --git a/crates/ui-egui/src/panels/grid.rs b/crates/ui-egui/src/panels/grid.rs index 09fe9c185b..24f12c0e53 100644 --- a/crates/ui-egui/src/panels/grid.rs +++ b/crates/ui-egui/src/panels/grid.rs @@ -812,18 +812,22 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, view: let (photo_rect, failure) = paint_cell_thumbnail(app, p, &t, id, img_rect, flags); // labels and badges paint_cell_caption(app, p, &t, &photo, r, square); - let show_badges = match app.ui.settings.grid_badges { - crate::state::GridBadges::Auto => resp.hovered() || selected || photo.rating > 0 || photo.flag != Flag::None || photo.label.is_some(), - crate::state::GridBadges::Always => true, - crate::state::GridBadges::Never => false, + // Stars on hover: the decision marks (flag, colour label) always show; the stars and the edited + // mark only while the photo is hovered or selected, so a mostly rated library stays clean. + let engaged = resp.hovered() || selected; + let (show_marks, show_extras) = match app.ui.settings.grid_badges { + crate::state::GridBadges::Auto => (true, engaged), + crate::state::GridBadges::Always => (true, true), + crate::state::GridBadges::Never => (false, false), }; let overlay = crate::thumb::Thumb { surface: crate::thumb::Surface::Grid, photo: &photo, rect: photo_rect, stack, - marks: show_badges, - hot: resp.hovered() || selected, + marks: show_marks, + extras: show_extras, + hot: engaged, failure, surround: square, }; diff --git a/crates/ui-egui/src/state/settings.rs b/crates/ui-egui/src/state/settings.rs index ffd2a0f8d0..c45936dd38 100644 --- a/crates/ui-egui/src/state/settings.rs +++ b/crates/ui-egui/src/state/settings.rs @@ -30,7 +30,7 @@ pub enum LaunchLibrary { #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub enum GridBadges { - /// On hover, on the selection, and on rated or flagged photos. + /// Flags and colour labels always; stars and the edited mark on hover and on the selection. #[default] Auto, Always, diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index 72a52f00ad..1cec8500dc 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -35,6 +35,7 @@ mod focus_point; mod folder_drop; mod grading; mod grid; +mod grid_badges; mod grid_drag; mod guided_guides; mod histogram_drag; diff --git a/crates/ui-egui/src/tests/grid_badges.rs b/crates/ui-egui/src/tests/grid_badges.rs new file mode 100644 index 0000000000..0d0f80f382 --- /dev/null +++ b/crates/ui-egui/src/tests/grid_badges.rs @@ -0,0 +1,165 @@ +//! Grid badges under Settings ▸ Interface ▸ Grid: Auto keeps a mostly rated library clean (the +//! stars and the edited mark show on hover and selection), while the decision marks (flag, colour +//! label) stay visible; Always shows everything, Never nothing. + +use std::sync::Arc; +use std::time::Duration; + +use lightcraft_catalog::{ColorLabel, Flag, Op, Photo, PhotoId, Source}; +use lightcraft_engine::Session; +use serde_json::json; + +use crate::headless::Headless; +use crate::state::{GridBadges, ViewMode}; +use crate::{LightcraftApp, Services}; + +const T: Duration = Duration::from_secs(30); +const SETTLE: Duration = Duration::from_secs(60); + +const RATED: PhotoId = PhotoId(1); +const PICKED: PhotoId = PhotoId(2); +const REJECTED: PhotoId = PhotoId(3); +const EDITED: PhotoId = PhotoId(4); +const PLAIN: PhotoId = PhotoId(5); +const UNRATED_PICK: PhotoId = PhotoId(6); + +fn library() -> Session { + let mut s = Session::new(); + for i in 1..=6u64 { + let name = format!("IMG_{i:03}.jpg"); + let mut p = Photo::new( + PhotoId(i), + Source::File { path: format!("/lightcraft-badges-test/{name}") }, + &name, + "JPEG", + 6000, + 4000, + "2026-01-01T00:00:00", + ); + match PhotoId(i) { + RATED => p.rating = 4, + PICKED => { + p.rating = 5; + p.flag = Flag::Pick; + p.label = Some(ColorLabel::Red); + } + REJECTED => { + p.flag = Flag::Reject; + p.label = Some(ColorLabel::Blue); + } + EDITED => Arc::make_mut(&mut p.develop).light.exposure = 1.0, + UNRATED_PICK => p.flag = Flag::Pick, + _ => {} + } + s.catalog.apply(Op::AddPhoto { photo: Box::new(p) }).unwrap(); + } + s +} + +/// The grid with `badges`, the plain photo selected and the pointer away from every tile. +fn grid(badges: GridBadges) -> Headless { + let app = LightcraftApp::new(library(), Services { png: None, ..Default::default() }); + let mut h = Headless::new(app, [1200.0, 800.0], 1.0); + h.app.ui.view = ViewMode::PhotoGrid; + h.app.ui.settings.grid_badges = badges; + let r = h.request("engine.execute", json!({"command": "library.select", "params": {"ids": [PLAIN.0]}}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + move_to(&mut h, egui::pos2(1.0, 1.0)); + h +} + +fn move_to(h: &mut Headless, at: egui::Pos2) { + h.request("ui.move", json!({"x": at.x, "y": at.y}), T); + h.settle(SETTLE); + h.step(); +} + +fn hover(h: &mut Headless, id: PhotoId) { + let r = h.request("ui.hoverWidget", json!({"id": format!("thumb:{}", id.0)}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + h.step(); +} + +/// Which marks are drawn on the photo's tile, in a fixed order. +fn marks(h: &Headless, id: PhotoId) -> Vec<&'static str> { + ["stars", "flag", "label", "edited"].into_iter().filter(|m| h.app.widgets.iter().any(|(w, _)| *w == format!("badge:{m}:{}", id.0))).collect() +} + +#[test] +fn auto_hides_the_stars_of_a_photo_that_is_neither_hovered_nor_selected() { + let h = grid(GridBadges::Auto); + assert_eq!(marks(&h, RATED), Vec::<&str>::new()); +} + +#[test] +fn auto_shows_the_stars_while_the_photo_is_hovered_or_selected() { + let mut h = grid(GridBadges::Auto); + hover(&mut h, RATED); + assert_eq!(marks(&h, RATED), ["stars"], "hovered"); + move_to(&mut h, egui::pos2(1.0, 1.0)); + assert_eq!(marks(&h, RATED), Vec::<&str>::new(), "the pointer left"); + let r = h.request("engine.execute", json!({"command": "library.select", "params": {"ids": [RATED.0]}}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + assert_eq!(marks(&h, RATED), ["stars"], "selected"); +} + +#[test] +fn auto_always_shows_the_flag_and_the_colour_label() { + let mut h = grid(GridBadges::Auto); + assert_eq!(marks(&h, PICKED), ["flag", "label"], "the stars of a picked photo stay hidden"); + assert_eq!(marks(&h, REJECTED), ["flag", "label"]); + hover(&mut h, PICKED); + assert_eq!(marks(&h, PICKED), ["stars", "flag", "label"], "hover adds the stars to the marks"); +} + +#[test] +fn always_shows_everything_and_never_shows_nothing() { + let h = grid(GridBadges::Always); + assert_eq!(marks(&h, RATED), ["stars"]); + assert_eq!(marks(&h, PICKED), ["stars", "flag", "label"]); + assert_eq!(marks(&h, EDITED), ["edited"]); + // (the setting is about ratings and flags: the justified grid has no surround to tint with a + // colour label, so the label's dot stays, #2164) + let h = grid(GridBadges::Never); + for id in [RATED, EDITED] { + assert_eq!(marks(&h, id), Vec::<&str>::new(), "photo {}", id.0); + } + for id in [PICKED, REJECTED] { + assert_eq!(marks(&h, id), ["label"], "photo {}", id.0); + } +} + +#[test] +fn auto_shows_the_edited_mark_with_the_stars() { + let mut h = grid(GridBadges::Auto); + assert_eq!(marks(&h, EDITED), Vec::<&str>::new()); + hover(&mut h, EDITED); + assert_eq!(marks(&h, EDITED), ["edited"]); +} + +fn rect(h: &Headless, id: String) -> egui::Rect { + h.app.widgets.iter().find(|(w, _)| *w == id).map(|(_, r)| *r).unwrap_or_else(|| panic!("no widget {id}")) +} + +#[test] +fn auto_puts_the_flag_at_the_left_when_the_stars_are_hidden() { + let mut h = grid(GridBadges::Auto); + let cell = rect(&h, format!("thumb:{}", PICKED.0)); + let flag = rect(&h, format!("badge:flag:{}", PICKED.0)); + assert!(flag.left() - cell.left() < 12.0, "no gap for stars that aren't drawn: flag {flag:?} in {cell:?}"); + hover(&mut h, PICKED); + let flag = rect(&h, format!("badge:flag:{}", PICKED.0)); + let stars = rect(&h, format!("badge:stars:{}", PICKED.0)); + assert!(flag.left() >= stars.right(), "the flag follows the stars: {flag:?} after {stars:?}"); +} + +#[test] +fn an_unrated_photos_flag_does_not_move_on_hover() { + let mut h = grid(GridBadges::Auto); + let before = rect(&h, format!("badge:flag:{}", UNRATED_PICK.0)); + hover(&mut h, UNRATED_PICK); + assert_eq!(rect(&h, format!("badge:flag:{}", UNRATED_PICK.0)), before); +} diff --git a/crates/ui-egui/src/tests/thumb.rs b/crates/ui-egui/src/tests/thumb.rs index 24a6d81307..c5b5057c30 100644 --- a/crates/ui-egui/src/tests/thumb.rs +++ b/crates/ui-egui/src/tests/thumb.rs @@ -47,7 +47,12 @@ fn hover_says(h: &mut Headless, id: &str, says: impl Fn(&str) -> bool) -> bool { #[test] fn a_virtual_copy_is_tagged_in_the_filmstrip_as_it_is_in_the_grid() { let mut h = demo(); - let master = first_photos(&mut h, 1)[0]; + // (a landscape photo: a copy in a stack on a narrow portrait one has no room for its tag beside the + // stack badge in the filmstrip, which then leaves it out by design) + let master = first_photos(&mut h, 12) + .into_iter() + .find(|id| h.app.session.catalog.photo(*id).is_some_and(|p| p.width > p.height)) + .expect("a landscape photo"); run(&mut h, "photo.virtualCopy", json!({"ids": [master.0]})); let copy = h.app.session.catalog.photos().find(|p| p.copy_name.is_some()).map(|p| p.id).expect("a virtual copy"); h.settle(SETTLE); diff --git a/crates/ui-egui/src/thumb.rs b/crates/ui-egui/src/thumb.rs index 171665fad5..38dcc783a5 100644 --- a/crates/ui-egui/src/thumb.rs +++ b/crates/ui-egui/src/thumb.rs @@ -413,6 +413,9 @@ pub(crate) struct Thumb<'a> { pub stack: Option<(StackId, usize)>, /// Whether the marks row is drawn (Settings → Interface). pub marks: bool, + /// Whether the stars and the edited mark are in it (the grid's Stars on hover shows only the + /// flag and the colour label until the photo is hovered or chosen). + pub extras: bool, /// The pointer is over the cell, or it is chosen: the row's band shows even without marks. pub hot: bool, /// Why the thumbnail could not be drawn, when it could not. @@ -438,10 +441,10 @@ pub(crate) fn overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, th: &Thumb) -> failure_mark(app, ui, th, &t, error); } let bar = if th.marks { - marks_row(&p, &t, &m, th, false) + marks_row(ui.ctx(), &p, &t, &m, th, false) } else if !th.surround && photo.label.is_some() { // the setting is about ratings and flags: where no tinted surround says the label, its dot stays - marks_row(&p, &t, &m, th, true) + marks_row(ui.ctx(), &p, &t, &m, th, true) } else { None }; @@ -471,9 +474,21 @@ fn failure_mark(app: &LightcraftApp, ui: &mut egui::Ui, th: &Thumb, t: &Tokens, } /// Draws the marks row; returns the strip it covers, if it drew anything. -fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) -> Option { +fn marks_row(ctx: &egui::Context, p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) -> Option { let (photo, rect) = (th.photo, th.rect); - let marks = if only_label { Marks { label: true, ..Marks::default() } } else { Marks::of(photo) }; + // (each mark drawn is registered as `badge:{name}:{id}`, in the filmstrip `film:badge:…`) + let mark = |name: &str, at: Rect| { + let prefix = if th.surface == Surface::Grid { "badge" } else { "film:badge" }; + // painted only, nothing here takes a click: geometry, not a widget + crate::widgets::register_geometry(ctx, format!("{prefix}:{name}:{}", photo.id.0), at); + }; + let marks = if only_label { + Marks { label: true, ..Marks::default() } + } else if th.extras { + Marks::of(photo) + } else { + Marks { rating: 0, edited: false, ..Marks::of(photo) } + }; let layout = bar_layout(rect.width(), marks, m, !th.surround); let bar = marks_extent(rect, marks, th.hot, only_label, !th.surround, m)?; if !only_label && (th.hot || m.band) { @@ -484,11 +499,14 @@ fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) match layout.stars { Stars::None => {} Stars::Row(n) => { - x += crate::rating::paint_rating(p, pos2(x, y), n, m.rating, t.star); + let width = crate::rating::paint_rating(p, pos2(x, y), n, m.rating, t.star); + mark("stars", Rect::from_min_size(pos2(x, y - m.star / 2.0), vec2(width, m.star))); + x += width; } Stars::Compact(n) => { paint(p, Rect::from_min_size(pos2(x, y - m.star / 2.0), vec2(m.star, m.star)), Icon::StarFilled, t.star); p.text(pos2(x + m.star + 1.0, y), Align2::LEFT_CENTER, n.to_string(), t.semibold(m.font), t.star); + mark("stars", Rect::from_min_size(pos2(x, y - m.star / 2.0), vec2(m.star + 1.0 + m.digit, m.star))); x += m.star + 1.0 + m.digit; } } @@ -499,17 +517,20 @@ fn marks_row(p: &Painter, t: &Tokens, m: &Metrics, th: &Thumb, only_label: bool) Flag::Reject => paint(p, at, Icon::FlagReject, t.reject), Flag::None => {} } + mark("flag", at); } let mut right = bar.right() - m.pad; if layout.label && let Some(l) = photo.label { p.circle(pos2(right - m.label / 2.0, y), m.dot, crate::theme::label_color(l), Stroke::new(1.0, Color32::from_black_alpha(120))); + mark("label", Rect::from_center_size(pos2(right - m.label / 2.0, y), vec2(m.label, m.label))); right -= m.label; } if layout.edited { let at = Rect::from_center_size(pos2(right - m.edited / 2.0, y), vec2(m.edited_icon, m.edited_icon)); paint(p, at, Icon::Sliders, t.text_label); + mark("edited", at); } Some(bar) } From dcf402a01945ebf29395cbde8268ed6fd672c028 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Sun, 18 Oct 2026 13:14:28 -0400 Subject: [PATCH 08/15] LR-PREF-INTERFACE: What's New and parity checklist for Stars on hover grid badges (folded in from #2163) Co-Authored-By: Claude Opus 5.5 --- docs/parity-checklist.md | 7 +++---- docs/whats-new.md | 6 ++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index c3f8829185..dc50c45caa 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -101,10 +101,8 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-LIB-OFFLINE | Keep album offline | P2 | 🚫 | | not applicable: local-first library | | LR-LIB-TARGET | Target album | P2 | ✅ | `cmd:album.setTarget`, `cmd:album.toggleTarget` | see LRC-LIB-COLLECTIONS | | LR-LIB-RATING | Star ratings | P0 | ✅ | `cmd:photo.rate` (`advance`), `cmd:photo.decreaseRating`, `cmd:photo.increaseRating`, `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/widgets/rating.rs` | one shared star row in the bottom bar, Info panel and filter bar (hover previews, ←/→ on a focused star) and one painter for badges (grid cells, filmstrip, Compare caption); menu rows with star text (Photo ▸ Set Rating, Select By Rating, the grid context menu) are separate menu items, unchanged; 0 clears; 1–5 set; Shift+0–5 applies and advances once, including with Auto Advance. A rating, flag or label that takes the active photo out of the view (filter bar, Picks, smart album) makes the photo after it active (the one before at the end), and Shift / Auto Advance doesn't step past it (#2312). Default grid brackets adjust each photo by one, clamped to 0–5; one batch undo and AutoWrite. Batch grid and undo/redo regressions; macOS native ownership corrected (PR #261) | -| LR-LIB-FLAG | Pick / reject flags | P0 | ✅ | `cmd:photo.pick`, `cmd:photo.reject`, `cmd:photo.unflag`, `cmd:photo.flag`, `crates/ui-egui/src/thumb.rs` | a rejected photo is dimmed on the grids and on the filmstrip, under its marks (the flag keeps its red); P pick, X reject, U clear; Shift+P picks and advances in both grids (Presets elsewhere); Shift+X/U and legacy Shift+Z advance; no flag cycle; rejection does not delete the file | +| LR-LIB-FLAG | Pick / reject flags | P0 | ✅ | `cmd:photo.pick`, `cmd:photo.reject`, `cmd:photo.unflag`, `cmd:photo.flag`, `crates/ui-egui/src/thumb.rs` | a rejected photo is dimmed on the grids and on the filmstrip, under its marks (the flag keeps its red); P pick, X reject, U clear; Shift+P picks and advances in both grids (Presets elsewhere); Shift+X/U and legacy Shift+Z advance; no flag cycle; rejection does not delete the file; a pick shows as a filled flag on thumbnails, in Compare, in the loupe and on the Pick button, a reject outlined (#1013) | | LR-LIB-LABEL | Colour labels | P1 | ✅ | `cmd:photo.label`, `cmd:label.setNames`, `cmd:label.names`, `cmd:dialog.labelNames`, keys 6–9 in `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/thumb.rs` | Photo menu and grid context menu (coloured, named), Info-panel swatches, the label is a dot in the marks row on every surface (justified grid, square grid, filmstrip) plus translucent colour on the square-grid and filmstrip surrounds; nothing is laid over the photo's pixels (the justified grid's tinted footer band is gone). On the justified grid, which has no surround, the dot is kept before the stars and flag on a narrow photo and stays when Ratings & flags is Never; elsewhere the surround says the label; colour-label toasts have pale matching backgrounds; setting/clearing through keys (including Shift), menus or Info swatches shows the same bottom toast as ratings, with the colour/custom name; editable label names (undoable, journaled); no purple key (as in Lightroom), no custom extra labels | -| LR-LIB-FLAG | Pick / reject flags | P0 | ✅ | `cmd:photo.pick`, `cmd:photo.reject`, `cmd:photo.unflag`, `cmd:photo.flag` | P pick, X reject, U clear; Shift+P picks and advances in both grids (Presets elsewhere); Shift+X/U and legacy Shift+Z advance; no flag cycle; rejection does not delete the file; a pick shows as a filled flag on thumbnails, in Compare, in the loupe and on the Pick button, a reject outlined (#1013) | -| LR-LIB-LABEL | Colour labels | P1 | ✅ | `cmd:photo.label`, `cmd:photo.clearLabel`, `cmd:label.setNames`, `cmd:label.names`, `cmd:dialog.labelNames`, keys 6–9 in `crates/ui-egui/src/shortcuts.rs`, `crates/ui-egui/src/thumb.rs` | Photo menu and grid context menu (coloured, named), Info-panel swatches, the label is a dot in the marks row on every surface (justified grid, square grid, filmstrip) plus translucent colour on the square-grid and filmstrip surrounds; nothing is laid over the photo's pixels (the justified grid's tinted footer band is gone); colour-label toasts have pale matching backgrounds; setting/clearing through keys (including Shift), menus or Info swatches shows the same bottom toast as ratings, with the colour/custom name; editable label names (undoable, journaled); no purple key (as in Lightroom), Clear Color Label (`photo.clearLabel`) has no key until one is given in Help → Keyboard Shortcuts, no custom extra labels | | LR-LIB-KEYWORD | Keywords | P0 | ✅ | `cmd:panel.keywords`, `cmd:photo.setMeta` (`addKeywords`/`removeKeywords`), `cmd:keyword.list`, `cmd:keyword.rename`, `cmd:keyword.delete`, `cmd:keyword.merge`, `cmd:keyword.suggest`, `crates/catalog/src/keywords.rs`, `crates/ui-egui/src/panels/left.rs` | left-panel keyword tree with counts (click filters, children included; context menu rename / merge / delete / add / remove); library-wide ops are one undo step and replay from the op log; suggestions (co-occurring / most used / completions) in the Keywords panel; keywords reorganize by drag and drop in the Keyword List (LRC-LIB-KEYWORDS) | | LR-LIB-PEOPLE | People / faces | P2 | 🟡 | `cmd:faces.detect`, `cmd:view.people`, `cmd:view.faceBoxes`, `cmd:photo.removeRegion`, `cmd:photo.setRegion`, `cmd:library.filter`, `crates/ui-egui/src/panels/people.rs`, `crates/catalog/src/query.rs` (`people`), `crates/engine/src/media.rs` (`face_job`), `crates/meta/src/xmp.rs` | MVP: named face regions read from XMP (MWG-RS, read-only, see `docs/xmp-interop.md`; clipped to the photo; Lightroom's `Rotation` of ±π/2 and π handled, mirrored orientations taken as written; boxes follow Rotate Left/Right and flips; a sidecar stating `mwg-rs:Regions`, even empty, replaces the photo's on re-read, one without leaves them) become cards in the People view (View ▸ People, or the People button in the toolbar): a close-up of the person's largest face, name and photo count; a click filters the grid (`person` in `library.filter`, `person:` search token, filter chip). Face boxes in the loupe can be switched off (View ▸ Face Boxes, toolbar) resized with eight drag handles and removed with the × shown on hover (catalog-only and undoable, one undo step per drag; the sidecar is never rewritten for either); no moving a box by dragging it yet. Photo ▸ Detect Faces (`cmd:faces.detect`) finds faces with the YuNet detector (pure Rust, about 200 ms a photo, matches OpenCV's own YuNet on a 45-photo test set; the 232 KB model is a one-time download offered in the same step, never part of LightCraft) and adds them as unnamed boxes; names are suggested from the faces already named (recognition models are opt-in downloads, run on the CPU in a background thread; a face is named only when you confirm it); a person's page shows their cropped faces and the unnamed faces that look like them (LRC-LIB-PEOPLE), with a user-triggered ↑ action or targeted A key to name all shown suggestions at or above one score in one undo step; with recognition on, a background scan finds faces in photos that have none and embeds every face (one to three worker threads, raws through their embedded preview); an Unnamed faces section orders faces by likeness and names a selected group at once; no separated clusters, no manual tagging, no writing regions back | | LR-LIB-STACK | Stacks | P1 | ✅ | `cmd:stack.group`, `cmd:stack.ungroup`, `cmd:stack.toggle`, `cmd:stack.setTop`, `cmd:stack.remove`, `cmd:stack.auto`, `cmd:photo.delete`, `crates/catalog/src/stacks.rs`, `crates/ui-egui/src/thumb.rs` | grid/filmstrip count badges (the same badge on both, a click expands or collapses the stack, selected or not, one translated tooltip; widgets `stack:`, `film:stack:`), expand/collapse (a click or double-click on a grid badge toggles the stack once, #2233), auto-stack by capture time; delete / remove folder drop the photo from the stack so `i/n` updates (#1493); no visual-similarity auto-stack | @@ -434,7 +432,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-PREF-GENERAL | General settings | P0 | ✅ | `cmd:app.settings`, `cmd:app.openLibrary`, `crates/ui-egui/src/dialogs/settings.rs`, `crates/ui-egui/src/panels/notices.rs` | General / Import / Performance / Display / Interface tabs; app settings in ui.json (written atomically, saved when the library changes and every few seconds), library settings in prefs.json; At launch: open the last library or ask (see LRC-LIB-CATALOG-SWITCH); a damaged settings file is kept as `.corrupt-