PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Notices: auto-hide after a delay, with Interface preferences (#2022) (#2100)
Max Murphy995c895c3347
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex 1347c19d4..1ffba0686 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -238,6 +238,11 @@ pub struct Interface {/// own one-row title bar (tiling window managers, desktops that draw their own decorations;/// #1271, #1316). Read when the app starts. macOS always uses the system's.pub system_title_bar: bool,+ /// Notices (the lower-right cards) hide themselves after+ /// [`Interface::notification_duration_seconds`] unless the pointer rests on them (#2022).+ pub notification_auto_hide: bool,+ /// Seconds a notice stays on screen before it hides itself (Auto Hide Notifications).+ pub notification_duration_seconds: u32,}impl Default for Interface {@@ -259,6 +264,8 @@ impl Default for Interface {show_tooltips: true,show_bounding_box_when_dragging_layer: false,system_title_bar: false,+ notification_auto_hide: true,+ notification_duration_seconds: 6,}}}@@ -945,6 +952,7 @@ pub fn range(path: &str) -> Option<(f64, f64)> {Some(match path {"fileHandling.autosaveMinutes" => (1.0, 240.0),"fileHandling.recentFileCount" => (0.0, 100.0),+ "interface.notificationDurationSeconds" => (1.0, 120.0),"export.jpegQuality" | "export.webpQuality" => (1.0, 100.0),"performance.memoryUsageMb" => (256.0, 1_048_576.0),"performance.historyStates" => (1.0, 1000.0),diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rsindex 4c3419250..4ad258ff5 100644--- a/crates/engine/src/prefs/tests.rs+++ b/crates/engine/src/prefs/tests.rs@@ -404,6 +404,36 @@ fn gpu_backend_round_trips_and_validates() {}}+/// #2022: notices auto-hide after a user-set delay by default; both settings round-trip.+#[test]+fn notification_autohide_preferences() {+ let p = Preferences::default();+ assert!(p.interface.notification_auto_hide);+ assert_eq!(p.interface.notification_duration_seconds, 6);+ assert_eq!(range("interface.notificationDurationSeconds"), Some((1.0, 120.0)));++ let mut s = Session::new();+ s.execute("prefs.set", json!({"path": "interface.notificationAutoHide", "value": false})).unwrap();+ s.execute("prefs.set", json!({"path": "interface.notificationDurationSeconds", "value": 30})).unwrap();+ assert!(!s.prefs().interface.notification_auto_hide);+ assert_eq!(s.prefs().interface.notification_duration_seconds, 30);+ // Out-of-range and wrong-typed values are rejected and change nothing.+ for bad in [json!(0), json!(121), json!("soon")] {+ assert!(s.execute("prefs.set", json!({"path": "interface.notificationDurationSeconds", "value": bad})).is_err());+ }+ assert_eq!(s.prefs().interface.notification_duration_seconds, 30);++ let mut t = Session::new();+ t.load_prefs_json(&s.prefs_to_json()).unwrap();+ assert!(!t.prefs().interface.notification_auto_hide);+ assert_eq!(t.prefs().interface.notification_duration_seconds, 30);+ // Older files without the settings keep the defaults.+ let mut u = Session::new();+ u.load_prefs_json(r#"{"interface": {"theme": "studio"}}"#).unwrap();+ assert!(u.prefs().interface.notification_auto_hide);+ assert_eq!(u.prefs().interface.notification_duration_seconds, 6);+}+#[test]fn linux_only_preferences_show_only_on_linux() {assert_eq!(is_hidden("performance.linuxDisplayServer"), !cfg!(target_os = "linux"));diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 1f16d64de..cac622f36 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -2309,6 +2309,8 @@ fontWeight Italic KurzívaCycle Orientation Přepnout orientaciSet the overlay options for the Crop tool Nastavit volby překryvu pro nástroj OříznutíAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt+klik převzalo pracovní prostředí, které pomocí Alt+tažení přesouvá okna. Nastavte jeho klávesu pro přesun oken na Super, nebo zamkněte Alt v nabídce Okno › Modifikační klávesy.+ Auto Hide Notifications Automaticky skrývat oznámení+ Notification Duration (seconds) Trvání oznámení (sekundy)Appearance Mode Režim vzhleduDark Theme Tmavý motivLight Theme Světlý motivdiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex 1a1291405..b72dded81 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -2348,6 +2348,8 @@ fontWeight Italic KursivCycle Orientation Ausrichtung wechselnSet the overlay options for the Crop tool Überlagerungsoptionen für das Freistellungswerkzeug festlegenAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Der Alt-Klick ging an die Arbeitsumgebung, die Fenster mit Alt-Ziehen verschiebt. Stelle dort die Taste zum Verschieben von Fenstern auf Super oder raste Alt unter Fenster › Modifikatortasten ein.+ Auto Hide Notifications Benachrichtigungen automatisch ausblenden+ Notification Duration (seconds) Dauer der Benachrichtigung (Sekunden)Appearance Mode ErscheinungsmodusDark Theme Dunkles DesignLight Theme Helles Designdiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex a8d57ae6b..f127bf31b 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -3419,6 +3419,8 @@ fontWeight Thin Πολύ λεπτάCycle Orientation Εναλλαγή προσανατολισμούSet the overlay options for the Crop tool Ορισμός επιλογών επικάλυψης για το εργαλείο ΠερικοπήAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Το Alt-κλικ πήγε στο περιβάλλον εργασίας, που μετακινεί παράθυρα με Alt-σύρσιμο. Ορίστε το πλήκτρο μετακίνησης παραθύρων του σε Super ή κλειδώστε το Alt στο Παράθυρο › Πλήκτρα τροποποίησης.+ Auto Hide Notifications Αυτόματη απόκρυψη ειδοποιήσεων+ Notification Duration (seconds) Διάρκεια ειδοποίησης (δευτερόλεπτα)Appearance Mode Λειτουργία εμφάνισηςPro Medium Pro MediumStudio Light Studio Lightdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 7f2cfb6f8..fc99c2366 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -2377,6 +2377,8 @@ fontWeight Italic CursivaCycle Orientation Alternar orientaciónSet the overlay options for the Crop tool Definir las opciones de superposición de la herramienta RecortarAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. El Alt+clic lo recibió el escritorio, que mueve ventanas con Alt+arrastrar. Cambia su tecla para mover ventanas a Super o bloquea Alt en Ventana › Teclas modificadoras.+ Auto Hide Notifications Ocultar notificaciones automáticamente+ Notification Duration (seconds) Duración de la notificación (segundos)Appearance Mode Modo de aparienciaDark Theme Tema oscuroLight Theme Tema clarodiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 4bc8db7f0..789060d4f 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -2730,6 +2730,8 @@ fontWeight Italic ItaliqueCycle Orientation Changer d’orientationSet the overlay options for the Crop tool Définir les options de superposition de l’outil RecadrageAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. L’Alt-clic a été intercepté par le bureau, qui déplace les fenêtres avec Alt-glisser. Réglez sa touche de déplacement des fenêtres sur Super, ou verrouillez Alt dans Fenêtre › Touches de modification.+ Auto Hide Notifications Masquer automatiquement les notifications+ Notification Duration (seconds) Durée de la notification (secondes)Appearance Mode Mode d’apparenceDark Theme Thème sombreLight Theme Thème clairdiff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 25df5c1c3..5a779c728 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -2717,6 +2717,8 @@ fontWeight Italic MiringCycle Orientation Ganti OrientasiSet the overlay options for the Crop tool Atur opsi overlay untuk alat CropAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt-klik diambil oleh desktop, yang memindahkan jendela dengan Alt-seret. Atur tombol pemindah jendelanya ke Super, atau kunci Alt di Jendela › Tombol Pengubah.+ Auto Hide Notifications Sembunyikan notifikasi secara otomatis+ Notification Duration (seconds) Durasi notifikasi (detik)Appearance Mode Mode tampilanDark Theme Tema gelapLight Theme Tema terangdiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex a59bf9baf..62608d3b7 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -2379,6 +2379,8 @@ fontWeight Italic CorsivoCycle Orientation Cambia orientamentoSet the overlay options for the Crop tool Imposta le opzioni di sovrapposizione dello strumento TaglierinaAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. L’Alt-click è andato al desktop, che sposta le finestre con Alt-trascina. Imposta il suo tasto per spostare le finestre su Super, oppure blocca Alt in Finestra › Tasti modificatori.+ Auto Hide Notifications Nascondi automaticamente le notifiche+ Notification Duration (seconds) Durata della notifica (secondi)Appearance Mode Modalità aspettoDark Theme Tema scuroLight Theme Tema chiarodiff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 29a8f4437..42c66a8b3 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -3333,6 +3333,8 @@ fontWeight Italic 斜体Cycle Orientation 方向を切り替えSet the overlay options for the Crop tool 切り抜きツールのオーバーレイオプションを設定Alt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt+クリックはデスクトップに取られました(Alt+ドラッグでウィンドウを移動する設定です)。デスクトップのウィンドウ移動キーを Super に変更するか、ウィンドウ › 修飾キーで Alt を固定してください。+ Auto Hide Notifications 通知を自動的に隠す+ Notification Duration (seconds) 通知の表示時間(秒)Appearance Mode 外観モードDark Theme ダークテーマLight Theme ライトテーマdiff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex a2e299bbe..9b77c05a2 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -2888,6 +2888,8 @@ fontWeight Italic 기울임Cycle Orientation 방향 순환Set the overlay options for the Crop tool 자르기 도구의 오버레이 옵션 설정Alt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt 클릭이 데스크톱으로 전달되었습니다. 데스크톱이 Alt 드래그로 창을 이동합니다. 창 이동 키를 Super로 바꾸거나 창 › 보조 키에서 Alt를 고정하세요.+ Auto Hide Notifications 알림 자동 숨기기+ Notification Duration (seconds) 알림 지속 시간(초)Appearance Mode 화면 모드Dark Theme 어두운 테마Light Theme 밝은 테마diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex febc6ac09..8af68e5ad 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -3494,6 +3494,8 @@ cameraRaw Whites WittenCycle Orientation Oriëntatie wisselenSet the overlay options for the Crop tool Overlay-opties voor het gereedschap Uitsnijden instellenAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. De Alt-klik ging naar het bureaublad, dat vensters verplaatst met Alt-slepen. Stel daar de toets voor het verplaatsen van vensters in op Super, of vergrendel Alt via Venster › Wijzigingstoetsen.+ Auto Hide Notifications Meldingen automatisch verbergen+ Notification Duration (seconds) Duur van melding (seconden)Appearance Mode WeergavemodusNext Appearance Mode Volgende weergavemodusdiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 429371983..eb3696788 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -3332,6 +3332,8 @@ cameraRaw Roughness ChropowatośćCycle Orientation Przełącz orientacjęSet the overlay options for the Crop tool Ustaw opcje nakładki narzędzia KadrowanieAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt+kliknięcie przejęło środowisko pulpitu, które przesuwa okna przez Alt+przeciąganie. Ustaw w nim klawisz przesuwania okien na Super lub zablokuj Alt w Okno › Klawisze modyfikujące.+ Auto Hide Notifications Automatycznie ukrywaj powiadomienia+ Notification Duration (seconds) Czas trwania powiadomienia (sekundy)Appearance Mode Tryb wygląduDark Theme Ciemny motywLight Theme Jasny motywdiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 7ccc6074b..7293ba6af 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -2738,6 +2738,8 @@ fontWeight Italic ItálicoCycle Orientation Alternar orientaçãoSet the overlay options for the Crop tool Definir as opções de sobreposição da ferramenta Corte demarcadoAlt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. O Alt-clique foi para o desktop, que move janelas com Alt-arrastar. Mude a tecla de mover janelas dele para Super ou trave o Alt em Janela › Teclas modificadoras.+ Auto Hide Notifications Ocultar notificações automaticamente+ Notification Duration (seconds) Duração da notificação (segundos)Appearance Mode Modo de aparênciaDark Theme Tema escuroLight Theme Tema clarodiff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex e735376ae..6966f3f7f 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2584,6 +2584,8 @@ fontWeight Italic КурсивCycle Orientation Сменить ориентациюSet the overlay options for the Crop tool Задать параметры перекрытия для инструмента «Рамка»Alt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt+щелчок перехватило окружение рабочего стола: оно перемещает окна через Alt+перетаскивание. Назначьте для перемещения окон клавишу Super или зафиксируйте Alt в меню Окно › Клавиши-модификаторы.+ Auto Hide Notifications Автоскрытие уведомлений+ Notification Duration (seconds) Длительность уведомления (секунды)Appearance Mode Режим оформленияDark Theme Тёмная темаLight Theme Светлая темаdiff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex f61c18dae..dea4e8535 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -3419,6 +3419,8 @@ cameraRaw Masking МаскуванняCycle Orientation Змінити орієнтаціюSet the overlay options for the Crop tool Задати параметри накладання для інструмента «Рамка»Alt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt-клік перехопило робоче середовище, яке переміщує вікна через Alt-перетягування. Призначте для переміщення вікон клавішу Super або зафіксуйте Alt у меню Вікно › Клавіші-модифікатори.+ Auto Hide Notifications Автоматично приховувати сповіщення+ Notification Duration (seconds) Тривалість сповіщення (секунди)Appearance Mode Режим виглядуDark Theme Темна темаdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex 153d6715a..346fcc45b 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -2317,6 +2317,8 @@ fontWeight Italic 斜体Cycle Orientation 循环切换取向Set the overlay options for the Crop tool 设置裁剪工具的叠加选项Alt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt 单击被桌面环境截获了,它用 Alt 拖动来移动窗口。请把桌面的窗口移动键改为 Super,或在 窗口 › 修饰键 中锁定 Alt。+ Auto Hide Notifications 自动隐藏通知+ Notification Duration (seconds) 通知持续时间(秒)Appearance Mode 外观模式Dark Theme 深色主题Light Theme 浅色主题diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex a2ed9db59..ccfdfdd87 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -2286,6 +2286,8 @@ fontWeight Italic 斜體Cycle Orientation 循環切換方向Set the overlay options for the Crop tool 設定裁切工具的覆蓋選項Alt-click went to the desktop, which moves windows with Alt-drag. Set its window-move key to Super, or latch Alt in Window › Modifier Keys. Alt 按一下被桌面環境攔截了,它用 Alt 拖曳來移動視窗。請把桌面的視窗移動鍵改為 Super,或在 視窗 › 輔助鍵 中鎖定 Alt。+ Auto Hide Notifications 自動隱藏通知+ Notification Duration (seconds) 通知持續時間(秒)Appearance Mode 外觀模式Dark Theme 深色主題Light Theme 淺色主題diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex f8d97f85b..e532bbd33 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -408,6 +408,10 @@ pub struct PhotocraftApp {pub live_adjust: Option<(photocraft_doc::LayerId, Value)>,/// Frames rendered (for tests and the status bar).pub frame: u64,+ /// The pointer rested on the notice stack last frame. Used to give a fresh auto-hide delay in+ /// the frame the pointer leaves, so a long stationary hover never counts as elapsed time+ /// (#2022); set by `notices::show`.+ pub(crate) notices_hovered: bool,/// Apply theme on first frame.styled: bool,/// Whether the window uses an integrated (transparent) macOS title bar.@@ -574,6 +578,7 @@ impl PhotocraftApp {input_waiters: Vec::new(),live_adjust: None,frame: 0,+ notices_hovered: false,styled: false,integrated_titlebar: false,custom_titlebar: false,diff --git a/crates/ui-egui/src/notices.rs b/crates/ui-egui/src/notices.rsindex 75889979f..786cf6168 100644--- a/crates/ui-egui/src/notices.rs+++ b/crates/ui-egui/src/notices.rs@@ -30,6 +30,10 @@ pub struct Notice {/// `{name}` values filled into the title and lines after they are translated.#[serde(default, skip_serializing_if = "Vec::is_empty")]pub args: Vec<(String, String)>,+ /// egui input time (seconds) this notice was first drawn; the auto-hide timer runs from here+ /// and is reset while the pointer rests on the stack (issue #2022). `None` until first shown.+ #[serde(default, skip_serializing_if = "Option::is_none")]+ pub shown_at: Option<f64>,}impl Notice {@@ -43,7 +47,7 @@ impl Notice {/// Show a notice (newest last); returns its id.pub fn post(app: &mut PhotocraftApp, title: impl Into<String>, lines: Vec<String>, error: bool, dismiss_pref: Option<&str>) -> u64 {let id = app.ui.alloc_id();- app.ui.notices.push(Notice { id, title: title.into(), lines, error, dismiss_pref: dismiss_pref.map(str::to_owned), args: Vec::new() });+ app.ui.notices.push(Notice { id, title: title.into(), lines, error, dismiss_pref: dismiss_pref.map(str::to_owned), args: Vec::new(), shown_at: None });cap_notices(app);id}@@ -139,15 +143,53 @@ pub fn error(app: &mut PhotocraftApp, message: String) {post(app, message, Vec::new(), true, None);}-/// Draw the notices; each has a close button.+/// Auto-hide (issue #2022): drop notices whose delay has elapsed, pausing the timers of any the+/// pointer is resting on. `hovered` is true when the pointer is over the notice stack; `just_left`+/// is true on the frame it moves away. In both cases the timers restart from `now`, so a long+/// stationary hover is never counted as elapsed time. Returns the seconds until the next notice+/// would expire, so the caller can request a repaint then.+fn expire(app: &mut PhotocraftApp, now: f64, hovered: bool, just_left: bool, auto_hide: bool, duration: f64) -> Option<f64> {+ if !auto_hide {+ return None;+ }+ let mut expired = Vec::new();+ let mut next = f64::INFINITY;+ for n in &mut app.ui.notices {+ if n.shown_at.is_none() {+ n.shown_at = Some(now);+ }+ if hovered {+ n.shown_at = Some(now);+ continue;+ }+ if just_left {+ n.shown_at = Some(now);+ }+ let shown_at = n.shown_at.unwrap_or(now);+ let elapsed = (now - shown_at).max(0.0);+ if elapsed >= duration {+ expired.push(n.id);+ } else {+ next = next.min(duration - elapsed);+ }+ }+ if !expired.is_empty() {+ app.ui.notices.retain(|n| !expired.contains(&n.id));+ }+ next.is_finite().then_some(next)+}++/// Draw the notices; each has a close button. When Interface › Notification › Auto Hide Notices+/// is on, a notice disappears once its delay is up unless the pointer rests on the stack.pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {if app.ui.notices.is_empty() {+ app.notices_hovered = false;return;}let t = crate::theme::Tokens::get(ctx);let mut dismiss_id = None;// Clear the status bar (~24 px) and leave the dock's edge some air.- egui::Area::new(egui::Id::new("photocraft-notices"))+ let area = egui::Area::new(egui::Id::new("photocraft-notices")).order(egui::Order::Foreground).anchor(egui::Align2::RIGHT_BOTTOM, egui::vec2(-16.0, -36.0)).interactable(true)@@ -186,6 +228,25 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {if let Some(id) = dismiss_id {dismiss(app, id);}+ let (auto_hide, duration) = {+ let i = &app.session.prefs().interface;+ (i.notification_auto_hide, f64::from(i.notification_duration_seconds.max(1)))+ };+ let now = ctx.input(|input| input.time);+ let hovered = ctx.pointer_hover_pos().is_some_and(|p| area.response.rect.contains(p));+ // The frame the pointer leaves the stack starts a fresh delay, so time spent hovering never+ // counts towards the auto-hide (#2022).+ let just_left = std::mem::replace(&mut app.notices_hovered, hovered) && !hovered;+ let before = app.ui.notices.len();+ let next = expire(app, now, hovered, just_left, auto_hide, duration);+ if app.ui.notices.len() < before {+ // The cards dropped this frame were already painted by it: ask for another frame at once+ // so the refreshed stack is drawn without waiting for unrelated input.+ ctx.request_repaint();+ }+ if let Some(wait) = next {+ ctx.request_repaint_after(std::time::Duration::try_from_secs_f64(wait).unwrap_or_default());+ }}#[cfg(test)]@@ -318,4 +379,69 @@ mod tests {dismiss(&mut app, id);assert_eq!(app.session.prefs().dialogs.get("ui.testNoticeDismissed").and_then(serde_json::Value::as_bool), Some(true));}++ #[test]+ fn notices_auto_hide_after_their_delay() {+ let mut app = PhotocraftApp::new(Session::new(), Services::default());+ post(&mut app, "Transient", Vec::new(), false, None);+ // The first draw stamps the timer and schedules the hide.+ assert_eq!(expire(&mut app, 100.0, false, false, true, 6.0), Some(6.0));+ assert_eq!(app.ui.notices.len(), 1);+ // Still there just before the delay, the next repaint a second away.+ assert_eq!(expire(&mut app, 105.0, false, false, true, 6.0), Some(1.0));+ assert_eq!(app.ui.notices.len(), 1);+ // Gone once the delay has elapsed.+ assert_eq!(expire(&mut app, 106.0, false, false, true, 6.0), None);+ assert!(app.ui.notices.is_empty());+ }++ #[test]+ fn hover_pauses_the_autohide_timer() {+ let mut app = PhotocraftApp::new(Session::new(), Services::default());+ post(&mut app, "Transient", Vec::new(), false, None);+ // While the pointer rests on the stack the timer keeps resetting: it never expires.+ for t in [5.0, 6.0, 7.0, 100.0] {+ assert_eq!(expire(&mut app, t, true, false, true, 6.0), None, "paused at {t}");+ assert_eq!(app.ui.notices.len(), 1, "still shown at {t}");+ }+ }++ #[test]+ fn leaving_a_long_hover_gives_a_fresh_delay() {+ let mut app = PhotocraftApp::new(Session::new(), Services::default());+ post(&mut app, "Transient", Vec::new(), false, None);+ // Hovering starts the pause...+ assert_eq!(expire(&mut app, 0.0, true, false, true, 6.0), None);+ // ...and the pointer then rests still for far longer than the delay, so no frame+ // refreshes the stamp. The leave frame must restart the timer, not expire at once.+ assert_eq!(expire(&mut app, 10.0, false, true, true, 6.0), Some(6.0));+ assert_eq!(app.ui.notices.len(), 1, "leaving a hover is not elapsed time");+ }++ #[test]+ fn autohide_can_be_switched_off() {+ let mut app = PhotocraftApp::new(Session::new(), Services::default());+ post(&mut app, "Persistent", Vec::new(), false, None);+ assert_eq!(expire(&mut app, 0.0, false, false, false, 6.0), None);+ assert_eq!(expire(&mut app, 1_000_000.0, false, false, false, 6.0), None);+ assert_eq!(app.ui.notices.len(), 1, "off: the notice stays until dismissed");+ }++ /// #2022 review: the frame that drops a notice has already painted it, so it must ask for+ /// another frame at once; otherwise the card lingers until unrelated input.+ #[test]+ fn expiring_a_notice_requests_a_frame_to_clear_it() {+ let mut app = PhotocraftApp::new(Session::new(), Services::default());+ post(&mut app, "Transient", Vec::new(), false, None);+ let ctx = egui::Context::default();+ let mut out = ctx.run_ui(Default::default(), |ui| show(&mut app, ui.ctx()));+ out.textures_delta.clear();+ assert_eq!(app.ui.notices.len(), 1);+ // Past the 6 s default: the notice is dropped and a repaint is requested in the same frame.+ let input = egui::RawInput { time: Some(10.0), ..Default::default() };+ let mut out = ctx.run_ui(input, |ui| show(&mut app, ui.ctx()));+ out.textures_delta.clear();+ assert!(app.ui.notices.is_empty());+ assert!(ctx.has_requested_repaint(), "the frame that drops a notice asks for another");+ }}diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rsindex 90f016c7b..8628cc3b9 100644--- a/crates/ui-egui/src/prefs_ui.rs+++ b/crates/ui-egui/src/prefs_ui.rs@@ -900,6 +900,13 @@ fn humanize(key: &str) -> String {if key == "webpQuality" {return "Quality".into();}+ // The auto-hide notice settings read best with their own labels (Interface › Notification, #2022).+ if key == "notificationAutoHide" {+ return "Auto Hide Notifications".into();+ }+ if key == "notificationDurationSeconds" {+ return "Notification Duration (seconds)".into();+ }let mut s = String::new();for (i, ch) in key.chars().enumerate() {if i == 0 {diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 4dbb42023..699e4ce1c 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 15 not run, 7 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 4 | 12 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 || [Tools](#tools) | 17 | 14 | 8 | |-| [Workspace and UI](#workspace-and-ui) | 5 | 7 | 11 | settings that do nothing: 48 of 144 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 5 | 7 | 11 | settings that do nothing: 48 of 146 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) || [Reliability](#reliability) | 5 | 0 | 2 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -172,7 +172,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 48 of 144** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.+**Settings that do nothing: 48 of 146** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.Unread: `general.color_picker`, `general.beep_when_done`, `general.resize_image_during_place`, `general.always_create_smart_objects_when_placing`, `general.animated_zoom`, `general.zoom_resizes_windows`, `interface.dynamic_color_sliders`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.open_documents_as_tabs`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `tools.enable_flick_panning`, `tools.vary_round_brush_hardness_on_hud`, `tools.show_transformation_values`, `tools.double_click_layer_mask_launches_select_and_mask`, `file_handling.image_previews`, `file_handling.save_in_background`, `file_handling.ignore_exif_profile_tag`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `cursors.brush_preview_color`, `units_and_rulers.type_units`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `units_and_rulers.print_resolution`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.smart_quotes`, `type_.missing_glyph_protection`, `type_.show_font_names_in_english`, `type_.text_engine`, `type_.font_preview`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `enhanced_controls.zoom_with_trackpad_pinch`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.