LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
egui-037: preserve modal input ownership and packaged font notices
skylar taylor-barrickc627ce7210c4
diff --git a/NOTICE b/NOTICEindex c18729355..39eb49db2 100644--- a/NOTICE+++ b/NOTICE@@ -12,7 +12,9 @@ Third-party materialThis product bundles third-party material under its own licenses, listed below. The per-filelist (author, source, license) is in assets/ATTRIBUTION.md.-Inter (assets/fonts/Inter-*.ttf) — SIL Open Font License 1.1. See assets/fonts/OFL-Inter.txt.+Inter (assets/fonts/Inter-*.ttf) — SIL Open Font License 1.1. The licence text is+assets/fonts/OFL-Inter.txt in the source tree; release packages ship it beside NOTICE as+OFL-Inter.txt (Windows installers include it in FONT-LICENCES.txt).Showcase photographs by Ansel Adams, Dorothea Lange and NASA (docs/images/) — public domain. See assets/ATTRIBUTION.md.crates/raw/src/spectral_table.rs (lightcraft-raw) holds camera colour matrices derived from the@@ -68,6 +70,255 @@ under Creative Commons Attribution 4.0 (https://creativecommons.org/licenses/by/attribution: "GeoNames, geonames.org". The lookup code (crates/geocode) is our own.+epaint_default_fonts, the egui default-font crate LightCraft builds with, also bundles Hack Regular+and Ubuntu Light, and Noto Emoji Regular when egui's `monochrome_emoji_fonts` feature is on (the+LightCraft workspace enables both `default_fonts` and `monochrome_emoji_fonts` on egui 0.37). The+LightCraft binaries embed these faces unmodified, registered through egui's default font definitions.+Source for all of them (the same pin as the icon fonts below):+https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts++Hack Regular (Hack-Regular.ttf) is Copyright (c) 2018 Source Foundry Authors and+Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. It is licensed under the MIT License, and+the Bitstream Vera parts under the Bitstream Vera License with Reserved Font Names "Bitstream" and+"Vera": the font as a whole is MIT AND Bitstream Vera License. The work in the DejaVu project it+derives from was committed to the public domain.+The following text is reproduced verbatim from Hack-Regular.txt:++The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License++The work in the DejaVu project was committed to the public domain.++Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera"+MIT License++Copyright (c) 2018 Source Foundry Authors++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.+BITSTREAM VERA LICENSE++Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc.++Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:++The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces.++The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera".++This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names.++The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.++THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.++Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org.+++Ubuntu Light (Ubuntu-Light.ttf) is Copyright 2011 Canonical Ltd., was designed by Dalton Maag Ltd,+and is licensed under the Ubuntu Font Licence 1.0 (not the SIL Open Font License).+The following text is reproduced verbatim from UFL.txt; that file carries no copyright line, so the+copyright notice above is taken from the font's own name table:++-------------------------------+UBUNTU FONT LICENCE Version 1.0+-------------------------------++PREAMBLE+This licence allows the licensed fonts to be used, studied, modified and+redistributed freely. The fonts, including any derivative works, can be+bundled, embedded, and redistributed provided the terms of this licence+are met. The fonts and derivatives, however, cannot be released under+any other licence. The requirement for fonts to remain under this+licence does not require any document created using the fonts or their+derivatives to be published under this licence, as long as the primary+purpose of the document is not to be a vehicle for the distribution of+the fonts.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this licence and clearly marked as such. This may+include source files, build scripts and documentation.++"Original Version" refers to the collection of Font Software components+as received under this licence.++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to+a new environment.++"Copyright Holder(s)" refers to all individuals and companies who have a+copyright ownership of the Font Software.++"Substantially Changed" refers to Modified Versions which can be easily+identified as dissimilar to the Font Software by users of the Font+Software comparing the Original Version with the Modified Version.++To "Propagate" a work means to do anything with it that, without+permission, would make you directly or secondarily liable for+infringement under applicable copyright law, except executing it on a+computer or modifying a private copy. Propagation includes copying,+distribution (with or without modification and with or without charging+a redistribution fee), making available to the public, and in some+countries other activities as well.++PERMISSION & CONDITIONS+This licence does not grant any rights under trademark law and all such+rights are reserved.++Permission is hereby granted, free of charge, to any person obtaining a+copy of the Font Software, to propagate the Font Software, subject to+the below conditions:++1) Each copy of the Font Software must contain the above copyright+notice and this licence. These can be included either as stand-alone+text files, human-readable headers or in the appropriate machine-+readable metadata fields within text or binary files as long as those+fields can be easily viewed by the user.++2) The font name complies with the following:+(a) The Original Version must retain its name, unmodified.+(b) Modified Versions which are Substantially Changed must be renamed to+avoid use of the name of the Original Version or similar names entirely.+(c) Modified Versions which are not Substantially Changed must be+renamed to both (i) retain the name of the Original Version and (ii) add+additional naming elements to distinguish the Modified Version from the+Original Version. The name of such Modified Versions must be the name of+the Original Version, with "derivative X" where X represents the name of+the new work, appended to that name.++3) The name(s) of the Copyright Holder(s) and any contributor to the+Font Software shall not be used to promote, endorse or advertise any+Modified Version, except (i) as required by this licence, (ii) to+acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with+their explicit written permission.++4) The Font Software, modified or unmodified, in part or in whole, must+be distributed entirely under this licence, and must not be distributed+under any other licence. The requirement for fonts to remain under this+licence does not affect any document created using the Font Software,+except any version of the Font Software extracted from a document+created using the Font Software may only be distributed under this+licence.++TERMINATION+This licence becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF+COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER+DEALINGS IN THE FONT SOFTWARE.+++Noto Emoji Regular (NotoEmoji-Regular.ttf) is Copyright 2013 Google Inc. All Rights Reserved. It was+designed by the Monotype Design Team and is licensed under the SIL Open Font License 1.1.+The following text is reproduced verbatim from OFL.txt; that file carries no copyright line, so the+copyright notice above is taken from the font's own name table:++This Font Software is licensed under the SIL Open Font License,+Version 1.1.++This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font+creation efforts of academic and linguistic communities, and to+provide a free and open framework in which fonts may be shared and+improved in partnership with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply to+any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software+components as distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to,+deleting, or substituting -- in part or in whole -- any of the+components of the Original Version, by changing formats or by porting+the Font Software to a new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed,+modify, redistribute, and sell modified and unmodified copies of the+Font Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components, in+Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the+corresponding Copyright Holder. This restriction only applies to the+primary font name as presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created using+the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.++The UI's egui-icons.ttf subset and emoji-icon-font.ttf fallback are provided by epaint_default_fontsand registered through egui's default font definitions. They derive from emoji-icon-font byJohn Slegers, under the MIT License. The subset and full face share the following upstream notice.diff --git a/apps/lightcraft-web/src/web.rs b/apps/lightcraft-web/src/web.rsindex c2d7eb457..bd6426e53 100644--- a/apps/lightcraft-web/src/web.rs+++ b/apps/lightcraft-web/src/web.rs@@ -700,14 +700,18 @@ impl eframe::App for WebApp {self.save();}- fn raw_input_hook(&mut self, _ctx: &egui::Context, raw: &mut egui::RawInput) {- self.app.raw_input_hook(raw);+ fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {+ self.app.raw_input_hook(ctx, raw);}fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {// Drops are the UI phase's: a hidden `logic`/`run_logic` tick must not import them twice.+ // A prompt owns the library too: keep taking the queue only after it is gone, so a drop+ // during a notice cannot add photos behind it.let ctx = ui.ctx().clone();- self.import_dropped(&ctx);+ if !lightcraft_ui_egui::panels::notices::blocks_input(&self.app) {+ self.import_dropped(&ctx);+ }self.app.ui(ui);// eframe's web runner ignores `ViewportCommand::Title`: name the open photo in the page titlelet title = self.app.page_title(self.files.is_dirty() || self.flushing.get());diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rsindex 85ad652fb..f68018465 100644--- a/apps/lightcraft/src/main.rs+++ b/apps/lightcraft/src/main.rs@@ -75,8 +75,8 @@ impl eframe::App for App {self.0.logic(ctx);self.1.tick(&mut self.0, ctx);}- fn raw_input_hook(&mut self, _ctx: &egui::Context, raw: &mut egui::RawInput) {- self.0.raw_input_hook(raw);+ fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {+ self.0.raw_input_hook(ctx, raw);}fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {self.0.perf.host_frame_ms = frame.info().cpu_usage.map(|s| f64::from(s) * 1000.0);diff --git a/apps/lightcraft/src/native_menu.rs b/apps/lightcraft/src/native_menu.rsindex e9323a210..a5a14e208 100644--- a/apps/lightcraft/src/native_menu.rs+++ b/apps/lightcraft/src/native_menu.rs@@ -11,6 +11,11 @@//! - while a text field has keyboard focus, accelerators without ⌘ (`G`, `1`, `Delete`…) and the//! text-editing ones (⌘A/⌘C/⌘V/⌘X/⌘Z) are removed, so typing and text editing work; they come//! back when the field loses focus.+//!+//! Menu events never pass through the egui shortcut handler. [`NativeMenu::update`] therefore runs+//! every queued command through [`lightcraft_ui_egui::menubar::run_native_command`]: while the+//! blocking library window or a quit/settings notice owns input it drops the command (Settings…+//! and About included), and only Quit stays available for the host's existing confirmation.use std::collections::{HashMap, HashSet};use std::sync::mpsc::{Receiver, channel};@@ -480,17 +485,21 @@ impl NativeMenu {lightcraft_ui_egui::i18n::set_language(app.ui.language);let mut quit = false;while let Ok(key) = self.rx.try_recv() {- if key == QUIT {- quit = true;- continue;- }- if key == "app.about" || key == SETTINGS {- let _ = app.run(&key, serde_json::json!({}));+ // Resolve the native id to its command, then let the shared policy decide. Native menu+ // events never reach `shortcuts::handle`, so this is the one guard for AppKit's+ // accelerators and clicks: while the blocking library window or a quit/settings notice+ // owns input, a queued command is dropped (Quit stays for the existing confirmation).+ let (cmd, params) = if key == QUIT {+ (key, serde_json::json!({}))+ } else if key == "app.about" || key == SETTINGS {+ (key, serde_json::json!({}))+ } else if let Some(it) = self.items.get(&key) {+ (it.cmd.clone(), it.params.clone())+ } else {continue;- }- if let Some(it) = self.items.get(&key) {- let (cmd, params) = (it.cmd.clone(), it.params.clone());- let _ = lightcraft_ui_egui::menubar::run_item(app, &cmd, params);+ };+ if lightcraft_ui_egui::menubar::run_native_command(app, &cmd, params) == lightcraft_ui_egui::menubar::NativeCommand::Quit {+ quit = true;}}let bar = menu_bar(app);diff --git a/assets/ATTRIBUTION.md b/assets/ATTRIBUTION.mdindex 3bb745457..4bc2e927e 100644--- a/assets/ATTRIBUTION.md+++ b/assets/ATTRIBUTION.md@@ -9,6 +9,9 @@ covers a whole directory), or if a licence file referenced in the Licence column| Path | Asset | Creator | Source | Licence | Added | Modifications ||---|---|---|---|---|---|---|| `epaint_default_fonts::EGUI_ICONS`, `epaint_default_fonts::EMOJI_ICON` (dependency font inputs) | egui icon subset and monochrome fallback | John Slegers | [egui 6d518fc](https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts), [emoji-icon-font](https://github.com/jslegers/emoji-icon-font) | MIT (Copyright (c) 2014 John Slegers; full upstream text in `NOTICE`) | 2026-10-24 (notice audit) | egui-icons.ttf is the five-glyph subset; emoji-icon-font.ttf is the full fallback. Registered by production default font definitions; dependency assets unmodified here, no font file copied into this repository. |+| `epaint_default_fonts::HACK_REGULAR` (dependency font input) | Hack Regular (the monospace default) | Source Foundry Authors (built on the DejaVu project, which was committed to the public domain) and Bitstream Inc. | [egui 6d518fc](https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts) | MIT AND Bitstream Vera License (Copyright (c) 2018 Source Foundry Authors; Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.; full upstream texts in `NOTICE`) | 2026-10-25 (notice audit) | unmodified egui default font embedded in the binary and registered by the production default font definitions (egui's `default_fonts`); no font file copied into this repository |+| `epaint_default_fonts::UBUNTU_LIGHT` (dependency font input) | Ubuntu Light (the proportional default) | Canonical Ltd.; designed by Dalton Maag Ltd | [egui 6d518fc](https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts) | Ubuntu Font Licence 1.0, not the SIL Open Font License (Copyright 2011 Canonical Ltd.; full upstream text in `NOTICE`) | 2026-10-25 (notice audit) | unmodified egui default font embedded in the binary and registered by the production default font definitions (egui's `default_fonts`); no font file copied into this repository |+| `epaint_default_fonts::NOTO_EMOJI_REGULAR` (dependency font input) | Noto Emoji Regular | Google Inc.; designed by the Monotype Design Team | [egui 6d518fc](https://github.com/storytold/egui/tree/6d518fc799681571963842f95b55a6b68431b15a/crates/epaint_default_fonts/fonts) | SIL Open Font License 1.1 (Copyright 2013 Google Inc. All Rights Reserved.; full upstream text in `NOTICE`) | 2026-10-25 (notice audit) | unmodified egui default font embedded in the binary and registered by the production default font definitions (egui's `default_fonts` and `monochrome_emoji_fonts`); no font file copied into this repository || `assets/fonts/Inter-*.ttf` (Regular, Medium, SemiBold) | Inter | Rasmus Andersson | https://github.com/rsms/inter | SIL Open Font License 1.1 (`assets/fonts/OFL-Inter.txt`) | 2026-09-30 | none || `assets/app-icon/` (`lightcraft.svg` and the PNG/ICNS/ICO/SVG files derived from it) | LightCraft app icon (lynx) | LightCraft project owner (drawn in ArtCraft) | original work (vectorised from the owner's drawing; see `assets/app-icon/README.md`) | MIT OR Apache-2.0 (`assets/app-icon/LICENSE.txt`) | 2026-10-02 | vectorised to SVG; rendered to PNG/ICNS/ICO by `packaging/icons.sh` || `assets/camera-profiles/*.json` | Camera colour profiles (matrix + hue/saturation/value table), built into LightCraft | ILCE-7M4: Harald Hoyer | original work: fitted by `lightcraft-cli calibrate` to the contributor's own raw photos and their in-camera JPEGs (597 ILCE-7M4 photos, 2026); aggregate colour statistics only, no image content; no Adobe or third-party profile data | MIT OR Apache-2.0 | 2026-10-07 | none |@@ -41,6 +44,9 @@ covers a whole directory), or if a licence file referenced in the Licence column| `crates/ui-egui/locales/vi.json`, `crates/ui-egui/locales/vi-formats.json` | Vietnamese interface catalogs | @duydev (DUY Tran Nhat) with AI assistance (Cursor) | original work: translations of English source phrases; no external translation material | MIT OR Apache-2.0 (`LICENSE-MIT`, `LICENSE-APACHE`) | 2026-10-13 | plural-neutral counts, Vietnamese dates and weekdays, reviewed placeholders |Notes+- egui's default fonts (Hack, Ubuntu Light, Noto Emoji, egui-icons and emoji-icon-font) come from the+ `epaint_default_fonts` dependency, not from files in this repository; their creators, licences and the full+ upstream texts are recorded in the rows above and in `NOTICE`.- Fonts authored or published by Adobe (Source Sans/Serif/Code, Source Han, …) are not used, even though some areOFL-licensed: the asset rule excludes anything from Adobe. Source Sans 3 was removed on 2026-09-30 and replaced by Inter.- CJK fonts (BIZ UDPGothic, BIZ UDMincho, Shippori Mincho, Noto Sans CJK SC) are not in this repository. They live indiff --git a/crates/ui-egui/src/album_picker.rs b/crates/ui-egui/src/album_picker.rsindex 44c534743..1c59bcae8 100644--- a/crates/ui-egui/src/album_picker.rs+++ b/crates/ui-egui/src/album_picker.rs@@ -211,7 +211,7 @@ impl<'a> AlbumPicker<'a> {ui.add_sized(vec2(width, ui.spacing().interact_size.y), egui::Button::new(text.as_str()).truncate().right_text(" ")).on_hover_text(text);let arrow_color = crate::theme::Tokens::get(ui.ctx()).icon;disclosure(ui.painter(), egui::pos2(button.rect.right() - 10.0, button.rect.center().y), true, arrow_color);- register(ui.ctx(), format!("albumPicker:{id}"), button.rect);+ register(ui, format!("albumPicker:{id}"), button.rect);let key = egui::Id::unique(("albumPicker", id.as_str()));if button.clicked() {// open on the chosen album's folders, with the search empty and ready for typing@@ -232,7 +232,7 @@ impl<'a> AlbumPicker<'a> {}let search_box =ui.add(egui::TextEdit::singleline(&mut state.query).hint_text(crate::i18n::tr("Search albums")).desired_width(f32::INFINITY));- register(ui.ctx(), format!("albumPickerSearch:{id}"), search_box.rect);+ register(ui, format!("albumPickerSearch:{id}"), search_box.rect);if state.focus {search_box.request_focus();state.focus = false;@@ -252,7 +252,7 @@ impl<'a> AlbumPicker<'a> {let resp = ui.add_enabled(e.blocked.is_none(), egui::Button::selectable(Some(e.id) == chosen || highlighted, label).truncate()).on_hover_text(label);- register(ui.ctx(), format!("albumPickerItem:{}:{id}", e.id), resp.rect);+ register(ui, format!("albumPickerItem:{}:{id}", e.id), resp.rect);let resp = match &e.blocked {Some(why) => resp.on_disabled_hover_text(why.as_str()),None => resp,@@ -289,7 +289,7 @@ impl<'a> AlbumPicker<'a> {egui::TextStyle::Button.resolve(ui.style()),t.text_label,);- register(ui.ctx(), format!("albumPickerFolder:{}:{id}", e.id), r.rect);+ register(ui, format!("albumPickerFolder:{}:{id}", e.id), r.rect);// what assistive tools announce: the folder, and whether it is openlet name = e.name.clone();crate::widgets::announce_disclosure(&r, true, open, &name);diff --git a/crates/ui-egui/src/button.rs b/crates/ui-egui/src/button.rsindex ee397a78c..d3fa98821 100644--- a/crates/ui-egui/src/button.rs+++ b/crates/ui-egui/src/button.rs@@ -359,7 +359,7 @@ impl<'a> Button<'a> {ui.ctx().accesskit_node_builder(resp.id, |node| node.set_busy());}if let Some(w) = &self.widget {- crate::widgets::register(ui.ctx(), w.clone(), rect);+ crate::widgets::register(ui, w.clone(), rect);}let state = if !enabled {State::Disableddiff --git a/crates/ui-egui/src/canvas_keys.rs b/crates/ui-egui/src/canvas_keys.rsindex 1a4857372..d0c9ee3ad 100644--- a/crates/ui-egui/src/canvas_keys.rs+++ b/crates/ui-egui/src/canvas_keys.rs@@ -53,7 +53,7 @@ pub fn handle(ui: &mut Ui, key: &str, name: &str, value: String, at: Pos2) -> Haui.ctx().accesskit_node_builder(id, |node| {node.set_value(value);});- crate::widgets::register(ui.ctx(), format!("canvasHandle:{key}"), rect);+ crate::widgets::register(ui, format!("canvasHandle:{key}"), rect);let mut out = HandleKeys::default();if !resp.has_focus() {return out;diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rsindex e53b02ad1..d12edebab 100644--- a/crates/ui-egui/src/control.rs+++ b/crates/ui-egui/src/control.rs@@ -189,6 +189,48 @@ fn key_from(name: &str) -> Option<egui::Key> {})}+/// Most clicks one `ui.click`/`ui.clickWidget` request may inject. The control server is a+/// local automation surface, but a request must not be able to fill memory with synthetic events.+pub(crate) const MAX_CLICKS: u64 = 16;+/// Most pointer-move steps one `ui.drag`/`ui.dragWidget` request may inject.+pub(crate) const MAX_DRAG_STEPS: u64 = 1000;++/// What a widget gesture's synthetic events were aimed at when they were resolved. Delivery+/// rechecks this against the latest completed layout before the first event and again before every+/// press: a moved widget cancels the request instead of being retargeted.+#[derive(Clone, Debug)]+pub(crate) struct GestureTarget {+ pub id: String,+ /// The rect the request resolved against. An explicit `fx`/`fy` may place `at` outside it;+ /// delivery accepts that only while egui's actual clipped interaction rectangle still+ /// contains the point.+ pub rect: egui::Rect,+ /// The point the pointer events aim at.+ pub at: egui::Pos2,+ /// Whether the release must still find this widget. egui attributes a click on release while a+ /// drag may legitimately end outside the widget it started on, so only `ui.clickWidget` sets+ /// this.+ pub check_release: bool,+ /// Whether the first event must find the widget visible and topmost. A hover is not harmless+ /// when its point is clipped out of the widget or covered by a non-modal overlay: the+ /// documented contract refuses it rather than moving the pointer at a stale place.+ pub check_visible: bool,+}++/// The events queued for a resolved gesture, plus the widget target whose geometry must still hold+/// when the first event and each press are injected.+#[derive(Debug)]+pub(crate) struct GestureOutcome {+ pub result: Value,+ pub target: Option<GestureTarget>,+}++impl GestureOutcome {+ fn done(result: Value) -> Self {+ Self { result, target: None }+ }+}+fn push_drag(app: &mut LightcraftApp, a: egui::Pos2, b: egui::Pos2, steps: u64, m: egui::Modifiers) {app.synthetic.push(egui::Event::PointerMoved(a));app.synthetic.push(egui::Event::PointerButton { pos: a, button: egui::PointerButton::Primary, pressed: true, modifiers: m });@@ -199,10 +241,76 @@ fn push_drag(app: &mut LightcraftApp, a: egui::Pos2, b: egui::Pos2, steps: u64,app.synthetic.push(egui::Event::PointerButton { pos: b, button: egui::PointerButton::Primary, pressed: false, modifiers: m });}-fn widget_rect(app: &LightcraftApp, id: &str) -> Option<egui::Rect> {+pub(crate) fn widget_rect(app: &LightcraftApp, id: &str) -> Option<egui::Rect> {app.widgets.iter().rev().find(|(w, _)| w == id).map(|(_, r)| *r)}+/// The real egui widget that owns automation id `id` in the latest completed pass (the last+/// registration wins, as [`widget_rect`] does).+pub(crate) fn widget_hit(app: &LightcraftApp, id: &str) -> Option<crate::widgets::WidgetHit> {+ app.widget_hits.iter().rev().find(|(w, _)| w == id).map(|(_, hit)| *hit)+}++/// Whether the registered automation rectangle still owns egui's pointer hit at `at`.+///+/// A registration records the egui id and layer of a hover probe (or of the widget's own+/// response), plus that response's clipped `interact_rect` in the same completed pass. This asks+/// egui for the current areas at the point and checks:+///+/// - the recorded clipped rectangle still contains the point (a widget scrolled out of its panel+/// has an empty interact rect even though its unclipped rect still contains the old point);+/// - the top-most interactable area at the point is the recorded layer; or+/// - the top-most area is the current modal layer and the recorded layer is below it. egui routes+/// every point below a modal to that modal, even outside the dialog window, so leaving the press+/// to egui is safe: the dialog consumes it or `clicked_backdrop` closes the dialog, and a+/// background widget cannot receive it. A non-modal overlay is not the modal layer, so it must+/// still match the target and is refused otherwise. The one exception is the explicitly+/// blocking library-problem/launch-list window: its dim also owns the modal layer, but a+/// background target is refused here rather than reported `ok:true` after the dim swallows the+/// press; only controls drawn in that window's own layer pass. Same-layer overlaps are invisible+/// to this area check; egui still delivers the press to whichever widget is top-most in that+/// layer.+///+/// `interact_rect` comes from the latest completed registry, not `Context::read_response`:+/// `raw_input_hook` runs before `begin_pass`, where `read_response` checks `this_pass` before+/// `prev_pass` and can therefore return the pass before the one that just published the registry.+/// This matters when clipping, scrolling or a viewport change alters the target without changing+/// its layer.+///+/// In pinned egui `6d518fc`, `Response::hovered` is deliberately false while any button is down+/// unless this is the clicked widget (`context.rs:1884-1886`, `interaction.rs:257-300`). A+/// hover-only probe cannot use it for a click release. `Response::contains_pointer` would survive+/// the press, but its hit-test snapshot is one frame behind the pointer move that precedes the+/// press (`context.rs:517-548` reads `prev_pass.widgets` at `begin_pass`). The recorded clipped rect+/// plus the current layer has no such lag.+///+/// This also avoids the old centre-of-an-interactive-rect heuristic: a registration may be a+/// sub-rect of its widget's interactive response (rating stars, date cells, a checkbox's box, a+/// profile card's star), so the interactive rect's centre need not lie in the registered rect.+/// Disabled controls keep working as a no-op: their own probe is enabled and the injected click+/// is ignored by egui, which is the documented `ui.clickWidget` semantics.+pub(crate) fn widget_target_visible(ctx: &egui::Context, hit: Option<crate::widgets::WidgetHit>, at: egui::Pos2) -> bool {+ let Some(hit) = hit else {+ // A hand-built registry entry (tests) or painted geometry has no egui widget to own a+ // press. Production widget registrations always record a probe or a real response.+ return false;+ };+ let interact_rect = ctx.layer_transform_to_global(hit.layer_id).map_or(hit.interact_rect, |to_global| to_global * hit.interact_rect);+ if !interact_rect.is_finite() || !interact_rect.contains(at) {+ return false;+ }+ let (top_modal, allows_interaction, above_modal) =+ ctx.memory(|memory| (memory.top_modal_layer(), memory.allows_interaction(hit.layer_id), memory.is_above_modal_layer(hit.layer_id)));+ if crate::panels::library_problem::refuses_control_target(top_modal, hit.layer_id) {+ return false;+ }+ let at_layer = ctx.layer_id_at(at);+ if at_layer == Some(hit.layer_id) {+ return allows_interaction;+ }+ top_modal == at_layer && !above_modal+}+pub fn handle(app: &mut LightcraftApp, ctx: &egui::Context, req: &ControlRequest) -> Outcome {let p = &req.params;let s = |k: &str| p.get(k).and_then(Value::as_str);@@ -488,7 +596,7 @@ pub fn export_active(app: &mut LightcraftApp, p: &Value) -> Result<Value, String/// and the image rect therefore come from that pass; nothing is retargeted. A successful return/// has pushed the events onto `app.synthetic`; the app answers the request once the UI consumed/// them.-pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, method: &str, p: &Value) -> Result<Value, String> {+pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, method: &str, p: &Value) -> Result<GestureOutcome, String> {let s = |k: &str| p.get(k).and_then(Value::as_str);let f = |k: &str| p.get(k).and_then(Value::as_f64);match method {@@ -496,11 +604,19 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, metholet Some(id) = s("id") else { return Err("missing `id`".into()) };let Some(r) = widget_rect(app, id) else { return Err(format!("no widget `{id}` on screen (see ui.widgets)")) };let m = modifiers(p);- let at = egui::pos2(r.left() + r.width() * f("fx").unwrap_or(0.5) as f32, r.top() + r.height() * f("fy").unwrap_or(0.5) as f32);- if method == "ui.hoverWidget" {+ let (fx, fy) = (f("fx").unwrap_or(0.5), f("fy").unwrap_or(0.5));+ let at = egui::pos2(r.left() + r.width() * fx as f32, r.top() + r.height() * fy as f32);+ if !fx.is_finite() || !fy.is_finite() || !at.is_finite() {+ return Err(format!("{method}: fx and fy must resolve to a finite point"));+ }+ let hover = method == "ui.hoverWidget";+ if hover && !widget_target_visible(ctx, widget_hit(app, id), at) {+ return Err(format!("ui.hoverWidget: widget `{id}` has no visible interaction area at the requested point"));+ }+ if hover {app.synthetic.push(egui::Event::PointerMoved(at));} else if method == "ui.clickWidget" {- let n = p.get("count").and_then(Value::as_u64).unwrap_or(1);+ let n = p.get("count").and_then(Value::as_u64).unwrap_or(1).min(MAX_CLICKS);let button = if s("button") == Some("right") { egui::PointerButton::Secondary } else { egui::PointerButton::Primary };app.synthetic.push(egui::Event::PointerMoved(at));for _ in 0..n {@@ -512,15 +628,18 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, methof("toX").map(|v| v as f32).unwrap_or(at.x + f("dx").unwrap_or(0.0) as f32),f("toY").map(|v| v as f32).unwrap_or(at.y + f("dy").unwrap_or(0.0) as f32),);- push_drag(app, at, to, p.get("steps").and_then(Value::as_u64).unwrap_or(10), m);+ push_drag(app, at, to, p.get("steps").and_then(Value::as_u64).unwrap_or(10).min(MAX_DRAG_STEPS), m);}ctx.request_repaint();- Ok(json!({"rect": rect_json(r)}))+ Ok(GestureOutcome {+ result: json!({"rect": rect_json(r)}),+ target: Some(GestureTarget { id: id.to_string(), rect: r, at, check_release: method == "ui.clickWidget", check_visible: hover }),+ })}"ui.move" => {app.synthetic.push(egui::Event::PointerMoved(egui::pos2(f("x").unwrap_or(0.0) as f32, f("y").unwrap_or(0.0) as f32)));ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}"ui.click" | "ui.drag" => {let a = egui::pos2(f("x").unwrap_or(0.0) as f32, f("y").unwrap_or(0.0) as f32);@@ -528,16 +647,16 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, metholet button = if s("button") == Some("right") { egui::PointerButton::Secondary } else { egui::PointerButton::Primary };if method == "ui.drag" {let b = egui::pos2(f("toX").unwrap_or(0.0) as f32, f("toY").unwrap_or(0.0) as f32);- push_drag(app, a, b, p.get("steps").and_then(Value::as_u64).unwrap_or(10), m);+ push_drag(app, a, b, p.get("steps").and_then(Value::as_u64).unwrap_or(10).min(MAX_DRAG_STEPS), m);} else {app.synthetic.push(egui::Event::PointerMoved(a));- for _ in 0..p.get("count").and_then(Value::as_u64).unwrap_or(1) {+ for _ in 0..p.get("count").and_then(Value::as_u64).unwrap_or(1).min(MAX_CLICKS) {app.synthetic.push(egui::Event::PointerButton { pos: a, button, pressed: true, modifiers: m });app.synthetic.push(egui::Event::PointerButton { pos: a, button, pressed: false, modifiers: m });}}ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}"ui.pointer" => {let Some(img) = app.image_rect else { return Err("no image on screen (switch to Detail view)".into()) };@@ -559,7 +678,7 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, metho}}ctx.request_repaint();- Ok(json!({"events": events.len()}))+ Ok(GestureOutcome::done(json!({"events": events.len()})))}"ui.key" => {let Some(k) = s("key").and_then(key_from) else { return Err("unknown or missing `key`".into()) };@@ -567,14 +686,34 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, methoapp.synthetic.push(egui::Event::Key { key: k, physical_key: None, pressed: true, repeat: false, modifiers: m });app.synthetic.push(egui::Event::Key { key: k, physical_key: None, pressed: false, repeat: false, modifiers: m });ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}"ui.text" => {app.synthetic.push(egui::Event::Text(s("text").unwrap_or("").to_string()));ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}"ui.clipboard" => {+ // RequestPaste is a viewport command, not an event: the prompt/library input barrier+ // cannot inspect it after the fact. Refuse the command while either barrier owns input,+ // including a window created after this pass began resolving the gesture. Without+ // `text` this only queues RequestPaste in egui; it is not a host-dispatch or delivery+ // acknowledgement. egui 0.37 documents RequestPaste as asking the host to paste into+ // the focused text edit, with no completion or correlation id. egui-winit emits a later+ // Event::Paste only for non-empty text (or a PasteImage fallback; Wayland reads finish+ // later), so a barrier created after the request can drop that later event; the reply+ // below cannot promise dispatch or delivery. With `text`, the synthetic+ // Event::Paste is filtered and canceled like other injected input.+ let barrier = if crate::panels::notices::blocks_input(app) {+ Some("a modal prompt")+ } else if crate::panels::library_problem::blocks_dialog_input(app) {+ Some("the blocking library window")+ } else {+ None+ };+ if let Some(barrier) = barrier {+ return Err(format!("ui.clipboard: {barrier} is blocking background input"));+ }if !ctx.text_edit_focused() {return Err("ui.clipboard: no text field has the focus (click one first)".into());}@@ -588,7 +727,7 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, metho_ => return Err("ui.clipboard: `action` is cut, copy or paste".into()),}ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}"ui.scroll" => {// Omitted keys keep the pre-0.37 request meaning; all other values are validated@@ -621,7 +760,7 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, methomodifiers: modifiers(p),});ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}"ui.zoom" => {let Some(factor) = f("factor").map(|v| v as f32).filter(|v| v.is_finite() && *v > 0.0) else {@@ -629,7 +768,7 @@ pub(crate) fn gesture_events(app: &mut LightcraftApp, ctx: &egui::Context, metho};app.synthetic.push(egui::Event::Zoom(factor));ctx.request_repaint();- Ok(Value::Null)+ Ok(GestureOutcome::done(Value::Null))}other => Err(format!("not a synthetic-input gesture: `{other}`")),}diff --git a/crates/ui-egui/src/credits.rs b/crates/ui-egui/src/credits.rsindex ac893ebf0..578616068 100644--- a/crates/ui-egui/src/credits.rs+++ b/crates/ui-egui/src/credits.rs@@ -257,12 +257,12 @@ pub fn contributors_ui(app: &mut LightcraftApp, ui: &mut egui::Ui) {}ui.separator();let r = ui.selectable_label(!v.table, crate::i18n::tr("Grab bag"));- crate::widgets::register(ui.ctx(), "button:creditsGrabBag", r.rect);+ crate::widgets::register(ui, "button:creditsGrabBag", r.rect);if r.clicked() {v.table = false;}let r = ui.selectable_label(v.table, crate::i18n::tr("Table"));- crate::widgets::register(ui.ctx(), "button:creditsTable", r.rect);+ crate::widgets::register(ui, "button:creditsTable", r.rect);if r.clicked() {v.table = true;}diff --git a/crates/ui-egui/src/date_picker.rs b/crates/ui-egui/src/date_picker.rsindex 710cd8956..eda461eb7 100644--- a/crates/ui-egui/src/date_picker.rs+++ b/crates/ui-egui/src/date_picker.rs@@ -238,7 +238,7 @@ impl<'a> DatePicker<'a> {pub fn show(self, ui: &mut Ui) -> Response {let DatePicker { id, value, precisions, min, max, today } = self;let mut button = crate::widgets::icon_button(ui, &format!("datePicker:{id}"), Icon::Calendar, vec2(24.0, 22.0), false, true, "Pick a date");- register(ui.ctx(), format!("datePicker:{id}"), button.rect);+ register(ui, format!("datePicker:{id}"), button.rect);let state = egui::Id::unique(("datePicker", id.as_str()));if button.clicked() {// open on the value (or today), at its precision when it is one of those offered@@ -257,7 +257,7 @@ impl<'a> DatePicker<'a> {ui.horizontal(|ui| {for p in precisions {let r = ui.selectable_label(view.precision == *p, crate::i18n::tr(p.label()));- register(ui.ctx(), format!("datePickerPrecision:{}:{id}", p.id()), r.rect);+ register(ui, format!("datePickerPrecision:{}:{id}", p.id()), r.rect);if r.clicked() {view.precision = *p;}@@ -268,7 +268,7 @@ impl<'a> DatePicker<'a> {ui.horizontal(|ui| {let prev = crate::widgets::arrow_button(ui, "", Icon::ChevronLeft, true);prev.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::tr("Previous page")));- register(ui.ctx(), format!("datePickerPrev:{id}"), prev.rect);+ register(ui, format!("datePickerPrev:{id}"), prev.rect);let title = match view.precision {Precision::Day => crate::i18n::date_group_label(&format!("{:04}-{:02}", view.year, view.month), false),Precision::Month => format!("{:04}", view.year),@@ -281,7 +281,7 @@ impl<'a> DatePicker<'a> {ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {let next = crate::widgets::arrow_button(ui, "", Icon::ChevronRight, false);next.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), crate::i18n::tr("Next page")));- register(ui.ctx(), format!("datePickerNext:{id}"), next.rect);+ register(ui, format!("datePickerNext:{id}"), next.rect);if next.clicked() {view = step(view, true);}@@ -294,7 +294,7 @@ impl<'a> DatePicker<'a> {let allowed = in_bounds(&date, min.as_ref(), max.as_ref());let text = if holds_today(&date, today) { RichText::new(text).strong().underline() } else { RichText::new(text) };let r = ui.add_enabled(allowed, egui::Button::selectable(*value == Some(date), text).min_size(vec2(26.0, 0.0)));- register(ui.ctx(), format!("datePickerCell:{}:{id}", date.iso()), r.rect);+ register(ui, format!("datePickerCell:{}:{id}", date.iso()), r.rect);if r.clicked() {*picked = Some(date);}diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rsindex 9044d2579..01b1aefbd 100644--- a/crates/ui-egui/src/docking.rs+++ b/crates/ui-egui/src/docking.rs@@ -439,11 +439,11 @@ pub fn show(app: &mut crate::LightcraftApp, ui: &mut egui::Ui) {canvas = Some(ui.new_child(egui::UiBuilder::new().id_salt("photo-view").max_rect(ui.max_rect())));}Panel::Library => {- crate::widgets::register(ui.ctx(), "panel:left_panel", ui.max_rect());+ crate::widgets::register(ui, "panel:left_panel", ui.max_rect());crate::panels::left::show(app, ui);}Panel::Tools => {- crate::widgets::register(ui.ctx(), "panel:right_panel", ui.max_rect());+ crate::widgets::register(ui, "panel:right_panel", ui.max_rect());crate::panels::right::show(app, ui);}Panel::Presets => crate::panels::presets::show(app, ui),diff --git a/crates/ui-egui/src/drop_overlay.rs b/crates/ui-egui/src/drop_overlay.rsindex 501b99903..8be75ee88 100644--- a/crates/ui-egui/src/drop_overlay.rs+++ b/crates/ui-egui/src/drop_overlay.rs@@ -69,6 +69,11 @@ fn lines(app: &LightcraftApp, paths: Vec<String>, unknown: bool) -> Vec<String>/// Veil and card while files are dragged over the window.pub fn show(app: &LightcraftApp, ctx: &Context) {+ // This card is an `Order::Tooltip` layer, above the prompt's Foreground window. While a prompt+ // owns input the drag can only be background noise: do not paint over or register it.+ if crate::panels::notices::blocks_input(app) {+ return;+ }let count = ctx.input(|i| i.raw.hovered_files.len());if count == 0 {return;@@ -94,6 +99,6 @@ pub fn show(app: &LightcraftApp, ctx: &Context) {painter.galley(Align2::CENTER_TOP.anchor_size(at, g.size()).min, g, t.text);y += height + 8.0;}- crate::widgets::register(ctx, "dropOverlay", card);+ crate::widgets::register_geometry(ctx, "dropOverlay", card);ctx.request_repaint();}diff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rsindex de8060ec3..e47165557 100644--- a/crates/ui-egui/src/headless.rs+++ b/crates/ui-egui/src/headless.rs@@ -49,8 +49,11 @@ fn native_viewport_pixels(size: [f32; 2], pixels_per_point: f32) -> Result<[usizOk(pixels as usize)};let (w, h) = (axis(width)?, axis(height)?);- if w.checked_mul(h).is_none_or(|pixels| pixels > softpaint::MAX_IMAGE_PIXELS) {- return Err(format!("scaled viewport exceeds {} pixels", softpaint::MAX_IMAGE_PIXELS));+ // The rasterizer's limit is not enough: a screenshot is also bounded by the RGBA budget it is+ // admitted against, so reject a size `ui.screenshot` would only refuse later.+ let max_pixels = softpaint::MAX_IMAGE_PIXELS.min(crate::MAX_SHOT_PIXELS);+ if w.checked_mul(h).is_none_or(|pixels| pixels > max_pixels) {+ return Err(format!("scaled viewport exceeds {max_pixels} pixels"));}Ok([w, h])}@@ -258,6 +261,10 @@ pub struct Headless {pub window_commands: Vec<ViewportCommand>,/// The pointer cursor the last frame asked for (what a real host would show).pub last_cursor: egui::CursorIcon,+ /// Test-only hook run after `raw_input_hook` and before `logic`/`ui`, as eframe does: it can+ /// create a prompt after the host input was already filtered for the previous frame.+ #[cfg(test)]+ after_raw_input_hook: Option<Box<dyn FnMut(&mut LightcraftApp)>>,}/// A headless run (`lightcraft-cli snapshot`, tests) is a one-shot process: however it ends, it@@ -298,9 +305,19 @@ impl Headless {window_maximized: false,window_commands: vec![],last_cursor: egui::CursorIcon::Default,+ #[cfg(test)]+ after_raw_input_hook: None,}}+ /// Run `hook` once, between the next frame's [`LightcraftApp::raw_input_hook`] and its+ /// `logic`/`ui` call. This is the production order in eframe: a prompt can be created there+ /// after the host input was already accepted for the frame.+ #[cfg(test)]+ pub(crate) fn set_after_raw_input_hook(&mut self, hook: impl FnMut(&mut LightcraftApp) + 'static) {+ self.after_raw_input_hook = Some(Box::new(hook));+ }+pub fn frames(&self) -> u64 {self.frames}@@ -329,7 +346,11 @@ impl Headless {self.reported_texture_side = Some(self.max_texture_side);// A headless run's timers follow its simulated clock, not the host's wall clock.self.app.set_simulated_clock(Some(self.time));- self.app.raw_input_hook(&mut raw);+ self.app.raw_input_hook(&self.view.ctx, &mut raw);+ #[cfg(test)]+ if let Some(mut hook) = self.after_raw_input_hook.take() {+ hook(&mut self.app);+ }let app = &mut self.app;let mut cursor = egui::CursorIcon::Default;let commands = self.view.run(raw, |ui| {@@ -645,7 +666,9 @@ mod tests {fn screenshot_dimensions_are_checked_before_layout() {assert_eq!(viewport_pixels([1600.0, 1000.0], 2.0).unwrap(), [3200, 2000]);assert_eq!(viewport_pixels([345.0, 200.0], 0.9).unwrap(), [311, 180]);- assert_eq!(viewport_pixels([8000.0, 8000.0], 1.0).unwrap(), [8000, 8000]);+ // The largest accepted surface is exactly the 128 MiB screenshot budget (32 Mi pixels).+ assert_eq!(viewport_pixels([16384.0, 2048.0], 1.0).unwrap(), [16384, 2048]);+ assert_eq!(viewport_pixels([5792.0, 5792.0], 1.0).unwrap(), [5792, 5792]);for (size, scale) in [([f32::NAN, 10.0], 1.0),([10.0, f32::INFINITY], 1.0),@@ -654,6 +677,9 @@ mod tests {([10.0, 10.0], 0.0),([0.0, 10.0], 1.0),([10.0, 10.0], 0.01),+ ([16384.0, 2049.0], 1.0),+ ([8000.0, 8000.0], 1.0),+ ([5793.0, 5793.0], 1.0),([9000.0, 9000.0], 1.0),([9000.0, 100.0], 2.0),] {diff --git a/crates/ui-egui/src/import.rs b/crates/ui-egui/src/import.rsindex b707a589e..2071d3e01 100644--- a/crates/ui-egui/src/import.rs+++ b/crates/ui-egui/src/import.rs@@ -1138,7 +1138,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {.map(|summary| summary.display()).unwrap_or_else(|| crate::i18n::tr_format!("{} item{}", d.sources.len(), if d.sources.len() == 1 { "" } else { "s" }));let r = ui.label(egui::RichText::new(summary).color(t.text_label)).on_hover_text(joined);- register(ui.ctx(), "label:importSource", r.rect);+ register(ui, "label:importSource", r.rect);});ui.label(egui::RichText::new(crate::i18n::tr("Importing scans the source for photos; it doesn't add the folder to Local (use Local → Browse Folder… to work in a folder without importing)."))@@ -1184,7 +1184,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {.color(if d.copy && d.move_files { t.caution } else { t.text_dim }).small(),);- register(ui.ctx(), "label:importModeHelp", r.rect);+ register(ui, "label:importModeHelp", r.rect);if d.copy {field(ui, if d.move_files { "Move to" } else { "Copy to" }, |ui| {ui.spacing_mut().item_spacing.x = 4.0;@@ -1212,7 +1212,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {let combo = crate::widgets::combo_box("import-organize").selected_text(crate::i18n::tr(cur)).show_ui(ui, |ui| {for (k, label) in opts {let r = ui.selectable_label(key == k, crate::i18n::tr(label));- register(ui.ctx(), format!("button:importOrganize-{k}"), r.rect);+ register(ui, format!("button:importOrganize-{k}"), r.rect);if r.clicked() {d.organize = k.to_string();if k == "custom" && d.folder_template.trim().is_empty() {@@ -1222,7 +1222,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {}});crate::widgets::name_combo(&combo.response, crate::i18n::tr("Organize into"));- register(ui.ctx(), "combo:importOrganize", combo.response.rect);+ register(ui, "combo:importOrganize", combo.response.rect);});if d.organize == "custom" {let folders_id = egui::Id::unique("import-folder-template");@@ -1230,7 +1230,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {ui.spacing_mut().item_spacing.x = 4.0;let w = tag_field_width(ui);let r = ui.add(egui::TextEdit::singleline(&mut d.folder_template).id(folders_id).hint_text(DEFAULT_FOLDER_TEMPLATE).desired_width(w));- register(ui.ctx(), "field:importFolderTemplate", r.rect);+ register(ui, "field:importFolderTemplate", r.rect);tag_toggle(ui, "importFolders")});if tags_open {@@ -1254,7 +1254,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {if !d.move_files {field(ui, "Raw files", |ui| {let r = ui.checkbox(&mut d.dng, crate::i18n::tr("Copy as DNG"));- register(ui.ctx(), "check:importDng", r.rect);+ register(ui, "check:importDng", r.rect);});}let rename_id = egui::Id::unique("import-rename");@@ -1267,7 +1267,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {.hint_text(crate::i18n::tr("keep names — or e.g. {date}_{seq:3}")).desired_width(w),);- register(ui.ctx(), "field:importRename", r.rect);+ register(ui, "field:importRename", r.rect);tag_toggle(ui, "importRename")});if tags_open {@@ -1277,7 +1277,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {if let Some(example) = example_destination(app, d) {let t = Tokens::get(ui.ctx());let r = ui.label(egui::RichText::new(crate::i18n::tr_format!("Example: {example}", example = example)).color(t.text_dim));- register(ui.ctx(), "label:importExample", r.rect);+ register(ui, "label:importExample", r.rect);ui.label(egui::RichText::new(crate::i18n::tr("Folders and {date} use the capture time; a photo without one uses today's date.")).color(t.text_dim)@@ -1326,12 +1326,12 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {.empty_text(empty).show_with_choices(ui, |ui| {let none = ui.selectable_label(d.album.is_none() && d.new_album.is_empty(), crate::i18n::tr("None"));- register(ui.ctx(), "importAlbum:none", none.rect);+ register(ui, "importAlbum:none", none.rect);if none.clicked() {extra = Some(false);}let new = ui.selectable_label(d.album.is_none() && !d.new_album.is_empty(), crate::i18n::tr("New album…"));- register(ui.ctx(), "importAlbum:new", new.rect);+ register(ui, "importAlbum:new", new.rect);if new.clicked() {extra = Some(true);}@@ -1352,7 +1352,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {}if d.album.is_none() && !d.new_album.is_empty() {let r = ui.add(egui::TextEdit::singleline(&mut d.new_album).desired_width(f32::INFINITY));- register(ui.ctx(), "field:importAlbumName", r.rect);+ register(ui, "field:importAlbumName", r.rect);}});});@@ -1393,7 +1393,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDialog) {}field(ui, "Keywords", |ui| {let r = ui.add(egui::TextEdit::singleline(&mut d.keywords).hint_text(crate::i18n::tr("comma, separated")).desired_width(f32::INFINITY));- register(ui.ctx(), "field:importKeywords", r.rect);+ register(ui, "field:importKeywords", r.rect);});}@@ -1404,7 +1404,7 @@ fn candidate_cell(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &mut ImportDiallet img = Rect::from_min_size(rect.min, vec2(rect.width(), rect.width()));let resp = ui.interact(img, egui::Id::unique(("import-cell", i)), Sense::click());crate::widgets::announce(&resp, c.name.clone());- register(ui.ctx(), format!("import:{i}"), img);+ register(ui, format!("import:{i}"), img);let p = ui.painter();p.rect_filled(img, 3.0, t.skeleton);// thumbnail (background job; the grid only asks for the cells in view)@@ -1551,7 +1551,7 @@ pub(crate) fn tag_help(ui: &mut egui::Ui, key: &str, text: &mut String, edit_id:crate::i18n::tr_format!("Insert at the cursor (also written {})", tok.aliases.join(", "))},);- register(ui.ctx(), format!("button:{key}Tag-{i}"), r.rect);+ register(ui, format!("button:{key}Tag-{i}"), r.rect);if r.clicked() {insert_at_cursor(ui.ctx(), edit_id, text, tok.tag);}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex e5cfd08b7..ca598b5f4 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -411,6 +411,8 @@ pub struct LightcraftApp {pub notices: Vec<String>,/// Quitting was stopped to ask first: changes couldn't be saved, or tasks are running.pub quit_prompt: Option<QuitPrompt>,+ /// Keyboard/focus/input state for the prompt above, including its one-frame creation barrier.+ pub(crate) notice_input: panels::notices::PromptInput,/// Quit Anyway was chosen: the window may close with unsaved changes.pub quit_confirmed: bool,control_rx: Option<Receiver<ControlRequest>>,@@ -447,10 +449,20 @@ pub struct LightcraftApp {synthetic_in_flight: bool,/// Completed, nondiscarded root UI passes; host frames, not layout passes.ui_passes: u64,+ /// Test-only: the library barrier's per-pass decisions, so a first-return test can observe the+ /// dedicated shield/discard pass and the following background pass rather than only its input+ /// effects (which the global shortcut guard also hides).+ #[cfg(test)]+ pub(crate) library_passes: Vec<panels::library_problem::LibraryPass>,/// Offscreen context for headless screenshots of the windowed app.shadow: Option<headless::HeadlessView>,/// Synthetic input events (from the control channel) injected one step per frame.pub synthetic: Vec<egui::Event>,+ /// A gesture was canceled after its synthetic pointer press reached egui. The next+ /// [`Self::raw_input_hook`] cancels that press before egui's next input pass, without a+ /// `PointerMoved` (which can start a drag) or a `PointerButton` release (which can become a+ /// click).+ pointer_cleanup: bool,/// Files the control channel (`ui.dropFiles`) holds over the window: every frame reports them/// as hovered, as the OS does while a drag is over the window.drop_hover: Vec<String>,@@ -460,10 +472,15 @@ pub struct LightcraftApp {pub copied: Option<String>,/// Native file dialogs up for commands (`pick`): each command runs again when its closes.pub(crate) pending_picks: Vec<pick::Pending>,- /// Modifiers announced for synthetic input (held from a button down to its release).+ /// Modifiers announced for synthetic input (held from a button down to its release). This is+ /// only the app's synthetic ownership; the real host state is tracked separately in+ /// `host_mods`, so a canceled synthetic gesture never clears a physically held key.synthetic_mods: egui::Modifiers,/// Clear `synthetic_mods` on the next frame.synthetic_mods_release: bool,+ /// The host's last reported physical modifier state (`ModifiersChanged`), restored after a+ /// synthetic gesture releases instead of unconditionally announcing `NONE`.+ host_mods: egui::Modifiers,styled: bool,/// The language the installed fonts were built for: the CJK fallback order follows the UI/// language's script, so switching language reinstalls them.@@ -479,8 +496,14 @@ pub struct LightcraftApp {/// drawn last (`ui.inspect` → `scroll`).pub grid_scroll: Option<f32>,pub film_scroll: Option<f32>,- /// Widget registry from the last frame (automation ids → rects).+ /// Widget registry from the last completed, nondiscarded frame (automation ids → rects).pub widgets: Vec<(String, egui::Rect)>,+ /// Egui hit owners for [`Self::widgets`] from the same completed pass. A press is delivered+ /// only when this id still owns egui's pointer hit (see `control::widget_target_visible`).+ pub widget_hits: Vec<(String, widgets::WidgetHit)>,+ /// Registry collected by the pass being laid out, published only if that pass completes.+ next_widgets: Vec<(String, egui::Rect)>,+ next_widget_hits: Vec<(String, widgets::WidgetHit)>,/// In-progress on-canvas gesture (brush stroke points, gradient drag…).pub gesture: Option<panels::detail::Gesture>,/// The brush stroke being painted, as drawn on the photo until it's committed (issue #517).@@ -560,6 +583,8 @@ pub struct LightcraftApp {/// The library failed to open at launch: the blocking window, then the temporary-session/// banner (issue #100). Cleared once a library opens.pub library_problem: Option<panels::library_problem::LibraryProblem>,+ /// First-frame focus/input state for a newly shown blocking library window.+ pub(crate) library_window_input: panels::library_problem::WindowBarrier,/// Alt/Option held as the window first appears offers the recent libraries once (issue/// #1290); the desktop host arms it when nothing chose the library already.pub alt_asks_for_library: bool,@@ -589,6 +614,7 @@ impl LightcraftApp {headless_host: false,notices: vec![],quit_prompt: None,+ notice_input: Default::default(),quit_confirmed: false,control_rx: None,pending_screenshots: vec![],@@ -606,14 +632,18 @@ impl LightcraftApp {dropped_files: vec![],synthetic_in_flight: false,ui_passes: 0,+ #[cfg(test)]+ library_passes: vec![],shadow: None,synthetic: vec![],+ pointer_cleanup: false,drop_hover: vec![],drop_pending: vec![],copied: None,pending_picks: vec![],synthetic_mods: egui::Modifiers::NONE,synthetic_mods_release: false,+ host_mods: egui::Modifiers::NONE,styled: false,font_language: i18n::Locale::En,chinese_font: None,@@ -624,6 +654,9 @@ impl LightcraftApp {grid_scroll: None,film_scroll: None,widgets: vec![],+ widget_hits: vec![],+ next_widgets: vec![],+ next_widget_hits: vec![],gesture: None,brush_live: None,loupe_shown: None,@@ -661,6 +694,7 @@ impl LightcraftApp {screen_profile: None,screen_profile_read: None,library_problem: None,+ library_window_input: Default::default(),alt_asks_for_library: false,recent_checks: Default::default(),activity_expanded: false,@@ -1206,6 +1240,8 @@ impl LightcraftApp {resolved_pass: None,remaining_events: 0,started: false,+ target: None,+ pressed: None,result: Value::Null,});ctx.request_repaint();@@ -1223,23 +1259,18 @@ impl LightcraftApp {let epoch = self.layout_epoch;let mut gestures = std::mem::take(&mut self.pending_gestures);let mut keep = Vec::with_capacity(gestures.len());- let mut timed_out = false;for mut gesture in gestures.drain(..) {+ if gesture.resolved_pass.is_some() {+ // Already handed to the delivery queue; `reply_delivered_gestures` (or+ // `expire_gestures`) owns its deadline and must remove its unsent events too.+ keep.push(gesture);+ continue;+ }if now > gesture.deadline_ms {+ // Only this request failed to get a fresh layout. A later gesture has its own+ // deadline and must not be canceled with it.let _ =gesture.reply.send(serde_json::json!({"ok": false, "error": format!("{} timed out before the UI consumed it", gesture.method)}));- timed_out = true;- continue;- }- if timed_out {- let _ = gesture.reply.send(serde_json::json!({- "ok": false,- "error": "control gesture canceled: another request timed out before the UI consumed it",- }));- continue;- }- if gesture.resolved_pass.is_some() {- keep.push(gesture);continue;}if epoch <= gesture.admitted_epoch {@@ -1255,8 +1286,9 @@ impl LightcraftApp {}let before = self.synthetic.len();match control::gesture_events(self, ctx, &gesture.method, &gesture.params) {- Ok(result) => {- gesture.result = result;+ Ok(outcome) => {+ gesture.target = outcome.target;+ gesture.result = outcome.result;gesture.resolved_pass = Some(self.ui_passes);gesture.remaining_events = self.synthetic.len().saturating_sub(before);gesture.started = gesture.remaining_events == 0;@@ -1268,17 +1300,6 @@ impl LightcraftApp {}}self.pending_gestures = keep;- if timed_out {- // Fail closed: an error must not be followed by a late synthetic click.- self.synthetic.clear();- let remaining = std::mem::take(&mut self.pending_gestures);- for gesture in remaining {- let _ = gesture.reply.send(serde_json::json!({- "ok": false,- "error": "control gesture canceled: another request timed out before the UI consumed it",- }));- }- }}/// Answer gestures whose last synthetic event a completed, nondiscarded UI pass consumed.@@ -1294,16 +1315,21 @@ impl LightcraftApp {return;}let now = self.tick_now_ms();- if self.pending_gestures.iter().any(|g| g.resolved_pass.is_some() && now > g.deadline_ms) {- self.synthetic.clear();- let gestures = std::mem::take(&mut self.pending_gestures);- for gesture in gestures {- let _ = gesture.reply.send(serde_json::json!({- "ok": false,- "error": format!("{} timed out before the UI consumed its last event", gesture.method),- }));+ // Cancel only the gestures that actually stalled: their unsent events are at the front of+ // the queue, and gestures queued behind them are independent input that must survive.+ let mut i = 0;+ while i < self.pending_gestures.len() {+ if self.pending_gestures[i].resolved_pass.is_none() || now <= self.pending_gestures[i].deadline_ms {+ i += 1;+ continue;}- return;+ let at_head = self.head_gesture() == Some(i);+ let gesture = self.pending_gestures.remove(i);+ self.cancel_gesture_events(&gesture, at_head);+ let _ = gesture.reply.send(serde_json::json!({+ "ok": false,+ "error": format!("{} timed out before the UI consumed its last event", gesture.method),+ }));}if !self.synthetic.is_empty() || self.synthetic_in_flight {return;@@ -1319,6 +1345,15 @@ impl LightcraftApp {keep.push(gesture);continue;}+ if gesture.remaining_events > 0 {+ // A defensive queue reset (a non-head gesture owned unsent events) dropped this+ // batch. It must not become an `ok: true` for input no panel ever saw.+ let _ = gesture.reply.send(serde_json::json!({+ "ok": false,+ "error": format!("{} canceled: its queued input was dropped before delivery", gesture.method),+ }));+ continue;+ }let result = std::mem::take(&mut gesture.result);let _ = gesture.reply.send(serde_json::json!({"ok": true, "result": result}));}@@ -1335,29 +1370,183 @@ impl LightcraftApp {/// passes and may change what an automation id or a photo click means; fail closed instead of/// delivering it against the new state.///- /// Only the gesture at the head of the queue, and only before its first batch, is checked:- /// later batches of the same gesture may see its own partial effect (the first click of a- /// double click selects the photo the second one opens), and a second, concurrently queued- /// gesture is checked when its events reach the head.- fn drop_gestures_stale_before_injection(&mut self) -> bool {+ /// A widget gesture also has to keep aiming at the requested widget. egui attributes a click+ /// to the widget under the press point in the *previous completed pass*, while the control+ /// batch spans several host frames (a move, then press, then release). Recheck the target+ /// before the first event and before every press; if it moved or disappeared, cancel this+ /// gesture with an error instead of clicking whatever is now at those coordinates.+ ///+ /// Only the gesture at the head of the queue is checked, and later batches of the same gesture+ /// may see its own partial effect (the first click of a double click selects the photo the+ /// second one opens). A second, concurrently queued gesture is checked when its events reach+ /// the head.+ fn drop_gestures_stale_before_injection(&mut self, ctx: &egui::Context) -> bool {let Some(head) = self.head_gesture() else { return false };- let gesture = &self.pending_gestures[head];- if gesture.started || gesture.frame == self.gesture_frame() {+ let first_batch = !self.pending_gestures[head].started;+ if first_batch && self.pending_gestures[head].frame != self.gesture_frame() {+ let gestures = std::mem::take(&mut self.pending_gestures);+ for gesture in gestures {+ if gesture.resolved_pass.is_none() {+ self.pending_gestures.push(gesture);+ } else {+ if gesture.pressed.is_some() {+ self.queue_pointer_cleanup();+ }+ let _ = gesture.reply.send(serde_json::json!({+ "ok": false,+ "error": format!("{} canceled: the view, document, dialog or panel layout changed before delivery", gesture.method),+ }));+ }+ }+ self.synthetic.clear();+ return true;+ }+ let Some(target) = self.pending_gestures[head].target.clone() else { return false };+ let press_next = matches!(self.synthetic.first(), Some(egui::Event::PointerButton { pressed: true, .. }));+ let release_next = matches!(self.synthetic.first(), Some(egui::Event::PointerButton { pressed: false, .. }));+ // A drag legitimately ends outside the widget it started on; only a click must still find+ // its target at the release that egui attributes the click to. A hover must still find a+ // visible widget for its single pointer move.+ let check_release = release_next && target.check_release;+ let check_visible = first_batch && target.check_visible;+ if !first_batch && !press_next && !check_release && !check_visible {return false;}- let gestures = std::mem::take(&mut self.pending_gestures);- for gesture in gestures {- if gesture.resolved_pass.is_none() {- self.pending_gestures.push(gesture);- } else {+ let latest = control::widget_rect(self, &target.id);+ let latest_hit = control::widget_hit(self, &target.id);+ // A press must go to the widget that owns the point. A click's release must too (a drag+ // may legitimately end outside the widget it started on), so an overlay that appears+ // between press and release cancels the click before the release rather than activating it.+ // A hover's single move must also still find the widget visible: the documented contract+ // rejects a clipped or newly covered target instead of moving the pointer at stale coordinates.+ let must_own = press_next || (release_next && target.check_release) || check_visible;+ // A quit prompt or settings notice owns input even before its Foreground areas have+ // settled (egui's first layout pass is non-interactable), and even when a control request+ // is resolved against the registry of that first pass. Only the prompt's own buttons pass.+ let notice_ok = !must_own || crate::panels::notices::allows_target(self, latest_hit);+ let still_aimed = latest.is_some_and(|rect| {+ // A changed widget cancels any gesture before its first event. Owned presses, click+ // releases and hovers must also be inside egui's clipped, visible part and be the+ // topmost widget hit: a target scrolled out of its panel, or one under a non-modal+ // overlay, must not be pressed or hovered at stale coordinates.+ let geometry_ok = rect == target.rect || rect.contains(target.at);+ geometry_ok && notice_ok && (!must_own || control::widget_target_visible(ctx, latest_hit, target.at))+ });+ if still_aimed {+ return false;+ }+ let outside_registered = !target.rect.contains(target.at);+ let reason = match latest {+ None => "disappeared",+ Some(rect) if !(rect == target.rect || rect.contains(target.at)) => "moved",+ Some(_) if outside_registered => "has no visible interaction area at the requested point",+ Some(_) => "is no longer visible",+ };+ let phase = if first_batch {+ "its first event"+ } else if check_release {+ "its release"+ } else {+ "its press"+ };+ // Only this gesture's unsent events are removed: they are at the front of the queue, and+ // gestures resolved after it are checked in turn when they reach the head. Failing the+ // whole click would also discard unrelated input.+ let gesture = self.pending_gestures.remove(head);+ self.cancel_gesture_events(&gesture, true);+ let _ = gesture.reply.send(serde_json::json!({+ "ok": false,+ "error": format!("{} canceled: widget `{}` {reason} before {phase}; nothing was retargeted", gesture.method, target.id),+ }));+ true+ }++ /// Remove a canceled gesture's unsent events from the front of the queue and release a pointer+ /// button it left down. Callers cancel in queue order, so the events removed are exactly this+ /// gesture's unsent prefix; a later gesture's events stay queued.+ fn cancel_gesture_events(&mut self, gesture: &PendingGesture, at_head: bool) {+ if at_head {+ let unsent = gesture.remaining_events.min(self.synthetic.len());+ self.synthetic.drain(..unsent);+ } else if gesture.remaining_events > 0 {+ // The queue order makes only the head own unsent events. If a caller ever breaks that+ // invariant, fail safe: stale synthetic input must not reach an unrelated widget, even+ // at the cost of dropping the rest of this batch instead of panicking or guessing a+ // prefix. `reply_delivered_gestures` fails any gesture whose events disappeared this+ // way instead of reporting a false success.+ log::warn!("canceled non-head gesture still owned {} unsent synthetic events; dropping the queue", gesture.remaining_events);+ self.synthetic.clear();+ self.synthetic_in_flight = false;+ }+ if gesture.pressed.is_some() {+ self.queue_pointer_cleanup();+ }+ }++ /// Cancel every synthetic gesture that a newly shown prompt or blocking library window makes+ /// unsafe.+ ///+ /// A gesture whose input is still queued must not be delivered under the barrier or later when+ /// it is gone. A gesture whose press already reached egui must be released without a click. A+ /// gesture that already delivered all its events may still complete its reply: the barrier may+ /// well be its own result (e.g. a key that opened the quit prompt). `all` is for a batch already+ /// injected this host frame before the barrier was discovered after `raw_input_hook`: the+ /// barrier filter drops it before any panel sees it, so even a fully injected gesture must fail+ /// rather than report a successful delivery.+ fn cancel_gestures_for_barrier(&mut self, all: bool, reason: &str) {+ // All not-yet-injected events belong to the queue's head, one gesture at a time. Cancel+ // them in order so only that gesture's unsent prefix is removed.+ while let Some(head) = self.head_gesture() {+ let gesture = self.pending_gestures.remove(head);+ self.cancel_gesture_events(&gesture, true);+ let _ = gesture.reply.send(serde_json::json!({+ "ok": false,+ "error": format!("{} canceled: {reason} before its input was delivered", gesture.method),+ }));+ }+ let mut i = 0;+ while i < self.pending_gestures.len() {+ if all || self.pending_gestures[i].resolved_pass.is_none() || self.pending_gestures[i].pressed.is_some() {+ let gesture = self.pending_gestures.remove(i);+ self.cancel_gesture_events(&gesture, false);let _ = gesture.reply.send(serde_json::json!({"ok": false,- "error": format!("{} canceled: the view, document, dialog or panel layout changed before delivery", gesture.method),+ "error": format!("{} canceled: {reason} before its input was delivered", gesture.method),}));+ } else {+ i += 1;}}- self.synthetic.clear();- true+ }++ /// Cancel a press that reached egui without making it a click or starting a drag. The reset+ /// itself happens before egui's next input pass in [`Self::raw_input_hook`], where replacing+ /// the pointer state and stopping the drag is safe (the same approach as the sibling+ /// SoundCraft/VectorCraft apps). No pointer movement is injected: moving beyond+ /// `max_click_dist` suppresses a click but can also start a drag on a slider or curve.+ fn queue_pointer_cleanup(&mut self) {+ self.pointer_cleanup = true;+ }++ /// Apply a queued pointer cancellation before egui processes the next input pass.+ fn apply_pointer_cleanup(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {+ if !std::mem::take(&mut self.pointer_cleanup) {+ return;+ }+ ctx.input_mut(|input| input.pointer = egui::PointerState::default());+ ctx.stop_dragging();+ if self.synthetic_mods != egui::Modifiers::NONE {+ // The cleanup removes only the app's synthetic modifiers, never a real host change.+ // A host `ModifiersChanged` in this same raw batch is already authoritative and was+ // recorded before this call; otherwise restore the host's last known state (which may+ // be a physically held Shift), rather than clearing it unconditionally with NONE.+ let host_changed = raw.events.iter().any(|event| matches!(event, egui::Event::ModifiersChanged(_)));+ self.synthetic_mods = egui::Modifiers::NONE;+ if !host_changed {+ raw.events.push(egui::Event::ModifiersChanged(self.host_mods));+ }+ }+ self.synthetic_mods_release = false;}/// Fail pending gestures at the monotonic deadline even when no UI pass runs (a hidden window@@ -1367,13 +1556,20 @@ impl LightcraftApp {return;}let now = self.tick_now_ms();- if self.pending_gestures.iter().any(|gesture| now > gesture.deadline_ms) {- self.synthetic.clear();- let gestures = std::mem::take(&mut self.pending_gestures);- for gesture in gestures {- let _ =- gesture.reply.send(serde_json::json!({"ok": false, "error": format!("{} timed out before the UI consumed it", gesture.method)}));+ if !self.pending_gestures.iter().any(|gesture| now > gesture.deadline_ms) {+ return;+ }+ // Cancel exactly the stalled requests, in queue order, so a later gesture's input survives.+ let mut i = 0;+ while i < self.pending_gestures.len() {+ if now <= self.pending_gestures[i].deadline_ms {+ i += 1;+ continue;}+ let at_head = self.head_gesture() == Some(i);+ let gesture = self.pending_gestures.remove(i);+ self.cancel_gesture_events(&gesture, at_head);+ let _ = gesture.reply.send(serde_json::json!({"ok": false, "error": format!("{} timed out before the UI consumed it", gesture.method)}));}}@@ -1745,7 +1941,7 @@ impl LightcraftApp {let now = self.tick_now();self.drain_control(ctx);self.apply_settings(ctx);- if !self.synthetic.is_empty() {+ if self.queued_input_needs_repaint() {ctx.request_repaint();}self.renderer.poll(ctx, &mut self.session);@@ -1871,11 +2067,19 @@ impl LightcraftApp {/// `RequestPaintWhileHidden`; its fallback and timeout keep running from `logic`.fn needs_ui_pass_while_hidden(&self) -> bool {!self.pending_gestures.is_empty()+ || self.pointer_cleanup|| self.pending_screenshots.iter().any(|shot| shot.sent_at_ms.is_none())|| !self.synthetic.is_empty()|| self.synthetic_in_flight}+ /// Queued synthetic input, including a queued pointer cancellation that is not part of+ /// `synthetic`, needs the next visible frame even when an earlier stall left the synthetic+ /// queue empty.+ fn queued_input_needs_repaint(&self) -> bool {+ !self.synthetic.is_empty() || self.pointer_cleanup+ }+/// Input, layout and setup for a known UI phase: at most once per host frame, and never from a/// hidden logic tick. `current_pass_index() == 0` is the first pass of this `run_ui`; a second/// pass has empty events.@@ -1883,6 +2087,15 @@ impl LightcraftApp {if ctx.current_pass_index() != 0 {return;}+ // A prompt owns the keyboard and focus. A notice may have been added by this frame's logic+ // after `raw_input_hook`; capture its Tab/Enter/Space/Escape and drop everything else+ // before any panel, focused control or shortcut reads the input. A new prompt gets a+ // shielding pass whose background is not drawn at all (see `draw_window`).+ let batch_in_flight = self.synthetic_in_flight;+ if panels::notices::prepare_ui_pass(self, ctx) {+ self.cancel_gestures_for_barrier(batch_in_flight, "a modal prompt appeared");+ }+ panels::library_problem::prepare_ui_pass(self, ctx, batch_in_flight);let now = self.tick_now();// the last pass's time is fine here: this is a UI phase, not a hidden ticklet t = ctx.input(|i| i.time);@@ -1893,7 +2106,11 @@ impl LightcraftApp {self.last_time = t;panels::denoise::pump_ui_input(self, ctx, now);panels::faces::pump_ui_input(self, ctx, now);- self.import_dropped_files(ctx);+ // A prompt owns the library too: files dropped while it is up wait in the queue and are+ // imported on the first UI pass after it goes away, never behind it.+ if !panels::notices::blocks_input(self) {+ self.import_dropped_files(ctx);+ }self.check_external_editor(ctx);// Recent-library checks and launch-list keys read focus/time/keys: they belong to the UI// phase, not the hidden-capable `logic` tick (plan §4.5 / migration input contract).@@ -2084,7 +2301,7 @@ impl LightcraftApp {/// The hook also runs before a hidden logic-only tick, so it injects at most one batch and/// keeps that batch in flight until a completed UI pass consumed it. It never injects while/// the fonts are not installed (the pass would draw nothing and the events would be lost).- pub fn raw_input_hook(&mut self, raw: &mut egui::RawInput) {+ pub fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {let file = |p: &String| (!p.is_empty()).then(|| std::path::PathBuf::from(p));if !self.drop_pending.is_empty() {raw.dropped_files = std::mem::take(&mut self.drop_pending)@@ -2097,16 +2314,50 @@ impl LightcraftApp {}// Queue after injecting, so a `ui.dropFiles` request is consumed exactly once by the UI phase.self.queue_dropped_files(raw);+ // Track the real host modifier state separately from the app's synthetic ownership. A host+ // change means the host now owns the modifier state: relinquish any synthetic claim and do+ // not later synthesise a release for a key that is physically held.+ if let Some(host_mods) = raw.events.iter().rev().find_map(|event| match event {+ egui::Event::ModifiersChanged(modifiers) => Some(*modifiers),+ _ => None,+ }) {+ self.host_mods = host_mods;+ self.synthetic_mods = egui::Modifiers::NONE;+ self.synthetic_mods_release = false;+ }+ // A prompt owns all input. On its first host frame this also removes pointer/touch input+ // before egui computes its hit test; later frames keep only key releases, the prompt's own+ // keys, and AccessKit actions targeted at a prompt button. See `notices::filter_raw_input`.+ let batch_in_flight = self.synthetic_in_flight;+ if crate::panels::notices::prepare_raw_input(self, ctx, raw) {+ // A prompt appearing during a synthetic drag must abort the drag, not let its remaining+ // move/release events act under the prompt or after it is dismissed. If a whole batch+ // was already injected, it is unsafe as well: this frame's prompt filter drops it+ // before a panel sees it, so it must not report a successful delivery.+ self.cancel_gestures_for_barrier(batch_in_flight, "a modal prompt appeared");+ self.queue_pointer_cleanup();+ }+ // Enforce the stall deadline before injecting another event: a request that expired during+ // a long frame gap must not get one more event on the frame that resumes.+ self.expire_gestures();+ // A canceled press is released by resetting egui's pointer state before its next input+ // pass, even while another batch is in flight or the fonts are not ready, so the pointer+ // cannot stay down. No move/release event is injected: either could start a drag or+ // become a click on the widget being canceled.+ self.apply_pointer_cleanup(ctx, raw);if !self.fonts_ready || self.synthetic_in_flight {return;}- if self.drop_gestures_stale_before_injection() {+ if self.drop_gestures_stale_before_injection(ctx) {+ // The stale check can cancel the head gesture while its press is already down.+ self.apply_pointer_cleanup(ctx, raw);return;}- // the frame after a synthetic release / key: modifiers back up+ // the frame after a synthetic release / key: restore the host's physical modifiers, not+ // necessarily NONE (Shift may still be held while a synthetic Alt gesture is released)if std::mem::take(&mut self.synthetic_mods_release) && self.synthetic_mods != egui::Modifiers::NONE {self.synthetic_mods = egui::Modifiers::NONE;- raw.events.push(egui::Event::ModifiersChanged(egui::Modifiers::NONE));+ raw.events.push(egui::Event::ModifiersChanged(self.host_mods));}if self.synthetic.is_empty() {return;@@ -2135,12 +2386,48 @@ impl LightcraftApp {}self.synthetic_mods_release = ends;}- raw.events.extend(self.synthetic.drain(..n));- if let Some(head) = self.head_gesture() {+ let blocked_by_prompt = self.synthetic[..n].iter().any(|event| !crate::panels::notices::prompt_allows_event(self, event));+ let head = self.head_gesture();+ if let Some(head) = head {let gesture = &mut self.pending_gestures[head];+ for event in &self.synthetic[..n] {+ match event {+ egui::Event::PointerButton { button, pressed: true, .. } => {+ gesture.pressed = Some(InjectedPress { button: *button });+ }+ egui::Event::PointerButton { button, pressed: false, .. }+ if gesture.pressed.as_ref().is_some_and(|press| press.button == *button) =>+ {+ gesture.pressed = None;+ }+ _ => {}+ }+ }gesture.started = true;gesture.remaining_events = gesture.remaining_events.saturating_sub(n);}+ raw.events.extend(self.synthetic.drain(..n));+ // The same barrier applies after injection: only the prompt's own keys and targeted+ // AccessKit actions survive; host input and `ui.text`/clipboard never reach the background.+ crate::panels::notices::filter_raw_input(self, raw);+ if blocked_by_prompt && let Some(index) = head {+ // A settled prompt is already laid out, so this is not the prompt-creation-cancels-all+ // path: only the gesture whose batch the barrier removed fails. Allowed prompt keys,+ // pointer input and targeted AccessKit actions still report a successful delivery.+ let gesture = self.pending_gestures.remove(index);+ self.cancel_gesture_events(&gesture, true);+ let _ = gesture.reply.send(serde_json::json!({+ "ok": false,+ "error": format!("{} canceled: the open modal prompt blocked this input", gesture.method),+ }));+ }+ // The 5 s deadline is a delivery-stall limit, not a limit on a gesture's frame count: a+ // drag feeds one event per host frame, so every batch that the app consumes proves the UI+ // is alive and restarts the clock for the whole queue.+ let now = self.tick_now_ms();+ for gesture in &mut self.pending_gestures {+ gesture.deadline_ms = now + GESTURE_TIMEOUT_MS;+ }self.synthetic_in_flight = true;}@@ -2252,19 +2539,65 @@ impl LightcraftApp {// bind to and a control gesture may resolve against.self.synthetic_in_flight = false;if ctx.will_discard() {+ self.next_widgets.clear();+ self.next_widget_hits.clear();return;}+ self.widgets = std::mem::take(&mut self.next_widgets);+ self.widget_hits = std::mem::take(&mut self.next_widget_hits);+ panels::notices::finish_ui_pass(self, ctx);+ panels::library_problem::finish_ui_pass(self, ctx);self.ui_passes = self.ui_passes.wrapping_add(1);self.layout_epoch = self.layout_epoch.wrapping_add(1);self.resolve_pending_gestures(ctx);self.reply_delivered_gestures();+ if self.pointer_cleanup {+ // A canceled press may be discovered by a timeout after the synthetic queue emptied;+ // nothing else may ask for the frame that applies its cancellation.+ ctx.request_repaint();+ }}/// Presentation only: the window's panels, dialogs and overlays.fn draw_window(&mut self, ui: &mut egui::Ui) {let ctx = ui.ctx().clone();- panels::dialogs::prepare(self, ui);let t0 = monotonic_ms();+ panels::library_problem::begin_draw(self);+ // A command or shortcut drawn before this can create the window after `ui_pass`; catch it+ // here before any panel draws with the still-focused background text field.+ let batch_in_flight = self.synthetic_in_flight;+ panels::library_problem::prepare_ui_pass(self, &ctx, batch_in_flight);+ // A newly shown blocking library window gets the same barrier as a prompt: its first Area+ // layout is non-interactable and hit testing still uses the previous pass, so background+ // panels (and a focused text field) must not draw in that pass.+ if panels::library_problem::shield_pass(self, &ctx) {+ #[cfg(test)]+ self.library_passes.push(panels::library_problem::LibraryPass::Shield);+ panels::library_problem::show(self, &ctx, false);+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);+ ctx.request_discard("library problem: shield the window's creation frame");+ self.end_frame(&ctx, t0);+ return;+ }+ // A newly shown prompt gets one pass with no background. egui's first Area layout is+ // non-interactable and its hit test uses the previous pass, so drawing panels here would+ // let a pointer press/release in the prompt's creation frame act underneath it. `ui()` then+ // reruns this pass with empty raw input, where the settled prompt and the full window draw+ // together. This is a state/input-routing barrier, not a wholesale input disable: once+ // settled, raw pointer input still reaches the prompt backdrop (a no-op) or its buttons.+ if panels::notices::shield_pass(self, &ctx) {+ panels::notices::show(self, &ctx);+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);+ ctx.request_discard("notice: shield the prompt's creation frame");+ self.end_frame(&ctx, t0);+ return;+ }+ #[cfg(test)]+ self.library_passes.push(panels::library_problem::LibraryPass::Background);+ panels::dialogs::prepare(self, ui);+ // Freeze this frame's notice barrier before `notices::show` can dismiss a prompt: the same+ // click or key must never be acted on again by the dialog drawn after it.+ let notice_blocks = panels::notices::blocks_input(self);if std::mem::take(&mut self.ui.quit) {ctx.send_viewport_cmd(egui::ViewportCommand::Close);}@@ -2277,12 +2610,23 @@ impl LightcraftApp {.frame(egui::Frame::NONE.fill(egui::Color32::BLACK)).show(ui, |ui| if self.ui.slideshow.is_some() { panels::slideshow::show(self, ui) } else { panels::detail::show(self, ui) });panels::second::show(self, &ctx);+ if notice_blocks {+ panels::notices::restore_prompt_pointer(self, &ctx);+ }panels::notices::show(self, &ctx);- panels::dialogs::show(self, &ctx);- panels::library_problem::show(self, &ctx);+ if notice_blocks {+ panels::notices::hide_background_pointer(&ctx);+ }+ panels::dialogs::show(self, &ctx, notice_blocks);+ panels::library_problem::show(self, &ctx, notice_blocks);panels::toast(self, &ctx);drop_overlay::show(self, &ctx);- self.widgets = widgets::take_registry(&ctx);+ if notice_blocks {+ // Keep the real press/release state for the next pass: an ordinary click spans+ // host frames, and resetting it above must only hide it from this pass's dialogs.+ panels::notices::restore_prompt_pointer(self, &ctx);+ }+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);self.end_frame(&ctx, t0);return;}@@ -2296,9 +2640,15 @@ impl LightcraftApp {egui::CentralPanel::default().frame(egui::Frame::NONE.fill(chrome)).show(ui, |ui| docking::show(self, ui));self.lights_out(&ctx);panels::second::show(self, &ctx);+ if notice_blocks {+ panels::notices::restore_prompt_pointer(self, &ctx);+ }panels::notices::show(self, &ctx);- panels::dialogs::show(self, &ctx);- panels::library_problem::show(self, &ctx);+ if notice_blocks {+ panels::notices::hide_background_pointer(&ctx);+ }+ panels::dialogs::show(self, &ctx, notice_blocks);+ panels::library_problem::show(self, &ctx, notice_blocks);export_task::poll(self, &ctx);slideshow_export::poll(self, &ctx);panels::activity::show(self, &ctx);@@ -2310,7 +2660,12 @@ impl LightcraftApp {panels::keyword_list::drag_feedback(self, &ctx);panels::toast(self, &ctx);drop_overlay::show(self, &ctx);- self.widgets = widgets::take_registry(&ctx);+ if notice_blocks {+ // Keep the real press/release state for the next pass: an ordinary click spans host+ // frames, and resetting it above must only hide it from this pass's dialogs.+ panels::notices::restore_prompt_pointer(self, &ctx);+ }+ (self.next_widgets, self.next_widget_hits) = widgets::take_registries(&ctx);self.text_focus = ctx.egui_wants_keyboard_input();self.end_frame(&ctx, t0);}@@ -2325,6 +2680,10 @@ const SCREENSHOT_FALLBACK_MS: f64 = 2000.0;const MAX_PENDING_SHOTS: usize = 4;/// Bytes one screenshot image may use.const MAX_SHOT_BYTES: usize = 128 * 1024 * 1024;+/// Largest RGBA surface that fits [`MAX_SHOT_BYTES`], checked with the viewport dimensions before+/// layout. The CPU rasterizer's own `softpaint::MAX_IMAGE_PIXELS` may be larger; a snapshot that+/// cannot be captured must be rejected up front rather than after admission.+pub(crate) const MAX_SHOT_PIXELS: usize = MAX_SHOT_BYTES / std::mem::size_of::<egui::Color32>();/// Bytes all pending/completed screenshots may reserve together.const MAX_SHOT_TOTAL_BYTES: usize = 256 * 1024 * 1024;/// Slack for PNG framing and deflate overhead while encoding one screenshot. zlib can exceed the@@ -2337,11 +2696,15 @@ const MAX_SHOT_WORKING_SET_BYTES: usize = MAX_SHOT_TOTAL_BYTES + 2 * MAX_SHOT_BYconst _: () = {assert!(MAX_SHOT_WORKING_SET_BYTES > MAX_SHOT_TOTAL_BYTES);assert!(SHOT_ENCODE_SLACK_BYTES > 0);+ assert!(MAX_SHOT_BYTES.is_multiple_of(std::mem::size_of::<egui::Color32>()));+ assert!(MAX_SHOT_PIXELS * std::mem::size_of::<egui::Color32>() == MAX_SHOT_BYTES);};/// Synthetic-input control requests waiting for a fresh layout/delivery at once.const MAX_PENDING_GESTURES: usize = 32;/// A control gesture is answered with an error after this long without a completed UI pass and/// delivery (milliseconds).+/// How long synthetic input may wait without the UI consuming a batch. Each consumed batch+/// restarts this clock, so it is a stall limit, not a cap on a many-step drag's total time.const GESTURE_TIMEOUT_MS: f64 = 5000.0;/// Completed UI frames a request waits for before it is issued (a settled, laid-out frame).const SHOT_SETTLE_FRAMES: u64 = 3;@@ -2440,19 +2803,34 @@ struct PendingGesture {/// [`LightcraftApp::layout_epoch`] at admission; resolution needs a later one.admitted_epoch: u64,frame: GestureFrame,- /// Monotonic deadline (milliseconds).+ /// Monotonic stall deadline (milliseconds): delivery refreshes it whenever the UI consumes a+ /// batch, so a long but progressing drag is not a timeout.deadline_ms: f64,/// [`LightcraftApp::ui_passes`] when the events were queued (`None`: not resolved yet).resolved_pass: Option<u64>,/// Synthetic events queued for this gesture that the host has not injected yet.remaining_events: usize,/// At least one batch of this gesture's events has reached a pass. Later batches may see the- /// gesture's own effect (a first click selects, the second opens), so freshness is only- /// checked before the first one.+ /// gesture's own effect (a first click selects, the second opens), so the semantic frame+ /// snapshot is only checked before the first one.started: bool,+ /// For a widget gesture, the id and point resolved against the completed layout. Delivery+ /// rechecks the widget's fresh rect before the first event, before each press and (for a click)+ /// before its release.+ target: Option<control::GestureTarget>,+ /// A pointer button this gesture has pressed but not yet released. Cancellation resets the+ /// pointer state before egui's next input pass, so a refused click neither leaves the pointer+ /// down nor turns the cleanup into a click or drag.+ pressed: Option<InjectedPress>,result: Value,}+/// A pointer press delivered to the UI, kept so a canceled gesture knows that a button is down.+#[derive(Clone, Copy, Debug)]+struct InjectedPress {+ button: egui::PointerButton,+}+/// A `ui.screenshot` request in progress.struct PendingShot {token: u64,diff --git a/crates/ui-egui/src/lightroom_destination.rs b/crates/ui-egui/src/lightroom_destination.rsindex a62c59825..5fd781cfd 100644--- a/crates/ui-egui/src/lightroom_destination.rs+++ b/crates/ui-egui/src/lightroom_destination.rs@@ -235,7 +235,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, dialog: &mut Dialog) {count = n);let r = ui.radio_value(new_library, false, merge);- crate::widgets::register(ui.ctx(), "radio:lightroomDestination-open", r.rect);+ crate::widgets::register(ui, "radio:lightroomDestination-open", r.rect);let indent = ui.spacing().icon_width + ui.spacing().icon_spacing;let note = |ui: &mut egui::Ui, text: &str| {ui.horizontal(|ui| {@@ -252,7 +252,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, dialog: &mut Dialog) {},);let r = ui.radio_value(new_library, true, tr("Create a new library"));- crate::widgets::register(ui.ctx(), "radio:lightroomDestination-new", r.rect);+ crate::widgets::register(ui, "radio:lightroomDestination-new", r.rect);ui.add_enabled_ui(*new_library, |ui| {// a field's caption, left-aligned in a column as wide as the longer one (in any language)let font = egui::TextStyle::Body.resolve(ui.style());@@ -298,7 +298,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, dialog: &mut Dialog) {// (it only speaks of merging: unticked and greyed out while a new library is chosen)let mut ticked = *dont_ask && !*new_library;let c = ui.add_enabled(!*new_library, egui::Checkbox::new(&mut ticked, tr("Don't ask again (always merge into the open library)")));- crate::widgets::register(ui.ctx(), "check:lightroomDontAsk", c.rect);+ crate::widgets::register(ui, "check:lightroomDontAsk", c.rect);if !*new_library {*dont_ask = ticked;}diff --git a/crates/ui-egui/src/menu_level.rs b/crates/ui-egui/src/menu_level.rsindex 70a5f9fd5..e888e9ca4 100644--- a/crates/ui-egui/src/menu_level.rs+++ b/crates/ui-egui/src/menu_level.rs@@ -104,7 +104,7 @@ pub fn level(ui: &mut Ui, depth: usize, bar_bottom: Option<f32>, rows: impl FnOnlet out = area.show(ui, rows);let down = over.then(|| ui.allocate_exact_size(vec2(0.0, ARROW), Sense::hover()).0);ctx.data_mut(|d| d.insert_temp(key, out.content_size.y));- crate::widgets::register(&ctx, format!("menu-level:{depth}"), ui.min_rect());+ crate::widgets::register(ui, format!("menu-level:{depth}"), ui.min_rect());let (Some(up), Some(down)) = (up, down) else { return };let t = crate::theme::Tokens::get(&ctx);let x = ui.min_rect().x_range();diff --git a/crates/ui-egui/src/menubar.rs b/crates/ui-egui/src/menubar.rsindex 58c1648b0..9b3d88036 100644--- a/crates/ui-egui/src/menubar.rs+++ b/crates/ui-egui/src/menubar.rs@@ -941,6 +941,54 @@ pub fn run_item(app: &mut LightcraftApp, id: &str, params: Value) -> Result<Valur}+/// What the native menu bar may do with one command it queued.+///+/// AppKit delivers menu accelerators and clicks straight to the host, so they never pass through+/// [`crate::shortcuts::handle`]. The explicit policy below is the equivalent guard for that path.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum NativeCommand {+ /// Run the command through the ordinary menu path.+ Run,+ /// Quit stays available: the host still runs the existing tasks/unsaved-changes confirmation.+ Quit,+ /// A quit/settings notice or the blocking library window owns input: drop the command.+ Blocked,+}++/// The safety policy for commands queued by the native menu bar.+///+/// While a prompt or the blocking library window owns input, no queued command may act on the+/// library behind it — including Settings… and About, which would otherwise open their dialog+/// behind the blocking window. Quit is the one exception: the window itself offers Quit, and the+/// host's existing confirmation ([`crate::panels::notices::may_close`]) still decides whether the+/// process may end.+pub fn native_command_policy(app: &LightcraftApp, id: &str) -> NativeCommand {+ if id == "app.quit" {+ return NativeCommand::Quit;+ }+ if crate::panels::notices::blocks_input(app) || crate::panels::library_problem::blocks_dialog_input(app) {+ return NativeCommand::Blocked;+ }+ NativeCommand::Run+}++/// Run one command resolved from a native menu event under [`native_command_policy`].+///+/// The host calls this for every queued native command, so a macOS accelerator, click or About/+/// Settings item respects the notice and blocking-library barriers. Ordinary dialogs retain+/// their existing native-menu behavior.+pub fn run_native_command(app: &mut LightcraftApp, id: &str, params: Value) -> NativeCommand {+ let policy = native_command_policy(app, id);+ match policy {+ NativeCommand::Run => {+ let _ = run_item(app, id, params);+ }+ NativeCommand::Blocked => log::debug!("native menu: {id} is blocked while another window owns input"),+ NativeCommand::Quit => {}+ }+ policy+}+/// Human-readable shortcut text for menus: `Cmd+Shift+Z` → `⌘⇧Z` on macOS, `Ctrl+Shift+Z` elsewhere.pub fn shortcut_text(sc: &str, mac: bool) -> String {if mac {@@ -1006,7 +1054,7 @@ pub fn show_in_window(app: &mut LightcraftApp, ui: &mut egui::Ui, max_width: f32.iter().map(|(title, _)| {let r = ui.add(egui::Button::new(egui::RichText::new(crate::i18n::tr(title)).font(font.clone()).color(t.text_label)).frame(false));- crate::widgets::register(ui.ctx(), format!("menu:{title}"), r.rect);+ crate::widgets::register(ui, format!("menu:{title}"), r.rect);r}).collect();@@ -1027,7 +1075,7 @@ pub fn show_in_window(app: &mut LightcraftApp, ui: &mut egui::Ui, max_width: f32ui.spacing_mut().item_spacing.x = saved;} else {let r = ui.add(egui::Button::new(egui::RichText::new(crate::i18n::tr("Menu")).font(font.clone()).color(t.text_label)).frame(false));- crate::widgets::register(ui.ctx(), "menu:all", r.rect);+ crate::widgets::register(ui, "menu:all", r.rect);egui::Popup::menu(&r).show(|ui| {crate::menu_level::level(ui, 1, bar_bottom, |ui| {for (title, items) in &bar {@@ -1095,7 +1143,7 @@ fn switch_open_title(ctx: &egui::Context, titles: &[egui::Response]) -> Option<e/// label), and while its submenu is open it is the anchor the next frame's room is measured from.fn submenu(ui: &mut egui::Ui, label: &str, text: String, depth: usize, bar_bottom: Option<f32>, children: impl FnOnce(&mut egui::Ui)) {let r = crate::widgets::menu_button(ui, text, |ui| crate::menu_level::level(ui, depth + 1, bar_bottom, children));- crate::widgets::register(ui.ctx(), format!("menusub:{label}"), r.response.rect);+ crate::widgets::register(ui, format!("menusub:{label}"), r.response.rect);if r.inner.is_some() {crate::menu_level::set_anchor(ui.ctx(), depth + 1, r.response.rect);}@@ -1121,7 +1169,7 @@ fn nodes_ui(ui: &mut egui::Ui, nodes: &[MenuNode], mac: bool, clicked: &mut Optib = b.shortcut_text(shortcut_text(sc, mac));}let r = ui.add_enabled(*enabled, b);- crate::widgets::register(ui.ctx(), format!("menuitem:{id}"), r.rect);+ crate::widgets::register(ui, format!("menuitem:{id}"), r.rect);if *checked == Some(true) {let t = crate::theme::Tokens::get(ui.ctx());let c = egui::Rect::from_center_size(egui::pos2(r.rect.left() + 11.0, r.rect.center().y), egui::vec2(13.0, 13.0));@@ -1841,6 +1889,73 @@ mod tests {assert_eq!(app.session.catalog.photo(other).unwrap().meta.copyright, "© Me");}+ /// Native menu accelerators never pass through `shortcuts::handle`: a command queued by the+ /// native menu must obey the same blocking-window/prompt policy. Settings… and About must not+ /// open behind the blocking window, and Quit stays available for its existing confirmation.+ #[test]+ fn native_menu_commands_respect_the_blocking_window_policy() {+ use crate::panels::library_problem::LibraryProblem;+ use crate::state::Dialog;++ let mut h = crate::headless::Headless::new(app(), [1000.0, 760.0], 1.0);+ h.settle(std::time::Duration::from_secs(20));+ h.app.ui.view = ViewMode::PhotoGrid;+ h.app.library_problem = Some(LibraryProblem::new("/no/such/library", "a test error"));++ assert_eq!(native_command_policy(&h.app, "app.settings"), NativeCommand::Blocked);+ assert_eq!(native_command_policy(&h.app, "app.about"), NativeCommand::Blocked);+ assert_eq!(native_command_policy(&h.app, "view.gridToggle"), NativeCommand::Blocked);+ assert_eq!(native_command_policy(&h.app, "app.quit"), NativeCommand::Quit, "Quit keeps its own confirmation");+ assert_eq!(run_native_command(&mut h.app, "app.settings", Value::Null), NativeCommand::Blocked);+ assert!(h.app.ui.dialog.is_none(), "Settings must not open behind the blocking library window");+ assert_eq!(run_native_command(&mut h.app, "app.about", Value::Null), NativeCommand::Blocked);+ assert!(h.app.ui.dialog.is_none(), "About must not open behind the blocking library window");+ assert_eq!(run_native_command(&mut h.app, "view.gridToggle", Value::Null), NativeCommand::Blocked);+ assert_eq!(h.app.ui.view, ViewMode::PhotoGrid, "a menu command did not act on the library behind the window");+ assert_eq!(+ run_native_command(&mut h.app, "app.quit", Value::Null),+ NativeCommand::Quit,+ "Quit stays for the host's existing tasks/unsaved-changes confirmation"+ );+ assert!(h.app.ui.dialog.is_none());++ // The launch list owns input the same way.+ let settings = crate::state::AppSettings {+ recent_libraries: vec!["/no/such/library-one".into()],+ library_path: "/no/such/library-one".into(),+ ..Default::default()+ };+ h.app.library_problem = Some(LibraryProblem::choose(&settings));+ assert_eq!(native_command_policy(&h.app, "app.about"), NativeCommand::Blocked);+ assert_eq!(run_native_command(&mut h.app, "app.about", Value::Null), NativeCommand::Blocked);+ assert!(h.app.ui.dialog.is_none(), "About must not open behind the launch list");+ // The launch list's own New Library prompt is not a background barrier: it keeps its+ // priority instead of being treated as an unrelated dialog behind the list.+ h.app.ui.dialog = Some(Dialog::TextPrompt {+ title: "New Library".into(),+ hint: "Library name".into(),+ value: "New Library".into(),+ command: "app.newLibrary".into(),+ params: json!({}),+ key: "name".into(),+ });+ assert_eq!(native_command_policy(&h.app, "app.settings"), NativeCommand::Run, "the launch list's own prompt is not a background barrier");+ h.app.ui.dialog = None;++ // A quit/settings notice owns input in the same way.+ h.app.library_problem = None;+ h.app.notices.push("The settings file could not be read and was reset.".into());+ assert_eq!(native_command_policy(&h.app, "app.settings"), NativeCommand::Blocked);+ assert_eq!(run_native_command(&mut h.app, "app.settings", Value::Null), NativeCommand::Blocked);+ assert!(h.app.ui.dialog.is_none(), "Settings must not open behind a notice");++ // Once nothing blocks input, the same queued command runs normally.+ h.app.notices.clear();+ assert_eq!(native_command_policy(&h.app, "app.settings"), NativeCommand::Run);+ assert_eq!(run_native_command(&mut h.app, "app.settings", Value::Null), NativeCommand::Run);+ assert!(matches!(h.app.ui.dialog, Some(Dialog::Settings { .. })), "the command runs when no barrier owns input");+ }+#[test]fn shortcut_text_per_platform() {assert_eq!(shortcut_text("Cmd+Shift+Z", true), "⌘⇧Z");diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 13348201f..03841d14a 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -709,11 +709,12 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<ReOk(Value::Null)}"view.fullScreenPreview" => {- app.ui.fullscreen = !app.ui.fullscreen;- if !app.ui.fullscreen {- app.ui.slideshow = None;- }if app.ui.fullscreen {+ // Through `slideshow::end`: it also releases the held slide textures. Clearing the+ // two fields directly left every rendered slide in the renderer.+ crate::panels::slideshow::end(app);+ } else {+ app.ui.fullscreen = true;app.ui.zoom = Zoom::Fit;app.ui.tool.clear();let _ = app.session.end_interaction();diff --git a/crates/ui-egui/src/merge.rs b/crates/ui-egui/src/merge.rsindex 13aad67a6..4dc744b6d 100644--- a/crates/ui-egui/src/merge.rs+++ b/crates/ui-egui/src/merge.rs@@ -428,7 +428,7 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, opts: &mut MergeDialog)let box_size = egui::vec2(520.0, 360.0);let (rect, resp) = ui.allocate_exact_size(box_size, egui::Sense::click_and_drag());ui.painter().rect_filled(rect, 4.0, t.canvas);- crate::widgets::register(ui.ctx(), "merge.preview", rect);+ crate::widgets::register(ui, "merge.preview", rect);if let Some((tex, size, _, _)) = &app.merge.preview {let (tex, size) = (tex.id(), *size);let (r, zoom) = preview_rect(rect, size, ui.ctx().pixels_per_point(), app.merge.zoom);diff --git a/crates/ui-egui/src/model_setup.rs b/crates/ui-egui/src/model_setup.rsindex 47cdfe1eb..9042a9502 100644--- a/crates/ui-egui/src/model_setup.rs+++ b/crates/ui-egui/src/model_setup.rs@@ -97,7 +97,7 @@ pub(crate) fn notice(app: &mut LightcraftApp, ui: &mut egui::Ui, kind: &str) {}ui.add(egui::Label::new(tr("After installation, AI Denoise will turn on for the requesting photo.")).wrap());let r = ui.small_button(tr("Cancel pending action"));- crate::widgets::register(ui.ctx(), "modelSetup:cancel:denoise", r.rect);+ crate::widgets::register(ui, "modelSetup:cancel:denoise", r.rect);if r.clicked() {let _ = app.run("modelSetup.cancel", json!({"kind": "denoise"}));}diff --git a/crates/ui-egui/src/panels/activity.rs b/crates/ui-egui/src/panels/activity.rsindex 8bf9a8556..dffdd1c4d 100644--- a/crates/ui-egui/src/panels/activity.rs+++ b/crates/ui-egui/src/panels/activity.rs@@ -96,7 +96,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {ui.add_space(4.0);let text = if hidden > 0 { tr_format!("+{n} more", n = hidden) } else { tr("Show less").to_string() };let r = ui.add(egui::Label::new(RichText::new(text).font(t.font(11.0)).color(t.accent)).sense(Sense::click()));- register(ui.ctx(), "activity:more", r.rect);+ register(ui, "activity:more", r.rect);toggle = r.clicked();}});@@ -132,7 +132,7 @@ fn row(ui: &mut egui::Ui, t: &Tokens, task: &TaskInfo, width: f32) -> bool {let (rect, resp) = ui.allocate_exact_size(vec2(CROSS, CROSS), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr("Cancel"));paint(ui.painter(), rect.shrink(2.0), Icon::Close, if resp.hovered() { t.text } else { t.icon });- register(ui.ctx(), format!("activity:cancel:{}", task.id), rect);+ register(ui, format!("activity:cancel:{}", task.id), rect);clicked = resp.on_hover_text(tr("Cancel")).clicked();}});@@ -142,7 +142,7 @@ fn row(ui: &mut egui::Ui, t: &Tokens, task: &TaskInfo, width: f32) -> bool {ui.add(egui::Label::new(RichText::new(line).font(t.font(11.0)).color(t.text_dim)).truncate());}});- register(ui.ctx(), format!("activity:row:{}", task.id), r.response.rect);+ register(ui, format!("activity:row:{}", task.id), r.response.rect);clicked}diff --git a/crates/ui-egui/src/panels/bottombar.rs b/crates/ui-egui/src/panels/bottombar.rsindex a0b9bf5c6..0b48d1e34 100644--- a/crates/ui-egui/src/panels/bottombar.rs+++ b/crates/ui-egui/src/panels/bottombar.rs@@ -123,7 +123,7 @@ fn centre(app: &mut LightcraftApp, ui: &mut egui::Ui, full: Rect, from: f32, to:}),flag == f,);- register(pill_ui.ctx(), format!("flag:{id}"), r);+ register(&pill_ui, format!("flag:{id}"), r);let on = flag == f && f != Flag::None;let c = if on {if f == Flag::Reject { t.reject } else { t.pick }@@ -148,7 +148,7 @@ fn centre(app: &mut LightcraftApp, ui: &mut egui::Ui, full: Rect, from: f32, to:let copy_r = Rect::from_min_size(pos2(pill.right() + 10.0, pill.top()), vec2(copy_width, 30.0));let cresp = ui.interact(copy_r, egui::Id::unique("copy-settings"), Sense::click());crate::widgets::announce(&cresp, label.to_string());- register(ui.ctx(), "button:copySettings", copy_r);+ register(ui, "button:copySettings", copy_r);ui.painter().rect_filled(copy_r, 15.0, if cresp.hovered() { t.hover } else { t.canvas });ui.painter().text(copy_r.center(), Align2::CENTER_CENTER, label, t.font(13.0), if active.is_some() { t.text_label } else { t.text_disabled });if cresp.clicked() && active.is_some() {@@ -159,7 +159,7 @@ fn centre(app: &mut LightcraftApp, ui: &mut egui::Ui, full: Rect, from: f32, to:let gear_r = Rect::from_min_size(pos2(copy_r.right() + 4.0, pill.top()), vec2(30.0, 30.0));let gresp = ui.interact(gear_r, egui::Id::unique("copy-gear"), Sense::click());crate::widgets::announce(&gresp, crate::i18n::tr("Copy Settings…"));- register(ui.ctx(), "icon:copyGear", gear_r);+ register(ui, "icon:copyGear", gear_r);ui.painter().rect_filled(gear_r, 15.0, if gresp.hovered() { t.hover } else { t.canvas });paint(ui.painter(), gear_r.shrink(7.0), Icon::Gear, t.icon);if gresp.clicked() {@@ -243,7 +243,7 @@ fn right_side(app: &mut LightcraftApp, ui: &mut egui::Ui, full: Rect, compact_zo// thumbnail size sliderlet (r, resp) = child.allocate_exact_size(vec2(110.0, 20.0), Sense::click_and_drag());crate::widgets::announce(&resp, crate::i18n::tr("Thumbnail size"));- register(child.ctx(), "slider:thumbSize", r);+ register(&child, "slider:thumbSize", r);let p = child.painter();let y = r.center().y;p.line_segment([pos2(r.left(), y), pos2(r.right(), y)], egui::Stroke::new(2.0, t.track));@@ -292,7 +292,7 @@ fn sort_menu(app: &mut LightcraftApp, ui: &mut egui::Ui) {// a view that holds its photos shows what matches now when asked toif app.session.hold_view {let r = ui.button(crate::i18n::tr("Refresh View"));- crate::widgets::register(ui.ctx(), "button:refreshView", r.rect);+ crate::widgets::register(ui, "button:refreshView", r.rect);if r.clicked() {let _ = app.run("library.refresh", json!({}));}diff --git a/crates/ui-egui/src/panels/chips.rs b/crates/ui-egui/src/panels/chips.rsindex 66442a975..c18b3ad72 100644--- a/crates/ui-egui/src/panels/chips.rs+++ b/crates/ui-egui/src/panels/chips.rs@@ -89,7 +89,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, chips: &[FilterChip]) {let t = Tokens::get(ui.ctx());let (bar, _) = ui.allocate_exact_size(vec2(ui.available_width(), HEIGHT), Sense::hover());ui.painter().rect_filled(bar, 0.0, t.canvas);- register(ui.ctx(), "filterchips", bar);+ register(ui, "filterchips", bar);let font = t.font(12.0);let right = bar.right() - 16.0;let mut x = bar.left() + 20.0;@@ -109,7 +109,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, chips: &[FilterChip]) {let xr = Rect::from_center_size(pos2(r.right() - 12.0, r.center().y), vec2(18.0, 18.0));let resp = ui.interact(xr, egui::Id::unique(("filter-chip-x", i)), Sense::click()).on_hover_text(crate::i18n::tr("Remove this filter"));crate::widgets::announce(&resp, format!("{}: {label}", crate::i18n::tr("Remove this filter")));- register(ui.ctx(), format!("chip:{i}"), xr);+ register(ui, format!("chip:{i}"), xr);let col = if resp.hovered() { t.text } else { t.text_dim };let m = 3.5;let (a, b) = (xr.center() - vec2(m, m), xr.center() + vec2(m, m));diff --git a/crates/ui-egui/src/panels/compare.rs b/crates/ui-egui/src/panels/compare.rsindex 5b9bb8185..829500da4 100644--- a/crates/ui-egui/src/panels/compare.rs+++ b/crates/ui-egui/src/panels/compare.rs@@ -361,9 +361,9 @@ fn photo_tile(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, slot: Slo&& lr.right() < cap.right(){pt.circle_filled(lr.center(), 5.0, super::grid::label_color(l));- register(ui.ctx(), format!("cull:{}:label", id.0), lr);+ register(ui, format!("cull:{}:label", id.0), lr);}- register(ui.ctx(), format!("cull:{}", id.0), display);+ register(ui, format!("cull:{}", id.0), display);(display, resp)}diff --git a/crates/ui-egui/src/panels/denoise.rs b/crates/ui-egui/src/panels/denoise.rsindex d070f5b74..575fa008d 100644--- a/crates/ui-egui/src/panels/denoise.rs+++ b/crates/ui-egui/src/panels/denoise.rs@@ -146,7 +146,7 @@ pub fn detail_toggle(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, onlet mut enabled = on || crate::model_setup::denoise_requested(app, id);egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 6, bottom: 2 }).show(ui, |ui| {let r = ui.add_enabled(applicable, egui::Checkbox::new(&mut enabled, crate::i18n::tr("AI Denoise")));- register(ui.ctx(), "denoise:enabled", r.rect);+ register(ui, "denoise:enabled", r.rect);if r.changed() {let _ = app.run("denoise.toggle", json!({"id": id.0, "enabled": enabled}));}@@ -185,7 +185,7 @@ pub fn detail_status(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, amnote(ui, "AI Denoise needs a model. Install one in Settings.", t.text_dim);ui.add_space(2.0);let r = ui.small_button(crate::i18n::tr("Set up AI Denoise…"));- register(ui.ctx(), "denoise:setup", r.rect);+ register(ui, "denoise:setup", r.rect);if r.clicked() {let _ = app.run("denoise.toggle", json!({"id": id.0, "enabled": true}));}@@ -208,7 +208,7 @@ pub fn detail_status(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, amnote(ui, "Its denoised picture is not made yet, and pictures are not made on their own (Settings, AI Denoise).", t.text_dim);ui.add_space(2.0);let r = ui.small_button(crate::i18n::tr("Make it now"));- register(ui.ctx(), "denoise:make", r.rect);+ register(ui, "denoise:make", r.rect);if r.clicked() {let _ = app.run("denoise.queue", json!({"ids": [id.0]}));}@@ -236,7 +236,7 @@ pub fn detail_status(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, amnote(ui, &sentence(&why), color);if !unsupported {let r = ui.small_button(crate::i18n::tr("Try again"));- register(ui.ctx(), "denoise:retry", r.rect);+ register(ui, "denoise:retry", r.rect);if r.clicked() {let _ = app.run("denoise.queue", json!({"ids": [id.0], "retry": true}));}@@ -335,7 +335,7 @@ fn work_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, list: &Vhint(ui, t, &device_line(&status["device"], run_on));if run_on != "cpu" && status["device"]["retry"] == true {let r = ui.small_button(crate::i18n::tr("Try the graphics card again"));- register(ui.ctx(), "denoise:retryGpu", r.rect);+ register(ui, "denoise:retryGpu", r.rect);if r.clicked() {// choosing where it runs, even the same again, forgets the failed set-uplet _ = app.run("denoise.settings", json!({"runOn": run_on}));@@ -373,13 +373,13 @@ fn work_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, list: &V}ui.horizontal(|ui| {let r = ui.button(tr("Denoise all photos with an Amount"));- register(ui.ctx(), "denoise:queueAll", r.rect);+ register(ui, "denoise:queueAll", r.rect);if r.clicked() {let _ = app.run("denoise.queue", json!({"scope": "withAmount"}));}if running.is_some() || queued > 0 {let r = ui.button(tr("Stop"));- register(ui.ctx(), "denoise:stop", r.rect);+ register(ui, "denoise:stop", r.rect);if r.clicked() {let _ = app.run("denoise.cancel", json!({}));}@@ -411,7 +411,7 @@ fn work_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, list: &Vapp.caches.denoise.epoch += 1;}let r = ui.button(tr("Clear cache"));- register(ui.ctx(), "denoise:clear", r.rect);+ register(ui, "denoise:clear", r.rect);if r.clicked() {let _ = app.run("denoise.clear", json!({}));}@@ -495,21 +495,21 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {if installed {let r = ui.button(tr("Remove"));- register(ui.ctx(), format!("denoise:remove:{id}"), r.rect);+ register(ui, format!("denoise:remove:{id}"), r.rect);if r.clicked() {let _ = app.run("denoise.models.remove", json!({"id": id}));app.caches.denoise.epoch += 1;}if selected {let r = ui.button(tr("Turn off"));- register(ui.ctx(), format!("denoise:off:{id}"), r.rect);+ register(ui, format!("denoise:off:{id}"), r.rect);if r.clicked() {let _ = app.run("denoise.models.select", json!({"id": null}));app.caches.denoise.epoch += 1;}} else {let r = ui.button(tr("Use"));- register(ui.ctx(), format!("denoise:use:{id}"), r.rect);+ register(ui, format!("denoise:use:{id}"), r.rect);if r.clicked() {let _ = app.run("denoise.models.select", json!({"id": id}));app.caches.denoise.epoch += 1;@@ -519,7 +519,7 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,match dl_state {Some("running") => {let r = ui.button(tr("Cancel"));- register(ui.ctx(), format!("denoise:cancelDownload:{id}"), r.rect);+ register(ui, format!("denoise:cancelDownload:{id}"), r.rect);if r.clicked() {let _ = app.run("denoise.models.downloadCancel", json!({"id": id}));app.caches.denoise.dl_watch.retain(|w| w != &id);@@ -532,7 +532,7 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,let r = ui.button(tr("Open page")).on_hover_text(tr("Opens the model's own page in your browser, to read about it or get the file yourself."));- register(ui.ctx(), format!("denoise:get:{id}"), r.rect);+ register(ui, format!("denoise:get:{id}"), r.rect);if r.clicked() {open_page(app, url);}@@ -545,7 +545,7 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,host = host);let r = ui.button(tr(label)).on_hover_text(tip);- register(ui.ctx(), format!("denoise:download:{id}"), r.rect);+ register(ui, format!("denoise:download:{id}"), r.rect);if r.clicked() {open_download_dialog(app, m);}@@ -723,7 +723,7 @@ pub fn model_dialog(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, info}if let Some(url) = m["source"].as_str().or(m["licence"]["url"].as_str()) {let r = ui.link(tr("Open the model's page"));- register(ui.ctx(), "denoiseModel:page", r.rect);+ register(ui, "denoiseModel:page", r.rect);if r.clicked() {open_page(app, url);}diff --git a/crates/ui-egui/src/panels/detail.rs b/crates/ui-egui/src/panels/detail.rsindex 3462d909f..05bd7a511 100644--- a/crates/ui-egui/src/panels/detail.rs+++ b/crates/ui-egui/src/panels/detail.rs@@ -12,7 +12,7 @@ use crate::LightcraftApp;use crate::render::Slot;use crate::state::{BeforeAfter, RightPanel, ToolOverlay, Zoom};use crate::theme::Tokens;-use crate::widgets::register;+use crate::widgets::{register, register_geometry};/// An in-progress on-canvas gesture.#[derive(Clone, Debug)]@@ -345,7 +345,7 @@ pub(crate) fn draw_focus_point(p: &egui::Painter, img: Rect, photo: &lightcraft_let c = b.center();p.circle_filled(c, 2.5, Color32::from_black_alpha(170));p.circle_filled(c, 1.5, green);- register(p.ctx(), key, b);+ register_geometry(p.ctx(), key, b);}/// Ease the loupe rect toward `target` while a click-zoom animation runs; otherwise follow it exactly.@@ -881,7 +881,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {if let Some((bg, g)) = before_badge {p.rect_filled(bg, 4.0, Color32::from_black_alpha(160));p.galley(bg.min + vec2(8.0, 4.0), g, Color32::WHITE);- register(ui.ctx(), "canvas:beforeLabel", bg);+ register(ui, "canvas:beforeLabel", bg);}// the line of a wipe over bothif app.ui.before_after == BeforeAfter::Split {@@ -895,7 +895,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {}// View ▸ Loupe Overlay ▸ Layout Image, over the photo (the After view in a before/after)super::layout_overlay::draw(app, &p, img_rect);- register(ui.ctx(), "canvas:image", img_rect);+ register(ui, "canvas:image", img_rect);let map = CanvasMap::new(&frame, img_rect);info_overlay(app, &p, canvas, &photo);if !fullscreen {@@ -1051,7 +1051,7 @@ fn info_overlay(app: &LightcraftApp, p: &egui::Painter, canvas: Rect, photo: &liy += g.size().y + INFO_OVERLAY_GAP;}y = overlay_badges(p, &t, pos2(canvas.left() + 14.0, y), photo);- register(p.ctx(), "canvas:infoOverlay", Rect::from_min_max(canvas.min, pos2(canvas.left() + 320.0, y)));+ register_geometry(p.ctx(), "canvas:infoOverlay", Rect::from_min_max(canvas.min, pos2(canvas.left() + 320.0, y)));}/// Where the info overlay's text starts below the canvas' top (without window controls over it),@@ -1135,7 +1135,7 @@ fn overlay_badges(p: &egui::Painter, t: &Tokens, at: Pos2, photo: &lightcraft_capaint(p, r, icon, color);x += side + 2.0;}- register(p.ctx(), "canvas:infoOverlayBadges", Rect::from_min_max(at, pos2(x, at.y + side + 2.0)));+ register_geometry(p.ctx(), "canvas:infoOverlayBadges", Rect::from_min_max(at, pos2(x, at.y + side + 2.0)));at.y + OVERLAY_BADGES_H}@@ -1243,7 +1243,7 @@ fn region_overlay(let xr = Rect::from_center_size(pos2(rect.right() - 13.0, rect.top() + 13.0), vec2(16.0, 16.0));let resp = ui.interact(xr, egui::Id::unique(("region-x", index)), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr("Remove region"));- register(ui.ctx(), format!("regionRemove:{index}"), xr);+ register(ui, format!("regionRemove:{index}"), xr);let fill = Color32::from_black_alpha(if resp.hovered() { 235 } else { 190 });p.rect_filled(xr, 2.0, fill);p.rect_stroke(xr, 2.0, Stroke::new(1.0, Color32::from_white_alpha(120)), StrokeKind::Inside);@@ -1293,7 +1293,7 @@ fn region_overlay(// a click on the label opens the name box, filled with the name or the guesslet resp = ui.interact(label, egui::Id::unique(("region-label", index)), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr("Click to name this face"));- register(ui.ctx(), format!("regionLabel:{index}"), label);+ register(ui, format!("regionLabel:{index}"), label);if resp.on_hover_text(crate::i18n::tr("Click to name this face")).clicked() {let start = r.name.clone().or_else(|| hint.and_then(|h| h.suggestion.as_ref().map(|(n, _)| n.clone()))).unwrap_or_default();*editing = Some(crate::state::NameEdit { photo: photo.id.0, index, text: start, fresh: true });@@ -1340,7 +1340,7 @@ fn filter_pill(app: &mut LightcraftApp, ui: &mut egui::Ui, canvas: Rect) {let r = Rect::from_min_size(canvas.min + vec2(inset, inset), vec2(w, FILTER_PILL_HEIGHT));let resp = ui.interact(r, egui::Id::unique("loupe-filter-pill"), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr("Filters"));- register(ui.ctx(), "loupe:filters", r);+ register(ui, "loupe:filters", r);p.rect_filled(r, 10.0, Color32::from_black_alpha(if resp.hovered() { 225 } else { 185 }));let text_clip = Rect::from_min_max(r.min, pos2(r.right() - 24.0, r.max.y));p.with_clip_rect(text_clip).galley(pos2(r.left() + 10.0, r.center().y - g.size().y / 2.0), g, Color32::from_gray(225));@@ -1365,7 +1365,7 @@ fn preview_only_pill(ui: &mut egui::Ui, canvas: Rect, reason: &str) {p.rect_filled(r, 13.0, Color32::from_black_alpha(185));crate::icons::paint(&p, Rect::from_center_size(pos2(r.left() + 16.0, r.center().y), vec2(15.0, 15.0)), crate::icons::Icon::Info, t.caution);p.galley(pos2(r.left() + 29.0, r.center().y - g.size().y / 2.0), g, Color32::WHITE);- register(ui.ctx(), "notice:previewOnly:loupe", r);+ register(ui, "notice:previewOnly:loupe", r);ui.interact(r, egui::Id::unique("preview-only-pill"), Sense::hover()).on_hover_text(crate::widgets::preview_only_explanation(reason));}@@ -1436,7 +1436,7 @@ fn navigator(app: &mut LightcraftApp, ui: &mut egui::Ui, canvas: Rect, img: Rectlet view = Rect::from_min_max(to_nav(a), to_nav(b));p.rect_stroke(view, 0.0, Stroke::new(1.5, Color32::WHITE), StrokeKind::Inside);p.rect_stroke(view.expand(1.5), 0.0, Stroke::new(1.0, Color32::from_black_alpha(160)), StrokeKind::Outside);- register(ui.ctx(), "canvas:navigator", frame);+ register(ui, "canvas:navigator", frame);let resp = ui.interact(frame.expand(5.0), egui::Id::unique("navigator"), Sense::click_and_drag());crate::widgets::announce(&resp, crate::i18n::tr("Navigator"));if (resp.clicked() || resp.dragged())@@ -1498,7 +1498,7 @@ pub(crate) fn loupe_pill(ui: &egui::Ui, canvas: Rect, over: Rect, navigator: Optcrate::icons::paint(&p, Rect::from_center_size(pos2(r.left() + 16.0, r.center().y), vec2(13.0, 13.0)), crate::icons::Icon::Info, t.caution);}p.galley(pos2(r.left() + inset, r.center().y - g.size().y / 2.0), g, Color32::from_gray(225));- register(ui.ctx(), id, r);+ register(ui, id, r);r}@@ -1744,7 +1744,7 @@ fn crop_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Respons// handles: 0..3 corners, 4..7 edges (top, right, bottom, left)let handles: Vec<Pos2> = (0..8).map(|i| if i < 4 { pts[i] } else { lerp(pts[i - 4], pts[(i - 3) % 4], 0.5) }).collect();for (i, h) in handles.iter().enumerate() {- register(ui.ctx(), format!("cropHandle:{i}"), Rect::from_center_size(*h, vec2(14.0, 14.0)));+ register(ui, format!("cropHandle:{i}"), Rect::from_center_size(*h, vec2(14.0, 14.0)));let s = if i < 4 { 12.0 } else { 9.0 };p.rect_filled(Rect::from_center_size(*h, vec2(s, 3.0)), 0.0, Color32::WHITE);p.rect_filled(Rect::from_center_size(*h, vec2(3.0, s)), 0.0, Color32::WHITE);@@ -1960,7 +1960,7 @@ fn rotate_cursor(ui: &egui::Ui, at: Pos2, turn: f32) {let r = Rect::from_center_size(at, vec2(22.0, 22.0));p.circle_filled(at, 12.0, Color32::from_black_alpha(150));crate::icons::paint_turned(&p, r.shrink(2.0), crate::icons::Icon::RotateDrag, Color32::WHITE, turn);- register(ui.ctx(), "cropRotateCursor", r);+ register(ui, "cropRotateCursor", r);}/// How far to turn the rotation pointer (radians, clockwise) so its arc, drawn bulging up, bulges@@ -1994,7 +1994,7 @@ fn angle_readout(ui: &egui::Ui, at: Pos2, angle: f64, bounds: Rect) {let rect = readout_rect(at, galley.size() + vec2(12.0, 6.0), bounds);p.rect_filled(rect, 4.0, Color32::from_black_alpha(170));p.galley(rect.min + vec2(6.0, 3.0), galley, Color32::WHITE);- register(ui.ctx(), "cropAngleReadout", rect);+ register(ui, "cropAngleReadout", rect);}/// Guided Upright: draw up to four guides along lines that should be vertical or horizontal. Guides are@@ -2027,7 +2027,7 @@ fn guided_overlay(};for (i, guide) in d.geometry.guides.iter().enumerate() {let (sa, sb) = on_screen(guide);- register(ui.ctx(), format!("uprightGuide:{i}"), Rect::from_two_pos(sa, sb));+ register(ui, format!("uprightGuide:{i}"), Rect::from_two_pos(sa, sb));draw(sa, sb, selected == Some(i));}ui.ctx().set_cursor_icon(egui::CursorIcon::Crosshair);@@ -2376,7 +2376,7 @@ fn mask_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Responslet (x, y) = (rx * a_local.cos(), ry * a_local.sin());let q = map.screen(Point::new(center.x + (x * co - y * s) * l.0, center.y + (x * s + y * co) * l.1));p.circle_stroke(q, 5.0, Stroke::new(1.5, Color32::WHITE));- register(ui.ctx(), format!("maskHandle:{}:{ci}:{}", m.id, i + 1), Rect::from_center_size(q, vec2(14.0, 14.0)));+ register(ui, format!("maskHandle:{}:{ci}:{}", m.id, i + 1), Rect::from_center_size(q, vec2(14.0, 14.0)));grips.push((m.id, ci, i as u8 + 1, q));}@@ -2386,7 +2386,7 @@ fn mask_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Responslet h1_q = map.screen(Point::new(center.x + (rx * co) * l.0, center.y + (rx * s) * l.1));p.line_segment([h1_q, rot_q], Stroke::new(1.0, Color32::from_white_alpha(200)));p.circle_stroke(rot_q, 4.0, Stroke::new(1.5, Color32::WHITE));- register(ui.ctx(), format!("maskHandle:{}:{ci}:5", m.id), Rect::from_center_size(rot_q, vec2(14.0, 14.0)));+ register(ui, format!("maskHandle:{}:{ci}:5", m.id), Rect::from_center_size(rot_q, vec2(14.0, 14.0)));grips.push((m.id, ci, 5, rot_q));}}@@ -2401,7 +2401,7 @@ fn mask_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Responsif sel {for (i, q) in [a, b].iter().enumerate() {p.circle_stroke(*q, 5.0, Stroke::new(1.5, Color32::WHITE));- register(ui.ctx(), format!("maskHandle:{}:{ci}:{i}", m.id), Rect::from_center_size(*q, vec2(14.0, 14.0)));+ register(ui, format!("maskHandle:{}:{ci}:{i}", m.id), Rect::from_center_size(*q, vec2(14.0, 14.0)));grips.push((m.id, ci, i as u8 + 1, *q));}}@@ -2414,7 +2414,7 @@ fn mask_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Respons{let q = map.screen(at);pin(&pins, q, sel);- register(ui.ctx(), format!("maskPin:{}:{ci}", m.id), Rect::from_center_size(q, vec2(14.0, 14.0)));+ register(ui, format!("maskPin:{}:{ci}", m.id), Rect::from_center_size(q, vec2(14.0, 14.0)));grips.push((m.id, ci, 0, q));}}@@ -2697,11 +2697,11 @@ fn remove_overlay(app: &mut LightcraftApp, ui: &mut egui::Ui, resp: &egui::Respo}let dir = (tq - sq).normalized();p.arrow(sq + dir * r, (tq - sq) - dir * (2.0 * r).min((tq - sq).length()), Stroke::new(1.0, Color32::from_white_alpha(200)));- register(ui.ctx(), format!("spotSource:{i}"), Rect::from_center_size(sq, vec2(14.0, 14.0)));+ register(ui, format!("spotSource:{i}"), Rect::from_center_size(sq, vec2(14.0, 14.0)));grips.push((i, true, sq, r));}pin(p, tq, sel);- register(ui.ctx(), format!("spotPin:{i}"), Rect::from_center_size(tq, vec2(14.0, 14.0)));+ register(ui, format!("spotPin:{i}"), Rect::from_center_size(tq, vec2(14.0, 14.0)));grips.push((i, false, tq, r));}if spot_keys(app, ui, map, d, &grips) {@@ -2931,7 +2931,7 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) {// only a new active photo (or the strip appearing) scrolls it; see `grid::follow_active`let follow = super::grid::follow_active(child.ctx(), egui::Id::unique("film-follow-active"), active, app.session.source);// a wheel notch scrolls a third of its width; see `grid::wheel_step`- register(ui.ctx(), "filmstrip", child.max_rect());+ register(ui, "filmstrip", child.max_rect());let wheel = super::grid::wheel_step(&child, egui::Id::unique("film-wheel"), child.max_rect(), child.max_rect().width(), true);egui::ScrollArea::horizontal().id_salt("filmstrip").auto_shrink([false, false]).show_viewport(&mut child, |ui, vp| {if wheel != egui::Vec2::ZERO {@@ -2952,7 +2952,7 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) {let resp = ui.interact(cr, egui::Id::unique(("film", id.0)), Sense::click());let failed = app.renderer.thumb(*id).is_none() && app.renderer.failure(Slot::Thumb(*id)).is_some();crate::widgets::announce(&resp, film_spoken(app.session.catalog.photo(*id).map_or("", |p| p.file_name.as_str()), failed));- register(ui.ctx(), format!("film:{}", id.0), cr);+ register(ui, format!("film:{}", id.0), cr);let state = app.session.selection.state_of(*id);let sel = state == lightcraft_engine::SelectionState::Active;let p = ui.painter();@@ -3009,7 +3009,7 @@ pub(crate) fn filmstrip(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect) {"Stack — click to collapse"});crate::widgets::announce(&badge, crate::i18n::tr(if collapsed { "Expand Stack" } else { "Collapse Stack" }));- register(ui.ctx(), format!("filmstack:{}", id.0), br);+ 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);diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rsindex 19e87d6c4..783109ed9 100644--- a/crates/ui-egui/src/panels/dialogs.rs+++ b/crates/ui-egui/src/panels/dialogs.rs@@ -169,7 +169,7 @@ fn watermark_preview(let size = tex.size_vec2();let scale = ui.available_width() / size.x.max(1.0);let r = ui.vertical_centered(|ui| ui.add(egui::Image::new((tex.id(), size * scale)))).inner;- crate::widgets::register(ui.ctx(), "image:exportWatermarkPreview", r.rect);+ crate::widgets::register(ui, "image:exportWatermarkPreview", r.rect);}/// About dialog tabs: (widget id suffix, label). The credits come from `crate::credits`.@@ -200,12 +200,21 @@ pub(crate) fn prepare(app: &LightcraftApp, ui: &mut egui::Ui) {}}-pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {+/// Draw the open dialog. `blocked` is true when a quit prompt or settings notice was on screen at+/// the start of this frame: the dialog is still drawn (its state is preserved), but none of its raw+/// keyboard/backdrop handling may act. The caller freezes `blocked` for the whole frame so the+/// click or key that dismisses the prompt cannot also reach the dialog drawn after it. The+/// blocking library-problem/launch-list window gets the same raw-input treatment while it is+/// actually on screen over this dialog; ordinary dialogs without that window keep their normal+/// Escape and outside-click behaviour.+pub fn show(app: &mut LightcraftApp, ctx: &egui::Context, blocked: bool) {let Some(mut dlg) = app.ui.dialog.clone() else { return };let at_start = dlg.clone();+ let library_blocks = crate::panels::library_problem::blocks_dialog_input(app);+ let raw_blocked = blocked || library_blocks;// Esc with a popup open in the dialog (a dropdown, a date picker's calendar) closes the popup// only: claimed before the dialog is drawn, since the popup is gone once it has handled the key- if ctx.input(|i| i.key_pressed(egui::Key::Escape)) && egui::Popup::is_any_open(ctx) {+ if !raw_blocked && ctx.input(|i| i.key_pressed(egui::Key::Escape)) && egui::Popup::is_any_open(ctx) {crate::widgets::take_escape(ctx);}let t = Tokens::get(ctx);@@ -220,7 +229,8 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {// Return presses OK in a dialog without a text field of its own (Lightroom's default button);// a widget that has the keyboard focus (a text field, a button or checkbox reached with Tab)// takes Return itself. Consumed before the dialog is drawn, so nothing else sees it too.- if return_confirms(&dlg)+ if !raw_blocked+ && return_confirms(&dlg)&& ctx.memory(|m| m.focused().is_none())&& !egui::Popup::is_any_open(ctx)&& ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Enter))@@ -330,6 +340,11 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {_ => 380.0,}).show(ctx, |ui| {+ // Disabled, not skipped: the dialog keeps its layout and state, but a raw event in the+ // first prompt frame cannot toggle a checkbox or press a button underneath it.+ if blocked {+ ui.disable();+ }ui.spacing_mut().item_spacing.y = 8.0;body_h = dialog_body(ui, (!import && !print).then_some(title.as_str()), body_max, |ui| match &mut dlg {Dialog::AutoStack { gap } => {@@ -354,10 +369,10 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {ui.label(egui::RichText::new(crate::i18n::tr_format!("Scores {scope} for focus and exposure and finds similar shots taken within seconds of each other (bursts).", scope = scope)).color(t.text_label));ui.add_space(6.0);let r = ui.add(egui::Slider::new(reject_below, 0.0..=80.0).text(crate::i18n::tr("Reject below focus")).step_by(1.0));- crate::widgets::register(ui.ctx(), "field:cullReject", r.rect);+ crate::widgets::register(ui, "field:cullReject", r.rect);ui.label(egui::RichText::new(crate::i18n::tr(if *reject_below > 0.0 { "Blurry photos below the score are flagged as rejects." } else { "0: nothing is rejected." })).color(t.text_dim));let r = ui.checkbox(pick_best, crate::i18n::tr("Pick the sharpest photo of each burst"));- crate::widgets::register(ui.ctx(), "check:cullPick", r.rect);+ crate::widgets::register(ui, "check:cullPick", r.rect);ui.add_space(6.0);// the sliders drag over the usual range; their value fields take whatever// `photo.analyze` accepts (a gap of 0 s to a day, a similarity of 0 to 1)@@ -370,7 +385,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {.custom_formatter(|v, _| crate::panels::dialogs::fmt_gap(v)).custom_parser(crate::panels::dialogs::parse_gap),);- crate::widgets::register(ui.ctx(), "field:cullGap", r.rect);+ crate::widgets::register(ui, "field:cullGap", r.rect);let r = ui.add(egui::Slider::new(similarity, 0.70..=0.99).clamping(egui::SliderClamping::Never)@@ -380,7 +395,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {.min_decimals(2).max_decimals(3),);- crate::widgets::register(ui.ctx(), "field:cullSimilar", r.rect);+ crate::widgets::register(ui, "field:cullSimilar", r.rect);clamp_cull_burst(burst_gap, similarity);ui.label(egui::RichText::new(crate::i18n::tr("Lower it when a panning or moving burst splits into several groups.")).color(t.text_dim));ui.label(egui::RichText::new(crate::i18n::tr("Scores stay on the photos: filter or make smart albums with Focus and Best of Similar Shots.")).color(t.text_dim));@@ -436,7 +451,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {Dialog::AllMetadata { title, rows, search } => {ui.label(egui::RichText::new(title.as_str()).color(t.text_label));let r = crate::widgets::named(ui.add(egui::TextEdit::singleline(search).hint_text(crate::i18n::tr("Filter fields")).desired_width(f32::INFINITY)), crate::i18n::tr("Filter fields"));- crate::widgets::register(ui.ctx(), "field:metadataSearch", r.rect);+ crate::widgets::register(ui, "field:metadataSearch", r.rect);let q = search.trim().to_lowercase();let keep = |n: &str, v: &str| q.is_empty() || n.to_lowercase().contains(&q) || v.to_lowercase().contains(&q);let mut groups: Vec<(String, Vec<(String, String)>)> = Vec::new();@@ -479,7 +494,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {}Dialog::SmartRules { id, name, rules, .. } => {let r = crate::widgets::named(ui.add(egui::TextEdit::singleline(name).hint_text(crate::i18n::tr("Name")).desired_width(f32::INFINITY)), crate::i18n::tr("Name"));- crate::widgets::register(ui.ctx(), "field:smartName", r.rect);+ crate::widgets::register(ui, "field:smartName", r.rect);ui.add_space(6.0);// the folder an album made from a folder view carries is not in the editor, but it countslet folder = id.and_then(|id| app.session.catalog.album(lightcraft_catalog::AlbumId(id))).and_then(|a| a.smart.as_deref().and_then(|f| f.library_folder.clone()));@@ -533,7 +548,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {"set" => {field(ui, "New time", |ui| {let r = ui.add(egui::TextEdit::singleline(time).hint_text("2026-09-30 14:05:00").desired_width(f32::INFINITY));- crate::widgets::register(ui.ctx(), "field:captureTime", r.rect);+ crate::widgets::register(ui, "field:captureTime", r.rect);});json!({"time": time})}@@ -599,12 +614,12 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {let (r, _) = ui.allocate_exact_size(egui::vec2(14.0, 14.0), egui::Sense::hover());ui.painter().circle_filled(r.center(), 6.0, crate::panels::grid::label_color(*l));let te = crate::widgets::named(ui.add(egui::TextEdit::singleline(&mut names[i]).hint_text(colour.as_str()).desired_width(f32::INFINITY)), crate::i18n::tr(&colour));- crate::widgets::register(ui.ctx(), format!("field:labelName-{}", colour.to_lowercase()), te.rect);+ crate::widgets::register(ui, format!("field:labelName-{}", colour.to_lowercase()), te.rect);});}field(ui, "Save as set", |ui| {let te = crate::widgets::named(ui.add(egui::TextEdit::singleline(save_as).hint_text(crate::i18n::tr("Optional name")).desired_width(f32::INFINITY)), crate::i18n::tr("Save as set"));- crate::widgets::register(ui.ctx(), "field:labelSetName", te.rect);+ crate::widgets::register(ui, "field:labelSetName", te.rect);});ui.label(egui::RichText::new(crate::i18n::tr("Names appear in the label menu, the filter bar and the Info panel, and are written to XMP. Empty = the colour's name."))@@ -619,7 +634,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {ui.spacing_mut().item_spacing.x = 4.0;let w = crate::import::tag_field_width(ui);let r = crate::widgets::named(ui.add(egui::TextEdit::singleline(template).id(template_id).hint_text("{name}").desired_width(w)), crate::i18n::tr("Template"));- crate::widgets::register(ui.ctx(), "field:renameTemplate", r.rect);+ crate::widgets::register(ui, "field:renameTemplate", r.rect);crate::import::tag_toggle(ui, "renameTemplate")});if tags_open {@@ -693,7 +708,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {.color(t.caution),);let r = ui.checkbox(merge, crate::i18n::tr("Combine with the existing person"));- crate::widgets::register(ui.ctx(), "check:personMerge", r.rect);+ crate::widgets::register(ui, "check:personMerge", r.rect);}}Dialog::RenameKeyword { from, to } => {@@ -742,7 +757,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {if !*folder && !app.session.selected().is_empty() {ui.add_space(6.0);let r = ui.checkbox(include_selected, crate::i18n::tr("Include selected photos"));- crate::widgets::register(ui.ctx(), "check:albumIncludeSelected", r.rect);+ crate::widgets::register(ui, "check:albumIncludeSelected", r.rect);}}Dialog::RenameAlbum { name, .. } => {@@ -805,7 +820,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {}});crate::widgets::name_combo(&c.response, crate::i18n::tr("Preset"));- crate::widgets::register(ui.ctx(), "combo:exportPreset", c.response.rect);+ crate::widgets::register(ui, "combo:exportPreset", c.response.rect);if let Some(name) = chosen&& let Ok(params) = app.session.export_params(&json!({"preset": name})){@@ -1096,7 +1111,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {#[cfg(target_os = "macos")]{let r = ui.checkbox(&mut opts.add_to_photos, crate::i18n::tr("Add to Apple Photos"));- crate::widgets::register(ui.ctx(), "exportAddToPhotos", r.rect);+ crate::widgets::register(ui, "exportAddToPhotos", r.rect);if opts.add_to_photos {field(ui, "Album", |ui| {crate::widgets::named(ui.add(egui::TextEdit::singleline(&mut opts.photos_album).hint_text(crate::i18n::tr("none")).desired_width(f32::INFINITY)), crate::i18n::tr("Album"))@@ -1177,11 +1192,11 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {if editing.is_none() {if let Some(p) = parent {let r = ui.checkbox(inside, crate::i18n::tr_format!("Put inside “{parent}”", parent = p.replace('|', " › ")));- crate::widgets::register(ui.ctx(), "check:keywordInside", r.rect);+ crate::widgets::register(ui, "check:keywordInside", r.rect);}let n = app.session.selection.ids.len();let r = ui.add_enabled(n > 0, egui::Checkbox::new(add_to_selected, crate::i18n::tr("Add to Selected Photos")));- crate::widgets::register(ui.ctx(), "check:keywordAddToSelected", r.rect);+ crate::widgets::register(ui, "check:keywordAddToSelected", r.rect);ui.add_space(4.0);}ui.label(egui::RichText::new(crate::i18n::tr("Keyword Tag Options")).color(t.text_dim));@@ -1192,7 +1207,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {(person, "Person", "check:keywordPerson"),] {let r = ui.checkbox(on, crate::i18n::tr(label));- crate::widgets::register(ui.ctx(), id, r.rect);+ crate::widgets::register(ui, id, r.rect);}}Dialog::KeywordSet { replaces, name, slots, as_new } => {@@ -1226,7 +1241,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {if replaces.is_some() {ui.add_space(6.0);let r = ui.checkbox(as_new, crate::i18n::tr("Save as a new set"));- crate::widgets::register(ui.ctx(), "check:keywordSetAsNew", r.rect);+ crate::widgets::register(ui, "check:keywordSetAsNew", r.rect);}// Return in any field saves the setif returned {@@ -1288,7 +1303,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {ui.label(egui::RichText::new(crate::i18n::tr("Their files and XMP sidecars move on disk. Edit → Undo moves them back.")).color(t.text_dim));ui.add_space(4.0);let c = ui.checkbox(dont_ask, crate::i18n::tr("Don't ask again"));- crate::widgets::register(ui.ctx(), "check:moveDontAsk", c.rect);+ crate::widgets::register(ui, "check:moveDontAsk", c.rect);c.on_hover_text(crate::i18n::tr("Settings → Confirm before moving photos to another folder on disk turns it back on"));}d @ Dialog::SynchronizeFolder { .. } => crate::sync::body(app, ui, d),@@ -1495,8 +1510,12 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {}if let Some(w) = &shown {// (the import review keeps its hand-picked photos however the click lands)- if app.ui.settings.close_dialogs_outside && !import && clicked_backdrop(ctx, w.response.rect, popup_was_open) {+ if !raw_blocked && app.ui.settings.close_dialogs_outside && !import && clicked_backdrop(ctx, w.response.rect, popup_was_open) {close = true;+ } else if raw_blocked {+ // A press made under the prompt or library window must not be remembered as a+ // backdrop press for a release that arrives after that covering window goes away.+ ctx.data_mut(|d| d.remove_temp::<bool>(egui::Id::unique("dialog-backdrop-press")));}}if let Some(w) = shown {@@ -1509,14 +1528,14 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {}}ctx.move_to_top(w.response.layer_id);- crate::widgets::register(ctx, "dialog:window", w.response.rect);+ crate::widgets::register_response("dialog:window", w.response.rect, &w.response);}// (while the shortcuts editor records a key, it takes Esc itself to cancel; an open popup in// the dialog, such as a date picker's calendar, takes it to close itself)- if ctx.input(|i| i.key_pressed(egui::Key::Escape)) && !crate::widgets::escape_taken(ctx) {+ if !raw_blocked && ctx.input(|i| i.key_pressed(egui::Key::Escape)) && !crate::widgets::escape_taken(ctx) {close = true;}- if confirm {+ if !raw_blocked && confirm {match confirm_dialog(app, &dlg) {// the import review stays open on an error (e.g. an unusable folder template), and so// does Export (e.g. no folder chosen) so the choices aren't lost, and Edit Capture Time@@ -1587,7 +1606,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {if app.ui.dialog.as_ref().is_some_and(|now| *now != at_start) {return;}- if !close {+ if !close && !blocked {let frame = ctx.cumulative_frame_nr();ctx.data_mut(|d| d.insert_temp(egui::Id::unique(BACKDROP_SHOWN), frame));}@@ -1830,7 +1849,7 @@ fn sam_model_body(app: &mut LightcraftApp, ui: &mut egui::Ui, error: Option<&str.color(t.text_label),);let r = ui.link(crate::i18n::tr("Read the SAM License")).on_hover_text(LICENSE_URL);- crate::widgets::register(ui.ctx(), "link:samLicense", r.rect);+ crate::widgets::register(ui, "link:samLicense", r.rect);if r.clicked() {let _ = crate::links::open(app, LICENSE_URL);}@@ -1840,7 +1859,7 @@ fn sam_model_body(app: &mut LightcraftApp, ui: &mut egui::Ui, error: Option<&strlet text = format!("{:.2} / {:.2} GB · {}", gb(d.done), gb(d.total), d.file);crate::progress::Progress::new(crate::progress::fraction_of(d.done, d.total)).label(text).widget("progress:samDownload").show(ui);let r = ui.button(crate::i18n::tr("Cancel Download"));- crate::widgets::register(ui.ctx(), "button:samCancel", r.rect);+ crate::widgets::register(ui, "button:samCancel", r.rect);if r.clicked() {app.session.segmenter.cancel_download();}@@ -1860,7 +1879,7 @@ fn sam_model_body(app: &mut LightcraftApp, ui: &mut egui::Ui, error: Option<&strui.horizontal_wrapped(|ui| {if dir.is_some() && crate::menus::ui_enabled(app, "app.openSamModelFolder") {let r = ui.button(crate::i18n::tr(crate::menus::reveal_label()));- crate::widgets::register(ui.ctx(), "button:samFolder", r.rect);+ crate::widgets::register(ui, "button:samFolder", r.rect);if r.clicked()&& let Err(e) = app.run("app.openSamModelFolder", json!({})){@@ -1868,7 +1887,7 @@ fn sam_model_body(app: &mut LightcraftApp, ui: &mut egui::Ui, error: Option<&str}}let r = ui.link(crate::i18n::tr("How to install the model")).on_hover_text(SAM_HELP);- crate::widgets::register(ui.ctx(), "link:samHelp", r.rect);+ crate::widgets::register(ui, "link:samHelp", r.rect);if r.clicked()&& let Err(e) = crate::links::open(app, SAM_HELP){@@ -2144,7 +2163,7 @@ fn group_checklist(ui: &mut egui::Ui, tag: &str, groups: &mut Vec<String>) {let key = key_of(g);let mut on = groups.contains(&key);let r = cols[i % 2].checkbox(&mut on, crate::i18n::tr(g.label()));- crate::widgets::register(&r.ctx, format!("{tag}:{key}"), r.rect);+ crate::widgets::register_response(format!("{tag}:{key}"), r.rect, &r);if r.changed() {if on {groups.push(key);@@ -2156,12 +2175,12 @@ fn group_checklist(ui: &mut egui::Ui, tag: &str, groups: &mut Vec<String>) {});ui.horizontal(|ui| {let all = ui.small_button(crate::i18n::tr("All"));- crate::widgets::register(ui.ctx(), format!("{tag}:all"), all.rect);+ crate::widgets::register(ui, format!("{tag}:all"), all.rect);if all.clicked() {*groups = SettingsGroup::ALL.iter().map(key_of).collect();}let none = ui.small_button(crate::i18n::tr("None"));- crate::widgets::register(ui.ctx(), format!("{tag}:none"), none.rect);+ crate::widgets::register(ui, format!("{tag}:none"), none.rect);if none.clicked() {groups.clear();}@@ -2198,7 +2217,7 @@ fn export_size(ui: &mut egui::Ui, full: &mut bool, r: &mut lightcraft_engine::ex(R::Percent, "Percentage"),];let r_full = ui.checkbox(full, crate::i18n::tr("Full size"));- crate::widgets::register(ui.ctx(), "check:exportFullSize", r_full.rect);+ crate::widgets::register(ui, "check:exportFullSize", r_full.rect);if !*full {field(ui, "Resize to", |ui| {let cur = MODES.iter().find(|m| m.0 == r.mode).map_or("Long Edge", |m| m.1);@@ -2209,7 +2228,7 @@ fn export_size(ui: &mut egui::Ui, full: &mut bool, r: &mut lightcraft_engine::ex}});crate::widgets::name_combo(&c.response, crate::i18n::tr("Resize"));- crate::widgets::register(ui.ctx(), "combo:exportResizeMode", c.response.rect);+ crate::widgets::register(ui, "combo:exportResizeMode", c.response.rect);if r.mode != before {// a sensible value for the new unitr.value = match r.mode {@@ -2240,7 +2259,7 @@ fn export_size(ui: &mut egui::Ui, full: &mut bool, r: &mut lightcraft_engine::ex}}let c = ui.checkbox(&mut r.dont_enlarge, crate::i18n::tr("Don't enlarge"));- crate::widgets::register(ui.ctx(), "check:exportDontEnlarge", c.rect);+ crate::widgets::register(ui, "check:exportDontEnlarge", c.rect);}let mut p = *ppi as f64;if num(ui, &PPI, &mut p) {@@ -2310,12 +2329,12 @@ fn slideshow_export_body(app: &mut LightcraftApp, ui: &mut egui::Ui, settings: &}field(ui, "Quality", |ui| {let r = ui.add(egui::Slider::new(&mut settings.quality, 1..=100));- crate::widgets::register(ui.ctx(), "slider:slideshowExportQuality", r.rect);+ crate::widgets::register(ui, "slider:slideshowExportQuality", r.rect);});let note = match settings.format {Format::Pdf => {let r = ui.checkbox(&mut settings.full_screen, crate::i18n::tr("Automatically show full screen"));- crate::widgets::register(ui.ctx(), "check:slideshowExportFullScreen", r.rect);+ crate::widgets::register(ui, "check:slideshowExportFullScreen", r.rect);"One page per slide (the long side in pixels = points), with the slide duration and fade for the viewer's presentation mode."}Format::Jpeg => "Numbered JPEG files (name-001.jpg…) in a new folder named in the next step.",diff --git a/crates/ui-egui/src/panels/edit.rs b/crates/ui-egui/src/panels/edit.rsindex 2ce723857..10542e443 100644--- a/crates/ui-egui/src/panels/edit.rs+++ b/crates/ui-egui/src/panels/edit.rs@@ -199,7 +199,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 0, bottom: 10 }).show(ui, |ui| {let mut on = d.profile.camera_local_tone;let r = ui.checkbox(&mut on, crate::i18n::tr("Camera local tone mapping"));- crate::widgets::register(ui.ctx(), "check:profile.cameraLocalTone", r.rect);+ crate::widgets::register(ui, "check:profile.cameraLocalTone", r.rect);if r.on_hover_text(crate::i18n::tr("Apply the local tone mapping stored in the raw (Apple ProRAW), as the camera renders it")).changed() {let _ = app.run("develop.merge", json!({"settings": {"profile": {"camera_local_tone": on}}, "label": "Camera Local Tone Mapping"}));}@@ -447,7 +447,7 @@ fn profile_menu_rows(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettlet mut pick: (Option<String>, Option<String>) = (None, None);let item = |ui: &mut egui::Ui, key: &str, id: &str, name: &str, pick: &mut (Option<String>, Option<String>)| {let r = ui.selectable_label(id == cur, crate::i18n::profile_label(id, name));- register(ui.ctx(), format!("profileMenu:{key}:{id}"), r.rect);+ register(ui, format!("profileMenu:{key}:{id}"), r.rect);if r.clicked() {pick.0 = Some(id.to_string());}@@ -478,7 +478,7 @@ fn profile_menu_rows(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSett}});});- register(ui.ctx(), format!("profileMenu:groupMenu:{g}"), r.response.rect);+ register(ui, format!("profileMenu:groupMenu:{g}"), r.response.rect);if r.inner.is_some() {crate::menu_level::set_anchor(ui.ctx(), 2, r.response.rect);}@@ -497,7 +497,7 @@ fn profile_menu_rows(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSett}});});- register(ui.ctx(), format!("profileMenu:lutGroupMenu:{g}"), r.response.rect);+ register(ui, format!("profileMenu:lutGroupMenu:{g}"), r.response.rect);if r.inner.is_some() {crate::menu_level::set_anchor(ui.ctx(), 2, r.response.rect);}@@ -511,13 +511,13 @@ fn profile_menu_rows(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettcrate::i18n::tr_format!("Add “{}” to Favorites", crate::i18n::profile_label(cur, name))};let r = ui.button(label);- register(ui.ctx(), "profileMenu:toggleFavorite", r.rect);+ register(ui, "profileMenu:toggleFavorite", r.rect);if r.clicked() {let _ = app.run("profile.favorite", json!({"id": cur}));}}let r = ui.button(crate::i18n::tr("Browse…"));- register(ui.ctx(), "profileMenu:browse", r.rect);+ register(ui, "profileMenu:browse", r.rect);if r.clicked() {let _ = app.run("panel.profiles", json!({}));}@@ -565,7 +565,7 @@ fn section(crate::widgets::context_menu(&resp, |ui| {let mut solo = app.ui.single_panel;let item = ui.checkbox(&mut solo, crate::i18n::tr("Solo Mode"));- register(ui.ctx(), "sectionMenu:solo", item.rect);+ register(ui, "sectionMenu:solo", item.rect);if item.clicked() {if let Err(e) = app.run("view.soloSections", json!({"on": solo})) {app.toast(ui.ctx(), e);@@ -633,7 +633,7 @@ fn histogram(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let legend = if hdr.is_some() { 26.0 } else { 0.0 };let (r, resp) = ui.allocate_exact_size(vec2(w, 118.0 + legend), Sense::click_and_drag());crate::widgets::announce(&resp, crate::i18n::tr("Histogram"));- register(ui.ctx(), "histogram", r);+ register(ui, "histogram", r);let p = ui.painter();p.rect_filled(r, 0.0, t.button);let plot = Rect::from_min_max(r.min + vec2(0.0, 6.0), pos2(r.right(), r.bottom() - 26.0 - legend));@@ -737,7 +737,7 @@ fn histogram(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {("highlights", highlight_rect, "Highlight clipping", clipping.map(|(_, hi)| hi > 0.003)),] {let response = ui.interact(rect, ui.scope_id().with(("histogram-clipping", name)), Sense::click());- register(ui.ctx(), format!("histogram:{name}"), rect);+ register(ui, format!("histogram:{name}"), rect);response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, ui.is_enabled(), app.ui.show_clipping, crate::i18n::tr(label)));clicked |= response.clicked();let active = app.ui.show_clipping;@@ -784,7 +784,7 @@ fn histogram(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {}// the tonal zone the pointer is on replaces the EXIF strip while it is thereif let Some(text) = zone.as_ref().and_then(|a| a.readout()) {- register(ui.ctx(), "histogramReadout", r);+ register(ui, "histogramReadout", r);p.text(pos2(r.left() + r.width() / 2.0, r.bottom() - 13.0), Align2::CENTER_CENTER, text, t.font(12.5), t.text_label);} else if let Some(ph) = app.session.catalog.photo(id) {let m = &ph.meta;@@ -821,12 +821,12 @@ fn soft_proofing(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let r = ui.toggle_value(&mut dest, RichText::new("■").color(Color32::from_rgb(255, 40, 40))).on_hover_text(crate::i18n::tr("Show destination gamut warning"));- register(ui.ctx(), "button:proofDestWarning", r.rect);+ register(ui, "button:proofDestWarning", r.rect);let mut disp = app.ui.proof.display_warning;let r2 = ui.toggle_value(&mut disp, RichText::new("■").color(Color32::from_rgb(40, 90, 255))).on_hover_text(crate::i18n::tr("Show display gamut warning"));- register(ui.ctx(), "button:proofDisplayWarning", r2.rect);+ register(ui, "button:proofDisplayWarning", r2.rect);if dest != app.ui.proof.dest_warning || disp != app.ui.proof.display_warning {let _ = app.run("view.softProof", json!({"destWarning": dest, "displayWarning": disp}));}@@ -865,7 +865,7 @@ fn soft_proofing(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {use lightcraft_engine::proof::ProofIntent;for (i, label) in [(ProofIntent::Perceptual, "Perceptual"), (ProofIntent::Relative, "Relative")] {let r = ui.selectable_label(app.ui.proof_intent == i, crate::i18n::tr(label));- register(ui.ctx(), format!("button:proofIntent-{}", i.name()), r.rect);+ register(ui, format!("button:proofIntent-{}", i.name()), r.rect);if r.clicked() && app.ui.proof_intent != i {let _ = app.run("view.softProof", json!({"intent": i.name()}));}@@ -873,13 +873,13 @@ fn soft_proofing(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {});let mut paper = app.ui.proof_paper_ink;let r = ui.checkbox(&mut paper, crate::i18n::tr("Simulate Paper & Ink"));- register(ui.ctx(), "button:proofPaperInk", r.rect);+ register(ui, "button:proofPaperInk", r.rect);if r.changed() {let _ = app.run("view.softProof", json!({"paperInk": paper}));}}let r = ui.button(crate::i18n::tr("Create Proof Copy"));- register(ui.ctx(), "button:createProofCopy", r.rect);+ register(ui, "button:createProofCopy", r.rect);if r.clicked() {let target = app.ui.proof_profile.as_ref().map_or_else(|| app.ui.proof.space.label().to_string(), |(_, n)| n.clone());let name = crate::i18n::tr_format!("Proof Copy ({})", target);@@ -1062,7 +1062,7 @@ fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, d: &Dev] {let (r, resp) = ui.allocate_exact_size(vec2(24.0, 24.0), Sense::click());crate::widgets::announce(&resp, format!("{} {ch}", crate::i18n::tr("Curve channel")));- register(ui.ctx(), format!("curveChannel:{ch}"), r);+ register(ui, format!("curveChannel:{ch}"), r);let sel = app.ui.curve_channel == ch;if ch == "parametric" {paint(ui.painter(), r.shrink(4.0), Icon::Curve, if sel { t.text } else { t.icon });@@ -1102,7 +1102,7 @@ fn curve_editor(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, d: &Devlet r = Rect::from_min_size(pos2(outer.left() + 24.0, outer.top() + 6.0), vec2(side, side));let resp = ui.interact(r, egui::Id::unique(("curve", &ch)), Sense::click_and_drag());crate::widgets::announce(&resp, crate::i18n::tr("Tone Curve"));- register(ui.ctx(), "curve", r);+ register(ui, "curve", r);crate::widgets::context_menu(&resp, |ui| curve_reset_menu(app, ui, &ch));let p = ui.painter();p.rect_filled(r, 2.0, t.canvas);@@ -1299,7 +1299,7 @@ fn curve_footer(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings)ui.separator();}let r = ui.selectable_label(current.as_deref() == Some(p.name.as_str()), crate::i18n::builtin_label(&p.name, p.builtin));- register(ui.ctx(), format!("curvePreset:{}", p.name), r.rect);+ register(ui, format!("curvePreset:{}", p.name), r.rect);if r.clicked() {let _ = app.run("curve.applyPreset", json!({"name": p.name}));ui.close();@@ -1316,7 +1316,7 @@ fn curve_footer(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings)ui.separator();let shaped = current.as_deref() != Some("Linear");let r = ui.add_enabled(shaped, egui::Button::new(crate::i18n::tr("Save Point Curve…")));- register(ui.ctx(), "curvePresetMenu:save", r.rect);+ register(ui, "curvePresetMenu:save", r.rect);if r.clicked() {crate::panels::dialogs::prompt(app, "Save Point Curve Preset", "Preset name", "", "curve.savePreset", json!({}), "name");ui.close();@@ -1354,13 +1354,13 @@ fn curve_reset_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, ch: &str) {crate::i18n::tr_format!("Reset {} Channel", crate::i18n::tr(channel_label(ch)))};let r = ui.button(label);- register(ui.ctx(), "curveMenu:resetChannel", r.rect);+ register(ui, "curveMenu:resetChannel", r.rect);if r.clicked() {let _ = app.run("curve.reset", json!({"channel": ch}));ui.close();}let r = ui.button(crate::i18n::tr("Reset All Curves"));- register(ui.ctx(), "curveMenu:resetAll", r.rect);+ register(ui, "curveMenu:resetAll", r.rect);if r.clicked() {let _ = app.run("curve.reset", json!({"channel": "all"}));ui.close();@@ -1409,7 +1409,7 @@ fn mixer(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings) {for (i, b) in bands.iter().enumerate() {let (r, resp) = ui.allocate_exact_size(vec2(22.0, 22.0), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr(b));- register(ui.ctx(), format!("mixerBand:{b}"), r);+ register(ui, format!("mixerBand:{b}"), r);ui.painter().circle_filled(r.center(), 9.0, hex(BAND_COLORS[i]));if i == sel {ui.painter().circle_stroke(r.center(), 10.5, Stroke::new(1.5, t.text));@@ -1501,7 +1501,7 @@ fn point_color(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings)for (i, p) in d.point_colors.iter().enumerate() {let (r, resp) = ui.allocate_exact_size(vec2(22.0, 22.0), Sense::click());crate::widgets::announce(&resp, format!("{} {}", crate::i18n::tr("Point Color"), i + 1));- register(ui.ctx(), format!("pointColor:{i}"), r);+ register(ui, format!("pointColor:{i}"), r);ui.painter().rect_filled(r.shrink(2.0), 3.0, oklch_color(p.lum, p.chroma, p.hue));if i == sel {ui.painter().rect_stroke(r, 4.0, Stroke::new(1.5, t.text), egui::StrokeKind::Inside);@@ -1552,7 +1552,7 @@ fn hdr_row(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettings) {egui::Frame::NONE.inner_margin(egui::Margin { left: 24, right: 22, top: 4, bottom: 4 }).show(ui, |ui| {let mut v = app.ui.hdr_visualize;let r = ui.checkbox(&mut v, "Visualize HDR");- register(ui.ctx(), "check:hdrVisualize", r.rect);+ register(ui, "check:hdrVisualize", r.rect);if r.on_hover_text("Grey below SDR white; yellow, orange, red, magenta up to 1, 2, 3 and over 3 stops above it").changed() {app.ui.hdr_visualize = v;}@@ -1640,7 +1640,7 @@ fn grading_wheel(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettingslet resp = resp.on_hover_text(crate::i18n::tr("Drag to set hue and saturation. Hold Shift to keep the hue, Cmd/Ctrl to keep the saturation, Alt/Option to fine-adjust. Double-click to reset.",));- register(ui.ctx(), format!("wheel:{key}"), r);+ register(ui, format!("wheel:{key}"), r);paint_wheel(ui.painter(), c, rad);if hidden {ui.painter().circle_filled(c, rad, Color32::from_black_alpha(150));@@ -1735,7 +1735,7 @@ fn grading_wheel(app: &mut LightcraftApp, ui: &mut egui::Ui, d: &DevelopSettingslet eye = Rect::from_center_size(r.left_bottom() + vec2(2.0, -2.0), vec2(16.0, 16.0));let er = ui.interact(eye, egui::Id::unique(("wheelEye", key)), Sense::click());crate::widgets::announce(&er, crate::i18n::tr("Show / hide"));- register(ui.ctx(), format!("wheelEye:{key}"), eye);+ register(ui, format!("wheelEye:{key}"), eye);paint(ui.painter(), eye, if hidden { Icon::EyeOff } else { Icon::Eye }, if hidden { t.text_disabled } else { t.icon });let er = er.on_hover_text(crate::i18n::tr(if hidden { "Show this wheel's effect" } else { "Hide this wheel's effect" }));if er.clicked() {@@ -2012,7 +2012,7 @@ fn quick_develop(app: &mut LightcraftApp, ui: &mut egui::Ui, n: usize) {crate::i18n::tr_format!("{label} {d:+} on every selected photo", d = d, label = crate::i18n::tr(label)),)});- crate::widgets::register(ui.ctx(), format!("button:quick-{ctl}-{txt}"), r.rect);+ crate::widgets::register(ui, format!("button:quick-{ctl}-{txt}"), r.rect);if r.on_hover_text(crate::i18n::tr_format!("{label} {d:+} on every selected photo", d = d, label = crate::i18n::tr(label))).clicked(){diff --git a/crates/ui-egui/src/panels/faces.rs b/crates/ui-egui/src/panels/faces.rsindex 461c7d626..76cd1295c 100644--- a/crates/ui-egui/src/panels/faces.rs+++ b/crates/ui-egui/src/panels/faces.rs@@ -156,7 +156,7 @@ pub fn setup_banner(app: &mut LightcraftApp, ui: &mut egui::Ui) {ui.horizontal_wrapped(|ui| {ui.label(RichText::new(message).font(t.font(12.5)).color(t.text_dim));let r = ui.button(button);- register(ui.ctx(), "faces:setup", r.rect);+ register(ui, "faces:setup", r.rect);if r.clicked() {take_step(app, ui.ctx(), step);}@@ -170,7 +170,7 @@ fn gpu_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, gpu: &Valheading(ui, t, "Processor");let mut cpu = gpu["cpuOnly"].as_bool().unwrap_or(false);let r = ui.checkbox(&mut cpu, crate::i18n::tr("Run face models on the CPU only"));- register(ui.ctx(), "check:settings.facesCpuOnly", r.rect);+ register(ui, "check:settings.facesCpuOnly", r.rect);if r.changed() {match app.run("faces.gpu", json!({"cpuOnly": cpu})) {Ok(_) => app.caches.faces_epoch += 1,@@ -194,7 +194,7 @@ fn gpu_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, gpu: &Valcrate::progress::spinner(ui, 12.0);}let r = ui.label(text);- register(ui.ctx(), format!("faces:device:{what}"), r.rect);+ register(ui, format!("faces:device:{what}"), r.rect);if let Some(why) = why {r.on_hover_text(sentence(why));}@@ -257,7 +257,7 @@ pub fn settings_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {let r = ui.add_enabled(on || (runtime && usable), egui::Checkbox::new(&mut on, crate::i18n::tr("Recognise faces (experimental)"))).on_disabled_hover_text(crate::i18n::tr("Choose a model below (Use) to start."));- register(ui.ctx(), "check:settings.facesEnabled", r.rect);+ register(ui, "check:settings.facesEnabled", r.rect);if r.changed() {match app.run("faces.enable", json!({"enabled": on})) {Ok(_) => app.caches.faces_epoch += 1,@@ -291,7 +291,7 @@ pub fn settings_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {ui.horizontal(|ui| {let can = app.services.pick_model_file.is_some();let r = ui.add_enabled(can, egui::Button::new(crate::i18n::tr("Add a model file…")));- register(ui.ctx(), "faces:addModel", r.rect);+ register(ui, "faces:addModel", r.rect);if r.clicked() {let _ = app.run("dialog.faceModel", json!({}));}@@ -388,14 +388,14 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {if installed {let r = ui.button(crate::i18n::tr("Remove"));- register(ui.ctx(), format!("faces:remove:{id}"), r.rect);+ register(ui, format!("faces:remove:{id}"), r.rect);if r.clicked() {let _ = app.run("faces.models.remove", json!({"id": id}));app.caches.faces_epoch += 1;}if !selected && !detector {let r = ui.button("Use");- register(ui.ctx(), format!("faces:use:{id}"), r.rect);+ register(ui, format!("faces:use:{id}"), r.rect);if r.clicked() {let _ = app.run("faces.models.select", json!({"id": id}));app.caches.faces_epoch += 1;@@ -405,7 +405,7 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,match dl_state {Some("running") => {let r = ui.button(crate::i18n::tr("Cancel"));- register(ui.ctx(), format!("faces:cancelDownload:{id}"), r.rect);+ register(ui, format!("faces:cancelDownload:{id}"), r.rect);if r.clicked() {let _ = app.run("faces.models.downloadCancel", json!({"id": id}));app.caches.faces_dl_watch.retain(|w| w != &id);@@ -418,7 +418,7 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,let r = ui.button(crate::i18n::tr("Open page")).on_hover_text(crate::i18n::tr("Opens the model's own page in your browser, to read about it or get the file yourself.",));- register(ui.ctx(), format!("faces:get:{id}"), r.rect);+ register(ui, format!("faces:get:{id}"), r.rect);if r.clicked() {open_page(app, url);}@@ -431,7 +431,7 @@ fn model_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, m: &Value,if detector { "" } else { ", starts using it" });let r = ui.button(label).on_hover_text(tip);- register(ui.ctx(), format!("faces:download:{id}"), r.rect);+ register(ui, format!("faces:download:{id}"), r.rect);if r.clicked() {open_download_dialog(app, m);}@@ -505,7 +505,7 @@ pub fn model_dialog(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, info}if let Some(url) = m["source"].as_str().or(m["licence"]["url"].as_str()) {let r = ui.link("Open the model's page");- register(ui.ctx(), "faceModel:page", r.rect);+ register(ui, "faceModel:page", r.rect);if r.clicked() {open_page(app, url);}@@ -651,7 +651,7 @@ pub fn name_editor(egui::Frame::popup(ui.style()).show(ui, |ui| {ui.set_min_width(230.0);let r = ui.add(egui::TextEdit::singleline(&mut edit.text).hint_text("Name").desired_width(220.0));- register(ui.ctx(), "field:faceName", r.rect);+ register(ui, "field:faceName", r.rect);if edit.fresh {r.request_focus();edit.fresh = false;@@ -677,14 +677,14 @@ pub fn name_editor(None => name.clone(),};let b = ui.add(egui::Button::new(RichText::new(label).color(t.text_label)).frame(false).min_size(egui::vec2(220.0, 0.0)));- register(ui.ctx(), format!("faceName:pick:{name}"), b.rect);+ register(ui, format!("faceName:pick:{name}"), b.rect);if b.clicked() {outcome = Editor::Submit(name);}}if let Some(label) = setup.short() {let b = ui.add(egui::Button::new(RichText::new(label).font(t.font(12.0)).color(t.accent)).frame(false));- register(ui.ctx(), "faces:setup", b.rect);+ register(ui, "faces:setup", b.rect);if b.clicked() {outcome = Editor::Setup;}diff --git a/crates/ui-egui/src/panels/filterbar.rs b/crates/ui-egui/src/panels/filterbar.rsindex 592baf32f..8b34fbaf9 100644--- a/crates/ui-egui/src/panels/filterbar.rs+++ b/crates/ui-egui/src/panels/filterbar.rs@@ -33,7 +33,7 @@ fn toggle(ui: &mut egui::Ui, id: &str, on: bool, tip: &str, draw: impl FnOnce(&elet t = Tokens::get(ui.ctx());let (r, resp) = ui.allocate_exact_size(vec2(26.0, 26.0), Sense::click());crate::widgets::announce_selected(&resp, crate::i18n::tr(tip), on);- register(ui.ctx(), format!("filter:{id}"), r);+ register(ui, format!("filter:{id}"), r);let p = ui.painter();if on {p.rect_filled(r, 5.0, t.tool_active);@@ -100,7 +100,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let (bar, _) = ui.allocate_exact_size(vec2(ui.available_width(), if two_rows { 2.0 * HEIGHT - 8.0 } else { HEIGHT }), Sense::hover());ui.painter().rect_filled(bar, 0.0, t.chrome);ui.painter().line_segment([bar.left_bottom(), bar.right_bottom()], Stroke::new(1.0, t.divider));- register(ui.ctx(), "filterbar", bar);+ register(ui, "filterbar", bar);let f = app.session.filter.clone();let row = |ui: &mut egui::Ui, i: f32| {let r = Rect::from_min_size(bar.min + vec2(16.0, 4.0 + i * (HEIGHT - 8.0)), vec2(bar.width() - 32.0, HEIGHT - 8.0));@@ -253,19 +253,19 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {ui.add_space(14.0);let filtering = app.session.filter != Default::default();let save = ui.add_enabled(filtering, egui::Button::new(egui::RichText::new(crate::i18n::tr("Save as Smart Album…")).font(t.font(12.5))));- register(ui.ctx(), "button:filterSave", save.rect);+ register(ui, "button:filterSave", save.rect);if save.clicked() {let _ = app.run("dialog.newSmartAlbum", json!({}));}let clear = ui.add_enabled(filtering, egui::Button::new(egui::RichText::new(crate::i18n::tr("Clear")).font(t.font(12.5))));- register(ui.ctx(), "button:filterClear", clear.rect);+ register(ui, "button:filterClear", clear.rect);if clear.clicked() {app.ui.search.clear();let _ = app.run("library.clearFilter", json!({}));}// filter presets: apply one, save the current filter, deletelet presets = crate::widgets::dropdown(ui, "filterPresets", crate::i18n::tr("Presets"), t.font(12.5), t.text);- register(ui.ctx(), "button:filterPresets", presets.rect);+ register(ui, "button:filterPresets", presets.rect);egui::Popup::menu(&presets).show(|ui| {let names: Vec<String> = app.session.filter_presets.iter().map(|f| f.name.clone()).collect();for n in &names {diff --git a/crates/ui-egui/src/panels/grid.rs b/crates/ui-egui/src/panels/grid.rsindex ebaf8ab07..ba2e48869 100644--- a/crates/ui-egui/src/panels/grid.rs+++ b/crates/ui-egui/src/panels/grid.rs@@ -309,8 +309,8 @@ fn show_inner(app: &mut LightcraftApp, ui: &mut egui::Ui) {let title = crate::widgets::elide_head(&full, room, |s| ui.painter().layout_no_wrap(s.to_string(), font.clone(), t.text).size().x);let title_rect = ui.painter().text(pos2(hr.left() + 20.0, hr.center().y), Align2::LEFT_CENTER, &title, font, t.text);let count_rect = ui.painter().text(pos2(hr.right() - 20.0, hr.center().y), Align2::RIGHT_CENTER, cnt, t.font(12.5), t.text_dim);- crate::widgets::register(ui.ctx(), "grid:title", title_rect);- crate::widgets::register(ui.ctx(), "grid:count", count_rect);+ crate::widgets::register(ui, "grid:title", title_rect);+ crate::widgets::register(ui, "grid:count", count_rect);if title != full {ui.interact(title_rect, ui.scope_id().with("grid-title"), Sense::hover()).on_hover_text(full);}@@ -393,7 +393,7 @@ fn show_inner(app: &mut LightcraftApp, ui: &mut egui::Ui) {let mut visited = 0u64;// a wheel notch scrolls a third of the grid's heightlet scroll_rect = ui.available_rect_before_wrap();- crate::widgets::register(ui.ctx(), "grid:scroll", scroll_rect);+ crate::widgets::register(ui, "grid:scroll", scroll_rect);let wheel = wheel_step(ui, egui::Id::unique("grid-wheel"), scroll_rect, scroll_rect.height(), false);egui::ScrollArea::vertical().id_salt("grid-scroll").auto_shrink([false, false]).show_viewport(ui, |ui, viewport| {if wheel != egui::Vec2::ZERO {@@ -659,7 +659,7 @@ fn group_header(app: &mut LightcraftApp, ui: &mut egui::Ui, run: &DateRun, ids:let resp = ui.interact(r, egui::Id::unique(("group-header", run.start, pinned)), Sense::click());crate::widgets::announce(&resp, if run.key.is_empty() { crate::i18n::tr("Unknown date").to_string() } else { run.key.clone() });if !pinned {- register(ui.ctx(), format!("group:{}", if run.key.is_empty() { "unknown" } else { &run.key }), r);+ register(ui, format!("group:{}", if run.key.is_empty() { "unknown" } else { &run.key }), r);}let p = ui.painter();if pinned {@@ -759,7 +759,7 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, squarelet 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());- register(ui.ctx(), format!("thumb:{}", id.0), r);+ register(ui, format!("thumb:{}", id.0), r);let state = app.session.selection.state_of(id);let selected = state != lightcraft_engine::SelectionState::NotSelected;// screen readers: the file, then rating / flag / label@@ -900,7 +900,7 @@ fn cell(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, r: Rect, squarep.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.ctx(), format!("badge:previewOnly:{}", id.0), br);+ 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)));}@@ -962,7 +962,7 @@ fn folder_header(app: &mut LightcraftApp, ui: &mut egui::Ui, b: &lightcraft_engifolder_breadcrumbs(app, ui, &b.path);});let count = ui.add_sized(vec2(count_w, 24.0), egui::Label::new(egui::RichText::new(cnt).size(12.5).color(t.text_dim)).truncate());- register(ui.ctx(), "grid:count", count.rect);+ register(ui, "grid:count", count.rect);count.on_hover_text(cnt);});ui.horizontal_wrapped(|ui| {@@ -970,7 +970,7 @@ fn folder_header(app: &mut LightcraftApp, ui: &mut egui::Ui, b: &lightcraft_engiui.style_mut().wrap_mode = Some(egui::TextWrapMode::Wrap);let mut sub = b.subfolders;let c = ui.checkbox(&mut sub, crate::i18n::tr("Include subfolders"));- register(ui.ctx(), "check:includeSubfolders", c.rect);+ register(ui, "check:includeSubfolders", c.rect);if c.changed() {let _ = app.run("library.browse", json!({"path": b.path, "subfolders": sub}));}@@ -979,7 +979,7 @@ fn folder_header(app: &mut LightcraftApp, ui: &mut egui::Ui, b: &lightcraft_engilet label = crate::i18n::tr_format!("Add {local_n} to My Photos", local_n = local_n);let button =ui.add(egui::Button::new(egui::RichText::new(label).font(t.semibold(11.5)).color(t.text)).wrap().min_size(vec2(37.0, 24.0)));- register(ui.ctx(), "button:addToLibrary", button.rect);+ register(ui, "button:addToLibrary", button.rect);if button.clicked() {let local: Vec<u64> = ids.iter().filter(|id| app.session.catalog.photo(**id).is_some_and(|p| p.local)).map(|id| id.0).collect();let n = local.len();@@ -991,7 +991,7 @@ fn folder_header(app: &mut LightcraftApp, ui: &mut egui::Ui, b: &lightcraft_engi}});});- register(ui.ctx(), "grid:folderHeader", header.response.rect);+ register(ui, "grid:folderHeader", header.response.rect);header.response.rect}@@ -1042,7 +1042,7 @@ fn folder_breadcrumbs(app: &mut LightcraftApp, ui: &mut egui::Ui, path: &str) {let width = ((ui.available_width() - separator_w * (remaining - 1) as f32) / remaining as f32).max(0.0).floor();let text = egui::RichText::new(*part).size(13.0).color(if last { t.text } else { t.text_label });let r = ui.add_sized(vec2(width, 24.0), egui::Label::new(if last { text.strong() } else { text }).truncate().sense(Sense::click()));- register(ui.ctx(), format!("crumb:{i}"), r.rect);+ register(ui, format!("crumb:{i}"), r.rect);if !last {if r.hovered() {ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);@@ -1087,7 +1087,7 @@ pub fn drag_feedback(app: &mut LightcraftApp, ctx: &egui::Context) {|ui| {egui::Frame::NONE.fill(t.accent).corner_radius(10.0).inner_margin(egui::Margin::symmetric(9, 3)).show(ui, |ui| {let label = ui.add(egui::Label::new(egui::RichText::new(text).color(Color32::WHITE).font(t.semibold(12.0))).extend());- crate::widgets::register(ui.ctx(), "dragPhotos", label.rect);+ crate::widgets::register(ui, "dragPhotos", label.rect);});},);@@ -1144,13 +1144,13 @@ pub fn label_items(app: &mut LightcraftApp, ui: &mut egui::Ui, current: Option<Cui.painter().circle_filled(r.center(), 5.0, label_color(l));ui.selectable_label(current == Some(l), name)});- register(ui.ctx(), format!("{widget}:{}", label_param(Some(l))), resp.inner.rect);+ register(ui, format!("{widget}:{}", label_param(Some(l))), resp.inner.rect);if resp.inner.clicked() {chosen = Some(Some(l));}}let none = ui.selectable_label(current.is_none(), crate::i18n::tr("None"));- register(ui.ctx(), format!("{widget}:none"), none.rect);+ register(ui, format!("{widget}:none"), none.rect);if none.clicked() {chosen = Some(None);}@@ -1184,7 +1184,7 @@ pub fn stack_badge(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, sid:"Stack — click to collapse (S)"});crate::widgets::announce(&resp, crate::i18n::tr(if collapsed { "Expand Stack" } else { "Collapse Stack" }));- register(ui.ctx(), format!("stack:{}", id.0), br);+ 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 {@@ -1276,14 +1276,14 @@ pub fn context_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {if local_only(app, &app.session.selected()) {// albums hold library photos (issue #684): nothing here to add until they join My Photoslet add = ui.add_enabled(false, egui::Button::new(crate::i18n::tr("Add to Album"))).on_disabled_hover_text(albums_hint());- register(ui.ctx(), "button:contextAddToAlbum", add.rect);+ register(ui, "button:contextAddToAlbum", add.rect);} else {let add = crate::widgets::menu_button(ui, crate::i18n::tr("Add to Album"), |ui| {let albums: Vec<_> = app.session.catalog.albums().filter(|a| !a.folder && !a.is_smart()).map(|a| (a.id.0, a.name.clone())).collect();let any = !albums.is_empty();for (aid, name) in albums {let b = ui.button(name);- register(ui.ctx(), format!("button:contextAlbum:{aid}"), b.rect);+ register(ui, format!("button:contextAlbum:{aid}"), b.rect);if b.clicked() {match app.run("album.addPhotos", json!({"id": aid})) {Ok(r) => toast_skipped(app, ui.ctx(), &r),@@ -1297,12 +1297,12 @@ pub fn context_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {// as in the Photo menu: a new album holding the selection, also when there is none yet// to pick (issue #676: the submenu came up empty)let new = ui.button(crate::i18n::tr("New Album…"));- register(ui.ctx(), "button:contextNewAlbum", new.rect);+ register(ui, "button:contextNewAlbum", new.rect);if new.clicked() {let _ = app.run("dialog.newAlbum", json!({}));}});- register(ui.ctx(), "button:contextAddToAlbum", add.response.rect);+ register(ui, "button:contextAddToAlbum", add.response.rect);}// in a (non-smart) album: take the selection out of it, or make this photo its coverif let lightcraft_engine::LibrarySource::Album(aid) = app.session.source@@ -1438,7 +1438,7 @@ pub fn context_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {}} else {let delete = ui.button(crate::i18n::tr("Delete Photo"));- register(ui.ctx(), "button:contextDeletePhoto", delete.rect);+ register(ui, "button:contextDeletePhoto", delete.rect);if delete.clicked() {let _ = crate::menubar::run_item(app, "photo.delete", json!({}));}diff --git a/crates/ui-egui/src/panels/histogram.rs b/crates/ui-egui/src/panels/histogram.rsindex e6c0b50c1..3f26b46bd 100644--- a/crates/ui-egui/src/panels/histogram.rs+++ b/crates/ui-egui/src/panels/histogram.rs@@ -202,7 +202,7 @@ pub fn interact(app: &mut LightcraftApp, ui: &egui::Ui, resp: &Response, plot: Rif dragging || hovered.is_some() {ui.ctx().set_cursor_icon(egui::CursorIcon::ResizeHorizontal);}- register(ui.ctx(), "histogram:zone", zone.rect(plot));+ register(ui, "histogram:zone", zone.rect(plot));Some(Active { zone, value: value_of(app, id, spec), dragging })}diff --git a/crates/ui-egui/src/panels/keymap.rs b/crates/ui-egui/src/panels/keymap.rsindex 314aa51d1..0d4ee5ef9 100644--- a/crates/ui-egui/src/panels/keymap.rs+++ b/crates/ui-egui/src/panels/keymap.rs@@ -24,12 +24,12 @@ pub fn body(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {let mut show_all: bool = ui.data(|d| d.get_temp(all_id)).unwrap_or(false);ui.horizontal(|ui| {let r = ui.add(egui::TextEdit::singleline(&mut search).hint_text(crate::i18n::tr("Search commands or keys")).desired_width(220.0));- register(ui.ctx(), "field:shortcutsSearch", r.rect);+ register(ui, "field:shortcutsSearch", r.rect);let r = ui.checkbox(&mut show_all, crate::i18n::tr("Show commands without a shortcut"));- register(ui.ctx(), "check:shortcuts.showAll", r.rect);+ register(ui, "check:shortcuts.showAll", r.rect);ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {let r = ui.add_enabled(!app.ui.settings.keymap.is_empty(), egui::Button::new(crate::i18n::tr("Reset All")));- register(ui.ctx(), "button:shortcutsResetAll", r.rect);+ register(ui, "button:shortcutsResetAll", r.rect);if r.clicked() {let _ = app.run("app.resetShortcuts", serde_json::json!({}));app.recording_shortcut = None;@@ -103,14 +103,14 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, b: &Bindable, sc:}};let r = ui.add(egui::Button::new(text).min_size(egui::vec2(110.0, 0.0)).selected(recording));- register(ui.ctx(), format!("button:shortcut-{}", b.id), r.rect);+ register(ui, format!("button:shortcut-{}", b.id), r.rect);if r.clicked() {app.recording_shortcut = if recording { None } else { Some(b.id.to_string()) };}ui.horizontal(|ui| {ui.spacing_mut().item_spacing.x = 2.0;let r = ui.add_enabled(sc.is_some(), egui::Button::new("×").small()).on_hover_text(crate::i18n::tr("Remove shortcut"));- register(ui.ctx(), format!("button:shortcutClear-{}", b.id), r.rect);+ register(ui, format!("button:shortcutClear-{}", b.id), r.rect);if r.clicked() {apply(app, ui.ctx(), serde_json::json!({"id": b.id, "shortcut": null}));}@@ -118,7 +118,7 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, b: &Bindable, sc:Some(d) => crate::i18n::tr_format!("Restore {}", menu_text(d, mac)),None => crate::i18n::tr("Restore (no shortcut)").to_string(),});- register(ui.ctx(), format!("button:shortcutReset-{}", b.id), r.rect);+ register(ui, format!("button:shortcutReset-{}", b.id), r.rect);if r.clicked() {apply(app, ui.ctx(), serde_json::json!({"id": b.id, "reset": true}));}diff --git a/crates/ui-egui/src/panels/keyword_list.rs b/crates/ui-egui/src/panels/keyword_list.rsindex d8d6c3a7c..ba31c6676 100644--- a/crates/ui-egui/src/panels/keyword_list.rs+++ b/crates/ui-egui/src/panels/keyword_list.rs@@ -23,7 +23,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {crate::widgets::divider(ui);// the title, where a dragged keyword goes back to the top levellet (title, title_resp) = ui.allocate_exact_size(vec2(ui.available_width(), 46.0), Sense::click());- register(ui.ctx(), "keywordList:topLevel", title);+ register(ui, "keywordList:topLevel", title);let dragging = app.ui.dragging_keyword.clone();let (pointer, released) = ui.input(|i| (i.pointer.latest_pos(), i.pointer.any_released()));let over_title = shown_under(ui, title, pointer);@@ -52,13 +52,13 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {.show(ui);// + creates a keyword (inside the picked one), − deletes the picked onelet plus = ui.button("+").on_hover_text(crate::i18n::tr("Create Keyword Tag"));- register(ui.ctx(), "keywordList:create", plus.rect);+ register(ui, "keywordList:create", plus.rect);if plus.clicked() {app.ui.dialog = Some(create_dialog(app));}let picked = app.ui.keyword_list_selected.clone().filter(|k| in_tree(&app.caches.keyword_tree(&app.session.catalog), k));let minus = ui.add_enabled(picked.is_some(), egui::Button::new("−")).on_hover_text(crate::i18n::tr("Delete Keyword"));- register(ui.ctx(), "keywordList:delete", minus.rect);+ register(ui, "keywordList:delete", minus.rect);if minus.clicked()&& let Some(k) = picked{@@ -170,7 +170,7 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, r: &Row, selection: &[PhotoIdlet t = Tokens::get(ui.ctx());let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), ROW_H), Sense::click_and_drag());crate::widgets::announce(&resp, r.path.clone());- register(ui.ctx(), format!("keywordRow:{}", r.path), rect);+ register(ui, format!("keywordRow:{}", r.path), rect);if resp.drag_started() {app.ui.dragging_keyword = Some(r.path.clone());}@@ -190,7 +190,7 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, r: &Row, selection: &[PhotoIdlet tri = Rect::from_center_size(c, vec2(16.0, 16.0));let tr = ui.interact(tri, egui::Id::unique(("keyword-list-tri", r.path.to_lowercase())), Sense::click());crate::widgets::announce(&tr, crate::i18n::tr(if r.open { "Collapse" } else { "Expand" }));- register(ui.ctx(), format!("keywordRowToggle:{}", r.path), tri);+ register(ui, format!("keywordRowToggle:{}", r.path), tri);// while a filter opens the levels the triangle does nothing: it doesn't light up eitherlet lit = tr.hovered() && can_fold;paint(ui.painter(), tri, if r.open { Icon::ChevronDown } else { Icon::ChevronRight }, if lit { t.text } else { t.text_dim });@@ -212,7 +212,7 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, r: &Row, selection: &[PhotoIdlet sense = if on { Sense::click_and_drag() } else { Sense::hover() };let tb = ui.interact(boxr.expand(3.0), egui::Id::unique(("keyword-list-tick", r.path.to_lowercase())), sense);crate::widgets::announce(&tb, format!("{} {}", crate::i18n::tr("Keyword"), r.path));- register(ui.ctx(), format!("keywordCheck:{}", r.path), boxr);+ register(ui, format!("keywordCheck:{}", r.path), boxr);let edge = if on { t.text_label } else { t.text_dim.gamma_multiply(0.5) };match state {Tick::All => {@@ -232,7 +232,7 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, r: &Row, selection: &[PhotoIdif !inside.is_empty() {let dot = Rect::from_center_size(boxr.center(), vec2(5.0, 5.0));ui.painter().circle_filled(dot.center(), 2.5, t.text);- register(ui.ctx(), format!("keywordInside:{}", r.path), dot);+ register(ui, format!("keywordInside:{}", r.path), dot);}}}@@ -257,12 +257,12 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, r: &Row, selection: &[PhotoId// the count, then the arrow left of it (shown on hover)let count = ui.painter().layout_no_wrap(r.count.to_string(), t.font(12.0), t.text_dim);let count_rect = Rect::from_min_size(pos2(inner.right() - 6.0 - count.size().x, cy - count.size().y / 2.0), count.size());- register(ui.ctx(), format!("keywordCount:{}", r.path), count_rect);+ register(ui, format!("keywordCount:{}", r.path), count_rect);ui.painter().galley(count_rect.min, count, t.text_dim);let arrow = Rect::from_center_size(pos2(count_rect.left() - 12.0, cy), vec2(16.0, 16.0));let ar = ui.interact(arrow, egui::Id::unique(("keyword-list-show", r.path.to_lowercase())), Sense::click());crate::widgets::announce(&ar, crate::i18n::tr("Show photos"));- register(ui.ctx(), format!("keywordShow:{}", r.path), arrow);+ register(ui, format!("keywordShow:{}", r.path), arrow);if resp.hovered() || ar.hovered() {paint(ui.painter(), arrow, Icon::ChevronRight, if ar.hovered() { t.text } else { t.text_dim });}@@ -280,7 +280,7 @@ fn row(app: &mut LightcraftApp, ui: &mut egui::Ui, r: &Row, selection: &[PhotoIdif app.session.catalog.default_keyword_parent().as_deref().is_some_and(|k| same(k, &r.path)) {let dot = Rect::from_center_size(pos2(label.right() + 7.0, cy), vec2(6.0, 6.0));ui.painter().circle_filled(dot.center(), 3.0, t.accent);- register(ui.ctx(), format!("keywordDefault:{}", r.path), dot);+ register(ui, format!("keywordDefault:{}", r.path), dot);}let resp = resp.on_hover_text(r.path.replace('|', " › "));if resp.clicked() {@@ -354,7 +354,7 @@ fn menu(app: &mut LightcraftApp, ui: &mut egui::Ui, path: &str, selection: &[Pholet name = path.replace('|', " › ");let item = |ui: &mut egui::Ui, id: &str, label: &str, enabled: bool| {let r = ui.add_enabled(enabled, egui::Button::new(label));- register(ui.ctx(), format!("keywordMenu:{id}"), r.rect);+ register(ui, format!("keywordMenu:{id}"), r.rect);r.clicked()};if item(ui, "create", &crate::i18n::tr_format!("Create Keyword Tag Inside “{name}”…", name = name), true) {diff --git a/crates/ui-egui/src/panels/keywording.rs b/crates/ui-egui/src/panels/keywording.rsindex 8a9516fe2..4861d4c6f 100644--- a/crates/ui-egui/src/panels/keywording.rs+++ b/crates/ui-egui/src/panels/keywording.rs@@ -18,7 +18,7 @@ pub fn view_switch(app: &mut LightcraftApp, ui: &mut egui::Ui) {[(V::Keywords, "keywords", "Keywords"), (V::Containing, "containing", "& Containing"), (V::WillExport, "willExport", "Will Export")]{let r = ui.selectable_label(app.ui.keywording_view == view, crate::i18n::tr(label));- register(ui.ctx(), format!("keywordView:{id}"), r.rect);+ register(ui, format!("keywordView:{id}"), r.rect);if r.clicked() {app.ui.keywording_view = view;}@@ -41,7 +41,7 @@ pub fn names_row(app: &mut LightcraftApp, ui: &mut egui::Ui) {ui.horizontal_wrapped(|ui| {for n in names.iter() {let (body, _) = chip(ui, &n.path, &n.path, !n.on_all(), false, ui.max_rect().width());- register(ui.ctx(), format!("{prefix}:{}", n.path), body.rect);+ register(ui, format!("{prefix}:{}", n.path), body.rect);if n.on_all() {body.on_hover_text(&n.path);} else {@@ -148,7 +148,7 @@ fn remove(app: &mut LightcraftApp, ctx: &egui::Context, chip: &Chip) {fn menu(app: &mut LightcraftApp, ui: &mut egui::Ui, chip: &Chip) {let item = |ui: &mut egui::Ui, id: &str, label: &str| {let r = ui.button(label);- register(ui.ctx(), format!("keywordChipMenu:{id}"), r.rect);+ register(ui, format!("keywordChipMenu:{id}"), r.rect);r.clicked()};if !chip.on_all() && item(ui, "add", crate::i18n::tr("Add to All Selected Photos")) {@@ -177,7 +177,7 @@ pub fn scope(app: &mut LightcraftApp, ui: &mut egui::Ui, selection: &[PhotoId])let t = Tokens::get(ui.ctx());let said = crate::i18n::tr_format!("Keywords of {n} selected photos", n = photos);let r = ui.label(egui::RichText::new(said).size(11.5).color(t.text_label));- register(ui.ctx(), "keywordScope", r.rect);+ register(ui, "keywordScope", r.rect);ui.add_space(4.0);}@@ -189,7 +189,7 @@ pub fn chip_row(app: &mut LightcraftApp, ui: &mut egui::Ui, selection: &[PhotoIdif chips.is_empty() {let t = Tokens::get(ui.ctx());let r = ui.label(egui::RichText::new(crate::i18n::tr("No keywords yet")).color(t.text_dim));- register(ui.ctx(), "keywordChipsEmpty", r.rect);+ register(ui, "keywordChipsEmpty", r.rect);return;}if app.ui.settings.keyword_chips == crate::state::KeywordChips::Grouped {@@ -208,9 +208,9 @@ pub fn chip_row(app: &mut LightcraftApp, ui: &mut egui::Ui, selection: &[PhotoId/// A drawn chip does its work: its × takes the keyword off the selected photos, its name has the/// tooltip and the menu.fn chip_acts(app: &mut LightcraftApp, ui: &egui::Ui, c: &Chip, body: egui::Response, x: Option<egui::Response>) {- register(ui.ctx(), format!("keywordChip:{}", c.path), body.rect);+ register(ui, format!("keywordChip:{}", c.path), body.rect);if let Some(x) = x {- register(ui.ctx(), format!("keywordChipRemove:{}", c.path), x.rect);+ register(ui, format!("keywordChipRemove:{}", c.path), x.rect);if x.on_hover_text(crate::i18n::tr("Remove from Selected Photos")).clicked() {remove(app, ui.ctx(), c);}@@ -220,7 +220,7 @@ fn chip_acts(app: &mut LightcraftApp, ui: &egui::Ui, c: &Chip, body: egui::Respolet body = if c.on_all() {body.on_hover_text(full)} else {- register(ui.ctx(), format!("keywordChipPartial:{}", c.path), body.rect);+ register(ui, format!("keywordChipPartial:{}", c.path), body.rect);let n = crate::i18n::tr_format!("On {have} of {of} selected photos", have = c.have, of = c.of);body.on_hover_text(format!("{full}\n{n}"))};@@ -279,7 +279,7 @@ fn chip_groups(app: &mut LightcraftApp, ui: &mut egui::Ui, groups: &[Group], selif shown != full {resp.on_hover_text(&full);}- register(ui.ctx(), format!("keywordGroup:{}", group.parent), r);+ register(ui, format!("keywordGroup:{}", group.parent), r);}Line::Chips(g, row) => {let Some(group) = groups.get(g) else { continue };@@ -296,7 +296,7 @@ fn chip_groups(app: &mut LightcraftApp, ui: &mut egui::Ui, groups: &[Group], selui.add_space(6.0);let label = crate::i18n::tr_format!("+{n} more", n = n);let r = ui.add(egui::Button::new(egui::RichText::new(label).color(t.text_label)).corner_radius(10.0));- register(ui.ctx(), "keywordChipsMore", r.rect);+ register(ui, "keywordChipsMore", r.rect);if r.on_hover_text(crate::i18n::tr("Show every keyword of the selected photos")).clicked() {app.ui.keyword_chips_all = Some(selection);}@@ -304,7 +304,7 @@ fn chip_groups(app: &mut LightcraftApp, ui: &mut egui::Ui, groups: &[Group], selLine::Fewer => {ui.add_space(6.0);let r = ui.add(egui::Button::new(egui::RichText::new(crate::i18n::tr("Show fewer")).color(t.text_label)).corner_radius(10.0));- register(ui.ctx(), "keywordChipsFewer", r.rect);+ register(ui, "keywordChipsFewer", r.rect);if r.clicked() {app.ui.keyword_chips_all = None;}@@ -470,9 +470,9 @@ pub(crate) fn offers_below(ui: &egui::Ui, below: egui::Rect, offers: &Offers, atlet whole = k.replace(SEP, " › ");let lit = at == Some(k.as_str());let r = line(ui, egui::Id::unique(("keyword-offer", k.to_lowercase())), name, place, &whole, lit);- register(ui.ctx(), format!("kwComplete:{k}"), r.rect);+ register(ui, format!("kwComplete:{k}"), r.rect);if lit {- register(ui.ctx(), format!("kwCompleteAt:{k}"), r.rect);+ register(ui, format!("kwCompleteAt:{k}"), r.rect);}if r.clicked() {picked = Some(Picked::Keyword(k.clone()));@@ -500,7 +500,7 @@ pub(crate) fn offers_below(ui: &egui::Ui, below: egui::Rect, offers: &Offers, atlet r = line(ui, egui::Id::unique("keyword-offer-create"), name, "", &said, false);let small = t.font(11.5);ui.painter().text(pos2(r.rect.right() - 8.0, r.rect.center().y), Align2::RIGHT_CENTER, place, small, t.text_label);- register(ui.ctx(), "kwCompleteCreate", r.rect);+ register(ui, "kwCompleteCreate", r.rect);// (Return gives the highlighted offer instead, while there is one)let r = if at.is_none() {r.on_hover_text(crate::i18n::tr("Return creates this keyword and gives it to the selected photos"))diff --git a/crates/ui-egui/src/panels/layout_overlay.rs b/crates/ui-egui/src/panels/layout_overlay.rsindex 323c035a6..655e2ae33 100644--- a/crates/ui-egui/src/panels/layout_overlay.rs+++ b/crates/ui-egui/src/panels/layout_overlay.rs@@ -16,7 +16,7 @@ use lightcraft_raster::Rgba8;use crate::LightcraftApp;use crate::theme::Tokens;-use crate::widgets::register;+use crate::widgets::register_geometry;/// The longest side a layout image keeps (a screen never shows more of it).pub const MAX_SIDE: usize = 4096;@@ -153,7 +153,7 @@ pub fn draw(app: &LightcraftApp, p: &egui::Painter, photo: Rect) {}let alpha = (li.opacity.clamp(0.0, 1.0) * 255.0).round() as u8;p.image(tex.id(), r, Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0)), Color32::from_white_alpha(alpha));- register(&ctx, "canvas:layoutImage", r.intersect(p.clip_rect()));+ register_geometry(&ctx, "canvas:layoutImage", r.intersect(p.clip_rect()));}ctx.data_mut(|d| d.insert_temp(id, cache));}@@ -173,7 +173,7 @@ fn note(p: &egui::Painter, why: &str) {p.galley(at, g, Color32::WHITE);y -= 3.0;}- register(p.ctx(), "canvas:layoutImageError", Rect::from_min_max(pos2(canvas.left(), y), pos2(canvas.left() + 360.0, canvas.bottom())));+ register_geometry(p.ctx(), "canvas:layoutImageError", Rect::from_min_max(pos2(canvas.left(), y), pos2(canvas.left() + 360.0, canvas.bottom())));}#[cfg(test)]diff --git a/crates/ui-egui/src/panels/left.rs b/crates/ui-egui/src/panels/left.rsindex c1c709fd7..680c5bf3b 100644--- a/crates/ui-egui/src/panels/left.rs+++ b/crates/ui-egui/src/panels/left.rs@@ -138,7 +138,7 @@ fn row_sensed(if scroll_asked(ui, id) {ui.scroll_to_rect_animation(r, None, egui::style::ScrollAnimation::none());}- register(ui.ctx(), format!("source:{id}"), r);+ register(ui, format!("source:{id}"), r);let mark_w = if mark.is_some() { MARK_W } else { 0.0 };let said = spoken.unwrap_or(label);let name = match count {@@ -153,7 +153,7 @@ fn row_sensed(let inner = Rect::from_min_max(r.min + vec2(8.0, 0.0), pos2((r.right() - 8.0).min(edge - 8.0).max(r.left() + 8.0), r.bottom()));if selected {ui.painter().rect_filled(inner, 4.0, t.canvas);- register(ui.ctx(), format!("highlight:{id}"), inner);+ register(ui, format!("highlight:{id}"), inner);} else if resp.hovered() {ui.painter().rect_filled(inner, 4.0, t.hover.gamma_multiply(0.6));}@@ -174,7 +174,7 @@ fn row_sensed(if let Some(c) = mark {let dot = Rect::from_center_size(pos2(count_left - MARK_W / 2.0, r.center().y), vec2(8.0, 8.0));ui.painter().circle_filled(dot.center(), 4.0, c);- register(ui.ctx(), format!("labelMark:{id}"), dot);+ register(ui, format!("labelMark:{id}"), dot);}// the name gives way to the count: cut with an ellipsis, in full on hoverlet room = count_left - mark_w - 8.0 - label_left;@@ -182,12 +182,12 @@ fn row_sensed(let full_w = measure(label);let shown = if full_w <= room { label.to_string() } else { crate::widgets::elide_head(label, room.max(0.0), measure) };let label_rect = ui.painter().text(pos2(label_left, r.center().y), Align2::LEFT_CENTER, &shown, font.clone(), color);- register(ui.ctx(), format!("label:{id}"), label_rect);+ register(ui, format!("label:{id}"), label_rect);let resp = if shown != label { resp.on_hover_text(label) } else { resp };note_width(ui, row_need(indent, full_w, mark_w, count_galley.as_ref().map(|g| g.size().x)));if let Some(galley) = count_galley {let rect = Rect::from_min_size(pos2(edge - 18.0 - galley.size().x, r.center().y - galley.size().y / 2.0), galley.size());- register(ui.ctx(), format!("count:{id}"), rect);+ register(ui, format!("count:{id}"), rect);ui.painter().galley(rect.min, galley, t.text_dim);}resp@@ -204,7 +204,7 @@ fn out_of_sight(app: &LightcraftApp, ui: &mut egui::Ui, id: &str, label: &str, creturn false;}ui.allocate_space(r.size());- register(ui.ctx(), format!("source:{id}"), r);+ register(ui, format!("source:{id}"), r);let indent = drawn_indent(ui, indent);let t = Tokens::get(ui.ctx());let painter = ui.painter();@@ -234,7 +234,7 @@ fn disclosure_chevron(ui: &mut egui::Ui, row: &egui::Response, indent: f32, openlet c = pos2(row.rect.left() + 10.0 + indent_x(ui.ctx(), indent), row.rect.center().y);let tri = Rect::from_center_size(c, vec2(16.0, 16.0));let tr = ui.interact(tri, id, Sense::click());- register(ui.ctx(), widget, tri);+ register(ui, widget, tri);let col = if tr.hovered() { t.text } else { t.text_dim };paint(ui.painter(), Rect::from_center_size(c, vec2(16.0, 16.0)), if open { Icon::ChevronDown } else { Icon::ChevronRight }, col);tr@@ -348,7 +348,7 @@ fn pinned_header(app: &mut LightcraftApp, ui: &mut egui::Ui, placed: &[PlacedSecfn empty_hint(ui: &mut egui::Ui, section: SidebarSection) {let t = Tokens::get(ui.ctx());let (r, _) = ui.allocate_exact_size(vec2(ui.available_width(), ROW_HEIGHT), Sense::hover());- register(ui.ctx(), format!("sidebarEmpty:{}", section.id()), r);+ register(ui, format!("sidebarEmpty:{}", section.id()), r);let text = crate::i18n::tr(section.empty_hint());let galley = ui.painter().layout_no_wrap(text.to_string(), t.font(12.5), t.text_dim);note_width(ui, 42.0 + galley.size().x + 18.0);@@ -416,7 +416,7 @@ fn section_drag(app: &mut LightcraftApp, ui: &mut egui::Ui, placed: &[PlacedSectlet t = Tokens::get(ui.ctx());let line = Rect::from_min_max(pos2(view.left() + 8.0, y - 1.0), pos2(visible_right(ui).min(view.right()) - 8.0, y + 1.0));ui.painter().rect_filled(line, 1.0, t.accent);- register(ui.ctx(), "sidebarSectionDrop", line);+ register(ui, "sidebarSectionDrop", line);}}@@ -453,7 +453,7 @@ fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, section: SidebarSelet title = crate::i18n::tr(section.title());let (interact, widget) = if pinned { ("sidebar-section-pinned", "sidebarSectionPinned") } else { ("sidebar-section", "sidebarSection") };let resp = ui.interact(r, ui.scope_id().with((interact, id)), Sense::click_and_drag());- register(ui.ctx(), format!("{widget}:{id}"), r);+ register(ui, format!("{widget}:{id}"), r);let toggled = resp.clicked();if toggled {app.ui.sidebar.toggle_collapsed(section);@@ -477,7 +477,7 @@ fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, section: SidebarSeui.painter().rect_filled(bar, 4.0, t.hover.gamma_multiply(0.6));}let c = pos2(r.left() + 10.0, r.center().y);- register(ui.ctx(), format!("{widget}Chevron:{id}"), Rect::from_center_size(c, vec2(16.0, 16.0)));+ register(ui, format!("{widget}Chevron:{id}"), Rect::from_center_size(c, vec2(16.0, 16.0)));let col = if hovered { t.text } else { t.text_dim };paint(ui.painter(), Rect::from_center_size(c, vec2(16.0, 16.0)), if open { Icon::ChevronDown } else { Icon::ChevronRight }, col);ui.painter().text(pos2(r.left() + 18.0, r.center().y), Align2::LEFT_CENTER, title, t.semibold(13.5), t.text_label);@@ -488,7 +488,7 @@ fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, section: SidebarSe// folded: how much is in there (left of the header's own button)let right = edge - 18.0 - if button.is_some() { HEADER_BUTTON + 4.0 } else { 0.0 };let count = ui.painter().text(pos2(right, r.center().y), Align2::RIGHT_CENTER, rows.to_string(), t.font(12.5), t.text_dim);- register(ui.ctx(), format!("{widget}Count:{id}"), count);+ register(ui, format!("{widget}Count:{id}"), count);}if section == SidebarSection::Albums {top_level_drop_target(app, ui, r);@@ -577,13 +577,13 @@ fn sections_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, on: Option<SidebarSlet mut run = None;if let Some(section) = on {let hide = ui.button(crate::i18n::tr("Hide This Section"));- register(ui.ctx(), "sidebarMenu:hide", hide.rect);+ register(ui, "sidebarMenu:hide", hide.rect);if hide.clicked() {run = Some(("view.sidebarSection", json!({"section": section.id(), "show": false})));}for (up, label, widget) in [(true, "Move Up", "sidebarMenu:moveUp"), (false, "Move Down", "sidebarMenu:moveDown")] {let item = ui.add_enabled(app.ui.sidebar.can_move(section, up), egui::Button::new(crate::i18n::tr(label)));- register(ui.ctx(), widget, item.rect);+ register(ui, widget, item.rect);if item.clicked() {run = Some(("view.sidebarMoveSection", json!({"section": section.id(), "direction": if up { "up" } else { "down" }})));}@@ -592,14 +592,14 @@ fn sections_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, on: Option<SidebarS}for s in app.ui.sidebar.sections().iter().filter(|s| s.id.available()) {let shown = ui.selectable_label(!s.hidden, crate::i18n::tr(s.id.title()));- register(ui.ctx(), format!("sidebarMenu:section:{}", s.id.id()), shown.rect);+ register(ui, format!("sidebarMenu:section:{}", s.id.id()), shown.rect);if shown.clicked() {run = Some(("view.sidebarSection", json!({"section": s.id.id(), "show": s.hidden})));}}ui.separator();let reset = ui.add_enabled(!app.ui.sidebar.is_default(), egui::Button::new(crate::i18n::tr("Reset Sidebar Sections")));- register(ui.ctx(), "sidebarMenu:reset", reset.rect);+ register(ui, "sidebarMenu:reset", reset.rect);if reset.clicked() {run = Some(("view.sidebarReset", json!({})));}@@ -647,7 +647,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {// the title offers the sections' menu too: where hidden sections come back fromlet (hr, title) = ui.allocate_exact_size(vec2(ui.available_width(), 44.0), Sense::click());crate::widgets::announce(&title, crate::i18n::tr("My Photos"));- register(ui.ctx(), "sidebarTitle", hr);+ register(ui, "sidebarTitle", hr);crate::widgets::context_menu(&title, |ui| sections_menu(app, ui, None));// the open library's name under the title, so nobody edits in the wrong one (issue #902)let library = crate::panels::settings::open_library_name(app);@@ -661,7 +661,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {t.font(11.0),t.text_dim,);- crate::widgets::register(ui.ctx(), "label:libraryName", hr);+ crate::widgets::register(ui, "label:libraryName", hr);if let Some(l) = app.session.library.as_ref() {title.on_hover_text(l.dir.display().to_string());}@@ -942,7 +942,7 @@ fn local_rows(app: &mut LightcraftApp, ui: &mut egui::Ui, now: &LocalNow) {fn hidden_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, hidden: &[(String, String)]) {for (name, path) in hidden {let r = ui.button(name).on_hover_text(path);- register(ui.ctx(), format!("local:restoreHidden:{path}"), r.rect);+ register(ui, format!("local:restoreHidden:{path}"), r.rect);if r.clicked() {let _ = app.run("local.restoreHidden", json!({"path": path}));ui.close();@@ -950,7 +950,7 @@ fn hidden_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, hidden: &[(String, St}ui.separator();let r = ui.button(crate::i18n::tr("Restore All"));- register(ui.ctx(), "local:restoreHidden:all", r.rect);+ register(ui, "local:restoreHidden:all", r.rect);if r.clicked() {let _ = app.run("local.restoreHidden", json!({}));ui.close();@@ -1304,7 +1304,7 @@ fn albums_tree(app: &mut LightcraftApp, ui: &mut egui::Ui, all: &AlbumKids, parelet label = if problems.is_empty() { label } else { format!("⚠ {label}") };let mut resp = row_sensed(app, ui, &format!("album:{}", a.id.0), icon, &label, None, Some(n), sel, indent, Sense::click_and_drag(), None);if !problems.is_empty() {- crate::widgets::register(ui.ctx(), format!("albumProblem:{}", a.id.0), resp.rect);+ crate::widgets::register(ui, format!("albumProblem:{}", a.id.0), resp.rect);}if resp.drag_started() {app.ui.dragging_album = Some(a.id.0);@@ -1560,7 +1560,7 @@ fn top_level_drop_target(app: &mut LightcraftApp, ui: &mut egui::Ui, header: Recreturn;}let t = Tokens::get(ui.ctx());- register(ui.ctx(), "albumDrop:top", header);+ register(ui, "albumDrop:top", header);let over = pointer_over(ui, header);let stroke = if over { egui::Stroke::new(1.5, t.accent) } else { egui::Stroke::new(1.0, t.text_dim.gamma_multiply(0.5)) };ui.painter().rect_stroke(header.shrink2(vec2(8.0, 3.0)), 4.0, stroke, egui::StrokeKind::Inside);@@ -1681,7 +1681,7 @@ fn folder_menu(app: &mut LightcraftApp, resp: &egui::Response, a: &Album) {let menu = crate::widgets::menu_button(ui, crate::i18n::tr("Import"), |ui| {let mut entry = |ui: &mut egui::Ui, label: String, widget: String, command: &str, params: serde_json::Value| {let r = ui.button(label);- crate::widgets::register(ui.ctx(), widget, r.rect);+ crate::widgets::register(ui, widget, r.rect);if r.clicked() {if let Err(e) = app.run(command, params) {app.toast(ui.ctx(), e);@@ -1706,9 +1706,9 @@ fn folder_menu(app: &mut LightcraftApp, resp: &egui::Response, a: &Album) {entry(ui, format!("{}…", d.name), format!("button:albumImportDevice:{i}"), "file.addFromDevice", params);}});- crate::widgets::register(ui.ctx(), "button:albumImportDevice", device.response.rect);+ crate::widgets::register(ui, "button:albumImportDevice", device.response.rect);});- crate::widgets::register(ui.ctx(), "button:albumImport", menu.response.rect);+ crate::widgets::register(ui, "button:albumImport", menu.response.rect);}if !a.folder && !a.is_smart() {let is_target = app.session.target_album == Some(a.id) || (app.session.target_album.is_none() && a.quick);@@ -1776,7 +1776,7 @@ fn folder_menu(app: &mut LightcraftApp, resp: &egui::Response, a: &Album) {app.ui.dialog = Some(crate::state::Dialog::RenameAlbum { id: a.id.0, name: a.name.clone() });}let delete = ui.button(crate::i18n::tr("Delete"));- register(ui.ctx(), format!("albumDelete:{}", a.id.0), delete.rect);+ register(ui, format!("albumDelete:{}", a.id.0), delete.rect);let delete =delete.on_hover_text(crate::i18n::tr("Photos stay in All Photos. Deleting a folder also deletes its albums. You can undo this."));if delete.clicked() {@@ -2054,7 +2054,7 @@ fn row_menu(app: &mut LightcraftApp, resp: &egui::Response, n: &FolderNode) {/// background finder relink only this folder's photos (including the folders inside it).fn locate_missing_item(app: &mut LightcraftApp, ui: &mut egui::Ui, n: &FolderNode) {let r = ui.button(crate::i18n::tr("Locate Missing Files…"));- register(ui.ctx(), "folderLocateMissing", r.rect);+ register(ui, "folderLocateMissing", r.rect);if r.clicked() {if let Err(e) = app.run("file.findMissing", json!({"within": n.path})) {app.toast(ui.ctx(), e);@@ -2101,7 +2101,7 @@ fn synchronize_item(app: &mut LightcraftApp, ui: &mut egui::Ui, n: &FolderNode,let r = ui.button(crate::i18n::tr("Synchronize Folder…")).on_hover_text(crate::i18n::tr("Find photos added to or missing from this folder on disk, and XMP sidecars changed by other apps"));- crate::widgets::register(ui.ctx(), "folderSynchronize", r.rect);+ crate::widgets::register(ui, "folderSynchronize", r.rect);if r.clicked() {// a disk, or a folder holding disks, was chosen as suchif let Err(e) = crate::sync::open(app, &n.path, name, n.volume || !n.selectable) {@@ -2122,7 +2122,7 @@ fn folder_label_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, n: &FolderNode)ui.close();}});- register(ui.ctx(), "folderLabelMenu", menu.response.rect);+ register(ui, "folderLabelMenu", menu.response.rect);}/// The context menu of a folder row: the folder's disk actions (the same as Local's, photosdiff --git a/crates/ui-egui/src/panels/library_problem.rs b/crates/ui-egui/src/panels/library_problem.rsindex 32e308145..841dac140 100644--- a/crates/ui-egui/src/panels/library_problem.rs+++ b/crates/ui-egui/src/panels/library_problem.rs@@ -24,6 +24,241 @@ use crate::state::{AppSettings, LaunchLibrary};use crate::theme::Tokens;use crate::widgets::register;+/// Egui ids/layers shared by the window drawing and the control-channel barrier: the two blocking+/// windows and their dim.+const DIM_ID: &str = "library-problem-dim";+const ERROR_WINDOW_ID: &str = "library-problem";+const CHOOSER_WINDOW_ID: &str = "library-chooser";++fn foreground_layer(id: &str) -> egui::LayerId {+ egui::LayerId::new(egui::Order::Foreground, egui::Id::unique(id))+}++/// The full-screen backdrop that takes the modal layer while the library window is up.+pub(crate) fn dim_layer() -> egui::LayerId {+ foreground_layer(DIM_ID)+}++/// Whether `layer` is one of the blocking library windows' own layers (the error window or the+/// launch list). Their registered controls are the only targets allowed through the dim.+fn is_window_layer(layer: egui::LayerId) -> bool {+ layer == foreground_layer(ERROR_WINDOW_ID) || layer == foreground_layer(CHOOSER_WINDOW_ID)+}++/// Whether a control-channel press must be explicitly refused because the library window's dim+/// owns the modal layer and the target is not one of that window's own controls. Ordinary dialogs+/// keep their existing backdrop semantics; only this blocking window is different.+pub(crate) fn refuses_control_target(top_modal: Option<egui::LayerId>, target: egui::LayerId) -> bool {+ top_modal == Some(dim_layer()) && !is_window_layer(target)+}++/// Which blocking window is on screen.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+enum WindowMode {+ Error,+ Chooser,+}++/// What one draw pass did for the blocking library window (test instrumentation).+///+/// The first-return tests used to prove shielding only through a rating shortcut, which the global+/// shortcut guard now blocks on every settled blocking frame. Recording the pass itself keeps+/// those regressions non-vacuous: removing the shield pass, its discard or its settlement changes+/// this sequence even though the rating shortcut would still stay blocked.+#[cfg(test)]+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) enum LibraryPass {+ /// The dedicated shield pass for a newly visible window: only the window drew, background+ /// input was dropped, and egui discarded the pass.+ Shield,+ /// A pass that went on to draw the background (with the visible window, when there is one).+ Background,+}++/// First-frame input state for the blocking library window.+///+/// Its `Foreground` areas are non-interactable during their first layout pass, and a text field+/// behind it may still own the keyboard focus. The frame that creates a window therefore draws+/// only that window and drops background input, just as a new notice prompt does.+#[derive(Default)]+pub(crate) struct WindowBarrier {+ /// The window whose completed layout has already settled. `None` until the first pass is+ /// accepted (and again once the window or its banner replaces it).+ shown: Option<WindowMode>,+ /// The next pass 0 is the shielding pass for a newly shown window. Also armed while the+ /// window is hidden by a prompt or by a dialog it opened, so the first pass that actually+ /// draws it again is shielded rather than reusing a background pass's hit-test snapshot.+ transition: bool,+ /// The window actually drew in the pass being completed (reset at the start of every draw).+ drawn: Option<WindowMode>,+ /// The shield pass for the current transition has already run (the discarded pass drew only+ /// the window); the following pass may settle it. Without this, a window that appeared in the+ /// middle of a pass could settle without ever having had a dedicated shield pass.+ shielded: bool,+ /// The current transition may have dropped an injected synthetic batch; cancel its gesture+ /// once so it reports an error instead of a false `ok: true`.+ cancel_injected: bool,+}++impl WindowBarrier {+ /// Begin a new shield transition. It stays armed until a completed pass has drawn the window+ /// after a dedicated shield pass.+ fn begin_transition(&mut self) {+ self.transition = true;+ self.shielded = false;+ self.cancel_injected = true;+ }+}++fn present_mode(app: &LightcraftApp) -> Option<WindowMode> {+ let problem = app.library_problem.as_ref().filter(|p| !p.dismissed)?;+ Some(if problem.chooser.is_some() { WindowMode::Chooser } else { WindowMode::Error })+}++/// Whether the open dialog is the launch list's own New Library name prompt.+///+/// Any other dialog (Settings opened before Alt/Option created the chooser, for example) is not+/// owned by the launch list: the blocking window stays visible over it and keeps owning input,+/// instead of stepping aside for a dialog it did not open.+fn chooser_owns_dialog(app: &LightcraftApp) -> bool {+ app.library_problem.as_ref().is_some_and(|p| p.chooser.is_some())+ && matches!(+ app.ui.dialog.as_ref(),+ Some(crate::state::Dialog::TextPrompt { command, .. }) if command == "app.newLibrary"+ )+}++/// The window actually drawn this pass. A prompt suppresses it, and the launch list yields only to+/// the New Library name dialog it opened itself.+fn visible_mode(app: &LightcraftApp) -> Option<WindowMode> {+ let mode = present_mode(app)?;+ if crate::panels::notices::blocks_input(app) {+ return None;+ }+ if mode == WindowMode::Chooser && chooser_owns_dialog(app) {+ return None;+ }+ Some(mode)+}++/// Whether the blocking library window is actually on screen over the rest of the UI this frame,+/// so a background dialog's own raw input handlers must stay still.+pub(crate) fn blocks_dialog_input(app: &LightcraftApp) -> bool {+ visible_mode(app).is_some()+}++/// A window drawn before its barrier saw it (a command late in a draw pass created it) must not+/// settle this pass: arm the transition so the next frame gets the shielded first draw.+fn note_first_draw(app: &mut LightcraftApp, mode: WindowMode) {+ if app.library_window_input.shown != Some(mode) && !app.library_window_input.transition {+ app.library_window_input.begin_transition();+ }+}++fn clear_focus(ctx: &egui::Context) {+ ctx.memory_mut(|memory| {+ if let Some(id) = memory.focused() {+ memory.surrender_focus(id);+ }+ });+}++/// Note a new blocking window before any panel or shortcut reads this pass's input. Its first+/// frame clears a background text field's focus and drops text, pointer, wheel, keys and+/// accessibility input. `keys_down` is cleared so no key is left held after the discarded pass;+/// touch End/Cancel still reach egui to clear its private touch state. Modifier and window-focus+/// changes also survive, as for a prompt.+pub(crate) fn prepare_ui_pass(app: &mut LightcraftApp, ctx: &egui::Context, batch_in_flight: bool) {+ if ctx.current_pass_index() != 0 {+ return;+ }+ // A pass 0 starts a new shield cycle; `shield_pass` records that its dedicated pass ran.+ app.library_window_input.shielded = false;+ let Some(mode) = visible_mode(app) else {+ if app.library_problem.as_ref().is_none_or(|p| p.dismissed) {+ app.library_window_input = WindowBarrier::default();+ } else if !app.library_window_input.transition {+ // The window is present but a prompt or the dialog it opened hides it. The next pass+ // that actually draws it must be shielded: while hidden, its controls are absent from+ // the previous pass's widget snapshot, and egui's hit test would belong to the+ // background.+ app.library_window_input.begin_transition();+ }+ return;+ };+ if app.library_window_input.shown != Some(mode) {+ app.library_window_input.begin_transition();+ }+ if !app.library_window_input.transition {+ return;+ }+ // A background text field may have kept or regained focus while the window was hidden by a+ // prompt or dialog; the shielded first frame must not let it receive the host's text.+ clear_focus(ctx);+ if batch_in_flight && std::mem::take(&mut app.library_window_input.cancel_injected) {+ // The library barrier below removes this pass's already-injected events before any panel+ // sees them. Like the prompt barrier, the gesture that queued them must fail, never report+ // a successful delivery of input that was discarded.+ app.cancel_gestures_for_barrier(true, "a blocking library window appeared");+ }+ ctx.stop_dragging();+ ctx.input_mut(|input| {+ // The discarded pass must not leave a key held merely because its release arrived in the+ // window's creation frame.+ input.keys_down.clear();+ input.pointer = egui::PointerState::default();+ input.smooth_scroll_delta = egui::Vec2::ZERO;+ input.events.retain(|event| {+ matches!(+ event,+ egui::Event::ModifiersChanged(_)+ | egui::Event::WindowFocused(_)+ | egui::Event::Touch { phase: egui::TouchPhase::End | egui::TouchPhase::Cancel, .. }+ )+ });+ });+}++/// Whether `draw_window` must render only the new blocking window for this first pass.+pub(crate) fn shield_pass(app: &mut LightcraftApp, ctx: &egui::Context) -> bool {+ let shield = ctx.current_pass_index() == 0 && app.library_window_input.transition && visible_mode(app).is_some();+ if shield {+ app.library_window_input.shielded = true;+ }+ shield+}++/// Reset the per-pass draw witness before any panel runs. `show` marks the window only when it+/// actually draws it; a prompt/dialog hiding the window must not inherit a previous pass's mark.+pub(crate) fn begin_draw(app: &mut LightcraftApp) {+ app.library_window_input.drawn = None;+}++/// A completed, nondiscarded pass has laid the window out. Only an actual draw after the shield+/// pass settles it; a window hidden by a prompt or by the dialog it opened, or one that appeared+/// midway through this pass (the banner's Open Library… button), keeps the transition armed so+/// the first pass that draws it again is shielded.+pub(crate) fn finish_ui_pass(app: &mut LightcraftApp, ctx: &egui::Context) {+ if ctx.will_discard() {+ return;+ }+ if let Some(mode) = visible_mode(app) {+ if app.library_window_input.drawn == Some(mode) && (!app.library_window_input.transition || app.library_window_input.shielded) {+ app.library_window_input.shown = Some(mode);+ app.library_window_input.transition = false;+ app.library_window_input.shielded = false;+ app.library_window_input.cancel_injected = false;+ } else if !app.library_window_input.transition {+ app.library_window_input.begin_transition();+ }+ } else if app.library_problem.as_ref().is_none_or(|p| p.dismissed) {+ app.library_window_input = WindowBarrier::default();+ } else if !app.library_window_input.transition {+ // A prompt appeared or changed during the draw and now hides the window.+ app.library_window_input.begin_transition();+ }+}+/// How long after the window appears holding Alt/Option still asks (egui time, seconds). The/// modifier keys can't be read before the first frame, and macOS reports one held since before/// launch only once it changes, so it is watched over the first frames.@@ -569,7 +804,12 @@ pub fn logic(app: &mut LightcraftApp, ctx: &egui::Context) {log::warn!("import: {e}");}}+ let batch_in_flight = app.synthetic_in_flight;alt_at_launch(app, ctx);+ // Alt/Option can create the launch list here, after the frame's input was accepted. Drop+ // background text/pointer/keys and give it a shield pass before its own key handler reads them.+ // An already injected synthetic batch is dropped by that barrier and must fail its gesture.+ prepare_ui_pass(app, ctx, batch_in_flight);reap_checks(app);// the launch list asks for fresh answers oncelet listed: Option<Vec<String>> =@@ -623,7 +863,11 @@ pub fn logic(app: &mut LightcraftApp, ctx: &egui::Context) {}ctx.request_repaint_after(std::time::Duration::from_millis(250));}- chooser_keys(app, ctx);+ // A quit prompt or settings notice sits above the launch list; its Escape/Return must not+ // quit or switch libraries behind the prompt.+ if !crate::panels::notices::blocks_input(app) {+ chooser_keys(app, ctx);+ }}/// Alt/Option held during the first [`ALT_SECONDS`] after the window appears opens the launch list@@ -653,10 +897,10 @@ fn alt_at_launch(app: &mut LightcraftApp, ctx: &egui::Context) {ctx.request_repaint();}-/// The launch list on screen (no dialog over it, e.g. New Library's name).+/// The launch list on screen (not covered by the New Library name dialog it opened).fn chooser_shown(app: &LightcraftApp) -> Option<&Chooser> {let p = app.library_problem.as_ref().filter(|p| !p.dismissed)?;- p.chooser.as_ref().filter(|_| app.ui.dialog.is_none())+ p.chooser.as_ref().filter(|_| !chooser_owns_dialog(app))}/// ↑ / ↓ move the selection, Return opens it (unless a button has the keyboard focus: it acts@@ -698,34 +942,53 @@ fn select(app: &mut LightcraftApp, at: usize) {}/// Dim everything behind the window; it swallows clicks, so nothing there can be used meanwhile.+/// The dim is `Foreground` and takes the modal layer: a `Middle` dialog such as Settings may be+/// open underneath, and without this the dialog's own modal layer would let its controls receive+/// clicks through the dim. Dialogs are drawn before this window, and a quit prompt or settings+/// notice suppresses this window entirely (`show` returns early), so neither is covered by it.+/// Pressing the dim raises its area, so each window is moved back above it after being shown.fn dim(ctx: &egui::Context) {let screen = ctx.content_rect();- egui::Area::new(egui::Id::unique("library-problem-dim")).order(egui::Order::Middle).fixed_pos(screen.min).interactable(true).show(ctx, |ui| {+ let dim = egui::Area::new(egui::Id::unique(DIM_ID)).order(egui::Order::Foreground).fixed_pos(screen.min).interactable(true).show(ctx, |ui| {// swallows clicks: nothing behind the window can be used meanwhileui.allocate_rect(screen, egui::Sense::click_and_drag());ui.painter().rect_filled(screen, 0.0, egui::Color32::from_black_alpha(160));});+ // A bare interactable Area does not become the modal layer by itself. Without this, a+ // Settings dialog opened before the library window can keep the modal layer and receive a+ // control-channel press that the dim is meant to cover.+ ctx.memory_mut(|memory| memory.set_modal_layer(dim.response.layer_id));}-/// The blocking window (until a choice is made).-pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {+/// The blocking window (until a choice is made). `blocked` freezes the barrier of a quit prompt+/// or settings notice that was on screen when this frame began: the launch list/error window is+/// `Order::Foreground` too, so drawing it after the prompt could cover it and let the same+/// click or key act twice. It returns on the first pass after the prompt goes away.+pub fn show(app: &mut LightcraftApp, ctx: &egui::Context, blocked: bool) {+ if blocked || crate::panels::notices::blocks_input(app) {+ return;+ }let Some(problem) = app.library_problem.clone() else { return };if problem.dismissed {return;}if let Some(chooser) = &problem.chooser {- // a dialog it opened (New Library's name) goes first; the list comes back after it- if app.ui.dialog.is_none() {+ // its own New Library name dialog goes first; the list comes back after it. An unrelated+ // dialog (Settings) does not hide the list: the blocking window stays above it.+ if !chooser_owns_dialog(app) {+ note_first_draw(app, WindowMode::Chooser);show_chooser(app, ctx, &problem, chooser);+ app.library_window_input.drawn = Some(WindowMode::Chooser);}return;}let t = Tokens::get(ctx);+ note_first_draw(app, WindowMode::Error);dim(ctx);let mut choice = None;let frame = egui::Frame::window(&ctx.global_style()).inner_margin(egui::Margin::symmetric(18, 14));- egui::Window::new(crate::i18n::tr("Your library couldn't be opened"))- .id(egui::Id::unique("library-problem"))+ let shown = egui::Window::new(crate::i18n::tr("Your library couldn't be opened"))+ .id(egui::Id::unique(ERROR_WINDOW_ID)).order(egui::Order::Foreground).collapsible(false).resizable(false)@@ -755,7 +1018,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {ui.horizontal(|ui| {let mut button = |ui: &mut egui::Ui, id: &str, label: &str, enabled: bool, c: Choice| {let r = ui.add_enabled(enabled, egui::Button::new(crate::i18n::tr(label)).min_size(vec2(0.0, 26.0)));- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);if r.clicked() {choice = Some(c);}@@ -766,6 +1029,11 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {button(ui, "libraryQuit", "Quit", true, Choice::Quit);});});+ if let Some(w) = &shown {+ // A press on the dim raises its area; keep this window (and its own buttons) above it.+ ctx.move_to_top(w.response.layer_id);+ }+ app.library_window_input.drawn = Some(WindowMode::Error);if let Some(c) = choice {act(app, c);}@@ -835,8 +1103,8 @@ fn show_chooser(app: &mut LightcraftApp, ctx: &egui::Context, problem: &LibraryPlet can_pick = app.services.pick_folder.is_some();let open_now = app.session.library.as_ref().filter(|l| l.on_disk).map(|l| l.dir.clone());let frame = egui::Frame::window(&ctx.global_style()).inner_margin(egui::Margin::symmetric(18, 14));- egui::Window::new(crate::i18n::tr("Open a Library"))- .id(egui::Id::unique("library-chooser"))+ let shown = egui::Window::new(crate::i18n::tr("Open a Library"))+ .id(egui::Id::unique(CHOOSER_WINDOW_ID)).order(egui::Order::Foreground).collapsible(false).resizable(false)@@ -850,7 +1118,7 @@ fn show_chooser(app: &mut LightcraftApp, ctx: &egui::Context, problem: &LibraryPui.label(RichText::new(crate::i18n::tr("Choose the library to open.")).color(t.text_label));if chooser.libraries.is_empty() {let r = ui.label(RichText::new(crate::i18n::tr("No recent libraries. Open one from a folder, or make a new one.")).color(t.text_dim));- register(ui.ctx(), "indicator:noRecentLibraries", r.rect);+ register(ui, "indicator:noRecentLibraries", r.rect);}egui::ScrollArea::vertical().max_height(300.0).auto_shrink([false, true]).show(ui, |ui| {ui.spacing_mut().item_spacing.y = 2.0;@@ -869,7 +1137,7 @@ fn show_chooser(app: &mut LightcraftApp, ctx: &egui::Context, problem: &LibraryPlet selected = chooser.selected.and_then(|i| chooser.libraries.get(i));let mut button = |ui: &mut egui::Ui, id: &str, label: &str, enabled: bool, c: Choice| {let r = ui.add_enabled(enabled, egui::Button::new(crate::i18n::tr(label)).min_size(vec2(0.0, 26.0)));- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);if r.clicked() {choice = Some(c);}@@ -888,6 +1156,10 @@ fn show_chooser(app: &mut LightcraftApp, ctx: &egui::Context, problem: &LibraryP});});});+ if let Some(w) = &shown {+ // A press on the dim raises its area; keep the launch list above it.+ ctx.move_to_top(w.response.layer_id);+ }if let Some((i, open)) = clicked_row {select(app, i);if open {@@ -938,7 +1210,7 @@ fn recent_row(ui: &mut egui::Ui, t: &Tokens, i: usize, library: &RecentLibrary,}});let r = ui.interact(inner.response.rect, egui::Id::unique(("library-recent", i)), egui::Sense::click());- register(ui.ctx(), format!("libraryRecent:{i}"), r.rect);+ register(ui, format!("libraryRecent:{i}"), r.rect);let fill = if selected {Some(t.tool_active)} else if r.hovered() {@@ -969,15 +1241,21 @@ pub fn banner(app: &mut LightcraftApp, ui: &mut egui::Ui) {.font(t.semibold(12.5)).color(t.canvas),);- register(ui.ctx(), "indicator:temporarySession", r.rect);+ register(ui, "indicator:temporarySession", r.rect);let b = ui.add(egui::Button::new(RichText::new(crate::i18n::tr("Open Library…")).color(t.canvas)).fill(egui::Color32::from_black_alpha(40)),);- register(ui.ctx(), "button:libraryReopen", b.rect);+ register(ui, "button:libraryReopen", b.rect);reopen = b.clicked();});});if reopen && let Some(p) = app.library_problem.as_mut() {p.dismissed = false;+ // The banner was drawn before the window; reopening it here would otherwise settle in this+ // same pass, whose background already consumed its input. Shield the next frame's first+ // actual window draw.+ app.library_window_input.begin_transition();+ clear_focus(ui.ctx());+ ui.ctx().request_repaint();}}diff --git a/crates/ui-egui/src/panels/mask_effects.rs b/crates/ui-egui/src/panels/mask_effects.rsindex db3b8b6d0..86f3796b9 100644--- a/crates/ui-egui/src/panels/mask_effects.rs+++ b/crates/ui-egui/src/panels/mask_effects.rs@@ -12,7 +12,7 @@ use serde_json::{Value, json};use crate::LightcraftApp;use crate::state::Dialog;use crate::theme::Tokens;-use crate::widgets::register;+use crate::widgets::{register, register_response};/// A slider's label in the effect lists (the colour tint's hue and saturation are one "Color").pub fn field_label(k: &str) -> &'static str {@@ -223,7 +223,7 @@ fn menu(app: &mut LightcraftApp, ui: &mut egui::Ui, mask: &Mask, current: Optionlet (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 22.0), Sense::click());// (rows scrolled out of view can't be clicked)if ui.is_rect_visible(rect) {- register(ui.ctx(), widget.clone(), rect);+ register(ui, widget.clone(), rect);}let lit = st.highlight == Some(i) || resp.hovered();if lit {@@ -270,7 +270,7 @@ fn menu(app: &mut LightcraftApp, ui: &mut egui::Ui, mask: &Mask, current: Optionui.separator();let item = |ui: &mut egui::Ui, id: &str, text: String, enabled: bool| {let r = ui.add_enabled(enabled, egui::Button::new(text).frame(false));- register(ui.ctx(), id.to_string(), r.rect);+ register(ui, id.to_string(), r.rect);r.clicked()};if item(ui, "maskEffectMenu:reset", crate::i18n::tr("Reset Sliders").to_string(), true) {@@ -322,7 +322,7 @@ fn preview(app: &mut LightcraftApp, mask: &Mask, name: &str) {fn row_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, mask: &Mask, name: &str, fav: bool) {let run = |app: &mut LightcraftApp, ui: &mut egui::Ui, text: &str, cmd: &str, p: Value| {let r = ui.button(crate::i18n::tr(text));- register(ui.ctx(), format!("maskEffectRow:{text}"), r.rect);+ register(ui, format!("maskEffectRow:{text}"), r.rect);if r.clicked() {if let Err(e) = app.run(cmd, p) {app.toast_error(ui.ctx(), e);@@ -398,7 +398,7 @@ pub fn save_body(.width(ui.available_width() - 30.0).show(ui);let pick = ui.small_button("…").on_hover_text(crate::i18n::tr("Choose a group"));- register(ui.ctx(), "button:effectGroupPick", pick.rect);+ register(ui, "button:effectGroupPick", pick.rect);egui::Popup::menu(&pick).show(|ui| {for (g, _) in fx::menu_order(&app.session.mask_effects) {if ui.button(if g.is_empty() { crate::i18n::tr("None").to_string() } else { g.clone() }).clicked() {@@ -422,7 +422,7 @@ pub fn save_body(// the sliders this mask changes stand out; the others are dimmedlet text = if changed.iter().any(|c| c == k) { text.color(t.text).strong() } else { text.color(t.text_dim) };let r = cols[i % 2].checkbox(&mut on, text);- register(&r.ctx, format!("effectInclude:{k}"), r.rect);+ register_response(format!("effectInclude:{k}"), r.rect, &r);if r.changed() {fields.retain(|f| f != k);if on {@@ -434,7 +434,7 @@ pub fn save_body(ui.horizontal(|ui| {for (id, text) in [("all", "All"), ("none", "None"), ("changed", "Changed Only")] {let b = ui.small_button(crate::i18n::tr(text));- register(ui.ctx(), format!("effectInclude:{id}"), b.rect);+ register(ui, format!("effectInclude:{id}"), b.rect);if b.clicked() {*fields = match id {"all" => list.iter().map(|k| k.to_string()).collect(),@@ -450,9 +450,9 @@ pub fn save_body(.size(11.0),);let r = ui.checkbox(amount, crate::i18n::tr("Include Amount"));- register(ui.ctx(), "check:effectAmount", r.rect);+ register(ui, "check:effectAmount", r.rect);let r = ui.checkbox(brush, crate::i18n::tr("Include brush size, feather and flow"));- register(ui.ctx(), "check:effectBrush", r.rect);+ register(ui, "check:effectBrush", r.rect);enter}@@ -519,7 +519,7 @@ pub fn manage_body(egui::Label::new(egui::RichText::new(format!("{heading} ({})", list.len())).font(t.semibold(12.0)).color(t.text_label)).sense(Sense::click()),);- register(ui.ctx(), format!("effectGroup:{group}"), h.rect);+ register(ui, format!("effectGroup:{group}"), h.rect);if h.clicked() {// a click on the heading selects the group*selected = list.iter().map(|e| e.name.clone()).collect();@@ -545,7 +545,7 @@ pub fn manage_body(}let (rect, r) = ui.allocate_exact_size(vec2(240.0, 22.0), Sense::click());if ui.is_rect_visible(rect) {- register(ui.ctx(), format!("effectRow:{}", e.name), rect);+ register(ui, format!("effectRow:{}", e.name), rect);}if sel {ui.painter().rect_filled(rect, 3.0, t.tool_active);@@ -603,14 +603,14 @@ pub fn manage_body();ui.horizontal(|ui| {let d = ui.button(crate::i18n::tr("Delete"));- register(ui.ctx(), "button:effectDeleteConfirm", d.rect);+ register(ui, "button:effectDeleteConfirm", d.rect);if d.clicked() {let _ = app.run("mask.deleteEffect", json!({"names": selected.clone()}));selected.clear();*confirm_delete = false;}let c = ui.button(crate::i18n::tr("Cancel"));- register(ui.ctx(), "button:effectDeleteCancel", c.rect);+ register(ui, "button:effectDeleteCancel", c.rect);if c.clicked() {*confirm_delete = false;}@@ -620,7 +620,7 @@ pub fn manage_body(ui.horizontal_wrapped(|ui| {let button = |ui: &mut egui::Ui, id: &str, text: &str, enabled: bool| {let r = ui.add_enabled(enabled, egui::Button::new(crate::i18n::tr(text)));- register(ui.ctx(), format!("button:effect{id}"), r.rect);+ register(ui, format!("button:effect{id}"), r.rect);r.clicked()};if button(ui, "Apply", "Apply", one.is_some() && mask.is_some())@@ -650,7 +650,7 @@ pub fn manage_body(let _ = app.run("mask.favoriteEffect", json!({"names": selected.clone(), "favorite": !all_fav}));}let g = ui.add_enabled(n > 0, egui::Button::new(crate::i18n::tr("Move to Group…")));- register(ui.ctx(), "button:effectGroup", g.rect);+ register(ui, "button:effectGroup", g.rect);egui::Popup::menu(&g).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).show(|ui| {let names = selected.clone();for (grp, _) in fx::menu_order(&app.session.mask_effects) {diff --git a/crates/ui-egui/src/panels/masking.rs b/crates/ui-egui/src/panels/masking.rsindex f48a7ff56..ce28482c4 100644--- a/crates/ui-egui/src/panels/masking.rs+++ b/crates/ui-egui/src/panels/masking.rs@@ -118,7 +118,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {for (i, (kind, label, icon)) in tiles.iter().enumerate() {let (r, resp) = ui.allocate_exact_size(vec2(tile, 52.0), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr(label));- register(ui.ctx(), format!("maskNew:{kind}"), r);+ register(ui, format!("maskNew:{kind}"), r);ui.painter().rect_filled(r, 4.0, if resp.hovered() { t.hover } else { t.inset });paint(ui.painter(), Rect::from_center_size(r.center() - vec2(0.0, 7.0), vec2(20.0, 20.0)), *icon, t.text_label);// (cut short only in a panel too narrow for the label: the full name on hover)@@ -126,7 +126,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let g = one_line(ui.painter(), label, t.font(size), t.text_dim, tile - 2.0 * TILE_PAD);let elided = g.elided;let at = pos2(r.center().x, r.bottom() - 9.0) - g.size() / 2.0;- register(ui.ctx(), format!("maskNewLabel:{kind}"), Rect::from_min_size(at, g.size()));+ register(ui, format!("maskNewLabel:{kind}"), Rect::from_min_size(at, g.size()));ui.painter().galley(at, g, t.text_dim);let resp = if elided { resp.on_hover_text(label) } else { resp };if resp.clicked() {@@ -221,7 +221,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {// inline rename: Enter (or leaving the field) commits, Escape cancelslet rid = *rid;let r = ui.add(egui::TextEdit::singleline(name).desired_width(ui.available_width()).id_salt(("maskRename", rid)));- register(ui.ctx(), format!("maskRename:{rid}"), r.rect);+ register(ui, format!("maskRename:{rid}"), r.rect);if !r.has_focus() && !r.lost_focus() {r.request_focus();}@@ -238,7 +238,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {}let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 30.0), Sense::click());crate::widgets::announce_selected(&resp, m.name.clone(), Some(m.id) == app.session.active_mask);- register(ui.ctx(), format!("mask:{}", m.id), r);+ register(ui, format!("mask:{}", m.id), r);ui.painter().rect_filled(r,4.0,@@ -257,14 +257,14 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let g = one_line(ui.painter(), &m.name, t.font(13.0), color, r.width() - 32.0 - 32.0);let elided = g.elided;let at = pos2(r.left() + 32.0, r.center().y - g.size().y / 2.0);- register(ui.ctx(), format!("maskName:{}", m.id), Rect::from_min_size(at, g.size()));+ register(ui, format!("maskName:{}", m.id), Rect::from_min_size(at, g.size()));ui.painter().galley(at, g, color);let resp = if elided { resp.on_hover_text(&m.name) } else { resp };// show / hide on hover (and always while hidden)// (the pointer test, not `hovered`: over the eye, the row itself no longer counts as hovered)if ui.rect_contains_pointer(r) || !m.visible {let er = Rect::from_center_size(pos2(r.right() - 16.0, r.center().y), vec2(22.0, 22.0));- register(ui.ctx(), format!("maskVisible:{}", m.id), er);+ register(ui, format!("maskVisible:{}", m.id), er);let eye = ui.interact(er, egui::Id::unique(("maskVisible", m.id)), Sense::click());crate::widgets::announce_selected(&eye, crate::i18n::tr("Show mask"), m.visible);paint(@@ -323,7 +323,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {if let Some((_, _, name)) = app.ui.renaming_component.as_mut().filter(|(mid, k, _)| *mid == m.id && *k == i) {// inline rename: Enter (or leaving the field) commits, Escape cancelslet r = ui.add(egui::TextEdit::singleline(name).desired_width(ui.available_width() - 30.0).id_salt(("compRename", m.id, i)));- register(ui.ctx(), format!("componentRename:{i}"), r.rect);+ register(ui, format!("componentRename:{i}"), r.rect);if !r.has_focus() && !r.lost_focus() {r.request_focus();}@@ -346,14 +346,14 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {ui.add(egui::Label::new(text).truncate().sense(Sense::click()))});let resp = resp.inner;- register(ui.ctx(), format!("component:{i}"), resp.rect);+ register(ui, format!("component:{i}"), resp.rect);if resp.double_clicked() {app.ui.renaming_component = Some((m.id, i, label.clone()));}crate::widgets::context_menu(&resp, |ui| component_row_menu(app, ui, m.id, i, &label, m.components.len()));ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {let more = ui.small_button("…").on_hover_text(crate::i18n::tr("Component options"));- register(ui.ctx(), format!("button:componentMenu{i}"), more.rect);+ register(ui, format!("button:componentMenu{i}"), more.rect);egui::Popup::menu(&more).show(|ui| component_row_menu(app, ui, m.id, i, &label, m.components.len()));});});@@ -474,7 +474,7 @@ fn overlay_options(app: &mut LightcraftApp, ui: &mut egui::Ui) {for c in OVERLAY_COLORS {let (r, resp) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::click());crate::widgets::announce(&resp, format!("{} #{:02x}{:02x}{:02x}", crate::i18n::tr("Overlay color"), c[0], c[1], c[2]));- register(ui.ctx(), format!("maskOverlayColor:{:02x}{:02x}{:02x}", c[0], c[1], c[2]), r);+ register(ui, format!("maskOverlayColor:{:02x}{:02x}{:02x}", c[0], c[1], c[2]), r);ui.painter().rect_filled(r.shrink(2.0), 3.0, egui::Color32::from_rgb(c[0], c[1], c[2]));if app.ui.mask_overlay_color == c {ui.painter().rect_stroke(r, 3.0, Stroke::new(1.5, t.text), egui::StrokeKind::Inside);@@ -523,7 +523,7 @@ fn range_controls(app: &mut LightcraftApp, ui: &mut egui::Ui, comp: usize, shapelet w = ui.available_width().min(240.0);let (rect, resp) = ui.allocate_exact_size(vec2(w, 18.0), Sense::click_and_drag());crate::widgets::announce(&resp, crate::i18n::tr("Select Luminance Range"));- register(ui.ctx(), format!("lumRange:{comp}"), rect);+ register(ui, format!("lumRange:{comp}"), rect);let p = ui.painter();// dark → light ramp, the selected span outlinedlet n = 24;@@ -590,7 +590,7 @@ fn range_controls(app: &mut LightcraftApp, ui: &mut egui::Ui, comp: usize, shape});let mut map = app.ui.mask_overlay && app.ui.mask_overlay_mode == "colorOnBw";let r = ui.checkbox(&mut map, crate::i18n::tr("Show Luminance Map"));- register(ui.ctx(), format!("check:lumMap{comp}"), r.rect);+ register(ui, format!("check:lumMap{comp}"), r.rect);if r.changed() {// the luminance map: the photo in black & white with the selected range tintedif map {@@ -810,7 +810,7 @@ fn describe_field(app: &mut LightcraftApp, ui: &mut egui::Ui, new_mask: bool) {.hint_text(crate::i18n::tr("e.g. sky · the red car · car, road")).desired_width(ui.available_width()),);- register(ui.ctx(), "maskDescribe", r.rect);+ register(ui, "maskDescribe", r.rect);if !r.has_focus() && !r.lost_focus() && text.is_empty() {r.request_focus();}@@ -840,12 +840,12 @@ fn describe_field(app: &mut LightcraftApp, ui: &mut egui::Ui, new_mask: bool) {fn component_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, op: &str) {let b = ui.button(crate::i18n::tr("Object"));- register(ui.ctx(), format!("maskComp:{op}:object"), b.rect);+ register(ui, format!("maskComp:{op}:object"), b.rect);if b.clicked() {start_object(app, ui.ctx(), op);}let b = ui.button(crate::i18n::tr("Describe…"));- register(ui.ctx(), format!("maskComp:{op}:prompt"), b.rect);+ register(ui, format!("maskComp:{op}:prompt"), b.rect);if b.clicked() {start_describe(app, op);}@@ -862,7 +862,7 @@ fn component_menu(app: &mut LightcraftApp, ui: &mut egui::Ui, op: &str) {continue;}let b = ui.button(menu_label(label));- register(ui.ctx(), format!("maskComp:{op}:{kind}"), b.rect);+ register(ui, format!("maskComp:{op}:{kind}"), b.rect);if b.clicked() {if kind == "brush" {let _ = app.run("tool.brush", json!({"op": op}));diff --git a/crates/ui-egui/src/panels/mod.rs b/crates/ui-egui/src/panels/mod.rsindex 19e55391d..e3300e04f 100644--- a/crates/ui-egui/src/panels/mod.rs+++ b/crates/ui-egui/src/panels/mod.rs@@ -70,7 +70,7 @@ pub fn resizable_side(let max = (avail.width() - reserve - crate::state::MIN_PHOTO_WIDTH).clamp(limits.min, limits.max);let panel = if left { egui::Panel::left(id) } else { egui::Panel::right(id) };let r = panel.frame(frame).resizable(true).size_range(limits.min..=max).default_size(limits.clamp(width).min(max)).show(ui, add);- crate::widgets::register(ui.ctx(), format!("panel:{id}"), r.response.rect);+ crate::widgets::register(ui, format!("panel:{id}"), r.response.rect);// egui names the edge's drag widget `<panel id>.with("__resize")`; the width is measured from// the panel's fixed edge to the pointer (contents wider than the panel don't count)if !ui.ctx().is_being_dragged(pid.with("__resize")) {@@ -173,7 +173,7 @@ pub fn empty_state(ui: &mut egui::Ui, rect: Rect, title: &str, body: &str, actiolet button =if i == 0 { egui::Button::new(label.color(egui::Color32::WHITE)).fill(t.accent) } else { egui::Button::new(label.color(t.text)) };let resp = ui.put(r, button);- crate::widgets::register(ui.ctx(), a.widget, resp.rect);+ crate::widgets::register(ui, a.widget, resp.rect);if resp.clicked() {clicked = Some(a.command);}diff --git a/crates/ui-egui/src/panels/notices.rs b/crates/ui-egui/src/panels/notices.rsindex beeff2e03..65aefb225 100644--- a/crates/ui-egui/src/panels/notices.rs+++ b/crates/ui-egui/src/panels/notices.rs@@ -5,7 +5,7 @@use egui::{Align2, RichText, vec2};use crate::theme::Tokens;-use crate::widgets::register;+use crate::widgets::WidgetHit;use crate::{LightcraftApp, QuitPrompt};/// Collect the library's settings-file warnings (each is shown once), and the no-GPU notice once the GPU device has@@ -82,6 +82,7 @@ pub fn may_close(app: &mut LightcraftApp) -> bool {}}+#[derive(Clone, Copy, PartialEq, Eq)]enum Choice {Retry,QuitAnyway,@@ -89,16 +90,373 @@ enum Choice {Ok,}-fn window(ctx: &egui::Context, id: &str, title: &str, text: &str, buttons: &[(&str, &str, Choice)]) -> Option<usize> {+/// The prompt (quit or settings notice) that owns input this frame, if any.+///+/// The dim area is `Order::Foreground`, so a settled egui pass routes pointer input to it before+/// the main view or a `Middle` dialog. The control channel and raw keyboard/event handlers do not+/// go through that hit test, however: they must consult this explicit barrier as well.+pub(crate) fn prompt_layer(app: &LightcraftApp) -> Option<egui::LayerId> {+ let id = match (&app.quit_prompt, app.notices.is_empty()) {+ (Some(QuitPrompt::Tasks(_)), _) => "quit-tasks",+ (Some(QuitPrompt::Unsaved(_)), _) => "quit-unsaved",+ (None, false) => "settings-notice",+ (None, true) => return None,+ };+ Some(egui::LayerId::new(egui::Order::Foreground, egui::Id::unique(id)))+}++/// Whether a prompt is on screen and owns all pointer and keyboard input.+pub fn blocks_input(app: &LightcraftApp) -> bool {+ prompt_layer(app).is_some()+}++/// Whether a registered automation target may receive input. While a prompt is up only its own+/// Foreground window is interactive; the same barrier must hold before the first prompt layout+/// settles, when egui has not yet made the new areas interactable.+pub(crate) fn allows_target(app: &LightcraftApp, hit: Option<WidgetHit>) -> bool {+ match prompt_layer(app) {+ None => true,+ Some(layer) => hit.is_some_and(|hit| hit.layer_id == layer),+ }+}++/// Identity of the prompt whose focus we track. A queued settings notice is a different prompt+/// from the one before it even though both use the same layer and id.+#[derive(Clone, Debug, PartialEq, Eq)]+struct PromptKey {+ layer: egui::LayerId,+ text: String,+ queue_len: usize,+}++fn prompt_key(app: &LightcraftApp) -> Option<PromptKey> {+ let (layer, text, queue_len) = match (&app.quit_prompt, app.notices.first()) {+ (Some(prompt), _) => (prompt_layer(app)?, prompt.text().to_string(), 0),+ (None, Some(text)) => (prompt_layer(app)?, text.clone(), app.notices.len()),+ (None, None) => return None,+ };+ Some(PromptKey { layer, text, queue_len })+}++/// The prompt's keyboard/focus state, isolated from the still-drawn background.+///+/// The first host frame of a new prompt is a shielding pass: pointer/touch/key/accessibility input+/// is removed before panels are drawn, and the frame is discarded so a second pass can lay out the+/// new `Area` without any input. From then on this state routes only the prompt's own keys and+/// AccessKit actions; everything else is dropped before egui or the panels can see it.+#[derive(Default)]+pub(crate) struct PromptInput {+ key: Option<PromptKey>,+ /// The prompt has completed a layout pass; its `Area`s are interactable and its button ids are+ /// known. Before this, input must not reach it or the panels under it.+ laid_out: bool,+ /// The next `pass 0` is the shielding pass for a newly shown prompt.+ transition: bool,+ /// Focused button index; `focus_set` distinguishes "not chosen yet" from index 0.+ focus: usize,+ focus_set: bool,+ /// Enter/Space or an AccessKit Click on a prompt button.+ activate: Option<usize>,+ /// Escape (safe cancel).+ cancel: bool,+ /// Actual egui response ids of the prompt's buttons from its latest draw.+ button_ids: Vec<(String, egui::Id)>,+ /// Pointer state saved before the background draws. Restored only while the prompt itself is+ /// drawn (egui's `Response::clicked` needs `pointer_events`), then hidden again for the+ /// dialogs and overlays drawn after it.+ pointer: Option<egui::PointerState>,+}++impl PromptInput {+ fn reset_to(&mut self, key: Option<PromptKey>) {+ let transition = key.is_some();+ self.key = key;+ self.laid_out = false;+ self.transition = transition;+ self.focus = 0;+ self.focus_set = false;+ self.activate = None;+ self.cancel = false;+ self.button_ids.clear();+ self.pointer = None;+ }++ fn button_index(&self, accesskit_node: egui::accesskit::NodeId) -> Option<usize> {+ self.button_ids.iter().position(|(_, id)| id.accesskit_id() == accesskit_node)+ }+}++fn clear_prompt_focus(ctx: &egui::Context) {+ ctx.memory_mut(|memory| {+ if let Some(id) = memory.focused() {+ memory.surrender_focus(id);+ }+ });+}++fn prompt_key_allowed(key: egui::Key, modifiers: egui::Modifiers) -> bool {+ match key {+ egui::Key::Tab => modifiers.is_none() || modifiers.shift_only(),+ egui::Key::Enter | egui::Key::Space | egui::Key::Escape => modifiers.is_none(),+ _ => false,+ }+}++fn prompt_accesskit_allowed(request: &egui::accesskit::ActionRequest, ids: &[(String, egui::Id)]) -> bool {+ request.target_tree == egui::accesskit::TreeId::ROOT+ && ids.iter().any(|(_, id)| id.accesskit_id() == request.target_node)+ && matches!(request.action, egui::accesskit::Action::Focus | egui::accesskit::Action::Click)+}++/// Drop host and synthetic input that the background must not receive while a prompt is up.+///+/// Key releases and modifier changes always survive: egui updates `keys_down` from them in+/// `begin_pass`, so dropping a release would leave a key held after the prompt goes away. Pointer+/// and accessibility input is kept only once the prompt's first layout has settled. Wheel/zoom/+/// rotate/text/clipboard input has no prompt meaning and is always removed. A touch Start/Move is+/// dropped while the prompt is open; End/Cancel always stays,+/// including the creation/transition frames, because egui's private `touch_states` tracks the+/// finger separately and dropping the release would leave it pressed after the prompt goes away.+fn filter_prompt_events(app: &LightcraftApp, raw: &mut egui::RawInput) {+ raw.events.retain(|event| prompt_allows_event(app, event));+}++/// Whether `event` is the release half of a touch gesture. Its state lives in egui's private+/// `touch_states`, outside the `PointerState` that the prompt's cleanup resets, so it must survive+/// even before the prompt's first layout has settled.+fn touch_release(event: &egui::Event) -> bool {+ matches!(event, egui::Event::Touch { phase: egui::TouchPhase::End | egui::TouchPhase::Cancel, .. })+}++/// Whether an input event may reach egui while a prompt is up. This is the single rule used both+/// for host input before `begin_pass` and for a synthetic batch after `raw_input_hook`; the control+/// channel can therefore reject the exact gestures that the prompt barrier would drop, while an+/// allowed prompt key, pointer action or targeted AccessKit action is still delivered.+pub(crate) fn prompt_allows_event(app: &LightcraftApp, event: &egui::Event) -> bool {+ if app.notice_input.key.is_none() {+ return true;+ }+ let laid_out = app.notice_input.laid_out;+ let ids = &app.notice_input.button_ids;+ match event {+ // Key releases and modifier/window-focus changes always survive: egui updates `keys_down`+ // from them in `begin_pass`, so dropping a release would leave a key held afterwards.+ egui::Event::Key { pressed: false, .. } | egui::Event::ModifiersChanged(_) | egui::Event::WindowFocused(_) => true,+ egui::Event::Key { key, pressed: true, modifiers, .. } => laid_out && prompt_key_allowed(*key, *modifiers),+ egui::Event::AccessKitActionRequest(request) => laid_out && prompt_accesskit_allowed(request, ids),+ egui::Event::Text(_)+ | egui::Event::Ime(_)+ | egui::Event::Cut+ | egui::Event::Copy+ | egui::Event::Paste(_)+ | egui::Event::PasteImage(_)+ | egui::Event::MiddleClickPaste { .. }+ | egui::Event::MouseWheel { .. }+ | egui::Event::Zoom(_)+ | egui::Event::Rotate(_) => false,+ // Pointer input at a settled prompt belongs to its backdrop or buttons. A new touch+ // gesture does not, but its End/Cancel must still clear egui's private touch state even+ // in the prompt's creation/transition frames.+ egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } | egui::Event::PointerGone => laid_out,+ touch @ egui::Event::Touch { .. } if touch_release(touch) => true,+ egui::Event::Touch { .. } => false,+ _ => true,+ }+}++/// Restore the pointer state saved for the prompt just before it is drawn. The background has+/// already drawn with no pointer; egui's `Response::clicked` still needs the pass's pointer events+/// to turn the interaction snapshot into a click on a prompt button.+pub(crate) fn restore_prompt_pointer(app: &LightcraftApp, ctx: &egui::Context) {+ if let Some(pointer) = &app.notice_input.pointer {+ ctx.input_mut(|input| input.pointer = pointer.clone());+ }+}++/// Hide pointer state again after the prompt has drawn, so a dialog or overlay drawn later in the+/// same pass cannot act on the same release that dismissed the prompt.+pub(crate) fn hide_background_pointer(ctx: &egui::Context) {+ ctx.input_mut(|input| {+ input.pointer = egui::PointerState::default();+ input.smooth_scroll_delta = egui::Vec2::ZERO;+ });+ ctx.stop_dragging();+}++/// Apply the prompt barrier after synthetic events have been appended to `raw`.+pub(crate) fn filter_raw_input(app: &LightcraftApp, raw: &mut egui::RawInput) {+ filter_prompt_events(app, raw);+}++/// Note a prompt transition before egui sees the host input. Returns true when this host frame+/// first sees a new prompt (its synthetic gestures must be canceled and its pointer state reset).+pub(crate) fn prepare_raw_input(app: &mut LightcraftApp, ctx: &egui::Context, raw: &mut egui::RawInput) -> bool {+ let current = prompt_key(app);+ let started = current.is_some() && app.notice_input.key != current;+ if app.notice_input.key != current {+ app.notice_input.reset_to(current);+ clear_prompt_focus(ctx);+ }+ filter_prompt_events(app, raw);+ started+}++/// Apply the same barrier to the live input after `begin_pass`. A prompt can be created by this+/// frame's logic after `raw_input_hook` already ran; this captures its keys before panels read+/// them, drops the rest, and reports whether the prompt was first discovered here (so its+/// pre-existing gesture queue must be canceled). The draw pass itself uses [`shield_pass`].+pub(crate) fn prepare_ui_pass(app: &mut LightcraftApp, ctx: &egui::Context) -> bool {+ let current = prompt_key(app);+ let has_prompt = current.is_some();+ let started = has_prompt && app.notice_input.key != current;+ if app.notice_input.key != current {+ app.notice_input.reset_to(current);+ clear_prompt_focus(ctx);+ }+ if !has_prompt {+ return false;+ }+ let shield = ctx.current_pass_index() == 0 && app.notice_input.transition;+ let laid_out = app.notice_input.laid_out && !shield;+ if laid_out {+ // A screen reader's Focus/Click can target only a button whose actual response id we+ // recorded in a completed prompt pass. Tab/Shift+Tab and Enter/Space/Escape are handled+ // here too, so no background panel sees a key that belongs to the prompt.+ let events = ctx.input(|input| input.events.clone());+ for event in &events {+ match event {+ egui::Event::Key { key, pressed: true, modifiers, .. } if prompt_key_allowed(*key, *modifiers) => match key {+ egui::Key::Tab => {+ let len = app.notice_input.button_ids.len();+ if len > 0 {+ app.notice_input.focus_set = true;+ app.notice_input.focus = if modifiers.shift_only() {+ app.notice_input.focus.checked_add(len - 1).map_or(0, |i| i % len)+ } else {+ app.notice_input.focus.checked_add(1).map_or(0, |i| i % len)+ };+ }+ }+ egui::Key::Enter | egui::Key::Space => {+ app.notice_input.focus_set = true;+ app.notice_input.activate = Some(app.notice_input.focus);+ }+ egui::Key::Escape => app.notice_input.cancel = true,+ _ => {}+ },+ egui::Event::AccessKitActionRequest(request) => {+ if let Some(index) = app.notice_input.button_index(request.target_node) {+ app.notice_input.focus_set = true;+ app.notice_input.focus = index;+ if request.action == egui::accesskit::Action::Click {+ app.notice_input.activate = Some(index);+ }+ }+ }+ _ => {}+ }+ }+ }+ if laid_out {+ app.notice_input.pointer = Some(ctx.input(|input| input.pointer.clone()));+ }+ ctx.input_mut(|input| {+ if shield || !laid_out {+ // The pass is discarded. Clear held keys too: the background must not keep a key down+ // merely because its release arrived in the prompt's creation frame.+ input.keys_down.clear();+ }+ // The interaction snapshot was computed at begin_pass, before this reset: a prompt+ // button's `Response::clicked` still reflects this pass's click. Removing the pointer from+ // the live input stops panels that read `ctx.input().pointer` directly from starting a+ // drag, scrolling or completing a click underneath the prompt.+ input.pointer = egui::PointerState::default();+ input.smooth_scroll_delta = egui::Vec2::ZERO;+ input.events.retain(|event| match event {+ egui::Event::ModifiersChanged(_) | egui::Event::WindowFocused(_) => true,+ egui::Event::Key { .. } | egui::Event::Text(_) | egui::Event::Ime(_) => false,+ egui::Event::Cut+ | egui::Event::Copy+ | egui::Event::Paste(_)+ | egui::Event::PasteImage(_)+ | egui::Event::MiddleClickPaste { .. }+ | egui::Event::MouseWheel { .. }+ | egui::Event::Zoom(_)+ | egui::Event::Rotate(_) => false,+ // The allowed Focus/Click was already dispatched above to the prompt's own button;+ // dropping every AccessKit request here leaves no residual for a covered panel to act+ // on in this pass (including a request that targeted a background node).+ egui::Event::AccessKitActionRequest(_) => false,+ egui::Event::PointerMoved(_) | egui::Event::PointerButton { .. } | egui::Event::PointerGone => false,+ // A touch End/Cancel must reach egui even in this creation pass; Start/Move is+ // background input like a new pointer gesture.+ touch @ egui::Event::Touch { .. } if touch_release(touch) => true,+ egui::Event::Touch { .. } => false,+ _ => true,+ });+ });+ ctx.stop_dragging();+ started+}++/// Whether `draw_window` must render only the new prompt for this first pass. The second pass+/// (after the discard) draws the whole window with empty raw input, so the new prompt's first+/// frame cannot activate a panel underneath it.+pub(crate) fn shield_pass(app: &LightcraftApp, ctx: &egui::Context) -> bool {+ ctx.current_pass_index() == 0 && app.notice_input.transition && prompt_key(app).is_some()+}++/// A completed, nondiscarded pass has laid out and focused the prompt: input may reach it from the+/// next host frame. A changed/dismissed prompt is reset here as well, so a queued next notice is+/// treated as a new transition.+pub(crate) fn finish_ui_pass(app: &mut LightcraftApp, ctx: &egui::Context) {+ if ctx.will_discard() {+ return;+ }+ let current = prompt_key(app);+ if app.notice_input.key != current {+ // A prompt can change during the draw itself (Tasks -> Unsaved, or OK -> next notice).+ // Leave it in its transition state so the next host frame shields the new prompt too.+ app.notice_input.reset_to(current);+ return;+ }+ if current.is_some() {+ app.notice_input.laid_out = true;+ app.notice_input.transition = false;+ }+}++fn window(ctx: &egui::Context, id: &str, title: &str, text: &str, buttons: &[(&str, &str, Choice)], input: &mut PromptInput) -> Option<usize> {let t = Tokens::get(ctx);let screen = ctx.content_rect();- egui::Area::new(egui::Id::unique((id, "dim"))).order(egui::Order::Middle).fixed_pos(screen.min).show(ctx, |ui| {+ let last = buttons.len().checked_sub(1)?;+ let cancel_index = buttons.iter().position(|(_, _, choice)| matches!(choice, Choice::Cancel | Choice::Ok)).unwrap_or(last);+ if !input.focus_set {+ input.focus = cancel_index;+ input.focus_set = true;+ }+ input.focus = input.focus.min(last);+ let focus = input.focus;+ let manual = if std::mem::take(&mut input.cancel) { Some(cancel_index) } else { input.activate.take().filter(|index| *index <= last) };+ // The backdrop must cover modal Middle-order dialogs as well as the main view.+ let dim = egui::Area::new(egui::Id::unique((id, "dim"))).order(egui::Order::Foreground).fixed_pos(screen.min).show(ctx, |ui| {+ // The first layout of a newly shown Area is a sizing pass: egui keeps it invisible and+ // `interactable = false`. A release injected before the next host frame would then bypass+ // the layer check and reach the widget below. Finish the real hit area in this same frame.+ if ui.is_sizing_pass() {+ ctx.request_discard("notice dim: settle the modal hit area before input");+ }ui.allocate_rect(screen, egui::Sense::click_and_drag());ui.painter().rect_filled(screen, 0.0, egui::Color32::from_black_alpha(140));});- let mut chosen = None;+ // The dim (with its full-screen hit area) is the modal scope; the prompt window below is moved+ // above it. Everything below the dim, including a Middle-order Settings dialog, is then+ // outside egui's modal layer and loses keyboard focus registration as well as pointer hits.+ ctx.memory_mut(|memory| memory.set_modal_layer(dim.response.layer_id));+ let mut chosen = manual;+ let mut seen = Vec::with_capacity(buttons.len());let frame = egui::Frame::window(&ctx.global_style()).inner_margin(egui::Margin::symmetric(18, 14));- egui::Window::new(crate::i18n::tr(title))+ let shown = egui::Window::new(crate::i18n::tr(title)).id(egui::Id::unique(id)).order(egui::Order::Foreground).collapsible(false)@@ -107,6 +465,10 @@ fn window(ctx: &egui::Context, id: &str, title: &str, text: &str, buttons: &[(&s.anchor(Align2::CENTER_CENTER, [0.0, 0.0]).default_width(440.0).show(ctx, |ui| {+ // The prompt window has the same first-pass sizing rule as the dim above.+ if ui.is_sizing_pass() {+ ctx.request_discard("notice prompt: settle its buttons before input");+ }// a fixed width: a wrapped label in an auto-sized, centred window would move it every frameui.set_width(420.0);ui.spacing_mut().item_spacing.y = 8.0;@@ -115,22 +477,42 @@ fn window(ctx: &egui::Context, id: &str, title: &str, text: &str, buttons: &[(&sui.horizontal(|ui| {for (i, (bid, label, _)) in buttons.iter().enumerate() {let r = ui.add(egui::Button::new(crate::i18n::tr(label)).min_size(vec2(0.0, 26.0)));- register(ui.ctx(), format!("button:{bid}"), r.rect);- if r.clicked() {+ let widget = format!("button:{bid}");+ // The real response id is the AccessKit node a screen reader targets. A hover+ // probe's id would make every Focus/Click action fail to match the button.+ crate::widgets::register_response(widget.clone(), r.rect, &r);+ if i == focus {+ r.request_focus();+ }+ seen.push((widget, r.id));+ if r.clicked() && chosen.is_none() {chosen = Some(i);}}});});+ // A backdrop press can raise its area; keep the prompt buttons above it.+ if let Some(window) = shown {+ ctx.move_to_top(window.response.layer_id);+ }+ input.button_ids = seen;+ if chosen.is_some() {+ // The focused prompt button is about to disappear. Drop its focus now so this pass's+ // `egui_wants_keyboard_input` (and `text_focus`) does not make the next Esc look like it+ // belongs to a text field/dialog still underneath.+ clear_prompt_focus(ctx);+ }chosen}pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {if let Some(QuitPrompt::Tasks(text)) = app.quit_prompt.clone() {let buttons = [("quitAnyway", "Quit Anyway", Choice::QuitAnyway), ("quitCancel", "Cancel", Choice::Cancel)];- let Some(i) = window(ctx, "quit-tasks", "Quit while tasks are running?", &text, &buttons) else { return };+ let Some(i) = window(ctx, "quit-tasks", "Quit while tasks are running?", &text, &buttons, &mut app.notice_input) else {+ return;+ };app.quit_prompt = None;- if matches!(buttons[i].2, Choice::QuitAnyway) {+ if buttons.get(i).is_some_and(|(_, _, choice)| *choice == Choice::QuitAnyway) {app.session.activity.cancel_all();// unsaved changes still get their own questionif may_close(app) {@@ -145,26 +527,34 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {("quitAnyway", "Quit Anyway", Choice::QuitAnyway),("quitCancel", "Cancel", Choice::Cancel),];- let Some(i) = window(ctx, "quit-unsaved", "Quit with unsaved changes?", &text, &buttons) else { return };- match buttons[i].2 {- Choice::Retry => {+ let Some(i) = window(ctx, "quit-unsaved", "Quit with unsaved changes?", &text, &buttons, &mut app.notice_input) else {+ return;+ };+ match buttons.get(i).map(|(_, _, choice)| *choice) {+ Some(Choice::Retry) => {app.quit_prompt = None;+ // A retry that fails again recreates the same notice text, so its `PromptKey`+ // would otherwise look unchanged: keep the old layout, focus and button ids from+ // the Retry press. Start a fresh prompt so the next frame shields it and resets+ // focus to the safe Cancel/OK choice.+ app.notice_input.reset_to(None);+ clear_prompt_focus(ctx);if may_close(app) {app.ui.quit = true;}}- Choice::QuitAnyway => {+ Some(Choice::QuitAnyway) => {app.quit_prompt = None;app.quit_confirmed = true;app.ui.quit = true;}- Choice::Cancel | Choice::Ok => app.quit_prompt = None,+ Some(Choice::Cancel | Choice::Ok) | None => app.quit_prompt = None,}return;}if let Some(text) = app.notices.first().cloned() {let buttons = [("noticeOk", "OK", Choice::Ok)];- if window(ctx, "settings-notice", "Settings file problem", &text, &buttons).is_some() {+ if window(ctx, "settings-notice", "Settings file problem", &text, &buttons, &mut app.notice_input).is_some() {app.notices.remove(0);}}@@ -172,7 +562,94 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {#[cfg(test)]mod tests {- use super::gpu_notice;+ use super::{PromptKey, gpu_notice, prepare_ui_pass, prompt_allows_event, prompt_key};++ /// The prompt barrier keeps its own keys and pointer input, drops text/wheel input, and drops+ /// the start/move half of a new touch gesture while keeping End/Cancel to clear egui's private+ /// touch state. No prompt means everything survives.+ #[test]+ fn a_settled_prompt_allows_its_keys_and_pointer_but_not_text_wheel_or_new_touches() {+ let mut app = crate::LightcraftApp::new(lightcraft_engine::Session::with_demo(), crate::Services::default());+ app.notice_input.key = Some(PromptKey {+ layer: egui::LayerId::new(egui::Order::Foreground, egui::Id::unique("test-prompt")),+ text: "prompt".into(),+ queue_len: 1,+ });+ app.notice_input.laid_out = true;+ let key = |key, modifiers| egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers };+ assert!(prompt_allows_event(&app, &key(egui::Key::Tab, egui::Modifiers::NONE)));+ assert!(prompt_allows_event(&app, &key(egui::Key::Escape, egui::Modifiers::NONE)));+ assert!(!prompt_allows_event(&app, &key(egui::Key::A, egui::Modifiers::NONE)));+ assert!(!prompt_allows_event(&app, &egui::Event::Text("x".into())));+ assert!(!prompt_allows_event(+ &app,+ &egui::Event::MouseWheel {+ unit: egui::MouseWheelUnit::Point,+ delta: egui::vec2(0.0, 10.0),+ phase: egui::TouchPhase::Move,+ source: egui::MouseWheelSource::Wheel,+ modifiers: egui::Modifiers::NONE,+ }+ ));+ let touch =+ |phase| egui::Event::Touch { device_id: egui::TouchDeviceId(1), id: egui::TouchId(1), phase, pos: egui::pos2(10.0, 10.0), force: None };+ assert!(!prompt_allows_event(&app, &touch(egui::TouchPhase::Start)));+ assert!(!prompt_allows_event(&app, &touch(egui::TouchPhase::Move)));+ assert!(prompt_allows_event(&app, &touch(egui::TouchPhase::End)));+ assert!(prompt_allows_event(&app, &touch(egui::TouchPhase::Cancel)));+ assert!(prompt_allows_event(&app, &egui::Event::PointerMoved(egui::pos2(10.0, 10.0))));+ app.notice_input.key = None;+ assert!(prompt_allows_event(&app, &egui::Event::Text("x".into())));+ assert!(prompt_allows_event(&app, &touch(egui::TouchPhase::Start)));+ }++ /// A touch that began before a prompt must still get its End/Cancel while the prompt is in its+ /// creation/transition frames (`laid_out` false). Start/Move remains background input. egui's+ /// private touch state is not cleared by the pointer cleanup, so dropping the release would+ /// leave the finger pressed after the prompt goes away.+ #[test]+ fn a_prompt_in_its_creation_frames_still_releases_touches() {+ let mut app = crate::LightcraftApp::new(lightcraft_engine::Session::with_demo(), crate::Services::default());+ app.notice_input.key = Some(PromptKey {+ layer: egui::LayerId::new(egui::Order::Foreground, egui::Id::unique("test-prompt")),+ text: "prompt".into(),+ queue_len: 1,+ });+ app.notice_input.laid_out = false;+ let touch =+ |phase| egui::Event::Touch { device_id: egui::TouchDeviceId(1), id: egui::TouchId(1), phase, pos: egui::pos2(10.0, 10.0), force: None };+ assert!(!prompt_allows_event(&app, &touch(egui::TouchPhase::Start)), "a new touch must not start on the background");+ assert!(!prompt_allows_event(&app, &touch(egui::TouchPhase::Move)), "a touch move is still background input");+ assert!(prompt_allows_event(&app, &touch(egui::TouchPhase::End)), "the release must clear egui's touch state");+ assert!(prompt_allows_event(&app, &touch(egui::TouchPhase::Cancel)), "a canceled touch must clear egui's touch state");+ app.notice_input.laid_out = true;+ assert!(!prompt_allows_event(&app, &touch(egui::TouchPhase::Start)), "settling does not let a new touch reach the background");+ assert!(prompt_allows_event(&app, &touch(egui::TouchPhase::End)), "settled prompts still release existing touches");+ }++ /// `prepare_ui_pass` dispatches the prompt's own AccessKit action manually; no AccessKit+ /// request may survive that pass for a covered background widget (or be dispatched twice).+ #[test]+ fn manual_prompt_dispatch_drops_all_accesskit_requests() {+ let ctx = egui::Context::default();+ let mut app = crate::LightcraftApp::new(lightcraft_engine::Session::with_demo(), crate::Services::default());+ app.quit_prompt = Some(crate::QuitPrompt::Tasks("tasks".into()));+ app.notice_input.key = prompt_key(&app);+ app.notice_input.laid_out = true;+ let mut raw = egui::RawInput::default();+ raw.events.push(egui::Event::AccessKitActionRequest(egui::accesskit::ActionRequest {+ action: egui::accesskit::Action::Click,+ target_tree: egui::accesskit::TreeId::ROOT,+ target_node: egui::accesskit::NodeId::from(42_u64),+ data: None,+ }));+ let mut output = ctx.run_ui(raw, |ui| {+ assert!(!prepare_ui_pass(&mut app, ui.ctx()), "the prompt was already known");+ let events = ui.ctx().input(|input| input.events.clone());+ assert!(events.is_empty(), "an AccessKit action survived manual prompt dispatch: {events:?}");+ });+ output.textures_delta.clear();+ }#[test]fn the_gpu_notice_is_only_for_a_missing_adapter() {diff --git a/crates/ui-egui/src/panels/people.rs b/crates/ui-egui/src/panels/people.rsindex 380bd829f..73d19cbaa 100644--- a/crates/ui-egui/src/panels/people.rs+++ b/crates/ui-egui/src/panels/people.rs@@ -74,7 +74,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let r = Rect::from_min_size(pos2(title.right() + 14.0, head.center().y - 12.0), vec2(width, 24.0));let mut child = ui.new_child(egui::UiBuilder::new().max_rect(r));let b = crate::widgets::arrow_button(&mut child, RichText::new(label).font(t.font(13.0)), crate::icons::Icon::ChevronRight, false);- register(ui.ctx(), "people:last", b.rect);+ register(ui, "people:last", b.rect);if b.on_hover_text(crate::i18n::tr("Back to this person")).clicked() {let _ = app.run("view.person", json!({"name": last}));}@@ -158,7 +158,7 @@ fn card(app: &mut LightcraftApp, ui: &mut egui::Ui, person: &Person, r: Rect, edlet face = Rect::from_min_size(r.min, vec2(edge, edge));let resp = ui.interact(r, egui::Id::unique(("person-card", &person.name)), Sense::click());crate::widgets::announce(&resp, person.name.clone());- register(ui.ctx(), format!("person:{}", person.name), r);+ register(ui, format!("person:{}", person.name), r);let view = app.session.face_view(person.photo, person.face);let p = ui.painter();p.rect_filled(face, 3.0, t.canvas);@@ -187,7 +187,7 @@ fn card(app: &mut LightcraftApp, ui: &mut egui::Ui, person: &Person, r: Rect, edlet full = person.name.clone();crate::widgets::context_menu(&resp, |ui| {let r = ui.button(crate::i18n::tr("Rename Person…"));- register(ui.ctx(), "personMenu:rename", r.rect);+ register(ui, "personMenu:rename", r.rect);if r.clicked() {open_rename(app, &full);}diff --git a/crates/ui-egui/src/panels/person.rs b/crates/ui-egui/src/panels/person.rsindex eab26a271..98b738cf2 100644--- a/crates/ui-egui/src/panels/person.rs+++ b/crates/ui-egui/src/panels/person.rs@@ -149,13 +149,13 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, name: &str) {ui.horizontal(|ui| {ui.add_space(PAD - 4.0);let back = crate::widgets::arrow_button(ui, crate::i18n::tr("People"), crate::icons::Icon::ChevronLeft, true);- register(ui.ctx(), "person:back", back.rect);+ register(ui, "person:back", back.rect);if back.clicked() {let _ = app.run("view.people", json!({}));}ui.label(RichText::new(&shown_name).font(t.semibold(15.0)).color(t.text));let rename = ui.button(crate::i18n::tr("Rename Person…"));- register(ui.ctx(), "person:rename", rename.rect);+ register(ui, "person:rename", rename.rect);if rename.clicked() {super::people::open_rename(app, &shown_name);}@@ -164,7 +164,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, name: &str) {ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {ui.add_space(PAD - 4.0);let photos = ui.button(crate::i18n::tr("Show photos")).on_hover_text(crate::i18n::tr("Their photos in the grid"));- register(ui.ctx(), "person:photos", photos.rect);+ register(ui, "person:photos", photos.rect);if photos.clicked() {let _ = app.run("library.filter", json!({"person": shown_name}));let _ = app.run("view.photoGrid", json!({}));@@ -238,7 +238,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, name: &str) {let r = Rect::from_min_size(pos2(area.left() + PAD + 330.0, area.top() + more_top + 8.0), vec2(120.0, 24.0));let label = if step == super::faces::Setup::TurnOn { "Turn on" } else { "Open Settings" };let b = ui.put(r, egui::Button::new(label));- register(ui.ctx(), "faces:setup", b.rect);+ register(ui, "faces:setup", b.rect);if b.clicked() {if step == super::faces::Setup::TurnOn {super::faces::take_step(app, ui.ctx(), step);@@ -294,14 +294,14 @@ fn tile(app: &mut LightcraftApp, ui: &mut egui::Ui, r: Rect, f: &Face, ppp: f32,let salt = if more { "more-face" } else { "person-face" };let resp = ui.interact(r, egui::Id::unique((salt, f.photo, f.index)), Sense::click());crate::widgets::announce(&resp, name.to_string());- register(ui.ctx(), format!("{salt}:{}:{}", f.photo, f.index), r);+ register(ui, format!("{salt}:{}:{}", f.photo, f.index), r);// the × is added after the tile, so it wins where they overlaplet x_rect = Rect::from_min_size(pos2(r.right() - 24.0, r.top() + 4.0), vec2(20.0, 20.0));let x_resp = more.then(|| ui.interact(x_rect, egui::Id::unique(("more-face-x", f.photo, f.index)), Sense::click()));let above_rect = Rect::from_min_size(pos2(r.left() + 4.0, r.top() + 4.0), vec2(24.0, 20.0));let above_resp = more.then(|| ui.interact(above_rect, egui::Id::unique(("more-face-above", f.photo, f.index)), Sense::click()));if more {- register(ui.ctx(), format!("more-face-above:{}:{}", f.photo, f.index), above_rect);+ register(ui, format!("more-face-above:{}:{}", f.photo, f.index), above_rect);}let hovered = resp.hovered() || x_resp.as_ref().is_some_and(|x| x.hovered()) || above_resp.as_ref().is_some_and(|x| x.hovered());let p = ui.painter();diff --git a/crates/ui-egui/src/panels/presets.rs b/crates/ui-egui/src/panels/presets.rsindex e34230cfc..6d35a5027 100644--- a/crates/ui-egui/src/panels/presets.rs+++ b/crates/ui-egui/src/panels/presets.rs@@ -111,7 +111,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let more = icon_button(&mut hdr, "presetMore", Icon::More, vec2(28.0, 28.0), false, true, crate::i18n::tr("More preset options"));egui::Popup::menu(&more).show(|ui| {let r = ui.checkbox(&mut app.ui.preset_thumbs, crate::i18n::tr("Show Thumbnails"));- register(ui.ctx(), "presetMenu:thumbnails", r.rect);+ register(ui, "presetMenu:thumbnails", r.rect);ui.separator();if ui.button(crate::i18n::tr("Import Presets…")).clicked() {let _ = app.run("file.importPresets", json!({}));@@ -175,7 +175,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 32.0), Sense::click());crate::widgets::announce(&resp, g.to_string());// outside the `presetGroup:` ids, which a user group of any name can take- register(ui.ctx(), if favorites { "presetFavorites".to_string() } else { format!("presetGroup:{g}") }, r);+ register(ui, if favorites { "presetFavorites".to_string() } else { format!("presetGroup:{g}") }, r);paint(ui.painter(),Rect::from_center_size(pos2(r.left() + 22.0, r.center().y), vec2(16.0, 16.0)),@@ -212,10 +212,10 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), row_h), Sense::click());crate::widgets::announce(&resp, name.clone());// a starred preset is listed twice: in Favorites and in its group- register(ui.ctx(), if favorites { format!("presetFavorite:{pid}") } else { format!("preset:{pid}") }, r);+ register(ui, if favorites { format!("presetFavorite:{pid}") } else { format!("preset:{pid}") }, r);let is_last = marked.as_deref() == Some(pid.as_str());if is_last {- register(ui.ctx(), "presetApplied", r);+ register(ui, "presetApplied", r);ui.painter().rect_filled(r, 0.0, t.tool_active);} else if resp.hovered() {ui.painter().rect_filled(r, 0.0, t.hover.gamma_multiply(0.7));diff --git a/crates/ui-egui/src/panels/profiles.rs b/crates/ui-egui/src/panels/profiles.rsindex 9604493c8..cf9a6c50c 100644--- a/crates/ui-egui/src/panels/profiles.rs+++ b/crates/ui-egui/src/panels/profiles.rs@@ -76,7 +76,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let open: bool = ui.data(|m| m.get_temp(open_id)).unwrap_or(true);let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 32.0), Sense::click());crate::widgets::announce(&resp, title.to_string());- register(ui.ctx(), if imported { format!("profileGroup:lut:{title}") } else { format!("profileGroup:{title}") }, r);+ register(ui, if imported { format!("profileGroup:lut:{title}") } else { format!("profileGroup:{title}") }, r);paint(ui.painter(),Rect::from_center_size(pos2(r.left() + 22.0, r.center().y), vec2(16.0, 16.0)),@@ -155,7 +155,7 @@ fn cell_ui(let key = if tag.is_empty() { format!("profileCell:{p_id}") } else { format!("profileCell:{tag}:{p_id}") };let resp = ui.interact(cell, egui::Id::unique(&key), Sense::click());crate::widgets::announce(&resp, p_name.to_string());- register(ui.ctx(), key, cell);+ register(ui, key, cell);let thumb = Rect::from_min_size(cell.min, vec2(cell.width(), th));let s = with_profile_id(d, p_id);let painter = ui.painter();@@ -178,7 +178,7 @@ fn cell_ui(// favourite star (always shown when set, on hover otherwise)let fav = app.session.profile_favorites.iter().any(|f| f == p_id);let star = Rect::from_center_size(pos2(thumb.right() - 13.0, thumb.top() + 13.0), vec2(20.0, 20.0));- register(ui.ctx(), format!("profileStar:{}{}", if tag.is_empty() { "" } else { "fav:" }, p_id), star);+ register(ui, format!("profileStar:{}{}", if tag.is_empty() { "" } else { "fav:" }, p_id), star);let over_star = resp.hover_pos().is_some_and(|q| star.contains(q));if fav || resp.hovered() {painter.circle_filled(star.center(), 10.0, Color32::from_black_alpha(110));diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rsindex c9fc40c59..45a7bf257 100644--- a/crates/ui-egui/src/panels/right.rs+++ b/crates/ui-egui/src/panels/right.rs@@ -112,7 +112,7 @@ pub fn fold_title(app: &mut LightcraftApp, ui: &egui::Ui, id: &str, r: Rect, reslet t = Tokens::get(ui.ctx());let open = !app.ui.section_folded(id);crate::widgets::announce_disclosure(resp, true, open, title);- register(ui.ctx(), format!("section:{id}"), r);+ register(ui, format!("section:{id}"), r);let p = ui.painter();if resp.hovered() {p.rect_filled(r, 0.0, t.chrome.gamma_multiply(1.06));@@ -187,11 +187,11 @@ fn custom_aspect(app: &mut LightcraftApp, ui: &mut egui::Ui) {ui.label(crate::i18n::tr("Custom"));let a = ui.add(egui::TextEdit::singleline(&mut w).desired_width(34.0));crate::widgets::screen_reader_name(ui.ctx(), a.id, crate::i18n::tr("Width"));- register(ui.ctx(), "field:cropCustomW", a.rect);+ register(ui, "field:cropCustomW", a.rect);ui.label("×");let b = ui.add(egui::TextEdit::singleline(&mut h).desired_width(34.0));crate::widgets::screen_reader_name(ui.ctx(), b.id, crate::i18n::tr("Height"));- register(ui.ctx(), "field:cropCustomH", b.rect);+ register(ui, "field:cropCustomH", b.rect);let go = text_button(ui, "cropCustomApply", "Apply", false);apply = go.clicked() || ((a.lost_focus() || b.lost_focus()) && ui.input(|i| i.key_pressed(egui::Key::Enter)));});@@ -286,7 +286,7 @@ fn crop(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {// keystroke: no half-typed angles, one undo step.update_while_editing(false),);- crate::widgets::register(ui.ctx(), "cropAngleField", r.rect);+ crate::widgets::register(ui, "cropAngleField", r.rect);// a drag on the field is one undo step, like the slider'sif r.drag_started() {let _ = app.run("develop.beginInteraction", json!({"label": "Straighten"}));@@ -549,7 +549,7 @@ pub(crate) fn tool_overlay_options(app: &mut LightcraftApp, ui: &mut egui::Ui) {egui::Popup::menu(&r).show(|ui| {for m in ToolOverlay::ALL {let item = ui.selectable_label(m == current, crate::i18n::tr(m.label()));- register(ui.ctx(), format!("toolOverlay:{}", m.name()), item.rect);+ register(ui, format!("toolOverlay:{}", m.name()), item.rect);if item.clicked() {let _ = app.run("view.toolOverlay", json!({"mode": m.name()}));}@@ -656,7 +656,7 @@ fn info(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {let (r, resp) = ui.allocate_exact_size(vec2(22.0, 22.0), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr(&format!("{l:?}")));let key = format!("{l:?}").to_lowercase();- register(ui.ctx(), format!("label:{key}"), r);+ register(ui, format!("label:{key}"), r);let on = p.label == Some(l);ui.painter().circle_filled(r.center(), if on || resp.hovered() { 8.0 } else { 6.5 }, crate::panels::grid::label_color(l));if on {@@ -892,7 +892,7 @@ fn camera_card(ui: &mut egui::Ui, p: &lightcraft_catalog::Photo) {ui.add_space(12.0);ui.label(egui::RichText::new(text).size(12.0).color(t.text));});- register(ui.ctx(), "info:focus", r.response.rect);+ register(ui, "info:focus", r.response.rect);}});}@@ -1051,7 +1051,7 @@ fn copyright_status(app: &mut LightcraftApp, ui: &mut egui::Ui, current: lightcr}});crate::widgets::name_combo(&r.response, crate::i18n::tr("Copyright Status"));- register(ui.ctx(), "field:copyrightStatus", r.response.rect);+ register(ui, "field:copyrightStatus", r.response.rect);ui.add_space(6.0);}@@ -1277,7 +1277,7 @@ fn keywording(app: &mut LightcraftApp, ui: &mut egui::Ui) {let name = names.get(i).unwrap_or(&whole);let r = ui.add(egui::Button::new(egui::RichText::new(format!("+ {name}")).color(t.text_label)).corner_radius(10.0));let r = if grouped { r.on_hover_text(&whole) } else { r };- register(ui.ctx(), format!("kwSuggest:{k}"), r.rect);+ register(ui, format!("kwSuggest:{k}"), r.rect);if r.clicked() {let _ = app.run("photo.setMeta", json!({"addKeywords": [k]}));}@@ -1342,7 +1342,7 @@ fn keyword_set(app: &mut LightcraftApp, ui: &mut egui::Ui) {ui.separator();// Edit Set…: the current nine, slot by slot (named, Recent Keywords becomes a set)let edit = ui.button(crate::i18n::tr("Edit Set…"));- register(ui.ctx(), "keywordSetMenu:edit", edit.rect);+ register(ui, "keywordSetMenu:edit", edit.rect);if edit.clicked() {let mut slots: Vec<String> =sets["keywords"].as_array().into_iter().flatten().filter_map(|k| k.as_str().map(str::to_string)).collect();@@ -1372,7 +1372,7 @@ fn keyword_set(app: &mut LightcraftApp, ui: &mut egui::Ui) {}});crate::widgets::name_combo(&combo.response, crate::i18n::tr("Keyword Set"));- register(ui.ctx(), "keywordSetCombo", combo.response.rect);+ register(ui, "keywordSetCombo", combo.response.rect);});let kws: Vec<String> = sets["keywords"].as_array().into_iter().flatten().filter_map(|k| k.as_str().map(str::to_string)).collect();if kws.is_empty() {@@ -1385,7 +1385,7 @@ fn keyword_set(app: &mut LightcraftApp, ui: &mut egui::Ui) {// an empty slot: an idle button, so the others keep their ⌥ keysif k.is_empty() {let r = ui.add_enabled_ui(false, |ui| ui.add_sized([bw, 22.0], egui::Button::new(""))).inner;- register(ui.ctx(), format!("kwSetEmpty:{}", i + 1), r.rect);+ register(ui, format!("kwSetEmpty:{}", i + 1), r.rect);if i % 3 == 2 {ui.end_row();}@@ -1401,11 +1401,11 @@ fn keyword_set(app: &mut LightcraftApp, ui: &mut egui::Ui) {egui::Button::new(egui::RichText::new(short).size(11.5).color(if on { t.text } else { t.text_label })).selected(on).truncate(),).on_hover_text(format!("{} — ⌥{}", k.replace('|', " › "), i + 1));- register(ui.ctx(), format!("kwSet:{}", i + 1), r.rect);+ register(ui, format!("kwSet:{}", i + 1), r.rect);if on {- register(ui.ctx(), format!("kwSetOn:{}", i + 1), r.rect);+ register(ui, format!("kwSetOn:{}", i + 1), r.rect);} else if some {- register(ui.ctx(), format!("kwSetSome:{}", i + 1), r.rect);+ register(ui, format!("kwSetSome:{}", i + 1), r.rect);}if r.clicked() {let _ = app.run("keyword.toggleFromSet", json!({"index": i + 1}));@@ -1448,7 +1448,7 @@ fn versions(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {for (i, v) in shown.into_iter().rev() {let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 58.0), Sense::click());crate::widgets::announce(&resp, format!("{} {}", crate::i18n::tr("Version"), i + 1));- register(ui.ctx(), format!("version:{i}"), r);+ register(ui, format!("version:{i}"), r);let current = *v.settings == *p.develop;if resp.hovered() {ui.painter().rect_filled(r, 4.0, t.hover.gamma_multiply(0.7));@@ -1559,7 +1559,7 @@ fn activity(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {for (i, h) in p.history.iter().enumerate().rev() {let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 24.0), Sense::click());crate::widgets::announce(&resp, crate::i18n::tr(&h.label));- register(ui.ctx(), format!("history:{i}"), r);+ register(ui, format!("history:{i}"), r);let row = history_row(i, cursor);if row == HistoryRow::Current {ui.painter().rect_filled(r, 3.0, t.pressed);diff --git a/crates/ui-egui/src/panels/rules_editor.rs b/crates/ui-egui/src/panels/rules_editor.rsindex c4504fe4c..509a096ec 100644--- a/crates/ui-egui/src/panels/rules_editor.rs+++ b/crates/ui-egui/src/panels/rules_editor.rs@@ -66,7 +66,7 @@ fn text_value(ui: &mut egui::Ui, v: &mut Value, width: f32, hint: &str, salt: &sother => other.to_string(),};let r = ui.add(egui::TextEdit::singleline(&mut s).hint_text(crate::i18n::tr(hint)).desired_width(width));- register(ui.ctx(), format!("field:{salt}"), r.rect);+ register(ui, format!("field:{salt}"), r.rect);if r.changed() {*v = json!(s);}@@ -243,7 +243,7 @@ fn field_menu(ui: &mut egui::Ui, salt: &str, field: &mut String, op: &mut Stringlet mut pick = None;let mut item = |ui: &mut egui::Ui, id: &'static str| {let r = ui.selectable_label(current == id, crate::i18n::tr(field_label(id).unwrap_or(id)));- register(ui.ctx(), format!("ruleFieldItem:{id}:{salt}"), r.rect);+ register(ui, format!("ruleFieldItem:{id}:{salt}"), r.rect);if r.clicked() {pick = Some(id);ui.close();@@ -265,12 +265,12 @@ fn field_menu(ui: &mut egui::Ui, salt: &str, field: &mut String, op: &mut Stringitem(ui, id);}});- register(ui.ctx(), format!("ruleFieldGroup:{group}:{salt}"), r.response.rect);+ register(ui, format!("ruleFieldGroup:{group}:{salt}"), r.response.rect);}pick});crate::widgets::name_combo(&r.response, crate::i18n::tr("Field"));- register(ui.ctx(), format!("ruleField:{salt}"), r.response.rect);+ register(ui, format!("ruleField:{salt}"), r.response.rect);let Some(Some(id)) = r.inner else { return };if field == id {return;@@ -295,7 +295,7 @@ fn problem_note(ui: &mut egui::Ui, problem: Option<&Problem>, salt: &str) {let Some(p) = problem else { return };let t = Tokens::get(ui.ctx());let r = ui.label(RichText::new(format!("⚠ {}", crate::i18n::problem_text(p))).color(t.caution).small());- register(ui.ctx(), format!("ruleProblem:{salt}"), r.rect);+ register(ui, format!("ruleProblem:{salt}"), r.rect);}/// Edit `rs` in place; `salt` keeps widget ids apart between groups, `path` is where `rs` sits@@ -350,12 +350,12 @@ pub fn edit(ui: &mut egui::Ui, rs: &mut RuleSet, salt: &str, depth: usize, path:let buttons = small_button_width(ui, "−") + ui.spacing().item_spacing.x + small_button_width(ui, "+");ui.add_space((ui.available_width() - buttons).max(0.0));let del = ui.small_button("−").on_hover_text(crate::i18n::tr("Remove this rule"));- register(ui.ctx(), format!("button:ruleRemove-{rsalt}"), del.rect);+ register(ui, format!("button:ruleRemove-{rsalt}"), del.rect);if del.clicked() {remove = Some(i);}let add = ui.small_button("+").on_hover_text(crate::i18n::tr("Add a rule (⌥-click: a group)"));- register(ui.ctx(), format!("button:ruleAdd-{rsalt}"), add.rect);+ register(ui, format!("button:ruleAdd-{rsalt}"), add.rect);if add.clicked() {let group = ui.input(|i| i.modifiers.alt) && depth < 3;insert = Some((@@ -377,7 +377,7 @@ pub fn edit(ui: &mut egui::Ui, rs: &mut RuleSet, salt: &str, depth: usize, path:if rs.rules.is_empty() || depth == 0 {ui.horizontal(|ui| {let add = ui.small_button(crate::i18n::tr("+ Rule"));- register(ui.ctx(), format!("button:ruleAddEnd-{salt}"), add.rect);+ register(ui, format!("button:ruleAddEnd-{salt}"), add.rect);if add.clicked() {rs.rules.push(new_rule());}diff --git a/crates/ui-egui/src/panels/second.rs b/crates/ui-egui/src/panels/second.rsindex 9772c43c5..49c616915 100644--- a/crates/ui-egui/src/panels/second.rs+++ b/crates/ui-egui/src/panels/second.rs@@ -24,7 +24,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {fn body(app: &mut LightcraftApp, ui: &mut egui::Ui) {let area = ui.available_rect_before_wrap();- crate::widgets::register(ui.ctx(), "view:secondWindow", area);+ crate::widgets::register(ui, "view:secondWindow", area);ui.allocate_rect(area, egui::Sense::hover());let Some(id) = app.session.active() else {ui.painter().text(diff --git a/crates/ui-egui/src/panels/settings.rs b/crates/ui-egui/src/panels/settings.rsindex 9f1623bf8..338d55c00 100644--- a/crates/ui-egui/src/panels/settings.rs+++ b/crates/ui-egui/src/panels/settings.rs@@ -94,7 +94,7 @@ pub fn window(app: &mut LightcraftApp, ui: &mut egui::Ui, tab: &mut String, max_let room = max_height - (ui.cursor().top() - top) - 1.0;if room < PAGE_MIN_HEIGHT {body(app, ui, tab.as_str());- register(ui.ctx(), "settings:page", ui.min_rect());+ register(ui, "settings:page", ui.min_rect());return;}let mut height = room.min(PAGE_SIZE.y);@@ -131,9 +131,9 @@ pub fn window(app: &mut LightcraftApp, ui: &mut egui::Ui, tab: &mut String, max_body(app, ui, tab.as_str());}// (what the page took: wider than the room for it would mean a control is cut off)- register(ui.ctx(), "settings:page", ui.min_rect());+ register(ui, "settings:page", ui.min_rect());});- register(ui.ctx(), "settings:pageRoom", page.inner_rect);+ register(ui, "settings:pageRoom", page.inner_rect);}/// `path` shortened to fit `max` (as `width` measures it) by dropping leading folders, after@@ -169,7 +169,7 @@ fn path_label(ui: &mut egui::Ui, id: &str, path: &str, font: egui::FontId, colorelide_path(path, (ui.available_width() - after).max(0.0), |s| ui.painter().layout_no_wrap(s.to_string(), font.clone(), color).size().x);// (`truncate` is the last resort, for a room narrower than "…")let r = ui.add(egui::Label::new(RichText::new(&shown).font(font).color(color)).truncate().show_tooltip_when_elided(false));- register(ui.ctx(), format!("text:{id}"), r.rect);+ register(ui, format!("text:{id}"), r.rect);if shown != path {r.on_hover_text(path);}@@ -216,7 +216,7 @@ pub(super) fn hint(ui: &mut egui::Ui, t: &Tokens, text: &str) {/// A checkbox addressable as `check:{id}`; true when toggled.pub(super) fn check(ui: &mut egui::Ui, id: &str, value: &mut bool, label: &str) -> bool {let r = ui.checkbox(value, crate::i18n::tr(label));- register(ui.ctx(), format!("check:{id}"), r.rect);+ register(ui, format!("check:{id}"), r.rect);r.changed()}@@ -255,12 +255,12 @@ fn general_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {row(ui, t, "", |ui| {let can = app.services.pick_folder.is_some();let r = ui.add_enabled(can, egui::Button::new(crate::i18n::tr("Open Library…")));- register(ui.ctx(), "button:settingsOpenLibrary", r.rect);+ register(ui, "button:settingsOpenLibrary", r.rect);if r.clicked() {let _ = app.run("app.openLibrary", json!({}));}let r = ui.add_enabled(can, egui::Button::new(crate::i18n::tr("New Library…")));- register(ui.ctx(), "button:settingsNewLibrary", r.rect);+ register(ui, "button:settingsNewLibrary", r.rect);if r.clicked() {let _ = app.run("app.newLibrary", json!({}));}@@ -380,7 +380,7 @@ fn preset_combo(app: &LightcraftApp, ui: &mut egui::Ui, id: &str, label: &str, c}});crate::widgets::name_combo(&r.response, label);- register(ui.ctx(), format!("combo:{id}"), r.response.rect);+ register(ui, format!("combo:{id}"), r.response.rect);out.filter(|v| v.as_deref() != current)}@@ -454,7 +454,7 @@ fn import_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {}});crate::widgets::name_combo(&r.response, crate::i18n::tr("Camera"));- register(ui.ctx(), format!("combo:{id}"), r.response.rect);+ register(ui, format!("combo:{id}"), r.response.rect);if let Some(c) = pick {let _ = app.run("library.preferences", json!({"camera": c}));}@@ -477,7 +477,7 @@ fn import_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {let id = egui::Id::unique(("settingsMeta", key));let mut text: String = ui.data(|m| m.get_temp(id)).unwrap_or(value.clone());let r = ui.add(egui::TextEdit::singleline(&mut text).hint_text(hint_text).desired_width(240.0));- register(ui.ctx(), format!("field:settings.{key}"), r.rect);+ register(ui, format!("field:settings.{key}"), r.rect);if r.lost_focus() && text.trim() != value {let _ = app.run("library.preferences", json!({"import": {key: text.trim()}}));}@@ -506,7 +506,7 @@ fn import_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {}});crate::widgets::name_combo(&r.response, crate::i18n::tr("Metadata preset"));- register(ui.ctx(), "combo:settingsMetaPreset", r.response.rect);+ register(ui, "combo:settingsMetaPreset", r.response.rect);if let Some(n) = pick {let _ = app.run("library.preferences", json!({"import": {"metadataPreset": n}}));}@@ -549,7 +549,7 @@ fn import_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {}let can = app.services.pick_folder.is_some();let r = ui.add_enabled(can, egui::Button::new(crate::i18n::tr("Choose…")));- register(ui.ctx(), "button:settingsAutoFolder", r.rect);+ register(ui, "button:settingsAutoFolder", r.rect);if r.clicked()&& let Some(f) = app.services.pick_folder.as_mut().and_then(|f| f())&& let Err(e) = app.run("library.autoImport", json!({"folder": f}))@@ -635,7 +635,7 @@ fn performance_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {.color(t.text),);let r = ui.button(crate::i18n::tr("Clear Cache"));- register(ui.ctx(), "button:settingsClearCache", r.rect);+ register(ui, "button:settingsClearCache", r.rect);if r.clicked() {let _ = app.run("library.clearPreviews", json!({}));}@@ -692,7 +692,7 @@ fn smart_previews(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {);if !custom {let r = ui.label(RichText::new("(library default)").color(t.text));- register(ui.ctx(), "text:settingsSmartDefault", r.rect);+ register(ui, "text:settingsSmartDefault", r.rect);}});let (count, bytes) = (loc["count"].as_u64().unwrap_or(0), loc["bytes"].as_u64().unwrap_or(0));@@ -732,7 +732,7 @@ fn smart_previews(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {ui.add_space(LABEL_W);if app.services.pick_folder.is_some() {let r = ui.button(crate::i18n::tr("Choose Folder…"));- register(ui.ctx(), "button:settingsSmartChoose", r.rect);+ register(ui, "button:settingsSmartChoose", r.rect);if r.clicked()&& let Some(dir) = app.services.pick_folder.as_mut().and_then(|f| f()){@@ -740,7 +740,7 @@ fn smart_previews(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {}}let r = ui.add_enabled(custom, egui::Button::new(crate::i18n::tr("Use Library Folder")));- register(ui.ctx(), "button:settingsSmartReset", r.rect);+ register(ui, "button:settingsSmartReset", r.rect);if r.clicked() {result = Some(app.run("library.smartPreviewsLocation", json!({"reset": true, "existing": existing})));}@@ -785,7 +785,7 @@ fn display_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {row(ui, t, "", |ui| {let can = app.services.pick_display_profile.is_some();let r = ui.add_enabled(can, egui::Button::new(crate::i18n::tr("Choose Profile…")));- register(ui.ctx(), "button:settingsDisplayProfile", r.rect);+ register(ui, "button:settingsDisplayProfile", r.rect);if r.clicked()&& let Some(path) = app.services.pick_display_profile.as_mut().and_then(|pick| pick().into_iter().next()){@@ -794,7 +794,7 @@ fn display_tab(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {// with no profile chosen, previews follow the screen's own profile where the host knows itlet none = if app.services.screen_profile.is_some() { crate::i18n::tr("Use Screen Profile") } else { crate::i18n::tr("Use sRGB") };let r = ui.add_enabled(!app.ui.settings.display_profile.is_empty(), egui::Button::new(none));- register(ui.ctx(), "button:settingsDisplayProfileNone", r.rect);+ register(ui, "button:settingsDisplayProfileNone", r.rect);if r.clicked() {app.ui.settings.display_profile.clear();}@@ -897,7 +897,7 @@ pub(super) fn view_options(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokenfor f in F::ALL {let key = serde_json::to_value(f).ok().and_then(|v| v.as_str().map(str::to_string)).unwrap_or_default();let r = ui.selectable_label(line == f, crate::i18n::tr(f.label()));- register(ui.ctx(), format!("button:{id}-{key}"), r.rect);+ register(ui, format!("button:{id}-{key}"), r.rect);if r.clicked() {*line = *f;}@@ -907,10 +907,10 @@ pub(super) fn view_options(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Token&r.response,&crate::i18n::tr_format!("{title}: {line}", title = crate::i18n::tr(title), line = crate::i18n::tr(line.label())),);- register(ui.ctx(), format!("combo:{id}"), r.response.rect);+ register(ui, format!("combo:{id}"), r.response.rect);}let r = ui.add_enabled(*lines != defaults, egui::Button::new(crate::i18n::tr("Use Defaults")));- register(ui.ctx(), format!("button:viewOptionsDefaults{n}"), r.rect);+ register(ui, format!("button:viewOptionsDefaults{n}"), r.rect);if r.clicked() {*lines = defaults;}@@ -932,7 +932,7 @@ pub(super) fn view_options(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokenfn duration_slider(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, key: &str, value: f64, range: std::ops::RangeInclusive<f64>) {let mut v = value;let r = ui.add(egui::Slider::new(&mut v, range).logarithmic(key == "slideDuration").suffix(" s").max_decimals(1));- register(ui.ctx(), format!("slider:{id}"), r.rect);+ register(ui, format!("slider:{id}"), r.rect);if r.changed()&& let Ok(next) = app.session.slideshow.merged(&json!({ key: v })){@@ -975,7 +975,7 @@ fn export_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {("slideshowExportVideo", "Export Video…", "video"),] {let r = ui.add_enabled(!running, egui::Button::new(crate::i18n::tr(label)));- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);if r.clicked() {let _ = app.run("dialog.slideshowExport", json!({"format": format}));}@@ -1028,7 +1028,7 @@ fn playback_section(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {&& let Some(mut c) = s.fade_color{let r = egui::color_picker::color_edit_button_srgb(ui, &mut c);- register(ui.ctx(), "button:slideshowFadeColor", r.rect);+ register(ui, "button:slideshowFadeColor", r.rect);if r.changed() {let _ = app.run("slideshow.playback", json!({"fadeColor": c}));}@@ -1122,7 +1122,7 @@ fn theme_card<V: PartialEq + Copy>(let hovered = ui.ctx().pointer_hover_pos().is_some_and(|p| row.contains(p));ui.horizontal(|ui| {let r = ui.radio_value(value, *v, crate::i18n::tr(kind.label()));- register(ui.ctx(), format!("radio:theme-{}", kind.id()), r.rect);+ register(ui, format!("radio:theme-{}", kind.id()), r.rect);ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {let favorite = favorites.iter().any(|id| id == kind.id());let r = ui@@ -1139,7 +1139,7 @@ fn theme_card<V: PartialEq + Copy>(),)});- register(ui.ctx(), format!("button:themeFavorite-{}", kind.id()), r.rect);+ register(ui, format!("button:themeFavorite-{}", kind.id()), r.rect);if favorite || hovered {crate::rating::paint_star(ui.painter(), r.rect.shrink(4.0), favorite, if favorite { t.accent } else { t.text_dim });}diff --git a/crates/ui-egui/src/panels/slide_layout.rs b/crates/ui-egui/src/panels/slide_layout.rsindex 1acb2efa4..82387f1e6 100644--- a/crates/ui-egui/src/panels/slide_layout.rs+++ b/crates/ui-egui/src/panels/slide_layout.rs@@ -45,7 +45,7 @@ fn slider(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, key: &str, valueUnit::Degrees => (value, -180.0..=180.0, "°"),};let r = ui.add(egui::Slider::new(&mut v, range).suffix(suffix).max_decimals(1));- register(ui.ctx(), format!("slider:{id}"), r.rect);+ register(ui, format!("slider:{id}"), r.rect);let value = match unit {Unit::Percent => v / 100.0,Unit::Degrees => v,@@ -64,7 +64,7 @@ fn slider(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, key: &str, valuefn colour(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, key: &str, value: [u8; 3]) {let mut c = value;let r = egui::color_picker::color_edit_button_srgb(ui, &mut c);- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);if r.changed() {set(app, json!({ key: c }));}@@ -132,7 +132,7 @@ pub fn sections(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens) {let active = app.session.active();let mut on = s.background_image.is_some();let r = ui.add_enabled(on || active.is_some(), egui::Checkbox::new(&mut on, crate::i18n::tr("Background image")));- register(ui.ctx(), "check:settings.slideshowBackgroundImage", r.rect);+ register(ui, "check:settings.slideshowBackgroundImage", r.rect);if r.changed() {set(app, json!({"backgroundImage": if on { active.map(|a| a.0) } else { None }}));}@@ -185,7 +185,7 @@ pub fn preview(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, max_h: f3let rect = Rect::from_center_size(room.center(), vec2(fit_w, fit_h));let h = rect.height();let w = rect.width();- register(ui.ctx(), "slideshow:preview", rect);+ register(ui, "slideshow:preview", rect);let p = ui.painter_at(room.expand(1.0));p.rect_stroke(rect, 0.0, Stroke::new(1.0, t.text_dim.gamma_multiply(0.5)), egui::StrokeKind::Outside);super::slide_titles::preview_choice(ui);diff --git a/crates/ui-egui/src/panels/slide_overlays.rs b/crates/ui-egui/src/panels/slide_overlays.rsindex 6a3976b19..e9c88f0b3 100644--- a/crates/ui-egui/src/panels/slide_overlays.rs+++ b/crates/ui-egui/src/panels/slide_overlays.rs@@ -38,7 +38,7 @@ fn slider(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, value: f64, lo:};let mut v = value * k;let r = ui.add(egui::Slider::new(&mut v, lo * k..=hi * k).suffix(suffix).max_decimals(1));- register(ui.ctx(), format!("slider:{id}"), r.rect);+ register(ui, format!("slider:{id}"), r.rect);let p = wrap(v / k);if r.changed()&& let Ok(next) = app.session.slide_overlays.merged(&p)@@ -54,7 +54,7 @@ fn slider(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, value: f64, lo:fn colour(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, value: [u8; 3], wrap: &dyn Fn([u8; 3]) -> Value) {let mut c = value;let r = egui::color_picker::color_edit_button_srgb(ui, &mut c);- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);if r.changed() {set(app, wrap(c));}diff --git a/crates/ui-egui/src/panels/slide_templates.rs b/crates/ui-egui/src/panels/slide_templates.rsindex 51b510906..3929be5ed 100644--- a/crates/ui-egui/src/panels/slide_templates.rs+++ b/crates/ui-egui/src/panels/slide_templates.rs@@ -17,7 +17,7 @@ use super::settings::{heading, hint};use crate::LightcraftApp;use crate::text_field::TextField;use crate::theme::Tokens;-use crate::widgets::register;+use crate::widgets::{register, register_response};/// The user templates list is at most this tall (it scrolls past it).const USER_LIST_H: f32 = 180.0;@@ -129,7 +129,7 @@ fn template_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, tpl: &Te}let w = ui.available_width();let (rect, resp) = ui.allocate_exact_size(vec2(w, 22.0), Sense::click());- register(&ctx, format!("template:{}", tpl.id), rect);+ register_response(format!("template:{}", tpl.id), rect, &resp);if resp.hovered() || resp.context_menu_opened() {*hovered = Some(tpl.id.clone());}@@ -151,7 +151,7 @@ fn template_row(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, tpl: &Te/// A menu entry registered as `button:{id}`.fn item(ui: &mut egui::Ui, id: &str, label: &str, enabled: bool) -> bool {let r = ui.add_enabled(enabled, egui::Button::new(crate::i18n::tr(label)));- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);r.clicked()}diff --git a/crates/ui-egui/src/panels/slide_titles.rs b/crates/ui-egui/src/panels/slide_titles.rsindex 4c2503569..b3c103402 100644--- a/crates/ui-egui/src/panels/slide_titles.rs+++ b/crates/ui-egui/src/panels/slide_titles.rs@@ -64,7 +64,7 @@ fn slider() {let mut v = value * k;let r = ui.add(egui::Slider::new(&mut v, (range.start() * k)..=(range.end() * k)).suffix(suffix).max_decimals(1));- register(ui.ctx(), format!("slider:{id}"), r.rect);+ register(ui, format!("slider:{id}"), r.rect);let p = json!({ t.id(): { key: v / k } });if r.changed() {if let Ok(next) = app.session.slide_titles.merged(&p) {@@ -81,7 +81,7 @@ fn slider(fn colour(app: &mut LightcraftApp, ui: &mut egui::Ui, id: &str, t: Title, key: &str, value: [u8; 3]) {let mut c = value;let r = egui::color_picker::color_edit_button_srgb(ui, &mut c);- register(ui.ctx(), format!("button:{id}"), r.rect);+ register(ui, format!("button:{id}"), r.rect);if r.changed() {set(app, ui.ctx(), t, key, json!(c));}diff --git a/crates/ui-egui/src/panels/slideshow.rs b/crates/ui-egui/src/panels/slideshow.rsindex 79461a4af..cfe0ce6e6 100644--- a/crates/ui-egui/src/panels/slideshow.rs+++ b/crates/ui-egui/src/panels/slideshow.rs@@ -368,7 +368,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {draw(frame.current, 1.0);}}- register(ui.ctx(), "slideshow:canvas", canvas);+ register(ui, "slideshow:canvas", canvas);controls(app, ui, canvas, now);}diff --git a/crates/ui-egui/src/panels/topbar.rs b/crates/ui-egui/src/panels/topbar.rsindex 8605eb000..f1d6f3043 100644--- a/crates/ui-egui/src/panels/topbar.rs+++ b/crates/ui-egui/src/panels/topbar.rs@@ -12,7 +12,7 @@ use crate::widgets::{icon_button, register};/// double-click zooms or restores it. Registered before the bar's widgets so they win the click.fn window_handle(app: &LightcraftApp, ui: &mut egui::Ui, bar: Rect, search_rect: Rect) {use crate::titlebar::{Gesture, WindowState, command_for};- register(ui.ctx(), "region:titlebar", bar);+ register(ui, "region:titlebar", bar);let handle = egui::Id::unique("titlebar-handle");let resp = ui.interact(bar, handle, Sense::click_and_drag());crate::widgets::announce(&resp, crate::i18n::tr("Title bar"));@@ -135,7 +135,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let fr = Rect::from_center_size(pos2(sr.right() + 22.0, sr.center().y), vec2(28.0, 28.0));let fresp = ui.interact(fr, egui::Id::unique("filter-btn"), Sense::click());crate::widgets::announce(&fresp, crate::i18n::tr("Filters"));- register(ui.ctx(), "icon:filter", fr);+ register(ui, "icon:filter", fr);let filtering = app.session.filter != Default::default() || app.ui.filter_bar;paint(ui.painter(),@@ -194,7 +194,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let r = Rect::from_center_size(pos2(x, full.center().y), vec2(28.0, 28.0));let resp = ui.interact(r, egui::Id::unique(("top", id)), Sense::click()).on_hover_text(crate::i18n::tr(tip));crate::widgets::announce(&resp, crate::i18n::tr(tip));- register(ui.ctx(), format!("icon:{id}"), r);+ register(ui, format!("icon:{id}"), r);let warn = id == "cloud" && unsaved.is_some();let colour = if warn {t.caution@@ -208,7 +208,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let c = r.right_top() + vec2(-5.0, 6.0);ui.painter().circle_filled(c, 6.0, t.reject);ui.painter().text(c, Align2::CENTER_CENTER, "!", t.semibold(9.5), t.canvas);- register(ui.ctx(), "indicator:unsaved", r);+ register(ui, "indicator:unsaved", r);}// a refusal says why (Import while a Lightroom catalog is coming in)if resp.clicked()@@ -225,14 +225,14 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {let tip = format!("{}: {}", crate::i18n::tr("Appearance Mode"), crate::i18n::tr(mode));let resp = ui.interact(r, egui::Id::unique(("top", "appearance")), Sense::click()).on_hover_text(tip.clone());crate::widgets::announce(&resp, tip.clone());- register(ui.ctx(), "icon:appearance", r);+ register(ui, "icon:appearance", r);paint(ui.painter(), r.shrink(5.0), icon, if resp.hovered() { t.text } else { t.icon });if resp.clicked() {let _ = app.run("view.appearance", json!({}));}crate::widgets::context_menu(&resp, |ui| {let settings = ui.button(crate::i18n::tr("Appearance Settings…"));- register(ui.ctx(), "menu:appearanceSettings", settings.rect);+ register(ui, "menu:appearanceSettings", settings.rect);if settings.clicked() {let _ = app.run("app.settings", json!({"tab": "interface"}));ui.close();@@ -246,7 +246,7 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {}for kind in group {let r = ui.selectable_label(app.ui.settings.theme(app.system_theme(ui.ctx())) == *kind, crate::i18n::tr(kind.label()));- register(ui.ctx(), format!("menu:themeFavorite-{}", kind.id()), r.rect);+ register(ui, format!("menu:themeFavorite-{}", kind.id()), r.rect);if r.clicked() {let _ = app.run("view.theme", json!({"theme": kind.id()}));ui.close();diff --git a/crates/ui-egui/src/panels/unnamed.rs b/crates/ui-egui/src/panels/unnamed.rsindex 4636ce8c1..7f42437b2 100644--- a/crates/ui-egui/src/panels/unnamed.rs+++ b/crates/ui-egui/src/panels/unnamed.rs@@ -144,12 +144,12 @@ pub fn naming_bar(app: &mut LightcraftApp, ui: &mut egui::Ui) {}let label = if n == 1 { "Name face".to_string() } else { format!("Name {n} faces") };let b = ui.add_enabled(!chosen.is_empty(), egui::Button::new(label));- register(ui.ctx(), "unnamed:name", b.rect);+ register(ui, "unnamed:name", b.rect);if b.clicked() {submit = Some(chosen);}let c = ui.button(crate::i18n::tr("Clear"));- register(ui.ctx(), "unnamed:clear", c.rect);+ register(ui, "unnamed:clear", c.rect);clear = c.clicked() || field.cancelled();});// the people already named, matching what is typed (a click names the faces)@@ -162,7 +162,7 @@ pub fn naming_bar(app: &mut LightcraftApp, ui: &mut egui::Ui) {ui.add_space(super::people::PAD - 4.0);for p in matching {let b = ui.add(egui::Button::new(RichText::new(p.as_str()).color(t.text_label)).frame(false));- register(ui.ctx(), format!("unnamed:pick:{p}"), b.rect);+ register(ui, format!("unnamed:pick:{p}"), b.rect);if b.clicked() {submit = Some(p.clone());}@@ -204,7 +204,7 @@ pub fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, list: &Unnamedif !list.ready && list.faces.is_empty() {let r = Rect::from_min_size(pos2(at.x, at.y + 38.0), vec2(120.0, 22.0));let b = ui.put(r, egui::Button::new(crate::i18n::tr("Open Settings")));- register(ui.ctx(), "unnamed:openSettings", b.rect);+ register(ui, "unnamed:openSettings", b.rect);if b.clicked() {let _ = app.run("app.settings", json!({"tab": "faces"}));}@@ -212,7 +212,7 @@ pub fn section_header(app: &mut LightcraftApp, ui: &mut egui::Ui, list: &Unnamedlet r = Rect::from_min_size(pos2(right - 130.0, at.y + 12.0), vec2(130.0, 22.0));let all = app.ui.unnamed_selected.len() == list.faces.len();let b = ui.put(r, egui::Button::new(crate::i18n::tr(if all { "Select none" } else { "Select all" })));- register(ui.ctx(), "unnamed:selectAll", b.rect);+ register(ui, "unnamed:selectAll", b.rect);if b.clicked() {app.ui.unnamed_selected.clear();if !all {@@ -230,12 +230,12 @@ pub fn tile(app: &mut LightcraftApp, ui: &mut egui::Ui, list: &Unnamed, i: usizelet selected = app.ui.unnamed_selected.contains(&key);let resp = ui.interact(r, egui::Id::unique(("unnamed-face", f.photo, f.index)), Sense::click());crate::widgets::announce_selected(&resp, crate::i18n::tr("Unnamed face"), selected);- register(ui.ctx(), format!("unnamed-face:{}:{}", f.photo, f.index), r);+ register(ui, format!("unnamed-face:{}:{}", f.photo, f.index), r);// a suggested name along the bottom: a click accepts it for this face (added after the tile, so it wins there)let strip = Rect::from_min_max(pos2(r.left(), r.bottom() - 20.0), r.right_bottom());let accept = f.suggestion.as_ref().map(|_| ui.interact(strip, egui::Id::unique(("unnamed-accept", f.photo, f.index)), Sense::click()));if let Some(a) = &accept {- register(ui.ctx(), format!("unnamed-accept:{}:{}", f.photo, f.index), a.rect);+ register(ui, format!("unnamed-accept:{}:{}", f.photo, f.index), a.rect);}let hovered = resp.hovered() || accept.as_ref().is_some_and(|a| a.hovered());let p = ui.painter();diff --git a/crates/ui-egui/src/print_view.rs b/crates/ui-egui/src/print_view.rsindex 2491f8abb..4a9940307 100644--- a/crates/ui-egui/src/print_view.rs+++ b/crates/ui-egui/src/print_view.rs@@ -105,14 +105,14 @@ fn length(ui: &mut Ui, id: &str, inches: f64, unit: Unit, min_in: f64, max_in: f.max_decimals(decimals(unit)).suffix(format!(" {}", unit.label())),);- register(ui.ctx(), format!("drag:{id}"), r.rect);+ register(ui, format!("drag:{id}"), r.rect);r.changed().then(|| unit.to_inches(v))}fn check(ui: &mut Ui, id: &str, label: &str, value: bool) -> Option<bool> {let mut v = value;let r = ui.checkbox(&mut v, crate::i18n::tr(label));- register(ui.ctx(), format!("check:{id}"), r.rect);+ register(ui, format!("check:{id}"), r.rect);r.changed().then_some(v)}@@ -130,7 +130,7 @@ fn choice<V: PartialEq + Copy>(ui: &mut Ui, id: &str, options: &[(V, &str)], curfn colour(ui: &mut Ui, id: &str, rgb: [u8; 3]) -> Option<[u8; 3]> {let mut c = rgb;let r = ui.color_edit_button_srgb(&mut c);- register(ui.ctx(), format!("color:{id}"), r.rect);+ register(ui, format!("color:{id}"), r.rect);(c != rgb).then_some(c)}@@ -284,7 +284,7 @@ fn settings(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi,}let mut pt = im.stroke_width_pt;let r = ui.add(egui::DragValue::new(&mut pt).range(0.0..=36.0).speed(0.05).max_decimals(2).suffix(" pt"));- register(ui.ctx(), "drag:printStrokeWidth", r.rect);+ register(ui, "drag:printStrokeWidth", r.rect);if r.changed() {patch(app, &ctx, json!({"image": {"strokeWidthPt": pt}}));}@@ -303,9 +303,9 @@ fn settings(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi,row(ui, t, "Grid", |ui| {let (mut c, mut r) = (g.columns, g.rows);let a = ui.add(egui::DragValue::new(&mut c).range(1..=layout::MAX_GRID).suffix(" cols"));- register(ui.ctx(), "drag:printColumns", a.rect);+ register(ui, "drag:printColumns", a.rect);let b = ui.add(egui::DragValue::new(&mut r).range(1..=layout::MAX_GRID).suffix(" rows"));- register(ui.ctx(), "drag:printRows", b.rect);+ register(ui, "drag:printRows", b.rect);if a.changed() || b.changed() {patch(app, &ctx, json!({"layout": {"grid": {"columns": c, "rows": r}}}));}@@ -415,7 +415,7 @@ fn settings(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi,}});crate::widgets::name_combo(&c.response, crate::i18n::tr("Paper"));- register(ui.ctx(), "combo:printPaper", c.response.rect);+ register(ui, "combo:printPaper", c.response.rect);});if l.page.paper.eq_ignore_ascii_case("custom") {row(ui, t, "Size", |ui| {@@ -471,7 +471,7 @@ fn settings(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi,row(ui, t, "Resolution", |ui| {let mut ppi = st.job.ppi;let r = ui.add(egui::DragValue::new(&mut ppi).range(72.0..=720.0).speed(1.0).max_decimals(0).suffix(" ppi"));- register(ui.ctx(), "drag:printPpi", r.rect);+ register(ui, "drag:printPpi", r.rect);if r.changed() {patch(app, &ctx, json!({"job": {"ppi": ppi}}));}@@ -502,7 +502,7 @@ fn print_job_color(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, color: &Prilet c = egui::ComboBox::from_id_salt("print-profile").width(190.0).selected_text(shown.clone()).show_ui(ui, |ui| {for (space, label) in [(ManagedSpace::Srgb, "Managed by Printer (sRGB)"), (ManagedSpace::AdobeRgb, "Managed by Printer (Adobe RGB)")] {let r = ui.selectable_label(color.profile == managed(space), crate::i18n::tr(label));- register(ui.ctx(), format!("item:printProfile-{}", to_value(space).as_str().unwrap_or_default()), r.rect);+ register(ui, format!("item:printProfile-{}", to_value(space).as_str().unwrap_or_default()), r.rect);if r.clicked() && color.profile != managed(space) {patch_color(app, &ctx, "profile", to_value(managed(space)));}@@ -512,12 +512,12 @@ fn print_job_color(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, color: &Pri}if app.services.pick_display_profile.is_some() {let r = ui.selectable_label(false, crate::i18n::tr("Other…"));- register(ui.ctx(), "item:printProfile-other", r.rect);+ register(ui, "item:printProfile-other", r.rect);pick |= r.clicked();}});crate::widgets::name_combo(&c.response, crate::i18n::tr("Profile"));- register(ui.ctx(), "combo:printProfile", c.response.rect);+ register(ui, "combo:printProfile", c.response.rect);});if pick && let Some(path) = app.services.pick_display_profile.as_mut().and_then(|pick| pick().into_iter().next()) {patch_color(app, &ctx, "profile", json!({"kind": "icc", "path": path}));@@ -536,7 +536,7 @@ fn print_job_color(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, color: &Prirow(ui, t, label, |ui| {let mut v = value;let r = ui.add(egui::DragValue::new(&mut v).range(-100.0..=100.0).speed(0.5).max_decimals(0));- register(ui.ctx(), format!("drag:print{label}"), r.rect);+ register(ui, format!("drag:print{label}"), r.rect);if r.changed() {patch_color(app, &ctx, key, json!(v));}@@ -591,7 +591,6 @@ impl Sheet {}fn preview(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi, st: &PrintSettings, ids: &[PhotoId], pages: usize) {- let ctx = ui.ctx().clone();// room for the page buttons and, for a package, the selected cell's row (which may wrap)let footer = if st.layout.style.is_package() { 104.0 } else { 44.0 };let size = vec2(ui.available_width(), (ui.available_height() - footer).max(120.0));@@ -607,7 +606,7 @@ fn preview(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi, slet inner = Rect::from_min_max(area.min + vec2(ruler, ruler), area.max).shrink(14.0);let scale = ((inner.width() as f64 / pw).min(inner.height() as f64 / ph) as f32).max(1.0);let sheet = Sheet { page: Rect::from_center_size(inner.center(), vec2(pw as f32, ph as f32) * scale), scale };- register(&ctx, "print:page", sheet.page);+ register(ui, "print:page", sheet.page);painter.rect_filled(sheet.page.translate(vec2(2.0, 3.0)), 0.0, Color32::from_black_alpha(70));let bg = st.page.background;@@ -657,7 +656,7 @@ fn preview(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi, slet mut shown = Vec::new();for (i, (r, photo)) in cells.iter().enumerate() {let rect = sheet.rect(r);- register(&ctx, format!("print:gridcell:{i}"), rect);+ register(ui, format!("print:gridcell:{i}"), rect);shown.extend(paint_cell(app, &painter, t, st, rect, *photo, &sheet, r));}page_options(&painter, st, &sheet, &shown, pu.page + 1);@@ -670,7 +669,7 @@ fn preview(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi, spu.selected = None;}let label = ui.label(egui::RichText::new(format!("{} {} / {}", crate::i18n::tr("Page"), pu.page + 1, pages)).color(t.text));- register(ui.ctx(), "print:pageLabel", label.rect);+ register(ui, "print:pageLabel", label.rect);if text_button(ui, "printPageNext", "▶", false).clicked() && pu.page + 1 < pages {pu.page += 1;pu.selected = None;@@ -712,7 +711,7 @@ fn package_cells(let rect = sheet.rect(&c.rect);paint_cell(app, painter, t, st, rect, photo, sheet, &c.rect);let resp = ui.interact(rect, egui::Id::unique(("print-cell", c.id)), Sense::click_and_drag());- register(&ctx, format!("print:cell:{}", c.id), rect);+ register(ui, format!("print:cell:{}", c.id), rect);if resp.clicked() || resp.drag_started() {pu.selected = Some(c.id);}@@ -754,7 +753,7 @@ fn package_cells(let handle = Rect::from_center_size(rect.right_bottom(), Vec2::splat(HANDLE));painter.rect_filled(handle, 2.0, t.accent);let resp = ui.interact(handle, egui::Id::unique(("print-resize", sel.id)), Sense::drag());- register(&ctx, format!("print:resize:{}", sel.id), handle);+ register(ui, format!("print:resize:{}", sel.id), handle);if resp.drag_started() {pu.drag = Some(Drag { cell: sel.id, origin: sel.rect, resize: true, press: press_origin(ui, &resp), total: Vec2::ZERO });}diff --git a/crates/ui-egui/src/progress.rs b/crates/ui-egui/src/progress.rsindex 9db1f8c25..ab7ba9603 100644--- a/crates/ui-egui/src/progress.rs+++ b/crates/ui-egui/src/progress.rs@@ -116,7 +116,7 @@ impl Progress {info});if let Some(w) = &self.widget {- crate::widgets::register(ui.ctx(), w.clone(), rect);+ crate::widgets::register(ui, w.clone(), rect);}if !ui.is_rect_visible(rect) {return resp;diff --git a/crates/ui-egui/src/rating.rs b/crates/ui-egui/src/rating.rsindex 4faf48b9e..8b1183eb6 100644--- a/crates/ui-egui/src/rating.rs+++ b/crates/ui-egui/src/rating.rs@@ -142,7 +142,7 @@ impl Rating {let sense = if i == stop || ui.memory(|m| m.has_focus(id)) { Sense::click() } else { Sense::CLICK };let resp = ui.interact(r, id, sense);announce_selected(&resp, format!("{} ★", i + 1), i < self.rating);- register(ui.ctx(), self.widget_id(i + 1), r);+ register(ui, self.widget_id(i + 1), r);if resp.hovered() {hover_n = Some(i + 1);}@@ -201,7 +201,7 @@ pub fn favorite_button(ui: &mut Ui, widget: String, favorite: bool, name: &str)announce_selected(&resp, name, favorite);// (rows scrolled out of view can't be clicked)if ui.is_rect_visible(r) {- register(ui.ctx(), widget, r);+ register(ui, widget, r);}if resp.hovered() {ui.painter().rect_filled(r, 4.0, t.hover.gamma_multiply(0.7));diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rsindex 9ae941661..e7b96644e 100644--- a/crates/ui-egui/src/shortcuts.rs+++ b/crates/ui-egui/src/shortcuts.rs@@ -367,8 +367,13 @@ pub fn handle(app: &mut LightcraftApp, ctx: &egui::Context) {if !matches!(app.ui.dialog, Some(crate::state::Dialog::Shortcuts)) {app.recording_shortcut = None;}- // Dialogs own their keys (including Esc and text editing); background photo actions wait.- if app.ui.dialog.is_some() {+ // Dialogs own their keys (including Esc and text editing); background photo actions wait. A+ // quit prompt or settings notice owns every key too: its Foreground dim only blocks the+ // pointer, so without this a rating or navigation shortcut would still act behind it. The+ // blocking library window (error or launch list) owns all app shortcuts for every settled+ // frame, not only its shield pass; its own list keys are consumed earlier by+ // `library_problem::logic`, and its buttons remain reachable through the control channel.+ if app.ui.dialog.is_some() || crate::panels::notices::blocks_input(app) || crate::panels::library_problem::blocks_dialog_input(app) {return;}if app.recording_shortcut.is_none() && app.ui.name_edit.is_none() && crate::panels::person::handle_bulk_key(app, ctx) {diff --git a/crates/ui-egui/src/sync.rs b/crates/ui-egui/src/sync.rsindex e349f694b..3ebf9ce3e 100644--- a/crates/ui-egui/src/sync.rs+++ b/crates/ui-egui/src/sync.rs@@ -184,7 +184,7 @@ pub fn body(app: &LightcraftApp, ui: &mut egui::Ui, dlg: &mut Dialog) {}let choice = |ui: &mut egui::Ui, on: &mut bool, n: usize, text: String, widget: &str| {let r = ui.add_enabled(n > 0, egui::Checkbox::new(on, text));- crate::widgets::register(ui.ctx(), widget, r.rect);+ crate::widgets::register(ui, widget, r.rect);};let count = |text: &str, n: usize| format!("{} ({n})", crate::i18n::tr(text));let dim = |ui: &mut egui::Ui, s: &str| ui.label(egui::RichText::new(s).color(t.text_dim));diff --git a/crates/ui-egui/src/tests_drop_import.rs b/crates/ui-egui/src/tests_drop_import.rsindex 837d60c76..8b6bf3dfd 100644--- a/crates/ui-egui/src/tests_drop_import.rs+++ b/crates/ui-egui/src/tests_drop_import.rs@@ -147,6 +147,31 @@ fn a_drop_while_a_dialog_is_open_leaves_the_dialog_and_imports_nothing() {assert!(h.app.ui.toast.is_some(), "the person is told why");}+/// A prompt owns the library and the top layer: a drop while it is up stays queued (it is not+/// imported behind the prompt), and the drop-hover card is not painted above it.+#[test]+fn a_drop_and_its_hover_card_wait_behind_a_notice_prompt() {+ let dir = Scratch::new("prompt");+ let mut h = app(&dir);+ h.app.notices.push("The settings file could not be read and was reset.".into());+ h.step();+ h.step();+ assert!(h.app.widgets.iter().any(|(w, _)| w == "button:noticeOk"), "the notice is laid out");+ drop_files(&mut h, &[dir.path("trip")], true);+ assert!(!overlay(&h), "the drop-hover Tooltip layer must not cover the prompt");+ assert!(h.app.widgets.iter().any(|(w, _)| w == "button:noticeOk"), "the prompt still owns the window");+ drop_files(&mut h, &[dir.path("trip")], false);+ assert_eq!(photos(&h), 0, "nothing was imported behind the prompt");+ assert!(h.app.ui.dialog.is_none() && h.app.import.is_none() && h.app.scan.is_none(), "the drop was not handled yet");+ assert_eq!(h.app.dropped_files.len(), 1, "the dropped folder is queued until the prompt is gone");+ assert_eq!(h.app.notices.len(), 1, "the notice is still up");+ let r = h.request("ui.clickWidget", json!({"id": "button:noticeOk"}), T);+ assert_eq!(r["ok"], true, "{r}");+ assert!(h.app.notices.is_empty(), "OK dismisses the notice");+ assert!(h.step_until(SETTLE, |h| matches!(h.app.ui.dialog, Some(Dialog::Import { .. }))), "the queued drop opens its review after the prompt");+ assert_eq!(photos(&h), 0, "the review still imports nothing before it is confirmed");+}+/// The scan of a dropped folder finishing while another dialog is open (the face model's licence, Settings…)/// keeps that dialog; the review opens, with the scan's photos, once it is closed.#[test]diff --git a/crates/ui-egui/src/tests_keyword_list.rs b/crates/ui-egui/src/tests_keyword_list.rsindex bdeaef0dc..579d79867 100644--- a/crates/ui-egui/src/tests_keyword_list.rs+++ b/crates/ui-egui/src/tests_keyword_list.rs@@ -456,8 +456,8 @@ fn ticking_a_keyword_keeps_the_list_in_place() {assert!(box_moved, "the box changed height (the list was held, not left alone)");}-/// At the top of the panel the box is in sight: a ticked keyword's chip pushes the list down,-/// as before.+/// At the top of the panel the box is in sight: adding keyword chips pushes the list down+/// without scrolling the panel. Checkbox interaction is covered separately above.#[test]fn at_the_top_the_box_grows_in_sight() {let (mut h, ids) = keywords_panel_at([1400.0, 640.0]);@@ -465,7 +465,10 @@ fn at_the_top_the_box_grows_in_sight() {let (title, box_top) = (rect(&h, "keywordList:topLevel"), rect(&h, "field:keyword"));for k in ["aaa1", "aaa2", "aaa3", "aaa4", "aaa5", "aaa6"] {run(&mut h, "keyword.create", json!({"name": k}));- ask(&mut h, "ui.clickWidget", json!({"id": format!("keywordCheck:{k}")}));+ // Growing chips eventually push later rows outside this short viewport. Add through+ // the command so this layout regression never relies on clicking a clipped checkbox.+ run(&mut h, "photo.setMeta", json!({"ids": ids, "addKeywords": [k]}));+ assert!(ids.iter().all(|id| keywords_of(&h, *id).iter().any(|keyword| keyword == k)), "{k} was added to both photos");}assert_eq!(rect(&h, "field:keyword"), box_top, "the panel stays at its top");assert!(rect(&h, "keywordList:topLevel").top() > title.top(), "the chips pushed the list down");diff --git a/crates/ui-egui/src/tests_library_problem.rs b/crates/ui-egui/src/tests_library_problem.rsindex 10783ff15..de61b3653 100644--- a/crates/ui-egui/src/tests_library_problem.rs+++ b/crates/ui-egui/src/tests_library_problem.rs@@ -16,6 +16,63 @@ fn has(h: &Headless, id: &str) -> bool {h.app.widgets.iter().any(|(w, _)| w == id)}+/// A settings notice owns the frame: the launch list / library-error window is another+/// `Foreground` area and must not be drawn above the prompt or consume its keys.+#[test]+fn a_notice_prompt_hides_the_library_problem_window_and_takes_its_keys() {+ let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() });+ let mut h = Headless::new(app, [1300.0, 900.0], 1.0);+ h.app.library_problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ h.step();+ h.step();+ assert!(has(&h, "button:libraryRetry"), "the library problem window is shown without a prompt");+ h.app.notices.push("The settings file could not be read and was reset.".into());+ h.step();+ h.step();+ assert!(has(&h, "button:noticeOk"), "the settings notice is laid out");+ assert!(!has(&h, "button:libraryRetry"), "the library problem window is not drawn above the prompt");+ let r = h.request("ui.key", json!({"key": "Escape"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.app.notices.is_empty(), "Escape safely dismissed the notice");+ assert!(!h.app.ui.quit, "the prompt's Escape did not reach the library window");+ assert!(has(&h, "button:libraryRetry"), "the library problem window returns after the prompt");+}++/// The launch list's own arrow/Return/Escape handling must stay still while a settings notice is+/// up. Use a real chooser: with the old error window this assertion could never reach+/// `chooser_keys` at all.+#[test]+fn a_notice_prompt_over_the_launch_list_takes_escape_without_quitting_it() {+ let mut app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() });+ app.ui.settings.recent_libraries = vec!["/no/such/library-one".into(), "/no/such/library-two".into()];+ app.ui.settings.library_path = "/no/such/library-one".into();+ app.library_problem = Some(LibraryProblem::choose(&app.ui.settings));+ let mut h = Headless::new(app, [1300.0, 900.0], 1.0);+ h.step();+ h.step();+ assert!(has(&h, "button:libraryOpen"), "the launch list is shown without a prompt");+ let selected = h.app.library_problem.as_ref().and_then(|p| p.chooser.as_ref()).map(|c| c.selected);+ h.app.notices.push("The settings file could not be read and was reset.".into());+ h.step();+ h.step();+ assert!(has(&h, "button:noticeOk"), "the settings notice is laid out");+ assert!(!has(&h, "button:libraryOpen"), "the launch list is not drawn above the prompt");+ let r = h.request("ui.key", json!({"key": "Escape"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ h.step();+ assert!(h.app.notices.is_empty(), "Escape safely dismissed the notice");+ assert!(!h.quit_requested(), "the prompt's Escape did not reach the launch list");+ assert!(h.app.library_problem.is_some(), "the launch list stays");+ assert_eq!(+ h.app.library_problem.as_ref().and_then(|p| p.chooser.as_ref()).map(|c| c.selected),+ selected,+ "the prompt's Escape did not move the launch-list selection"+ );+ assert!(has(&h, "button:libraryOpen"), "the launch list returns after the prompt");+}+#[test]fn unopenable_library_asks_instead_of_running_a_demo() {let dir = std::env::temp_dir().join(format!("lc-ui-libproblem-{}", std::process::id()));@@ -101,3 +158,575 @@ fn unopenable_library_asks_instead_of_running_a_demo() {drop(h);let _ = std::fs::remove_dir_all(&dir);}++/// Pressing the dim raises its egui area. The blocking window must be moved back above it, or its+/// own buttons are covered: the click then reports a no-op success and the state never changes.+#[test]+fn a_backdrop_press_keeps_the_library_window_above_its_dim() {+ let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() });+ let mut h = Headless::new(app, [1000.0, 760.0], 1.0);+ h.app.library_problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ assert!(h.settle(Duration::from_secs(20)), "the library window settles");+ assert!(has(&h, "button:libraryTemporary"), "the window is laid out");+ // Outside the centred window: on the full-screen dim, which egui raises when pressed.+ let at = egui::pos2(10.0, 10.0);+ let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(at), press(true), press(false)]);+ h.step();+ h.step();+ assert!(h.app.library_problem.as_ref().is_some_and(|p| !p.dismissed), "the backdrop itself chose nothing");+ let r = h.request("ui.clickWidget", json!({"id": "button:libraryTemporary"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(+ h.app.library_problem.as_ref().is_some_and(|p| p.dismissed),+ "the window's own button made the actual state change after the backdrop press"+ );+ assert!(!has(&h, "button:libraryRetry"), "Continue Without Saving removed the blocking window");+}++/// The library window is another foreground modal over Settings: its raw Escape and outside-click+/// handlers must stay still while it is on screen, then the dialog keeps its ordinary behaviour.+#[test]+fn the_library_window_blocks_settings_escape_and_the_backdrop() {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 900.0],+ 1.0,+ );+ h.step();+ assert!(h.app.run("app.settings", json!({})).is_ok(), "Settings opens");+ assert!(h.settle(Duration::from_secs(20)), "Settings settles");+ h.app.ui.settings.close_dialogs_outside = true;+ h.app.library_problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ assert!(h.settle(Duration::from_secs(20)), "the library window settles");+ assert!(has(&h, "button:libraryRetry"), "the library window is laid out");+ // Escape belongs to the window, not to Settings behind it (the window has no Escape action+ // for this error; the launch list handles its own keys separately).+ let r = h.request("ui.key", json!({"key": "Escape"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Escape closed Settings behind the library window");+ assert!(h.app.library_problem.is_some(), "the library window stayed");+ // The outside-click preference reads raw pointer events without asking the layer, so it must+ // be gated too. The dim swallows the click itself.+ let at = egui::pos2(10.0, 890.0);+ let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(at), press(true), press(false)]);+ h.step();+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "the backdrop click closed Settings behind the library window");+ // Positive control: with the library window gone, Settings' own Escape works again.+ h.app.library_problem = None;+ h.step();+ let r = h.request("ui.key", json!({"key": "Escape"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.app.ui.dialog.is_none(), "Escape closes Settings without the library window");+}++/// A dialog opened before the launch list (Settings) is not the list's own New Library prompt:+/// the list stays visible above it and keeps owning Escape, instead of vanishing and letting the+/// unrelated dialog's raw handlers run.+#[test]+fn an_unrelated_open_dialog_does_not_own_the_launch_list_or_its_barrier() {+ let settings = crate::state::AppSettings {+ recent_libraries: vec!["/no/such/library-one".into()],+ library_path: "/no/such/library-one".into(),+ ..Default::default()+ };+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 900.0],+ 1.0,+ );+ h.settle(T);+ assert!(h.app.run("app.settings", json!({})).is_ok(), "Settings opens first");+ h.step();+ let mut problem = LibraryProblem::choose(&settings);+ if let Some(c) = problem.chooser.as_mut() {+ c.over = Some(h.app.session.library_generation());+ }+ h.app.library_problem = Some(problem);+ h.step();+ h.step();+ assert!(has(&h, "button:libraryOpen"), "the launch list stays above the unrelated Settings dialog");+ assert!(crate::panels::library_problem::blocks_dialog_input(&h.app), "the launch list owns input over an unrelated dialog");+ let r = h.request("ui.key", json!({"key": "Escape"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.app.library_problem.is_none(), "the launch list's own Escape kept the open library");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Escape did not close Settings behind the launch list");+}++/// The launch list's own Escape is not a Settings raw handler: with no notice prompt blocking it,+/// it still quits from an empty list (the library chooser's long-standing behaviour).+#[test]+fn the_launch_list_still_quits_on_escape_without_a_notice() {+ let mut app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() });+ app.ui.settings.recent_libraries = vec!["/no/such/library-one".into(), "/no/such/library-two".into()];+ app.ui.settings.library_path = "/no/such/library-one".into();+ app.library_problem = Some(LibraryProblem::choose(&app.ui.settings));+ let mut h = Headless::new(app, [1300.0, 900.0], 1.0);+ h.step();+ h.step();+ assert!(has(&h, "button:libraryOpen"), "the launch list is shown without a prompt");+ let r = h.request("ui.key", json!({"key": "Escape"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.quit_requested(), "the launch list's own Escape still quits when no notice blocks it");+}++/// A blocking library window created after `raw_input_hook` must not let the background text+/// field swallow the same frame's host text before the new modal area has settled. The same+/// sequence without the window is the positive control.+fn creation_frame_drops_background_text(problem: LibraryProblem, button: &str) {+ let app = LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() });+ let mut h = Headless::new(app, [1200.0, 760.0], 1.0);+ h.settle(T);+ let r = h.request("ui.clickWidget", json!({"id": "field:search"}), T);+ assert_eq!(r["ok"], true, "the search field takes focus: {r}");+ let r = h.request("ui.text", json!({"text": "base"}), T);+ assert_eq!(r["ok"], true, "{r}");+ assert_eq!(h.app.ui.search, "base");++ h.events.push(egui::Event::Text("leak".into()));+ let mut problem = Some(problem);+ h.set_after_raw_input_hook(move |app| app.library_problem = problem.take());+ h.step();+ assert_eq!(h.app.ui.search, "base", "the new library window's creation frame dropped the background text");+ assert!(!h.view.ctx.text_edit_focused(), "the background text field's focus was surrendered");+ h.step();+ assert!(has(&h, button), "the blocking window is laid out after its shield pass");++ // Positive control: without the window, the same focused field receives text in one frame.+ h.app.library_problem = None;+ h.step();+ let r = h.request("ui.clickWidget", json!({"id": "field:search"}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.events.push(egui::Event::Text("after".into()));+ h.step();+ assert_eq!(h.app.ui.search, "baseafter", "ordinary background text input still works");+}++#[test]+fn library_error_and_chooser_creation_frames_drop_background_text() {+ let settings = crate::state::AppSettings {+ recent_libraries: vec!["/no/such/library-one".into()],+ library_path: "/no/such/library-one".into(),+ ..Default::default()+ };+ creation_frame_drops_background_text(LibraryProblem::new("/no/such/library", "a test error"), "button:libraryRetry");+ creation_frame_drops_background_text(LibraryProblem::choose(&settings), "button:libraryOpen");+}++/// The library barrier removes events that `raw_input_hook` already injected. Like the prompt+/// barrier, it must fail the owning gesture; otherwise `ui.text`, `ui.hoverWidget` and synthetic+/// paste can report `ok: true` for input no panel ever saw. The window is created after the hook,+/// exactly as `alt_at_launch` or a command drawn late in the frame can do.+fn creation_after_raw_input_cancels_injected_text(problem: LibraryProblem) {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ let (tx, rx) = std::sync::mpsc::channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.text".into(), json!({"text": "leak"}), tx).expect("the text gesture is admitted");+ h.step(); // resolve: one Text event is queued+ assert_eq!(h.app.synthetic.len(), 1, "the text gesture is ready to inject");+ let mut problem = Some(problem);+ h.set_after_raw_input_hook(move |app| app.library_problem = problem.take());+ h.step(); // raw hook injects; the hook creates the window; the barrier drops the batch+ let reply = rx.try_recv().expect("the dropped gesture answers");+ assert_eq!(reply["ok"], false, "the library barrier must not report a false success: {reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("blocking library window"), "{reply}");+ assert!(h.app.synthetic.is_empty(), "the dropped text batch left nothing queued");+ assert!(h.app.pending_gestures.is_empty(), "the dropped gesture was canceled, not kept");+}++#[test]+fn library_error_and_chooser_creation_after_raw_input_cancel_an_injected_gesture() {+ let settings = crate::state::AppSettings {+ recent_libraries: vec!["/no/such/library-one".into()],+ library_path: "/no/such/library-one".into(),+ ..Default::default()+ };+ creation_after_raw_input_cancels_injected_text(LibraryProblem::new("/no/such/library", "a test error"));+ creation_after_raw_input_cancels_injected_text(LibraryProblem::choose(&settings));+}++/// `alt_at_launch` creates the chooser from `logic`, after `raw_input_hook` injected this frame's+/// synthetic batch. That later creation path must cancel the dropped gesture too.+#[test]+fn alt_launch_creation_after_raw_input_cancels_an_injected_gesture() {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ let (tx, rx) = std::sync::mpsc::channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.text".into(), json!({"text": "leak"}), tx).expect("the text gesture is admitted");+ h.step();+ assert_eq!(h.app.synthetic.len(), 1);+ h.app.alt_asks_for_library = true;+ h.time = 0.1; // stay inside the Alt-at-launch watch window regardless of settle time+ h.events.push(egui::Event::ModifiersChanged(egui::Modifiers::ALT));+ h.step(); // raw hook injects Text, then alt_at_launch creates the chooser and its barrier drops it+ assert!(h.app.library_problem.as_ref().and_then(|p| p.chooser.as_ref()).is_some(), "Alt at launch opened the chooser");+ let reply = rx.try_recv().expect("the dropped gesture answers");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("blocking library window"), "{reply}");+ assert!(h.app.synthetic.is_empty() && h.app.pending_gestures.is_empty());+}++/// A held host press over a background control in the same frame as a library window created+/// after `raw_input_hook` is released by the window's first pass; its later release must not+/// become a background click.+#[test]+fn a_held_background_press_is_released_when_a_library_window_appears_after_raw_input() {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 900.0],+ 1.0,+ );+ h.step();+ assert!(h.app.run("app.settings", json!({})).is_ok(), "Settings opens");+ assert!(h.settle(T), "Settings settles");+ let id = "check:settings.confirmDelete";+ let at = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| rect.center()).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(at), press(true)]);+ h.set_after_raw_input_hook(|app| app.library_problem = Some(LibraryProblem::new("/no/such/library", "a test error")));+ h.step();+ assert!(h.app.library_problem.is_some(), "the library window is shown");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the creation pass released the held press");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the press did not reach Settings");+ h.events.push(press(false));+ h.step();+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the release did not become a background click");+ assert!(h.app.library_problem.is_some(), "the release did not activate the background control");+}++/// A library window first seen after `raw_input_hook` drops wheel, key and background pointer+/// input already accepted for the pass. Observed on egui's actual input state, not on the event+/// list the barrier edits.+#[test]+fn a_library_window_first_seen_after_begin_pass_drops_background_input() {+ let mut h =+ Headless::new(LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }), [800.0, 600.0], 1.0);+ h.settle(T);+ let _ = pass_log(&mut h);+ let at = egui::pos2(30.0, 40.0);+ h.events.extend([+ egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE },+ egui::Event::MouseWheel {+ unit: egui::MouseWheelUnit::Line,+ delta: egui::vec2(0.0, 2.0),+ phase: egui::TouchPhase::Start,+ source: egui::MouseWheelSource::Wheel,+ modifiers: egui::Modifiers::NONE,+ },+ egui::Event::PointerMoved(at),+ egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE },+ egui::Event::ModifiersChanged(egui::Modifiers::NONE),+ ]);+ let mut problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ h.set_after_raw_input_hook(move |app| app.library_problem = problem.take());+ h.step();+ assert!(h.app.library_problem.is_some(), "the window was created after this pass's raw input");+ let (down, keys, scroll) = h.view.ctx.input(|i| (i.pointer.any_down(), i.keys_down.clone(), i.smooth_scroll_delta));+ assert!(!down, "the held background pointer press was released");+ assert!(keys.is_empty(), "the background key press was dropped: {keys:?}");+ assert_eq!(scroll, egui::Vec2::ZERO, "wheel scrolling was cleared");+ assert!(!h.view.ctx.input(|i| i.key_pressed(egui::Key::A)), "the dropped key press is not reported to panels");+ // The creation frame is a dedicated shield pass that egui discards, then the background pass.+ assert_eq!(+ pass_log(&mut h),+ vec![crate::panels::library_problem::LibraryPass::Shield, crate::panels::library_problem::LibraryPass::Background],+ "the creation frame draws only the window and is discarded before the background pass"+ );+}++/// A Touch Start in one pass and its End/Cancel in a pass where a library window appears after+/// `raw_input_hook` must leave egui's own touch state empty: `begin_pass` processes the release+/// before the barrier filters the events. Asserting that the End/Cancel events merely survive the+/// filter would not prove the private touch state this protects.+fn touch_release_clears_egui_touch_state_when_the_library_window_appears_after_begin_pass(phase: egui::TouchPhase) {+ let mut h =+ Headless::new(LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }), [800.0, 600.0], 1.0);+ h.settle(T);+ let at = egui::pos2(30.0, 40.0);+ let touch = |phase| egui::Event::Touch { device_id: egui::TouchDeviceId(1), id: egui::TouchId(1), phase, pos: at, force: None };+ h.events.push(touch(egui::TouchPhase::Start));+ h.step();+ assert!(h.view.ctx.input(|i| i.any_touches()), "the touch is down before the window appears");+ let mut problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ h.set_after_raw_input_hook(move |app| app.library_problem = problem.take());+ h.events.push(touch(phase));+ h.step();+ assert!(h.app.library_problem.is_some(), "the window was created after this pass's raw input");+ assert!(!h.view.ctx.input(|i| i.any_touches()), "{phase:?} must clear egui's own touch state, not only stay in the filtered event batch");+}++#[test]+fn touch_end_and_cancel_clear_egui_touch_state_when_the_library_window_appears_after_begin_pass() {+ touch_release_clears_egui_touch_state_when_the_library_window_appears_after_begin_pass(egui::TouchPhase::End);+ touch_release_clears_egui_touch_state_when_the_library_window_appears_after_begin_pass(egui::TouchPhase::Cancel);+}++fn select_first_photo(h: &mut Headless) -> lightcraft_catalog::PhotoId {+ let photo = h.app.session.visible_cloned()[0];+ let r = h.request("engine.execute", json!({"command": "library.select", "params": {"ids": [photo.0]}}), T);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ photo+}++fn press_rating(h: &mut Headless, key: egui::Key) {+ for pressed in [true, false] {+ h.events.push(egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers: egui::Modifiers::NONE });+ }+}++fn rating(h: &Headless, photo: lightcraft_catalog::PhotoId) -> u8 {+ h.app.session.catalog.photo(photo).expect("the selected photo").rating+}++/// Take the recorded library-barrier passes (clearing them). A shielded return frame must be+/// visible here even while the global shortcut guard would also keep the rating shortcut from+/// acting: the sequence itself is what these regressions protect.+fn pass_log(h: &mut Headless) -> Vec<crate::panels::library_problem::LibraryPass> {+ std::mem::take(&mut h.app.library_passes)+}++/// The frame that just ran returned from a hidden/unsettled blocking window: it must first be a+/// dedicated shield pass that is discarded, then a background pass. The next frame must be+/// ordinary (no repeated transition). Removing the shield pass, its discard or its settlement+/// changes this sequence; the rating shortcut alone would still stay blocked.+fn assert_shielded_return(h: &mut Headless, what: &str) {+ use crate::panels::library_problem::LibraryPass;+ assert_eq!(+ pass_log(h),+ vec![LibraryPass::Shield, LibraryPass::Background],+ "{what}: the return frame must shield (and discard) the window's first pass, then draw the background"+ );+ h.step();+ assert_eq!(pass_log(h), vec![LibraryPass::Background], "{what}: once settled, later frames draw normally without re-shielding");+}++/// A notice dismissed after the error window was already settled must shield the first frame that+/// draws the window again. A background rating shortcut injected on that frame would otherwise act+/// through the still-focused/background state while egui's hit test uses the previous pass.+#[test]+fn a_notice_dismissal_shields_the_library_windows_first_return_frame() {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ let photo = select_first_photo(&mut h);+ let before = rating(&h, photo);+ h.app.library_problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ h.step();+ h.step();+ assert!(has(&h, "button:libraryRetry"), "the error window is settled");+ h.app.notices.push("The settings file could not be read and was reset.".into());+ h.step();+ h.step();+ assert!(has(&h, "button:noticeOk") && !has(&h, "button:libraryRetry"), "the notice hides the settling window");+ h.events.push(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE });+ h.step();+ assert!(h.app.notices.is_empty(), "Escape dismissed the notice");+ // The dismissal happened during the draw; this clears that frame's background-only record.+ let _ = pass_log(&mut h);+ // This is the first frame in which the window is drawn again. The shortcut must be dropped.+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ assert_eq!(rating(&h, photo), before, "the first return frame did not let a shortcut act behind the library window");+ assert_shielded_return(&mut h, "notice dismissal");+ assert!(has(&h, "button:libraryRetry"), "the window is back");+ // A settled blocking window keeps owning the keyboard: shortcuts stay blocked on later frames.+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ h.step();+ assert_eq!(rating(&h, photo), before, "a settled library window did not block a background rating shortcut");+ // Positive control: once the blocking window is dismissed, the same shortcut works.+ h.app.library_problem = None;+ h.step();+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ h.step();+ assert_eq!(rating(&h, photo), 5, "ordinary shortcuts work once the blocking window is gone");+}++/// A library window created while a notice is up has never drawn its own shielded pass. Dismissing+/// the notice must not settle it from a frame where it was hidden by the prompt.+#[test]+fn a_library_window_created_under_a_notice_shields_the_first_frame_after_dismissal() {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ let photo = select_first_photo(&mut h);+ let before = rating(&h, photo);+ h.app.notices.push("The settings file could not be read and was reset.".into());+ h.step();+ h.step();+ assert!(has(&h, "button:noticeOk"));+ let mut problem = Some(LibraryProblem::new("/no/such/library", "a test error"));+ h.set_after_raw_input_hook(move |app| app.library_problem = problem.take());+ h.step();+ assert!(has(&h, "button:noticeOk") && !has(&h, "button:libraryRetry"), "the prompt still owns the frame");+ h.events.push(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE });+ h.step();+ assert!(h.app.notices.is_empty());+ let _ = pass_log(&mut h);+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ assert_eq!(rating(&h, photo), before, "the first frame after dismissal was shielded");+ assert_shielded_return(&mut h, "window created under a notice");+ assert!(has(&h, "button:libraryRetry"), "the window is drawn after its shield pass");+}++/// Closing New Library's own name dialog returns the launch list. The list was hidden for the+/// dialog, so the first pass that draws it again must be shielded rather than settling from the+/// dialog-closing pass.+#[test]+fn closing_the_new_library_dialog_shields_the_launch_lists_first_return_frame() {+ let settings = crate::state::AppSettings {+ recent_libraries: vec!["/no/such/library-one".into()],+ library_path: "/no/such/library-one".into(),+ ..Default::default()+ };+ let mut h = Headless::new(+ LightcraftApp::new(+ lightcraft_engine::Session::with_demo(),+ Services { png: None, pick_folder: Some(Box::new(|| -> Option<String> { None })), ..Default::default() },+ ),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ let photo = select_first_photo(&mut h);+ let before = rating(&h, photo);+ h.app.library_problem = Some(LibraryProblem::choose(&settings));+ h.settle(T);+ assert!(has(&h, "button:libraryOpen"), "the launch list is settled");+ assert!(h.app.run("app.newLibrary", json!({})).is_ok(), "New Library opens its name prompt");+ h.step();+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::TextPrompt { .. })), "the name dialog is open");+ assert!(!has(&h, "button:libraryOpen"), "the launch list yields to the dialog it opened");+ let cancel = h+ .app+ .widgets+ .iter()+ .rev()+ .find(|(id, _)| id == "button:dialogCancel")+ .map(|(_, rect)| rect.center())+ .expect("the dialog's Cancel is on screen");+ let press = |pressed| egui::Event::PointerButton { pos: cancel, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(cancel), press(true), press(false)]);+ h.step();+ assert!(h.app.ui.dialog.is_none(), "Cancel closed the New Library name dialog");+ // The dialog-closing frame drew the list but must not settle it.+ let _ = pass_log(&mut h);+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ assert_eq!(rating(&h, photo), before, "the launch list's first return frame is shielded");+ assert_shielded_return(&mut h, "New Library dialog cancel");+ assert!(has(&h, "button:libraryOpen"), "the launch list is back");+ // Positive control: dismissing the blocking window restores ordinary shortcuts.+ h.app.library_problem = None;+ h.step();+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ h.step();+ assert_eq!(rating(&h, photo), 5, "ordinary shortcuts work once the launch list is gone");+}++/// The banner's Open Library… reopens the window from inside the draw pass, after the background+/// panels already consumed this frame's input. The next frame must be the shielded first frame.+#[test]+fn the_banner_reopen_shields_the_first_input_frame() {+ let mut h = Headless::new(+ LightcraftApp::new(lightcraft_engine::Session::with_demo(), Services { png: None, ..Default::default() }),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ let photo = select_first_photo(&mut h);+ let before = rating(&h, photo);+ h.app.library_problem = Some(LibraryProblem { dismissed: true, ..LibraryProblem::new("/no/such/library", "a test error") });+ h.step();+ h.step();+ assert!(has(&h, "indicator:temporarySession"), "the temporary-session banner is shown");+ let reopen = h+ .app+ .widgets+ .iter()+ .rev()+ .find(|(id, _)| id == "button:libraryReopen")+ .map(|(_, rect)| rect.center())+ .expect("the banner button is on screen");+ let press = |pressed| egui::Event::PointerButton { pos: reopen, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(reopen), press(true), press(false)]);+ h.step();+ assert!(h.app.library_problem.as_ref().is_some_and(|p| !p.dismissed), "the banner reopened the window");+ assert!(has(&h, "button:libraryRetry"));+ // The reopen happened late in that draw, after its own background pass began.+ let _ = pass_log(&mut h);+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ assert_eq!(rating(&h, photo), before, "input on the frame after a banner reopen was shielded");+ assert_shielded_return(&mut h, "banner reopen");+ assert!(has(&h, "button:libraryRetry"), "the window is back after its shield pass");+ // Positive control: dismissing the blocking window restores ordinary shortcuts.+ h.app.library_problem = None;+ h.step();+ press_rating(&mut h, egui::Key::Num5);+ h.step();+ h.step();+ assert_eq!(rating(&h, photo), 5, "ordinary shortcuts work once the window is gone");+}++/// The chooser's own New Library text prompt is not a background barrier: `visible_mode` is None+/// while the dialog is open, so clipboard paste must reach that dialog's focused field.+#[test]+fn clipboard_pastes_into_the_launch_lists_own_text_prompt() {+ let settings = crate::state::AppSettings {+ recent_libraries: vec!["/no/such/library-one".into()],+ library_path: "/no/such/library-one".into(),+ ..Default::default()+ };+ let mut h = Headless::new(+ LightcraftApp::new(+ lightcraft_engine::Session::with_demo(),+ Services { png: None, pick_folder: Some(Box::new(|| -> Option<String> { None })), ..Default::default() },+ ),+ [1200.0, 760.0],+ 1.0,+ );+ h.settle(T);+ h.app.library_problem = Some(LibraryProblem::choose(&settings));+ h.settle(T);+ assert!(h.app.run("app.newLibrary", json!({})).is_ok(), "New Library opens its name prompt");+ h.step();+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::TextPrompt { .. })), "the name dialog is open");+ assert!(!crate::panels::library_problem::blocks_dialog_input(&h.app), "a dialog opened by the launch list is not a background barrier");+ h.view.clipboard = "pasted-name".into();+ let r = h.request("ui.clipboard", json!({"action": "paste"}), T);+ assert_eq!(r["ok"], true, "the chooser's own prompt accepts a paste: {r}");+ h.step();+ let Some(crate::state::Dialog::TextPrompt { value, .. }) = &h.app.ui.dialog else {+ panic!("the name dialog closed unexpectedly");+ };+ assert!(value.contains("pasted-name"), "the paste reached the chooser's own text field: {value:?}");+}diff --git a/crates/ui-egui/src/tests_lifecycle_037.rs b/crates/ui-egui/src/tests_lifecycle_037.rsindex 2da8b674e..bfb08f1b4 100644--- a/crates/ui-egui/src/tests_lifecycle_037.rs+++ b/crates/ui-egui/src/tests_lifecycle_037.rs@@ -3,6 +3,7 @@use std::sync::mpsc::{Receiver, Sender, channel};use std::sync::{Arc, Mutex};+use std::time::Duration;use crate::headless::Headless;use crate::render::{Slot, Tex};@@ -17,6 +18,23 @@ fn raw(size: egui::Vec2) -> egui::RawInput {egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, size)), ..Default::default() }}+fn key_event(key: egui::Key, pressed: bool, modifiers: egui::Modifiers) -> egui::Event {+ egui::Event::Key { key, physical_key: None, pressed, repeat: false, modifiers }+}++fn pointer_event(pos: egui::Pos2, pressed: bool) -> egui::Event {+ egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }+}++fn accesskit_action(action: egui::accesskit::Action, target_node: egui::accesskit::NodeId) -> egui::Event {+ egui::Event::AccessKitActionRequest(egui::accesskit::ActionRequest {+ action,+ target_tree: egui::accesskit::TreeId::ROOT,+ target_node,+ data: None,+ })+}+fn viewport_raw(size: egui::Vec2, visible: bool) -> egui::RawInput {let mut raw = raw(size);raw.viewports.entry(egui::ViewportId::ROOT).or_default().minimized = Some(!visible);@@ -462,22 +480,22 @@ impl egui::DroppedFile for TestDropped {#[cfg(not(target_arch = "wasm32"))]#[test]fn one_synthetic_batch_until_a_completed_pass_and_drops_wait_for_the_ui_phase() {+ let ctx = egui::Context::default();let mut app = app();app.fonts_ready = true;app.synthetic.push(egui::Event::PointerMoved(egui::pos2(4.0, 4.0)));let mut first = raw(egui::vec2(800.0, 600.0));- app.raw_input_hook(&mut first);+ app.raw_input_hook(&ctx, &mut first);assert_eq!(first.events.len(), 1, "one pointer move is injected");assert!(app.synthetic_in_flight);let mut second = raw(egui::vec2(800.0, 600.0));- app.raw_input_hook(&mut second);+ app.raw_input_hook(&ctx, &mut second);assert!(second.events.is_empty(), "no second step while the first waits for a UI pass");// Drops are queued by the hook even while a batch is in flight, but only the UI phase takes them.second.dropped_files.push(Arc::new(TestDropped(std::env::temp_dir().join("lightcraft-drop.txt"))));- app.raw_input_hook(&mut second);+ app.raw_input_hook(&ctx, &mut second);assert_eq!(app.dropped_files.len(), 1);- let ctx = egui::Context::default();frame(&ctx, raw(egui::vec2(800.0, 600.0)), |_| {});app.logic(&ctx);app.logic(&ctx);@@ -492,7 +510,7 @@ fn one_synthetic_batch_until_a_completed_pass_and_drops_wait_for_the_ui_phase()assert!(!app.synthetic_in_flight, "a completed UI pass consumed the batch");app.synthetic.push(egui::Event::PointerMoved(egui::pos2(9.0, 9.0)));let mut third = raw(egui::vec2(800.0, 600.0));- app.raw_input_hook(&mut third);+ app.raw_input_hook(&ctx, &mut third);assert_eq!(third.events.len(), 1, "the next batch is injected after the completed pass");}@@ -782,14 +800,15 @@ fn an_existing_screenshot_target_replaced_while_queued_is_not_overwritten() {#[test]fn ui_scroll_carries_validated_unit_phase_and_source() {let (mut app, ctx) = (app(), egui::Context::default());- let result = crate::control::gesture_events(+ let outcome = crate::control::gesture_events(&mut app,&ctx,"ui.scroll",&serde_json::json!({"source": "wheel", "unit": "line", "phase": "start", "dy": 1.0}),).expect("a wheel line step is valid");- assert_eq!(result, serde_json::Value::Null);+ assert_eq!(outcome.result, serde_json::Value::Null);+ assert!(outcome.target.is_none(), "scrolling has no widget target to revalidate");match app.synthetic.first().expect("one wheel event") {egui::Event::MouseWheel { unit, phase, source, .. } => {assert_eq!(*unit, egui::MouseWheelUnit::Line);@@ -835,6 +854,36 @@ fn ui_scroll_carries_validated_unit_phase_and_source() {assert!(app.synthetic.is_empty());}+#[test]+fn synthetic_pointer_requests_bound_clicks_and_drag_steps() {+ let (mut app, ctx) = (app(), egui::Context::default());+ app.widgets.push(("bounded:test".into(), egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(20.0, 20.0))));+ let max_clicks = crate::control::MAX_CLICKS;+ let max_steps = crate::control::MAX_DRAG_STEPS;++ for (method, params) in [+ ("ui.clickWidget", serde_json::json!({"id": "bounded:test", "count": u64::MAX})),+ ("ui.click", serde_json::json!({"x": 1.0, "y": 1.0, "count": u64::MAX})),+ ] {+ app.synthetic.clear();+ crate::control::gesture_events(&mut app, &ctx, method, ¶ms).expect("a huge click count is bounded, not refused");+ assert_eq!(app.synthetic.len(), 1 + 2 * max_clicks as usize, "{method}: one move and two events per click");+ let presses = app.synthetic.iter().filter(|e| matches!(e, egui::Event::PointerButton { pressed: true, .. })).count();+ assert_eq!(presses, max_clicks as usize, "{method}: the click count is capped");+ }++ for (method, params) in [+ ("ui.dragWidget", serde_json::json!({"id": "bounded:test", "toX": 50.0, "toY": 50.0, "steps": u64::MAX})),+ ("ui.drag", serde_json::json!({"x": 1.0, "y": 1.0, "toX": 50.0, "toY": 50.0, "steps": u64::MAX})),+ ] {+ app.synthetic.clear();+ crate::control::gesture_events(&mut app, &ctx, method, ¶ms).expect("a huge drag step count is bounded, not refused");+ assert_eq!(app.synthetic.len(), 3 + max_steps as usize, "{method}: press, release and the capped moves");+ let moves = app.synthetic.iter().filter(|e| matches!(e, egui::Event::PointerMoved(_))).count();+ assert_eq!(moves, 1 + max_steps as usize, "{method}: the step count is capped");+ }+}+#[test]fn a_gesture_never_uses_the_previous_widget_registry() {let ctx = egui::Context::default();@@ -879,6 +928,996 @@ fn a_gesture_cancels_when_the_view_changes_before_the_fresh_layout() {assert!(app.synthetic.is_empty());}+#[test]+fn a_widget_gesture_cancels_if_its_target_moves_between_resolution_and_the_press() {+ let ctx = egui::Context::default();+ let mut app = app();+ frame(&ctx, raw(egui::vec2(1000.0, 700.0)), |ui| app.logic(ui.ctx()));+ app.logic(&ctx);+ assert!(app.fonts_ready);+ // Resolve a click against a completed layout at the widget's old place.+ app.widgets.push(("moving:test".into(), egui::Rect::from_min_size(egui::pos2(10.0, 10.0), egui::vec2(30.0, 20.0))));+ let (tx, rx) = reply_channel();+ app.admit_gesture(&ctx, "ui.clickWidget".into(), serde_json::json!({"id": "moving:test"}), tx).expect("admitted");+ app.layout_epoch = app.layout_epoch.wrapping_add(1);+ app.resolve_pending_gestures(&ctx);+ assert_eq!(app.synthetic.len(), 3, "move, press and release are queued");+ assert!(rx.try_recv().is_err(), "nothing is answered at resolution");+ // The first pass consumes the move; the pointer now rests at the resolved point.+ let mut next = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut next);+ assert!(next.events.iter().any(|e| matches!(e, egui::Event::PointerMoved(p) if *p == egui::pos2(25.0, 20.0))));+ app.synthetic_in_flight = false;+ // The next completed layout puts the widget somewhere else. egui would attribute the press+ // in the following pass to whatever sits at the old coordinates; fail closed instead.+ app.widgets = vec![("moving:test".into(), egui::Rect::from_min_size(egui::pos2(100.0, 10.0), egui::vec2(30.0, 20.0)))];+ let mut next = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut next);+ assert!(next.events.is_empty(), "no press is delivered at the stale point");+ assert!(app.synthetic.is_empty(), "the rest of the canceled click is dropped");+ let reply = rx.try_recv().expect("the moved target answers once");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("moving:test"), "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("nothing was retargeted"), "{reply}");+ assert!(app.pending_gestures.is_empty());+}++#[test]+fn a_maximum_step_drag_is_delivered_past_the_five_second_stall_limit() {+ let mut h = Headless::new(app(), [900.0, 650.0], 1.0);+ h.step();+ h.step();+ assert!(h.app.fonts_ready);+ // A capped drag is delivered one event per host frame. At 1/60 s each the whole gesture takes+ // far longer than GESTURE_TIMEOUT_MS, so only a deadline refreshed by real progress lets it+ // finish; the old absolute deadline failed it (and every queued gesture) halfway through.+ let r = h.request(+ "ui.drag",+ serde_json::json!({+ "x": 30.0,+ "y": 30.0,+ "toX": 30.0,+ "toY": 30.0,+ "steps": crate::control::MAX_DRAG_STEPS,+ }),+ Duration::from_secs(90),+ );+ assert_eq!(r["ok"], true, "{r}");+ assert!(h.time() > 5.0, "the drag's simulated delivery outlived the old 5 s deadline: {}", h.time());+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.synthetic.is_empty());+}++#[test]+fn a_click_on_a_control_under_a_nonmodal_overlay_is_refused_without_activating_the_overlay() {+ let mut h = Headless::new(app(), [1400.0, 900.0], 1.0);+ let photo = h.app.session.visible_cloned()[0];+ let t = Duration::from_secs(20);+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ assert_eq!(h.request("ui.set", serde_json::json!({"view": "detail", "right": "edit"}), t)["ok"], true);+ h.app.ui.open_sections = vec!["light".to_string()];+ assert!(h.settle(Duration::from_secs(60)), "the edit panel settles");+ let id = "slider:light.exposure";+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == id), "{id} is on screen");+ let before = h.app.session.develop_of(photo).expect("its develop settings").light.exposure;+ // The quit prompt's Foreground dim and window own the pointer (and the notice barrier also+ // covers the control channel's own hit check). The settings slider remains registered+ // underneath it, and its rect still contains the press point.+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == "button:quitCancel"), "the overlay is shown");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": id}), Duration::from_secs(20));+ assert_eq!(r["ok"], false, "{r}");+ let error = r["error"].as_str().unwrap_or_default();+ assert!(error.contains(id), "{r}");+ assert!(error.contains("no longer visible"), "{r}");+ assert!(error.contains("nothing was retargeted"), "{r}");+ assert!(h.app.quit_prompt.is_some(), "the click did not activate (or dismiss) the overlay");+ let r = h.request("ui.dragWidget", serde_json::json!({"id": id, "dx": 12.0, "steps": 4}), Duration::from_secs(20));+ assert_eq!(r["ok"], false, "{r}");+ assert!(r["error"].as_str().unwrap_or_default().contains("before its press"), "{r}");+ let after = h.app.session.develop_of(photo).expect("its develop settings").light.exposure;+ assert_eq!(after, before, "the covered slider did not change");+ assert!(h.app.quit_prompt.is_some(), "the drag did not activate (or dismiss) the overlay");+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.synthetic.is_empty());+}++/// The release ownership check must not reject an ordinary unobstructed click, including a click+/// on a sub-rect of a larger widget (the bottom rating row registers each star, not the row's+/// interactive centre). This is the positive control the hover-only probe lacked.+#[test]+fn an_unobstructed_click_on_a_subrect_reaches_the_widget() {+ let mut h = Headless::new(app(), [1400.0, 900.0], 1.0);+ let photo = h.app.session.visible_cloned()[0];+ let t = Duration::from_secs(20);+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ assert_eq!(h.request("ui.set", serde_json::json!({"view": "detail", "right": "edit"}), t)["ok"], true);+ assert!(h.settle(Duration::from_secs(60)), "the detail view settles");+ let id = "star:bottom:2";+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == id), "{id} is on screen");+ assert!(h.app.widget_hits.iter().any(|(widget, _)| widget == id), "{id} has a probe");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.session.catalog.photo(photo).expect("the photo").rating, 2, "the sub-rect click reached the rating row");+}++/// A non-modal overlay that appears after the press must cancel the click before its release and+/// must not turn the release into an overlay click; the pointer is released away from the target.+#[test]+fn an_overlay_that_appears_after_the_press_cancels_the_release() {+ let mut h = Headless::new(app(), [1000.0, 760.0], 1.0);+ h.step();+ let t = Duration::from_secs(20);+ assert_eq!(h.request("ui.key", serde_json::json!({"key": ",", "cmd": true}), t)["ok"], true);+ assert!(h.settle(Duration::from_secs(60)), "the Settings dialog settles");+ let id = "check:settings.confirmDelete";+ let target = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.clickWidget".into(), serde_json::json!({"id": id}), tx).expect("the click is admitted");+ h.step(); // resolve: move, press and release are queued+ h.step(); // the move is consumed+ h.step(); // the press is consumed: the pointer is now down+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the press reached egui");+ // Let the prompt complete its sizing pass while the release waits, as it does when it opens+ // between two host frames. A prompt now cancels the gesture at its appearance, before the+ // release is delivered; the release must still end the held press without a click.+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.app.synthetic_in_flight = true;+ h.step();+ assert!(!h.app.synthetic_in_flight, "the prompt's pass completed");+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == "button:quitCancel"), "the prompt is laid out");+ h.step(); // the release is refused; the pointer cleanup releases the held press+ let reply = rx.try_recv().expect("the canceled click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ let error = reply["error"].as_str().unwrap_or_default();+ assert!(error.contains("modal prompt appeared"), "{reply}");+ assert!(error.contains("before its input was delivered"), "{reply}");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the canceled press was released");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the covered checkbox did not change");+ assert_eq!(+ h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect),+ Some(target),+ "the target stayed where it was; nothing was retargeted"+ );+ assert!(h.app.quit_prompt.is_some(), "the prompt was not activated");+ // Remove the overlay: the same target is clickable again (a positive control after refusal).+ h.app.quit_prompt = None;+ assert!(h.settle(Duration::from_secs(60)), "the Settings dialog settles after the overlay");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.ui.settings.confirm_delete, !before, "the unobstructed click reached the checkbox");+}++/// A canceled click on a drag-sensing control must not keep the pointer down or move it. The old+/// cleanup moved 8 px to suppress the click, which could start a drag and change a slider/curve.+#[test]+fn canceling_a_pressed_slider_releases_it_without_dragging_it() {+ let mut h = Headless::new(app(), [1400.0, 900.0], 1.0);+ let photo = h.app.session.visible_cloned()[0];+ let t = Duration::from_secs(20);+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ assert_eq!(h.request("ui.set", serde_json::json!({"view": "detail", "right": "edit"}), t)["ok"], true);+ h.app.ui.open_sections = vec!["light".to_string()];+ assert!(h.settle(Duration::from_secs(60)), "the edit panel settles");+ let id = "slider:light.exposure";+ let target = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect).expect("the slider is on screen");+ let before = h.app.session.develop_of(photo).expect("its develop settings").light.exposure;+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.clickWidget".into(), serde_json::json!({"id": id}), tx).expect("the click is admitted");+ h.step(); // resolve: move, press and release are queued+ h.step(); // the move is consumed+ h.step(); // the press is consumed: the pointer is now down+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the press reached egui");+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.app.synthetic_in_flight = true;+ h.step(); // the prompt's pass completes while the release waits+ assert!(!h.app.synthetic_in_flight);+ h.step(); // the release is refused; cleanup resets the pointer before the next pass+ let reply = rx.try_recv().expect("the canceled click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("modal prompt appeared"), "{reply}");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the canceled press was released without a move");+ assert_eq!(h.app.session.develop_of(photo).expect("its develop settings").light.exposure, before, "cleanup did not drag the slider");+ assert_eq!(+ h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect),+ Some(target),+ "the target stayed where it was; nothing was retargeted"+ );+ assert!(h.app.quit_prompt.is_some(), "the prompt was not activated");+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.synthetic.is_empty());+}++/// A non-prompt `Foreground` window that appears after the press (the launch list / library error)+/// makes the target invisible too: the release is refused rather than clicking through it.+#[test]+fn a_nonprompt_overlay_that_appears_after_the_press_cancels_the_release() {+ let mut h = Headless::new(app(), [1000.0, 760.0], 1.0);+ h.step();+ let t = Duration::from_secs(20);+ assert_eq!(h.request("ui.key", serde_json::json!({"key": ",", "cmd": true}), t)["ok"], true);+ assert!(h.settle(Duration::from_secs(60)), "the Settings dialog settles");+ let id = "check:settings.confirmDelete";+ let target = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.clickWidget".into(), serde_json::json!({"id": id}), tx).expect("the click is admitted");+ h.step(); // resolve: move, press and release are queued+ h.step(); // the move is consumed+ h.step(); // the press is consumed: the pointer is now down+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the press reached egui");+ // Draw the non-prompt overlay while the release waits. Its creation barrier cancels the+ // queued release before the later stale-target visibility check can deliver it.+ h.app.library_problem = Some(crate::panels::library_problem::LibraryProblem::new("/no/such/library", "test error"));+ h.app.synthetic_in_flight = true;+ h.step();+ assert!(!h.app.synthetic_in_flight, "the overlay's pass completed");+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == "button:libraryRetry"), "the library window is laid out");+ h.step();+ let reply = rx.try_recv().expect("the canceled click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ let error = reply["error"].as_str().unwrap_or_default();+ assert!(error.contains("ui.clickWidget canceled: a blocking library window appeared"), "{reply}");+ assert!(error.contains("before its input was delivered"), "{reply}");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the canceled press was released");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the covered checkbox did not change");+ assert_eq!(+ h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect),+ Some(target),+ "the target stayed where it was; nothing was retargeted"+ );+ assert!(h.app.library_problem.is_some(), "the overlay was not activated");+ h.app.library_problem = None;+ assert!(h.settle(Duration::from_secs(60)), "Settings settles after the overlay");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.ui.settings.confirm_delete, !before, "the unobstructed click reached the checkbox");+}++/// The library-problem dim is above a `Middle` Settings dialog: a control-channel click on the+/// covered checkbox is refused instead of being delivered through the dim. This is the direct+/// `ui.clickWidget` counterpart of the press/release cancellation above.+#[test]+fn a_library_problem_overlay_blocks_a_control_click_in_settings() {+ let mut h = Headless::new(app(), [1000.0, 760.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ assert!(h.settle(Duration::from_secs(60)), "Settings settles");+ let id = "check:settings.confirmDelete";+ let before = h.app.ui.settings.confirm_delete;+ h.app.library_problem = Some(crate::panels::library_problem::LibraryProblem::new("/no/such/library", "test error"));+ assert!(h.settle(Duration::from_secs(60)), "the library problem window settles");+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == "button:libraryRetry"), "the library window is laid out");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], false, "{r}");+ let error = r["error"].as_str().unwrap_or_default();+ assert!(error.contains(id), "{r}");+ assert!(error.contains("no longer visible"), "{r}");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the covered checkbox did not change");+ assert!(h.app.library_problem.is_some(), "the overlay was not activated");+ // Positive control: the same control works once the covering window is gone.+ h.app.library_problem = None;+ assert!(h.settle(Duration::from_secs(60)), "Settings settles after the overlay");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.ui.settings.confirm_delete, !before, "the unobstructed click reached the checkbox");+}++/// A quit prompt over Settings owns the pointer even when Settings asks for outside clicks: the+/// raw backdrop handler must not close the dialog it cannot see. Dismissing the prompt with its+/// own button keeps Settings and does not replay the backdrop press into it.+#[test]+fn a_quit_prompt_over_settings_blocks_the_outside_click_and_keeps_the_dialog() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Settings is open");+ h.app.ui.settings.close_dialogs_outside = true;+ let confirm_delete = h.app.ui.settings.confirm_delete;+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ assert!(h.app.widgets.iter().any(|(id, _)| id == "button:quitCancel"), "the prompt is laid out");+ // The prompt's first completed frame is already the real, interactable layer: no sizing pass+ // (which egui makes invisible and non-interactable) may leak a release into Settings below.+ let cancel = h.app.widgets.iter().find(|(id, _)| id == "button:quitCancel").map(|(_, r)| r.center()).expect("the Cancel rect");+ assert!(h.view.ctx.layer_id_at(cancel) == crate::panels::notices::prompt_layer(&h.app), "the prompt owns its first settled button click");+ // Outside both the prompt and Settings, with the outside-click preference on.+ let at = egui::pos2(10.0, 890.0);+ let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(at), press(true), press(false)]);+ h.step();+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "the backdrop click did not close Settings");+ assert!(h.app.quit_prompt.is_some(), "the backdrop click did not dismiss the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "the raw click did not reach a Settings control");+ // A backdrop press raises its area; the prompt must stay above it, and its Cancel must work.+ let r = h.request("ui.clickWidget", serde_json::json!({"id": "button:quitCancel"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.app.quit_prompt.is_none(), "Cancel dismissed the prompt");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "dismissing the prompt kept Settings");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "the prompt click did not reach Settings");+}++/// Escape and Return are the prompt's safe Cancel, not Settings' dismissal/confirmation. The+/// dialog and its Settings stay exactly as they were, then keep their normal Escape afterwards.+#[test]+fn a_quit_prompt_takes_safe_keyboard_cancel_without_closing_settings() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Settings is open");+ let confirm_delete = h.app.ui.settings.confirm_delete;+ for key in ["Escape", "Enter"] {+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ let r = h.request("ui.key", serde_json::json!({"key": key}), t);+ assert_eq!(r["ok"], true, "{key}: {r}");+ assert!(h.app.quit_prompt.is_none(), "{key} safely dismissed the prompt");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "{key} did not close Settings behind the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "{key} did not change Settings");+ }+ // Positive control: the dialog's own Escape still works once no prompt owns it.+ let r = h.request("ui.key", serde_json::json!({"key": "Escape"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.app.ui.dialog.is_none(), "Escape closes Settings without a prompt");+}++/// The prompt's buttons are reachable with Tab/Shift+Tab and activate with Space. Focus is real+/// egui focus on the actual button responses, not a separate keyboard-only path.+#[test]+fn prompt_tab_shift_tab_and_space_reach_cancel() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ let confirm_delete = h.app.ui.settings.confirm_delete;+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ let cancel_id =+ h.app.widget_hits.iter().rev().find(|(id, _)| id == "button:quitCancel").map(|(_, hit)| hit.id).expect("Cancel has a real response");+ let anyway_id =+ h.app.widget_hits.iter().rev().find(|(id, _)| id == "button:quitAnyway").map(|(_, hit)| hit.id).expect("Quit Anyway has a real response");+ assert_eq!(h.view.ctx.memory(|m| m.focused()), Some(cancel_id), "the safe Cancel starts focused");+ assert_eq!(h.request("ui.key", serde_json::json!({"key": "Tab"}), t)["ok"], true);+ assert_eq!(h.view.ctx.memory(|m| m.focused()), Some(anyway_id), "Tab moved to Quit Anyway");+ assert!(h.app.quit_prompt.is_some(), "Tab did not activate anything");+ assert_eq!(h.request("ui.key", serde_json::json!({"key": "Tab", "shift": true}), t)["ok"], true);+ assert_eq!(h.view.ctx.memory(|m| m.focused()), Some(cancel_id), "Shift+Tab moved back to Cancel");+ assert_eq!(h.request("ui.key", serde_json::json!({"key": "Space"}), t)["ok"], true);+ assert!(h.app.quit_prompt.is_none(), "Space activated the focused safe Cancel");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Cancel kept Settings");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "the prompt key did not reach Settings");+}++/// Raw screen coordinates at a settled prompt button still work. Pointer state is hidden from the+/// background during each pass, but the real press is preserved for the next frame's release.+#[test]+fn raw_pointer_at_a_settled_prompt_button_activates_it() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ let confirm_delete = h.app.ui.settings.confirm_delete;+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ let cancel = h.app.widgets.iter().rev().find(|(id, _)| id == "button:quitCancel").map(|(_, rect)| rect.center()).expect("the Cancel rect");+ h.events.extend([egui::Event::PointerMoved(cancel), pointer_event(cancel, true)]);+ h.step();+ assert!(h.app.quit_prompt.is_some(), "the press alone does not dismiss the prompt");+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the real press survives for its release");+ h.events.push(pointer_event(cancel, false));+ h.step();+ assert!(h.app.quit_prompt.is_none(), "the release activated the settled prompt button");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Cancel kept Settings");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "the raw click did not reach Settings");+}++/// AccessKit Focus and Click target the prompt's actual button node. An action at a covered+/// Settings control is dropped, so it can neither focus nor activate the background.+#[test]+fn prompt_accepts_targeted_accesskit_and_rejects_background_actions() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ let confirm_delete = h.app.ui.settings.confirm_delete;+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ let cancel_id =+ h.app.widget_hits.iter().rev().find(|(id, _)| id == "button:quitCancel").map(|(_, hit)| hit.id).expect("Cancel has a real response");+ let checkbox_node = h+ .app+ .widget_hits+ .iter()+ .rev()+ .find(|(id, _)| id == "check:settings.confirmDelete")+ .map(|(_, hit)| hit.id.accesskit_id())+ .expect("the covered checkbox has a response");+ h.events.push(accesskit_action(egui::accesskit::Action::Click, checkbox_node));+ h.step();+ assert!(h.app.quit_prompt.is_some(), "a background AccessKit Click did not dismiss the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "a background AccessKit Click did not change Settings");+ h.events.push(accesskit_action(egui::accesskit::Action::Focus, cancel_id.accesskit_id()));+ h.events.push(accesskit_action(egui::accesskit::Action::Click, cancel_id.accesskit_id()));+ h.step();+ assert!(h.app.quit_prompt.is_none(), "the prompt's own AccessKit node activated Cancel");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "AccessKit Cancel kept Settings");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "the AccessKit action did not reach Settings");+ // The control still answers normally after the prompt is gone.+ let r = h.request("ui.clickWidget", serde_json::json!({"id": "check:settings.confirmDelete"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.ui.settings.confirm_delete, !confirm_delete, "Settings is usable again");+}++/// A prompt created in the same host frame as a raw press/release must shield it. A press that+/// began before the prompt is released by the creation barrier, without becoming a background+/// click after the prompt settles.+#[test]+fn a_new_prompt_shields_raw_pointer_and_cancels_a_held_press() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ let id = "check:settings.confirmDelete";+ let at = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| rect.center()).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ // Press and release in the prompt's creation frame.+ h.events.extend([egui::Event::PointerMoved(at), pointer_event(at, true), pointer_event(at, false)]);+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ assert!(h.app.quit_prompt.is_some(), "the raw click did not dismiss the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the creation-frame click did not reach Settings");+ // Dismiss that prompt, then start a press over Settings before a new prompt appears.+ assert_eq!(h.request("ui.key", serde_json::json!({"key": "Escape"}), Duration::from_secs(20))["ok"], true);+ h.step();+ h.events.extend([egui::Event::PointerMoved(at), pointer_event(at, true)]);+ h.step();+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the pre-prompt press reached egui");+ h.events.push(pointer_event(at, false));+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the prompt creation cancelled the held press");+ assert!(h.app.quit_prompt.is_some(), "the pre-prompt release did not activate the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the press-before-prompt became a click in Settings");+}++/// A prompt can be created after `raw_input_hook`, when eframe's `logic` runs. The prompt barrier+/// must then drop wheel/new-touch/pointer input that egui already accepted for the pass, before+/// any panel reads it, while a touch End still clears egui's private touch state.+#[test]+fn a_prompt_first_seen_after_begin_pass_drops_wheel_touch_and_background_pointer_input() {+ let ctx = egui::Context::default();+ let mut app = app();+ app.fonts_ready = true;+ let at = egui::pos2(30.0, 40.0);+ let mut input = raw(egui::vec2(800.0, 600.0));+ input.events = vec![+ key_event(egui::Key::A, true, egui::Modifiers::NONE),+ egui::Event::MouseWheel {+ unit: egui::MouseWheelUnit::Line,+ delta: egui::vec2(0.0, 2.0),+ phase: egui::TouchPhase::Start,+ source: egui::MouseWheelSource::Wheel,+ modifiers: egui::Modifiers::NONE,+ },+ egui::Event::Touch { device_id: egui::TouchDeviceId(1), id: egui::TouchId(1), phase: egui::TouchPhase::Start, pos: at, force: None },+ egui::Event::Touch { device_id: egui::TouchDeviceId(1), id: egui::TouchId(1), phase: egui::TouchPhase::End, pos: at, force: None },+ egui::Event::PointerMoved(at),+ pointer_event(at, true),+ egui::Event::ModifiersChanged(egui::Modifiers::NONE),+ ];+ let mut output = ctx.run_ui(input, |ui| {+ app.quit_prompt = Some(crate::QuitPrompt::Tasks("tasks".into()));+ assert!(crate::panels::notices::prepare_ui_pass(&mut app, ui.ctx()), "the prompt is first seen after begin_pass");+ let events = ui.ctx().input(|i| i.events.clone());+ assert!(+ events.iter().all(|event| !matches!(+ event,+ egui::Event::Key { .. }+ | egui::Event::Touch { phase: egui::TouchPhase::Start | egui::TouchPhase::Move, .. }+ | egui::Event::MouseWheel { .. }+ | egui::Event::PointerMoved(_)+ | egui::Event::PointerButton { .. }+ )),+ "background input must not survive the prompt's creation pass: {events:?}"+ );+ assert!(+ events.iter().any(|event| matches!(event, egui::Event::Touch { phase: egui::TouchPhase::End, .. })),+ "a touch End must still clear egui's private touch state: {events:?}"+ );+ assert!(events.iter().any(|event| matches!(event, egui::Event::ModifiersChanged(_))), "modifier changes still reach egui");+ assert!(!ui.ctx().input(|i| i.pointer.any_down()), "the pointer is not left down");+ assert_eq!(ui.ctx().input(|i| i.smooth_scroll_delta), egui::Vec2::ZERO, "wheel scrolling is cleared");+ });+ output.textures_delta.clear();+}++/// A held host press in the same frame as a prompt created after `raw_input_hook` is released by+/// the prompt's first pass, not delivered to the covered control when the release arrives.+#[test]+fn a_prompt_created_after_raw_input_hook_shields_a_held_background_press() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ let id = "check:settings.confirmDelete";+ let at = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| rect.center()).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ h.events.extend([egui::Event::PointerMoved(at), pointer_event(at, true)]);+ h.set_after_raw_input_hook(|app| app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into())));+ h.step();+ assert!(h.app.quit_prompt.is_some(), "the prompt is shown");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the creation pass released the held press");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the press did not reach Settings");+ h.events.push(pointer_event(at, false));+ h.step();+ assert!(h.app.quit_prompt.is_some(), "the release did not activate the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the release did not become a background click");+}++/// A synthetic press already delivered when `raw_input_hook` runs, then a prompt created by logic+/// before the UI pass: the whole in-flight batch was not seen by a panel and must fail, not report+/// success after the prompt filters it.+#[test]+fn a_synthetic_press_already_delivered_is_canceled_by_a_prompt_created_after_raw_input_hook() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ assert!(h.settle(Duration::from_secs(60)), "the Settings dialog settles before its target rect is captured");+ let id = "check:settings.confirmDelete";+ let target = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.clickWidget".into(), serde_json::json!({"id": id}), tx).expect("the click is admitted");+ h.step(); // resolve: move, press and release are queued+ h.step(); // the move is consumed+ h.step(); // the press is consumed: the pointer is now down+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the press reached egui");+ assert!(!h.app.synthetic.is_empty(), "the release is queued");+ h.set_after_raw_input_hook(|app| app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into())));+ h.step(); // the hook creates the prompt after the release was injected for this pass+ let reply = rx.try_recv().expect("the canceled click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("modal prompt appeared"), "{reply}");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the canceled press was released");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the filtered release did not reach Settings");+ assert_eq!(+ h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| *rect),+ Some(target),+ "the target stayed where it was; nothing was retargeted"+ );+ assert!(h.app.quit_prompt.is_some(), "the prompt was not activated");+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.synthetic.is_empty());+}++/// Raw `ui.click`, `ui.drag` and `ui.pointer` at a settled prompt are delivered to the prompt's+/// backdrop, not to the covered Settings control or image. The dialog, its control and the image+/// stay unchanged.+#[test]+fn raw_background_gestures_at_a_settled_prompt_do_not_reach_the_covered_view() {+ let mut h = Headless::new(app(), [1400.0, 900.0], 1.0);+ let photo = h.app.session.visible_cloned()[0];+ let t = Duration::from_secs(20);+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ assert_eq!(h.request("ui.set", serde_json::json!({"view": "detail", "right": "edit"}), t)["ok"], true);+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ assert!(h.settle(Duration::from_secs(60)), "the detail view and Settings settle");+ let image = h.app.image_rect.expect("the detail image is on screen");+ let at = image.min + egui::vec2(12.0, 12.0);+ let before = h.app.ui.settings.confirm_delete;+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ h.step();+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == "button:quitCancel"), "the prompt is settled");+ let click = h.request("ui.click", serde_json::json!({"x": at.x, "y": at.y}), t);+ assert_eq!(click["ok"], true, "{click}");+ h.step();+ let drag = h.request("ui.drag", serde_json::json!({"x": at.x, "y": at.y, "toX": at.x + 30.0, "toY": at.y + 20.0, "steps": 4}), t);+ assert_eq!(drag["ok"], true, "{drag}");+ h.step();+ let pointer = h.request(+ "ui.pointer",+ serde_json::json!({"events": [+ {"kind": "down", "x": 0.05, "y": 0.05},+ {"kind": "move", "x": 0.08, "y": 0.08},+ {"kind": "up", "x": 0.08, "y": 0.08}+ ]}),+ t,+ );+ assert_eq!(pointer["ok"], true, "{pointer}");+ h.step();+ assert!(h.app.quit_prompt.is_some(), "the raw background gestures did not dismiss the prompt");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the raw gestures did not reach Settings");+ assert_eq!(h.app.image_rect, Some(image), "the raw pointer gestures did not pan, zoom or drag the image");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Settings is still open");+}++/// Releases are not keyboard actions, but egui needs them to clear `keys_down`. A prompt must keep+/// the release (and the held key must not survive the prompt) even though it drops every press.+#[test]+fn a_prompt_keeps_key_releases_and_clears_held_keys() {+ let ctx = egui::Context::default();+ let mut app = app();+ app.fonts_ready = true;+ app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ let mut raw = raw(egui::vec2(800.0, 600.0));+ raw.events.push(key_event(egui::Key::Backslash, false, egui::Modifiers::NONE));+ app.raw_input_hook(&ctx, &mut raw);+ assert!(+ raw.events.iter().any(|event| matches!(event, egui::Event::Key { key: egui::Key::Backslash, pressed: false, .. })),+ "the prompt's raw filter kept the key release for keys_down"+ );+ // A held background key is cleared at the prompt transition, not left asserted under it.+ let mut h = Headless::new(app, [800.0, 600.0], 1.0);+ h.step();+ h.view.ctx.input_mut(|i| {+ i.keys_down.insert(egui::Key::Backslash);+ });+ h.events.push(key_event(egui::Key::Backslash, false, egui::Modifiers::NONE));+ h.step();+ assert!(!h.view.ctx.input(|i| i.key_down(egui::Key::Backslash)), "the release cleared the held key under the prompt");+}++/// A synthetic drag whose press already reached egui is aborted when a prompt appears: its queued+/// moves/release are discarded, the pointer is released without a click, and the slider is intact.+#[test]+fn a_prompt_aborts_an_in_progress_synthetic_drag() {+ let mut h = Headless::new(app(), [1400.0, 900.0], 1.0);+ let photo = h.app.session.visible_cloned()[0];+ let t = Duration::from_secs(20);+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ assert_eq!(h.request("ui.set", serde_json::json!({"view": "detail", "right": "edit"}), t)["ok"], true);+ h.app.ui.open_sections = vec!["light".to_string()];+ assert!(h.settle(Duration::from_secs(60)), "the edit panel settles");+ let id = "slider:light.exposure";+ let before = h.app.session.develop_of(photo).expect("its develop settings").light.exposure;+ let (tx, rx) = reply_channel();+ h.app+ .admit_gesture(&h.view.ctx.clone(), "ui.dragWidget".into(), serde_json::json!({"id": id, "dx": 40.0, "steps": 20}), tx)+ .expect("the drag is admitted");+ h.step(); // resolve: move, press and many moves are queued+ h.step(); // move+ h.step(); // press+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the drag press reached egui");+ assert!(!h.app.synthetic.is_empty(), "the drag still has queued moves");+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ let reply = rx.try_recv().expect("the aborted drag answers");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("modal prompt appeared"), "{reply}");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the drag's pointer was released");+ assert_eq!(h.app.session.develop_of(photo).expect("its develop settings").light.exposure, before, "the drag did not continue under the prompt");+ assert!(h.app.synthetic.is_empty(), "the rest of the drag was dropped");+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.quit_prompt.is_some(), "the drag did not dismiss the prompt");+}++/// Changing from a Tasks prompt to an Unsaved prompt, or from one settings notice to the next,+/// is a new prompt. Its creation frame must shield pointer input even though the old prompt was+/// already settled.+#[test]+fn prompt_queue_and_kind_transitions_shield_the_first_frame() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ let id = "check:settings.confirmDelete";+ let at = h.app.widgets.iter().rev().find(|(widget, _)| widget == id).map(|(_, rect)| rect.center()).expect("the checkbox is on screen");+ let before = h.app.ui.settings.confirm_delete;+ // A raw click resolved before the prompt exists must be refused before its first event, not+ // land in the prompt's creation frame or be replayed after it goes away.+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.click".into(), serde_json::json!({"x": at.x, "y": at.y}), tx).expect("the raw click is admitted");+ h.step();+ assert!(!h.app.synthetic.is_empty(), "the raw click is queued");+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("tasks".into()));+ h.step();+ let reply = rx.try_recv().expect("the pre-prompt raw click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains("modal prompt appeared"), "{reply}");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the queued raw click did not reach Settings");+ // Tasks -> Unsaved in the same host frame as a raw click on the covered checkbox.+ h.events.extend([egui::Event::PointerMoved(at), pointer_event(at, true), pointer_event(at, false)]);+ h.app.quit_prompt = Some(crate::QuitPrompt::Unsaved("unsaved".into()));+ h.step();+ assert!(matches!(h.app.quit_prompt, Some(crate::QuitPrompt::Unsaved(_))), "the new prompt is shown");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the transition frame did not click Settings");+ // Dismiss Unsaved, then switch from one settings notice to the next in a pointer frame.+ assert_eq!(h.request("ui.key", serde_json::json!({"key": "Escape"}), Duration::from_secs(20))["ok"], true);+ h.app.notices = vec!["first notice".into()];+ h.step();+ h.step();+ h.events.extend([egui::Event::PointerMoved(at), pointer_event(at, true), pointer_event(at, false)]);+ h.app.notices = vec!["second notice".into()];+ h.step();+ assert_eq!(h.app.notices, vec!["second notice".to_string()], "the queued notice is still shown");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "the notice transition did not click Settings");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Settings survived both transitions");+}++/// A prompt with no dialog must still stop global shortcuts. The rating key is a background+/// photo action, not part of the prompt.+#[test]+fn a_quit_prompt_blocks_global_rating_shortcuts() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ let photo = h.app.session.visible_cloned()[0];+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ h.step();+ // Positive control: the same key rates the photo while no prompt is up.+ let r = h.request("ui.key", serde_json::json!({"key": "4"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.session.catalog.photo(photo).expect("the photo").rating, 4, "the rating key works without a prompt");+ let before = h.app.session.catalog.photo(photo).expect("the photo").rating;+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ let r = h.request("ui.key", serde_json::json!({"key": "5"}), t);+ assert_eq!(r["ok"], false, "the prompt blocked the key, so it must not report a delivered shortcut: {r}");+ assert!(r["error"].as_str().unwrap_or_default().contains("modal prompt"), "{r}");+ assert_eq!(h.app.session.catalog.photo(photo).expect("the photo").rating, before, "no rating behind the prompt");+ assert!(h.app.quit_prompt.is_some(), "the shortcut did not dismiss the prompt");+ assert!(h.app.pending_gestures.is_empty() && h.app.synthetic.is_empty(), "the blocked key left no queued input");+}++/// A settled prompt drops text and scroll input, and the control channel must report that refusal+/// instead of a false success: neither event has a prompt meaning. The prompt stays up.+#[test]+fn a_settled_prompt_rejects_blocked_text_and_scroll_gestures() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ h.app.quit_prompt = Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into()));+ h.step();+ for (method, params) in [("ui.text", serde_json::json!({"text": "x"})), ("ui.scroll", serde_json::json!({"dx": 0.0, "dy": 30.0}))] {+ let r = h.request(method, params, t);+ assert_eq!(r["ok"], false, "{method}: {r}");+ assert!(r["error"].as_str().unwrap_or_default().contains("modal prompt"), "{method}: {r}");+ assert!(h.app.quit_prompt.is_some(), "{method} did not dismiss the prompt");+ assert!(h.app.pending_gestures.is_empty() && h.app.synthetic.is_empty(), "{method} left queued input");+ }+}++/// The settings-notice path uses the same barrier and window: it blocks the dialog below it (both+/// pointer and the outside-click preference), and its own OK dismisses it without closing Settings.+#[test]+fn a_settings_notice_blocks_background_input_and_its_ok_button_works() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "Settings is open");+ h.app.ui.settings.close_dialogs_outside = true;+ let confirm_delete = h.app.ui.settings.confirm_delete;+ h.app.notices.push("The settings file could not be read and was reset.".into());+ h.step();+ assert!(h.app.widgets.iter().any(|(id, _)| id == "button:noticeOk"), "the notice is laid out");+ assert!(h.app.widgets.iter().any(|(id, _)| id == "check:settings.confirmDelete"), "the covered checkbox is laid out");+ // A covered Settings control cannot be clicked, and a backdrop click cannot close Settings.+ let r = h.request("ui.clickWidget", serde_json::json!({"id": "check:settings.confirmDelete"}), t);+ assert_eq!(r["ok"], false, "{r}");+ assert_eq!(h.app.ui.settings.confirm_delete, confirm_delete, "the covered checkbox did not change");+ let at = egui::pos2(10.0, 890.0);+ let press = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE };+ h.events.extend([egui::Event::PointerMoved(at), press(true), press(false)]);+ h.step();+ h.step();+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "the backdrop click did not close Settings");+ assert!(!h.app.notices.is_empty(), "the backdrop click did not dismiss the notice");+ // OK dismisses only the notice; Settings survives and becomes usable again.+ let r = h.request("ui.clickWidget", serde_json::json!({"id": "button:noticeOk"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert!(h.app.notices.is_empty(), "OK dismissed the notice");+ assert!(matches!(&h.app.ui.dialog, Some(crate::state::Dialog::Settings { .. })), "dismissing the notice kept Settings");+ let r = h.request("ui.clickWidget", serde_json::json!({"id": "check:settings.confirmDelete"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ assert_eq!(h.app.ui.settings.confirm_delete, !confirm_delete, "the checkbox works again after the notice");+}++#[test]+fn clipping_changed_between_the_move_and_press_is_seen_in_the_latest_registry() {+ let mut h = Headless::new(app(), [1400.0, 900.0], 1.0);+ let photo = h.app.session.visible_cloned()[0];+ let t = Duration::from_secs(20);+ assert_eq!(h.request("engine.execute", serde_json::json!({"command": "library.select", "params": {"ids": [photo.0]}}), t)["ok"], true);+ assert_eq!(h.request("ui.set", serde_json::json!({"view": "detail", "right": "edit"}), t)["ok"], true);+ assert!(h.settle(Duration::from_secs(60)), "the detail view settles");+ let id = "star:bottom:2";+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&h.view.ctx.clone(), "ui.clickWidget".into(), serde_json::json!({"id": id}), tx).expect("the click is admitted");+ h.step(); // resolve: move, press and release are queued+ h.step(); // the move is consumed+ // The latest completed pass clipped the widget without moving it to another layer. Only the+ // clipped rect in the registry knows that; `read_response` before `begin_pass` can still see+ // the pass before the registry that was just published.+ let hit = &mut h.app.widget_hits.iter_mut().rev().find(|(widget, _)| widget == id).expect("the target has a probe").1;+ hit.interact_rect = egui::Rect::NOTHING;+ h.step(); // the press is refused instead of being delivered to the clipped target+ let reply = rx.try_recv().expect("the clipped click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ let error = reply["error"].as_str().unwrap_or_default();+ assert!(error.contains("no longer visible"), "{reply}");+ assert!(error.contains("before its press"), "{reply}");+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.synthetic.is_empty());+}++#[test]+fn a_timeout_cancels_only_its_own_gesture_and_preserves_a_later_queue() {+ let ctx = egui::Context::default();+ let mut app = app();+ frame(&ctx, raw(egui::vec2(1000.0, 700.0)), |ui| app.logic(ui.ctx()));+ app.logic(&ctx);+ assert!(app.fonts_ready);+ app.widgets = vec![+ ("first:test".into(), egui::Rect::from_min_size(egui::pos2(10.0, 10.0), egui::vec2(30.0, 20.0))),+ ("second:test".into(), egui::Rect::from_min_size(egui::pos2(60.0, 10.0), egui::vec2(30.0, 20.0))),+ ];+ let (tx1, rx1) = reply_channel();+ let (tx2, rx2) = reply_channel();+ app.admit_gesture(&ctx, "ui.clickWidget".into(), serde_json::json!({"id": "first:test"}), tx1).expect("the first click is admitted");+ app.admit_gesture(&ctx, "ui.clickWidget".into(), serde_json::json!({"id": "second:test"}), tx2).expect("the second click is admitted");+ app.layout_epoch = app.layout_epoch.wrapping_add(1);+ app.resolve_pending_gestures(&ctx);+ assert_eq!(app.synthetic.len(), 6, "move, press and release for each click");+ // The first gesture stalls after its events were queued; the second was resolved behind it and+ // has its own deadline. A timeout must remove only the first gesture's unsent prefix.+ app.pending_gestures[0].deadline_ms = 0.0;+ app.reply_delivered_gestures();+ let reply1 = rx1.try_recv().expect("the stalled first gesture answers");+ assert_eq!(reply1["ok"], false, "{reply1}");+ assert!(reply1["error"].as_str().unwrap_or_default().contains("timed out before the UI consumed its last event"), "{reply1}");+ assert_eq!(app.synthetic.len(), 3, "the later gesture's events are preserved");+ assert!(rx2.try_recv().is_err(), "the later gesture is still waiting");+ assert_eq!(app.pending_gestures.len(), 1);+ assert_eq!(app.pending_gestures[0].target.as_ref().map(|target| target.id.as_str()), Some("second:test"));+}++#[test]+fn queued_pointer_cleanup_requests_a_repaint_without_a_synthetic_event() {+ let mut app = app();+ app.synthetic.clear();+ app.pointer_cleanup = true;+ assert!(app.synthetic.is_empty());+ assert!(app.queued_input_needs_repaint(), "the pending cleanup alone must ask for the frame that injects it");+ // A timeout after the last synthetic batch is drained can queue cleanup inside finish_ui_pass;+ // that pass itself has to ask for the frame that delivers it.+ let ctx = egui::Context::default();+ app.finish_ui_pass(&ctx);+ assert!(ctx.has_requested_repaint(), "finish_ui_pass requested the cleanup frame");+ app.pointer_cleanup = false;+ assert!(!app.queued_input_needs_repaint());+}++#[test]+fn a_moved_widget_cancels_before_its_first_event_and_leaves_a_later_gesture_queued() {+ let mut h = Headless::new(app(), [1000.0, 760.0], 1.0);+ h.step();+ let t = Duration::from_secs(20);+ let r = h.request("ui.key", serde_json::json!({"key": ",", "cmd": true}), t);+ assert_eq!(r["ok"], true, "{r}");+ assert!(h.settle(Duration::from_secs(60)), "the Settings dialog settles");+ assert!(h.app.widgets.iter().any(|(id, _)| id == "check:settings.confirmDelete"));+ assert!(h.app.widgets.iter().any(|(id, _)| id == "button:settingsStartup-2"));++ let (tx1, rx1) = reply_channel();+ let (tx2, rx2) = reply_channel();+ let ctx = h.view.ctx.clone();+ h.app+ .admit_gesture(&ctx, "ui.clickWidget".into(), serde_json::json!({"id": "check:settings.confirmDelete"}), tx1)+ .expect("the first click is admitted");+ h.app+ .admit_gesture(&ctx, "ui.clickWidget".into(), serde_json::json!({"id": "button:settingsStartup-2"}), tx2)+ .expect("the second click is admitted");+ // This completed pass resolves both against the same registry and queues move, press, release+ // for each.+ h.step();+ assert!(rx1.try_recv().is_err(), "nothing is answered at resolution");+ assert!(rx2.try_recv().is_err(), "nothing is answered at resolution");+ assert_eq!(h.app.synthetic.len(), 6, "both gestures are queued");++ // Before the first event the first target's latest rect moves (the second target stays put).+ let moved = egui::Rect::from_min_size(egui::pos2(900.0, 700.0), egui::vec2(10.0, 10.0));+ let entry = h.app.widgets.iter_mut().rev().find(|entry| entry.0 == "check:settings.confirmDelete").expect("the first target is registered");+ entry.1 = moved;+ // The first event's injection now cancels only the head; the second gesture's three events must+ // stay at the front of the queue.+ h.step();+ let reply1 = rx1.try_recv().expect("the canceled first gesture answers");+ assert_eq!(reply1["ok"], false, "{reply1}");+ let error = reply1["error"].as_str().unwrap_or_default();+ assert!(error.contains("before its first event"), "{reply1}");+ assert!(error.contains("nothing was retargeted"), "{reply1}");+ assert_eq!(h.app.synthetic.len(), 3, "the later gesture's events are preserved");+ assert!(rx2.try_recv().is_err(), "the later gesture is still waiting");++ for _ in 0..8 {+ h.step();+ }+ let reply2 = rx2.try_recv().expect("the later gesture is delivered");+ assert_eq!(reply2["ok"], true, "{reply2}");+ assert_eq!(h.app.ui.settings.startup_view, crate::state::StartupView::Detail, "the second click ran");+ assert!(h.app.pending_gestures.is_empty());+}++#[test]+fn a_click_whose_target_vanishes_after_the_press_fails_and_releases_the_pointer() {+ let mut h = Headless::new(app(), [1000.0, 760.0], 1.0);+ h.step();+ let t = Duration::from_secs(20);+ let r = h.request("ui.key", serde_json::json!({"key": ",", "cmd": true}), t);+ assert_eq!(r["ok"], true, "{r}");+ assert!(h.settle(Duration::from_secs(60)), "the Settings dialog settles");+ let before = h.app.ui.settings.confirm_delete;++ let (tx, rx) = reply_channel();+ h.app+ .admit_gesture(&h.view.ctx.clone(), "ui.clickWidget".into(), serde_json::json!({"id": "check:settings.confirmDelete"}), tx)+ .expect("the click is admitted");+ h.step(); // resolve: move, press, release are queued+ h.step(); // the move is consumed+ h.step(); // the press is consumed: the pointer is now down+ assert!(h.view.ctx.input(|i| i.pointer.any_down()), "the press reached egui");++ // The widget vanishes between press and release (the click's own effect or a layout change).+ h.app.widgets.retain(|(id, _)| id != "check:settings.confirmDelete");+ h.step(); // the release is refused, and a safe release is injected for the down pointer+ let reply = rx.try_recv().expect("the canceled click answers");+ assert_eq!(reply["ok"], false, "{reply}");+ let error = reply["error"].as_str().unwrap_or_default();+ assert!(error.contains("disappeared before its release"), "{reply}");+ assert!(error.contains("nothing was retargeted"), "{reply}");+ assert!(!h.view.ctx.input(|i| i.pointer.any_down()), "the canceled press was released");+ assert_eq!(h.app.ui.settings.confirm_delete, before, "no click was delivered");+ assert!(h.app.pending_gestures.is_empty());+ assert!(h.app.synthetic.is_empty());+}++#[test]+fn a_discarded_layout_does_not_publish_its_widget_registry() {+ let ctx = egui::Context::default();+ let mut app = app();+ frame(&ctx, raw(egui::vec2(800.0, 600.0)), |ui| app.logic(ui.ctx()));+ app.logic(&ctx);+ assert!(app.fonts_ready);+ let kept = egui::Rect::from_min_size(egui::pos2(1.0, 2.0), egui::vec2(3.0, 4.0));+ let discarded = egui::Rect::from_min_size(egui::pos2(5.0, 6.0), egui::vec2(7.0, 8.0));+ app.widgets = vec![("kept:test".into(), kept)];+ app.next_widgets = vec![("discarded:test".into(), discarded)];+ let mut passes = 0;+ let mut output = ctx.run_pass(raw(egui::vec2(800.0, 600.0)), |ctx| {+ if passes == 0 {+ ctx.request_discard("test: throw this layout away");+ app.finish_ui_pass(ctx);+ }+ passes += 1;+ });+ output.textures_delta.clear();+ assert!(passes > 1, "egui reran the discarded layout");+ assert_eq!(app.widgets, vec![("kept:test".into(), kept)], "the discarded registry was not published");+ assert!(app.next_widgets.is_empty());+}+#[test]fn a_gesture_replies_only_after_the_completed_pass_consumed_its_event() {let ctx = egui::Context::default();@@ -896,7 +1935,7 @@ fn a_gesture_replies_only_after_the_completed_pass_consumed_its_event() {assert_eq!(app.synthetic.len(), 1, "resolution queued the event");assert!(rx.try_recv().is_err(), "not answered before the UI consumed it");let mut next = raw(egui::vec2(1000.0, 700.0));- app.raw_input_hook(&mut next);+ app.raw_input_hook(&ctx, &mut next);assert!(next.events.iter().any(|e| matches!(e, egui::Event::PointerMoved(_))), "the event is injected next frame");frame(&ctx, next, |ui| {app.logic(ui.ctx());@@ -924,7 +1963,7 @@ fn a_delivered_gesture_may_change_the_state_it_acted_on() {assert!(!app.synthetic.is_empty(), "the key is queued");// The pass that consumes it opens the dialog: that is the gesture doing its job, not drift.let mut next = raw(egui::vec2(1000.0, 700.0));- app.raw_input_hook(&mut next);+ app.raw_input_hook(&ctx, &mut next);frame(&ctx, next, |ui| {app.logic(ui.ctx());app.ui(ui);@@ -953,7 +1992,7 @@ fn a_gesture_cancels_when_the_view_changes_before_its_batch_is_injected() {// pass consumes it: fail closed instead of injecting it into the new view.app.ui.view = crate::state::ViewMode::PhotoGrid;let mut next = raw(egui::vec2(1000.0, 700.0));- app.raw_input_hook(&mut next);+ app.raw_input_hook(&ctx, &mut next);assert!(next.events.is_empty(), "no stale event reaches the new view");assert!(app.synthetic.is_empty());let reply = rx.try_recv().expect("the cancel error answers once");@@ -1009,3 +2048,179 @@ fn disclosure_rows_publish_expanded_not_toggled() {});assert_eq!(seen, vec![Some(true), Some(false)], "the disclosure reports Expanded, not Toggled");}++/// `ui.hoverWidget` obeys the same clipped/covered-target contract as a press: a hover whose+/// widget was clipped before delivery is refused, as is one under the non-modal library window.+#[test]+fn hover_widget_refuses_clipped_and_covered_targets() {+ let mut h = Headless::new(app(), [1200.0, 900.0], 1.0);+ let t = Duration::from_secs(20);+ h.step();+ assert!(h.app.run("app.settings", serde_json::json!({})).is_ok(), "Settings opens");+ assert!(h.settle(Duration::from_secs(60)), "Settings settles");+ let id = "check:settings.confirmDelete";+ assert!(h.app.widget_hits.iter().any(|(widget, _)| widget == id), "{id} has a probe");++ let (tx, rx) = reply_channel();+ let ctx = h.view.ctx.clone();+ h.app.admit_gesture(&ctx, "ui.hoverWidget".into(), serde_json::json!({"id": id}), tx).expect("the hover is admitted");+ h.step(); // resolve: the pointer move is queued, not consumed+ assert!(rx.try_recv().is_err(), "nothing is answered at resolution");+ // The latest completed registry says the widget has no clipped interaction area. The hover+ // must fail before its first pointer move, like a press at the same stale point.+ if let Some(hit) = h.app.widget_hits.iter_mut().rev().find(|(widget, _)| widget == id) {+ hit.1.interact_rect = egui::Rect::NOTHING;+ }+ h.step();+ let reply = rx.try_recv().expect("the clipped hover answers");+ assert_eq!(reply["ok"], false, "{reply}");+ let error = reply["error"].as_str().unwrap_or_default();+ assert!(error.contains("no longer visible"), "{reply}");+ assert!(error.contains("before its first event"), "{reply}");+ assert!(h.app.pending_gestures.is_empty() && h.app.synthetic.is_empty());++ // Positive control: the next pass publishes the real clipped rect again.+ let r = h.request("ui.hoverWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], true, "an unobstructed hover still works: {r}");++ // The library window is a non-modal overlay (its dim is the modal layer). A target below it+ // must be refused before a pointer move is queued, then work again after the window closes.+ h.app.library_problem = Some(crate::panels::library_problem::LibraryProblem::new("/no/such/library", "test error"));+ assert!(h.settle(Duration::from_secs(60)), "the library window settles");+ assert!(h.app.widgets.iter().any(|(widget, _)| widget == "button:libraryRetry"), "the library window is laid out");+ let r = h.request("ui.hoverWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], false, "{r}");+ assert!(r["error"].as_str().unwrap_or_default().contains(id), "{r}");+ h.app.library_problem = None;+ assert!(h.settle(Duration::from_secs(60)), "Settings settles after the overlay");+ let r = h.request("ui.hoverWidget", serde_json::json!({"id": id}), t);+ assert_eq!(r["ok"], true, "the same hover works once the overlay is gone: {r}");+}++/// A system paste request is a viewport command, not a synthetic event, so the prompt/library+/// barrier cannot filter it later. It must be refused while either newly-created barrier owns the+/// pass, and still work normally without one.+#[test]+fn a_system_paste_under_a_new_barrier_is_refused() {+ let mut h = Headless::new(app(), [1200.0, 760.0], 1.0);+ let t = Duration::from_secs(20);+ h.settle(Duration::from_secs(60));+ let r = h.request("ui.clickWidget", serde_json::json!({"id": "field:search"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.view.clipboard = "blocked".into();+ let ctx = h.view.ctx.clone();++ for (barrier, message) in [+ (Some(crate::QuitPrompt::Tasks("1 task is still running: Import. Quitting stops it.".into())), "modal prompt"),+ (None, "blocking library window"),+ ] {+ if barrier.is_some() {+ h.app.quit_prompt = barrier;+ } else {+ h.app.library_problem = Some(crate::panels::library_problem::LibraryProblem::new("/no/such/library", "test error"));+ }+ let (tx, rx) = reply_channel();+ h.app.admit_gesture(&ctx, "ui.clipboard".into(), serde_json::json!({"action": "paste"}), tx).expect("the paste is admitted");+ h.app.layout_epoch = h.app.layout_epoch.wrapping_add(1);+ h.app.resolve_pending_gestures(&ctx);+ let reply = rx.try_recv().expect("the blocked paste answers");+ assert_eq!(reply["ok"], false, "{reply}");+ assert!(reply["error"].as_str().unwrap_or_default().contains(message), "{reply}");+ assert!(h.app.pending_gestures.is_empty() && h.app.synthetic.is_empty());+ h.app.quit_prompt = None;+ h.app.library_problem = None;+ }++ // Positive control: with no barrier, the host clipboard answers and the focused field changes.+ h.step();+ h.view.clipboard = "allowed".into();+ let r = h.request("ui.clipboard", serde_json::json!({"action": "paste"}), t);+ assert_eq!(r["ok"], true, "{r}");+ h.step();+ h.step();+ assert_eq!(h.app.ui.search, "allowed", "an ordinary system paste still reaches the focused field");+}++/// A canceled synthetic press must not overwrite a real host modifier change that arrived in the+/// same frame, later cleanup must not clear that still-held host modifier, and a host release must+/// not leave stale synthetic ownership that suppresses the next synthetic Shift gesture.+#[test]+fn synthetic_modifier_ownership_follows_host_changes_across_frames() {+ let ctx = egui::Context::default();+ let mut app = app();+ app.fonts_ready = true;+ // The synthetic gesture held Alt; its cleanup is in flight when the real host presses Shift.+ app.synthetic_mods = egui::Modifiers::ALT;+ app.synthetic_mods_release = true;+ app.pointer_cleanup = true;+ let mut input = raw(egui::vec2(1000.0, 700.0));+ input.events.push(egui::Event::ModifiersChanged(egui::Modifiers::SHIFT));+ app.raw_input_hook(&ctx, &mut input);+ assert_eq!(input.events, vec![egui::Event::ModifiersChanged(egui::Modifiers::SHIFT)], "the host's Shift press survives cleanup");+ assert_eq!(app.host_mods, egui::Modifiers::SHIFT, "the host state is tracked separately");+ assert_eq!(app.synthetic_mods, egui::Modifiers::NONE, "the canceled gesture no longer owns modifiers");+ assert!(!app.synthetic_mods_release);++ // A later synthetic cleanup with no host event must restore the still-held Shift, not NONE.+ app.synthetic_mods = egui::Modifiers::ALT;+ app.synthetic_mods_release = true;+ app.pointer_cleanup = true;+ let mut input = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut input);+ assert_eq!(+ input.events,+ vec![egui::Event::ModifiersChanged(egui::Modifiers::SHIFT)],+ "cleanup restored the physical Shift rather than clearing it"+ );+ assert_eq!(app.host_mods, egui::Modifiers::SHIFT);+ assert_eq!(app.synthetic_mods, egui::Modifiers::NONE);++ // A plain synthetic event carrying NONE likewise must not clear the host's Shift.+ app.synthetic.push(egui::Event::Text("plain".into()));+ let mut input = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut input);+ assert!(+ !input.events.iter().any(|e| matches!(e, egui::Event::ModifiersChanged(_))),+ "a NONE synthetic event did not announce NONE: {:?}",+ input.events+ );+ assert!(input.events.iter().any(|e| matches!(e, egui::Event::Text(text) if text == "plain")));+ app.synthetic_in_flight = false;++ // The host releases Shift. Any stale synthetic ownership would now suppress a later gesture.+ let mut input = raw(egui::vec2(1000.0, 700.0));+ input.events.push(egui::Event::ModifiersChanged(egui::Modifiers::NONE));+ app.raw_input_hook(&ctx, &mut input);+ assert_eq!(app.host_mods, egui::Modifiers::NONE);+ assert_eq!(app.synthetic_mods, egui::Modifiers::NONE);++ // The next synthetic gesture that carries Shift must announce it.+ app.synthetic.push(key_event(egui::Key::A, true, egui::Modifiers::SHIFT));+ app.synthetic.push(key_event(egui::Key::A, false, egui::Modifiers::SHIFT));+ let mut input = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut input);+ assert!(+ input.events.iter().any(|e| matches!(e, egui::Event::ModifiersChanged(m) if *m == egui::Modifiers::SHIFT)),+ "the fresh synthetic Shift gesture announces its modifier: {:?}",+ input.events+ );+ assert_eq!(app.synthetic_mods, egui::Modifiers::SHIFT);+ app.synthetic_in_flight = false;++ // Its release returns to the host's state (NONE), not a stale synthetic Shift.+ let mut input = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut input);+ assert_eq!(input.events, vec![egui::Event::ModifiersChanged(egui::Modifiers::NONE)]);+ assert_eq!(app.synthetic_mods, egui::Modifiers::NONE);++ // Positive control: with no host change, cleanup still releases synthetic modifiers to the+ // host's last known (NONE) state.+ app.synthetic_mods = egui::Modifiers::ALT;+ app.synthetic_mods_release = true;+ app.pointer_cleanup = true;+ let mut input = raw(egui::vec2(1000.0, 700.0));+ app.raw_input_hook(&ctx, &mut input);+ assert_eq!(input.events, vec![egui::Event::ModifiersChanged(egui::Modifiers::NONE)]);+ assert_eq!(app.synthetic_mods, egui::Modifiers::NONE);+ assert!(!app.synthetic_mods_release);+}diff --git a/crates/ui-egui/src/tests_menubar.rs b/crates/ui-egui/src/tests_menubar.rsindex 758ac595a..a67796de8 100644--- a/crates/ui-egui/src/tests_menubar.rs+++ b/crates/ui-egui/src/tests_menubar.rs@@ -18,7 +18,14 @@ fn app(size: [f32; 2]) -> Headless {}fn widget(h: &Headless, id: &str) -> Option<egui::Rect> {- h.app.widgets.iter().find(|(w, _)| w == id).map(|(_, r)| *r)+ h.app.widgets.iter().rev().find(|(w, _)| w == id).map(|(_, r)| *r)+}++/// The scroll viewport clips a menu row independently of the popup's outer rectangle, which+/// also contains its scroll arrows. Target the portion a real pointer can reach.+fn visible_rect(h: &Headless, id: &str) -> Option<egui::Rect> {+ let hit = h.app.widget_hits.iter().rev().find(|(w, _)| w == id)?.1;+ Some(h.view.ctx.layer_transform_to_global(hit.layer_id).map_or(hit.interact_rect, |t| t * hit.interact_rect))}fn widgets_with(h: &Headless, prefix: &str) -> Vec<(String, egui::Rect)> {@@ -44,6 +51,7 @@ fn no_menu_or_submenu_covers_the_menu_bar() {// scrolled menu's submenus must open upward.let sizes = [[1280.0, 703.0], [1160.0, 560.0]];let mut submenus = 0;+ let mut clipped_rows = 0;for size in sizes {for top in ["Photo", "File", "View"] {let what = format!("{size:?} {top}");@@ -57,7 +65,16 @@ fn no_menu_or_submenu_covers_the_menu_bar() {let level = widget(&h, "menu-level:1").unwrap_or_else(|| panic!("{what}: menu"));let rows: Vec<String> = widgets_with(&h, "menusub:").into_iter().filter(|(_, r)| level.contains_rect(*r)).map(|(id, _)| id).collect();for row in rows {- let r = h.request("ui.hoverWidget", json!({"id": row}), T);+ let full = widget(&h, &row).unwrap_or_else(|| panic!("{what}: no {row}"));+ let visible = visible_rect(&h, &row).unwrap_or_else(|| panic!("{what}: no hit area for {row}"));+ assert!(full.is_positive() && visible.is_positive(), "{what}: {row} has no visible portion");+ let at = visible.center();+ if !visible.contains(full.center()) {+ clipped_rows += 1;+ }+ let fx = (at.x - full.left()) / full.width();+ let fy = (at.y - full.top()) / full.height();+ let r = h.request("ui.hoverWidget", json!({"id": row, "fx": fx, "fy": fy}), T);assert_eq!(r["ok"], true, "{what}: {r}");h.settle(SETTLE);if widget(&h, "menu-level:2").is_none() {@@ -69,6 +86,7 @@ fn no_menu_or_submenu_covers_the_menu_bar() {}}assert!(submenus >= 6, "opened {submenus} submenus");+ assert!(clipped_rows > 0, "exercise a row whose geometric centre is clipped away");}#[test]diff --git a/crates/ui-egui/src/tests_quit_unsaved.rs b/crates/ui-egui/src/tests_quit_unsaved.rsindex ef6fa8da4..f703c24a6 100644--- a/crates/ui-egui/src/tests_quit_unsaved.rs+++ b/crates/ui-egui/src/tests_quit_unsaved.rs@@ -106,6 +106,44 @@ fn quitting_with_unsaved_changes_asks_first() {assert!(h.app.quit_confirmed && crate::panels::notices::may_close(&mut h.app));}+/// "Try Saving Again" can recreate the identical unsaved prompt. It is still a new prompt: its+/// first frame is shielded and focus goes back to the safe Cancel, never the Retry button that was+/// just used.+#[test]+fn retrying_an_unsaved_prompt_resets_focus_to_safe_cancel() {+ let store = Unplugged::default();+ let mut s = lightcraft_engine::Session::new();+ let stores = LibraryStores { dir: "unplugged".into(), catalog: Box::new(store.clone()), files: Box::new(MemStore::new()), on_disk: false };+ s.open_library_in(stores, false).unwrap();+ let app = LightcraftApp::new(s, Services { png: None, ..Default::default() });+ let mut h = Headless::new(app, [1200.0, 800.0], 1.0);+ h.step();+ store.fail.store(true, Ordering::SeqCst);+ let r = h.request("engine.execute", json!({"command": "album.create", "params": {"name": "Kept"}}), T);+ assert_eq!(r["ok"], false, "{r}");+ assert!(!crate::panels::notices::may_close(&mut h.app), "retried, still failing: ask");+ h.step();+ h.step();+ let focused = |h: &Headless| h.view.ctx.memory(|m| m.focused());+ let cancel = h.app.widget_hits.iter().rev().find(|(w, _)| w == "button:quitCancel").map(|(_, hit)| hit.id).expect("Cancel has a real response");+ let retry = h.app.widget_hits.iter().rev().find(|(w, _)| w == "button:quitRetry").map(|(_, hit)| hit.id).expect("Retry has a real response");+ assert_eq!(focused(&h), Some(cancel), "the safe Cancel starts focused");+ assert_eq!(h.request("ui.key", json!({"key": "Tab"}), T)["ok"], true);+ assert_eq!(focused(&h), Some(retry), "Tab moved focus to Retry");+ // Activate Retry; the drive is still unplugged, so the same prompt is recreated.+ assert_eq!(h.request("ui.key", json!({"key": "Space"}), T)["ok"], true);+ h.step();+ h.step();+ assert!(matches!(h.app.quit_prompt, Some(crate::QuitPrompt::Unsaved(_))), "the retried save still asks");+ let cancel_after =+ h.app.widget_hits.iter().rev().find(|(w, _)| w == "button:quitCancel").map(|(_, hit)| hit.id).expect("the new Cancel has a real response");+ let retry_after =+ h.app.widget_hits.iter().rev().find(|(w, _)| w == "button:quitRetry").map(|(_, hit)| hit.id).expect("the new Retry has a real response");+ assert_ne!(cancel_after, retry_after);+ assert_eq!(focused(&h), Some(cancel_after), "the recreated prompt reset focus to safe Cancel");+ assert!(!h.app.quit_confirmed, "nothing quit");+}+#[test]fn damaged_settings_file_is_shown() {let files = MemStore::new();diff --git a/crates/ui-egui/src/tests_slideshow.rs b/crates/ui-egui/src/tests_slideshow.rsindex 95a148c98..7dc8ae400 100644--- a/crates/ui-egui/src/tests_slideshow.rs+++ b/crates/ui-egui/src/tests_slideshow.rs@@ -51,6 +51,10 @@ fn photo_up(h: &Headless) -> PhotoId {play(h).current_photo().expect("a photo is up")}+fn rect_json(r: egui::Rect) -> serde_json::Value {+ json!([r.left(), r.top(), r.width(), r.height()])+}+fn slides_held(h: &Headless) -> usize {h.app.renderer.textures.keys().filter(|s| matches!(s, Slot::Slide(_))).count()}@@ -81,6 +85,17 @@ fn slideshow_advances_pauses_and_ends() {h.settle(SETTLE);}+#[test]+fn turning_off_the_full_screen_preview_frees_the_slides() {+ let mut h = grid();+ run(&mut h, "view.slideshow", json!({"interval": 60, "fadeDuration": 0, "preparePreviews": false}));+ assert!(h.step_until(SETTLE, |h| slides_held(h) > 0), "a slide is rendered");+ let r = run(&mut h, "view.fullScreenPreview", json!({}));+ assert_eq!(r["fullscreen"], false);+ assert!(!h.app.ui.fullscreen && h.app.ui.slideshow.is_none(), "the toggle ends the slideshow");+ assert_eq!(slides_held(&h), 0, "slide textures freed");+}+#[test]fn next_slides_are_prepared_before_they_are_due() {let mut h = grid();@@ -277,15 +292,45 @@ fn playback_settings_drive_the_slideshow_and_bad_ones_are_refused() {run(&mut h, "view.slideshowOptions", json!({}));h.step();assert!(h.app.widgets.iter().any(|(w, _)| w == "check:settings.slideshowRandom"));+ // The preview render is a layout input too: wait for the selected photo's real slide before+ // scrolling and clicking, so its completion cannot move the checkbox between those steps.+ let preview = h.app.session.active().expect("the demo library has a selected photo");+ assert!(+ h.step_until(SETTLE, |h| h.app.renderer.textures.get(&Slot::SlidePreview).is_some_and(|t| t.photo == preview)),+ "the real preview is rendered"+ );// (below the Templates at the top of the tab)- reveal(&mut h, "check:settings.slideshowRandom");+ let validated = reveal(&mut h, "check:settings.slideshowRandom");let r = h.request("ui.clickWidget", json!({"id": "check:settings.slideshowRandom"}), T);assert_eq!(r["ok"], true, "{r}");- // (waits for it: one frame isn't always enough on a loaded machine)- assert!(h.step_until(T, |h| h.app.session.slideshow.random_order), "the checkbox goes through slideshow.playback");+ assert_eq!(r["result"]["rect"], rect_json(validated), "the click used the rect reveal validated");+ assert!(h.app.session.slideshow.random_order, "the checkbox goes through slideshow.playback");h.settle(SETTLE);}+#[test]+fn a_click_on_a_control_scrolled_out_of_the_settings_page_is_refused() {+ // A compact window leaves the lower controls of the Slideshow settings page outside the+ // scrolled page room, but they are still laid out and registered.+ let mut h = grid_sized([1000.0, 560.0]);+ run(&mut h, "view.slideshowOptions", json!({}));+ assert!(h.settle(SETTLE), "the settings page settles");+ let target = latest_widget_rect(&h, "check:settings.slideshowRandom").expect("the checkbox is registered");+ let hit = crate::control::widget_hit(&h.app, "check:settings.slideshowRandom").expect("the checkbox has an egui hit owner");+ assert!(+ !crate::control::widget_target_visible(&h.view.ctx, Some(hit), target.center()),+ "the random-order checkbox is clipped out of the page: {target:?}"+ );+ // Its centre is clipped out, so egui would not hit it. Clicking by id must fail closed rather+ // than pressing whatever is at those coordinates.+ let r = h.request("ui.clickWidget", json!({"id": "check:settings.slideshowRandom"}), T);+ assert_eq!(r["ok"], false, "{r}");+ let error = r["error"].as_str().unwrap_or_default();+ assert!(error.contains("check:settings.slideshowRandom"), "{r}");+ assert!(error.contains("nothing was retargeted"), "{r}");+ assert!(!h.app.session.slideshow.random_order, "the clipped control was not clicked");+}+#[test]fn a_photo_deleted_while_it_plays_does_not_stall_the_slideshow() {let mut h = grid();@@ -302,31 +347,77 @@ fn a_photo_deleted_while_it_plays_does_not_stall_the_slideshow() {h.settle(SETTLE);}+/// The latest registry entry for `id`, as [`crate::control::widget_rect`] looks it up (the last+/// registered rect wins).+fn latest_widget_rect(h: &Headless, id: &str) -> Option<egui::Rect> {+ h.app.widgets.iter().rev().find(|(w, _)| w == id).map(|(_, r)| *r)+}++fn in_page_room(room: egui::Rect, widget: egui::Rect) -> bool {+ widget.center().y >= room.top() + 10.0 && widget.center().y <= room.bottom() - 10.0+}++/// egui 0.37 smooths wheel deltas over several frames (and ends the action after a short idle).+/// Do not measure or click until the Settings page has really stopped scrolling.+fn wait_for_scroll_settled(h: &mut Headless) {+ for _ in 0..600 {+ if !h.view.ctx.input(|i| i.is_scrolling()) {+ return;+ }+ h.step();+ }+ panic!("the Settings page kept scrolling");+}++/// The widget's latest rect once the whole rect (not just its centre) has stayed unchanged for+/// three completed passes. A pinned widget is allowed above the page; a page widget must still be+/// inside the page's room.+fn settled_revealed(h: &mut Headless, id: &str, pinned: bool) -> egui::Rect {+ let mut last = None;+ let mut stable = 0;+ for _ in 0..240 {+ h.step();+ let Some(now) = latest_widget_rect(h, id) else {+ last = None;+ stable = 0;+ continue;+ };+ let room = latest_widget_rect(h, "settings:pageRoom").expect("the Slideshow settings are open");+ let in_place = if pinned { now.bottom() <= room.top() } else { in_page_room(room, now) };+ if !in_place || h.view.ctx.input(|i| i.is_scrolling()) {+ last = Some(now);+ stable = 1;+ continue;+ }+ if last == Some(now) {+ stable += 1;+ if stable >= 3 {+ return now;+ }+ } else {+ stable = 1;+ }+ last = Some(now);+ }+ panic!("{id} never settled in view");+}+/// Scroll the Settings ▸ Slideshow page until widget `id` is in view (in the middle of the room/// for the page): the sections are taller than the dialog. (The slide preview and its choice are pinned-/// above the page and are in view already.)-fn reveal(h: &mut Headless, id: &str) {- let find = |h: &Headless, w: &str| h.app.widgets.iter().find(|(i, _)| i == w).map(|(_, r)| *r);+/// above the page and are in view already.) Returns the settled rect that the click will use.+fn reveal(h: &mut Headless, id: &str) -> egui::Rect {+ // (the preview and its Photo / Intro / Ending choice are pinned above the page: always in+ // view, never scrolled to)+ let pinned = id == "slideshow:preview" || id.starts_with("button:settingsSlideshowPreviewShows-");for _ in 0..40 {h.step();- let room = find(h, "settings:pageRoom").expect("the Slideshow settings are open");- // (the preview and its Photo / Intro / Ending choice are pinned above the page: always in- // view, never scrolled to)- let pinned = id == "slideshow:preview" || id.starts_with("button:settingsSlideshowPreviewShows-");- if pinned && find(h, id).is_some_and(|w| w.bottom() <= room.top()) {- return;+ wait_for_scroll_settled(h);+ let room = latest_widget_rect(h, "settings:pageRoom").expect("the Slideshow settings are open");+ let in_view = latest_widget_rect(h, id).is_some_and(|w| if pinned { w.bottom() <= room.top() } else { in_page_room(room, w) });+ if in_view {+ return settled_revealed(h, id, pinned);}- let dy = match find(h, id) {- Some(w) if w.center().y >= room.top() + 10.0 && w.center().y <= room.bottom() - 10.0 => {- // (in view and still: the page eases to where it was scrolled to)- for _ in 0..3 {- h.step();- }- if find(h, id).is_some_and(|now| (now.center().y - w.center().y).abs() < 0.5) {- return;- }- continue;- }+ let dy = match latest_widget_rect(h, id) {Some(w) => (room.center().y - w.center().y).clamp(-500.0, 500.0),None => -300.0,};@@ -334,9 +425,7 @@ fn reveal(h: &mut Headless, id: &str) {assert_eq!(r["ok"], true, "{r}");let r = h.request("ui.scroll", json!({"dy": dy}), T);assert_eq!(r["ok"], true, "{r}");- for _ in 0..8 {- h.step();- }+ wait_for_scroll_settled(h);}panic!("{id} never came into view");}diff --git a/crates/ui-egui/src/text_field.rs b/crates/ui-egui/src/text_field.rsindex d9a28dadb..a9a98d86b 100644--- a/crates/ui-egui/src/text_field.rs+++ b/crates/ui-egui/src/text_field.rs@@ -236,7 +236,7 @@ impl<'a> TextField<'a> {state.cursor.set_char_range(selection);state.store(ui.ctx(), id);}- crate::widgets::register(ui.ctx(), self.widget, response.rect);+ crate::widgets::register(ui, self.widget, response.rect);// egui's own focus: `Response::has_focus` is also false while the window is in the// background (another app in front), which neither ends nor restarts an editlet focused = ui.memory(|m| m.has_focus(id));@@ -382,7 +382,7 @@ fn menu(ui: &mut Ui, widget: &str, id: egui::Id, text: &str, action: &mut Option}let button = egui::Button::new(crate::i18n::tr(label)).shortcut_text(crate::menubar::shortcut_text(shortcut, mac));let r = ui.add_enabled(enabled, button);- crate::widgets::register(ui.ctx(), format!("{widget}:{key}"), r.rect);+ crate::widgets::register(ui, format!("{widget}:{key}"), r.rect);if r.clicked() {*action = Some(a);ui.close();diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rsindex ab8ae253a..eb5e62589 100644--- a/crates/ui-egui/src/widgets.rs+++ b/crates/ui-egui/src/widgets.rs@@ -79,13 +79,87 @@ pub fn context_menu_close(response: &Response, default: egui::PopupCloseBehavior// ------------------------------------------------------------------ automation registry+/// The real egui widget that owns a registered automation rectangle.+///+/// Automation ids are names for scripts; egui hit-tests widget [`egui::Id`]s in a [`egui::LayerId`].+/// [`register`] records a small non-interactive probe with the registered rect so the control+/// channel can ask egui itself whether that rectangle owns the pointer, rather than guessing from+/// unrelated interactive rectangles.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub struct WidgetHit {+ pub id: egui::Id,+ pub layer_id: egui::LayerId,+ /// The widget's clipped interaction rectangle in its layer's local coordinates, recorded in+ /// the same pass as the registration. Delivery checks this instead of calling+ /// `Context::read_response` before the next pass: at that point `read_response` can still see+ /// the pass before the registry that was just published.+ pub interact_rect: Rect,+}+#[derive(Clone, Default)]-pub struct Registry(pub Vec<(String, Rect)>);+pub struct Registry {+ pub rects: Vec<(String, Rect)>,+ pub hits: Vec<(String, WidgetHit)>,+ /// How many times each automation id was registered in this pass (for stable duplicate probe+ /// ids). A map keeps registration linear; scanning `rects` would make a pass O(N²).+ occurrences: std::collections::HashMap<String, usize>,+}++/// Record a widget's automation id and screen rect for this frame, and register a hover probe at+/// the same rectangle in the current UI layer.+///+/// The probe senses hover only (no click or drag), so it never takes a click from the widget it+/// describes. It records the current UI layer and its clipped `Response::interact_rect` in the+/// same pass, and the control channel asks egui for the top-most interactable layer at the point.+/// A probe below a non-modal foreground/dim overlay is therefore refused without ever pressing the+/// overlay. A point below the top modal dialog is instead left to egui's modal routing: the dialog+/// consumes it, or a click on the backdrop closes the dialog, and no background widget is pressed.+pub fn register(ui: &egui::Ui, id: impl Into<String>, rect: Rect) {+ let ctx = ui.ctx();+ let registry = egui::Id::unique("lc-registry");+ let id = id.into();+ // Stable across frames even when unrelated widgets come and go: the probe id names the+ // automation id (and a duplicate occurrence of the same id in this pass), not its position.+ let duplicate = ctx.data_mut(|d| {+ let registry = d.get_temp_mut_or_default::<Registry>(registry);+ let occurrence = registry.occurrences.entry(id.clone()).or_insert(0);+ let duplicate = *occurrence;+ *occurrence = occurrence.saturating_add(1);+ duplicate+ });+ let hit = rect.is_finite().then(|| {+ let id = egui::Id::unique(("lc-automation-hit", id.as_str(), duplicate));+ let response = ui.interact(rect, id, egui::Sense::hover());+ WidgetHit { id, layer_id: response.layer_id, interact_rect: response.interact_rect }+ });+ ctx.data_mut(|d| {+ let registry = d.get_temp_mut_or_default::<Registry>(registry);+ registry.rects.push((id.clone(), rect));+ if let Some(hit) = hit {+ registry.hits.push((id, hit));+ }+ });+}-/// Record a widget's automation id and screen rect for this frame.-pub fn register(ctx: &egui::Context, id: impl Into<String>, rect: Rect) {+/// Record a widget whose real egui [`egui::Response`] is available. More precise than+/// [`register`]'s hover probe: the response carries the widget's own id, layer and clipped+/// geometry, and remains a valid automation target when disabled (`ui.clickWidget` on a disabled+/// control is a successful no-op, which is the documented automation semantics).+pub fn register_response(id: impl Into<String>, rect: Rect, response: &egui::Response) {let id = id.into();- ctx.data_mut(|d| d.get_temp_mut_or_default::<Registry>(egui::Id::unique("lc-registry")).0.push((id, rect)));+ let ctx = response.ctx.clone();+ ctx.data_mut(|d| {+ let registry = d.get_temp_mut_or_default::<Registry>(egui::Id::unique("lc-registry"));+ registry.rects.push((id.clone(), rect));+ registry.hits.push((id, WidgetHit { id: response.id, layer_id: response.layer_id, interact_rect: response.interact_rect }));+ });+}++/// Record painted geometry that has no interactive egui widget of its own (a preview image, a+/// drop card). `ui.clickWidget` will not press it: there is no widget hit to own the press.+pub fn register_geometry(ctx: &egui::Context, id: impl Into<String>, rect: Rect) {+ let id = id.into();+ ctx.data_mut(|d| d.get_temp_mut_or_default::<Registry>(egui::Id::unique("lc-registry")).rects.push((id, rect)));}/// Esc was handled this frame by something nested (an open popup closed on it): containers such@@ -100,8 +174,16 @@ pub fn escape_taken(ctx: &egui::Context) -> bool {ctx.data(|d| d.get_temp::<u64>(egui::Id::unique("lc-escape-taken"))) == Some(ctx.cumulative_frame_nr())}+/// Take this pass's registered rectangles and their egui hit owners. The app publishes both only+/// for a completed, nondiscarded pass.+pub fn take_registries(ctx: &egui::Context) -> (Vec<(String, Rect)>, Vec<(String, WidgetHit)>) {+ let registry = ctx.data_mut(|d| std::mem::take(d.get_temp_mut_or_default::<Registry>(egui::Id::unique("lc-registry"))));+ (registry.rects, registry.hits)+}++/// Take only the registered rectangles (for unit tests that inspect layout).pub fn take_registry(ctx: &egui::Context) -> Vec<(String, Rect)> {- ctx.data_mut(|d| std::mem::take(&mut d.get_temp_mut_or_default::<Registry>(egui::Id::unique("lc-registry")).0))+ take_registries(ctx).0}// ------------------------------------------------------------------ preview-only raws@@ -153,7 +235,7 @@ pub fn preview_only_notice(ui: &mut Ui, key: &str, reason: &str) -> bool {.response;let r = r.on_hover_text(crate::i18n::tr_format!("Decoder: {reason}", reason = reason));r.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Label, true, crate::i18n::tr("Preview only: editing the camera's embedded JPEG")));- register(ui.ctx(), format!("notice:previewOnly:{key}"), r.rect);+ register(ui, format!("notice:previewOnly:{key}"), r.rect);reload}@@ -333,14 +415,14 @@ pub fn slider(ui: &mut Ui, spec: &ControlSpec, value: f64, enabled: bool, label_let reset_hint = crate::i18n::tr_format!("{name} — double-click to reset it", name = label_text);let label_resp = if enabled { label_resp.on_hover_text(reset_hint.as_str()) } else { label_resp };crate::widgets::announce(&label_resp, crate::i18n::tr_format!("Reset {name}", name = label_text.clone()));- register(ui.ctx(), format!("sliderLabel:{}", spec.id), label_rect);- register(ui.ctx(), format!("slider:{}", spec.id), track_rect);+ register(ui, format!("sliderLabel:{}", spec.id), label_rect);+ register(ui, format!("slider:{}", spec.id), track_rect);// the value: click it to type an exact one, drag it sideways to scrub (over the label, so it// takes the click)let value_rect = Rect::from_min_max(pos2(label_rect.right() - 64.0, label_rect.top()), label_rect.max);let value_resp = ui.interact(value_rect, id.with("value"), if enabled { Sense::click_and_drag() } else { Sense::hover() });crate::widgets::announce(&value_resp, format!("{label_text}: {}", crate::i18n::tr("Click to type a value, drag to change it")));- register(ui.ctx(), format!("sliderValue:{}", spec.id), value_rect);+ register(ui, format!("sliderValue:{}", spec.id), value_rect);// say that an exact value can be typed here (issue #534: an exact crop angle was hard to find)let value_resp = if enabled { value_resp.on_hover_text(crate::i18n::tr("Click to type a value, drag to change it")) } else { value_resp };let typing_id = id.with("typing");@@ -644,7 +726,7 @@ pub fn section_header(ui: &mut Ui, id: &str, title: &str, open: bool, enabled: Olet w = ui.available_width();let (r, resp) = ui.allocate_exact_size(vec2(w, 52.0), Sense::click());announce_disclosure(&resp, true, open, title);- register(ui.ctx(), format!("section:{id}"), r);+ register(ui, format!("section:{id}"), r);let p = ui.painter();if ui.rect_contains_pointer(r) {p.rect_filled(r, 0.0, t.chrome.gamma_multiply(1.06));@@ -662,7 +744,7 @@ pub fn section_header(ui: &mut Ui, id: &str, title: &str, open: bool, enabled: Olet eye = Rect::from_center_size(pos2(r.right() - 34.0, r.center().y), vec2(18.0, 18.0));let er = ui.interact(eye, ui.scope_id().with(("eye", id)), Sense::click());crate::widgets::announce_selected(&er, crate::i18n::tr("Show / hide"), on);- register(ui.ctx(), format!("sectionEye:{id}"), eye);+ register(ui, format!("sectionEye:{id}"), eye);paint(ui.painter(), eye, Icon::Eye, if on { t.icon } else { t.text_disabled });if !on {ui.painter().line_segment([eye.left_bottom(), eye.right_top()], Stroke::new(1.5, t.text_disabled));@@ -691,7 +773,7 @@ pub fn flyout_row(ui: &mut Ui, id: &str, title: &str, icon: Icon, open: bool) ->let r = Rect::from_min_max(pos2(outer.left() + 16.0, outer.top() + 4.0), pos2(outer.right() - 16.0, outer.bottom() - 4.0));let resp = ui.interact(r, ui.scope_id().with(("flyout", id)), Sense::click());announce_disclosure(&resp, true, open, title);- register(ui.ctx(), format!("flyout:{id}"), r);+ register(ui, format!("flyout:{id}"), r);let p = ui.painter();p.rect_filled(r, 4.0, if resp.hovered() { t.hover.gamma_multiply(0.8) } else { t.inset });let tile = Rect::from_min_size(pos2(r.left() + 4.0, r.top() + 4.0), vec2(r.height() - 8.0, r.height() - 8.0));@@ -716,7 +798,7 @@ pub fn text_button(ui: &mut Ui, id: &str, label: &str, active: bool) -> Responselet size = vec2((galley.size().x + 18.0).max(37.0), 24.0);let (r, resp) = ui.allocate_exact_size(size, Sense::click());resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, true, active, label));- register(ui.ctx(), format!("button:{id}"), r);+ register(ui, format!("button:{id}"), r);let fill = if active {t.pressed} else if resp.hovered() {@@ -747,7 +829,7 @@ pub fn segmented(ui: &mut Ui, id: &str, items: &[(&str, &str)], active: Option<ulet i = row_i * per_row + j;let (r, resp) = ui.allocate_exact_size(vec2(seg_w, 24.0), Sense::click());crate::widgets::announce_selected(&resp, label.to_string(), active == Some(i));- register(ui.ctx(), format!("button:{id}-{key}"), r);+ register(ui, format!("button:{id}-{key}"), r);let fill = if active == Some(i) {t.pressed} else if resp.hovered() {@@ -773,7 +855,7 @@ pub fn icon_button(ui: &mut Ui, id: &str, icon: Icon, size: egui::Vec2, active:let t = Tokens::get(ui.ctx());let (r, resp) = ui.allocate_exact_size(size, if enabled { Sense::click() } else { Sense::hover() });resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, enabled, active, tooltip));- register(ui.ctx(), format!("icon:{id}"), r);+ register(ui, format!("icon:{id}"), r);let p = ui.painter();let sq = Rect::from_center_size(r.center(), vec2(32.0f32.min(size.x), 32.0f32.min(size.y)));if active {@@ -809,7 +891,7 @@ pub fn dropdown_within(ui: &mut Ui, id: &str, text: &str, font: egui::FontId, colet size = vec2(galley.size().x + 20.0, galley.size().y.max(20.0));let (r, resp) = ui.allocate_exact_size(size, Sense::click());resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::ComboBox, true, text));- register(ui.ctx(), format!("dropdown:{id}"), r);+ register(ui, format!("dropdown:{id}"), r);let c = if resp.hovered() { t.text } else { color };ui.painter().galley(pos2(r.left(), r.center().y - galley.size().y / 2.0), galley, c);paint(ui.painter(), Rect::from_center_size(pos2(r.right() - 10.0, r.center().y), vec2(16.0, 16.0)), Icon::ChevronDown, c);diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex ceb73fbc5..3b4c7ed95 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -10,7 +10,9 @@```Requests are answered on the UI thread between frames (timeout 60 s). A request is given up-if the app has not started it and draws no frame for 5 s. The reply is then `{"ok": false, "error": "the app drew no frame for 5 s, …"}`,+if the app has not started it and draws no frame for 5 s. Synthetic pointer input is fed one event+per frame; the same 5 s limit is a delivery stall, restarted whenever the app consumes a batch, so a+many-step drag on a slow frame is not cut off while an app that stops drawing still fails. The reply is then `{"ok": false, "error": "the app drew no frame for 5 s, …"}`,and the app never runs that request later, so a retry doesn't do it twice. This happens onWayland when the window is on a hidden workspace or minimized: the compositor sends no framecallbacks, so the app's loop is paused. Keep the window on screen while you drive it, or use@@ -79,12 +81,12 @@ filmstrip is visible.| `ui.menu.tree` | — | The menu bar as shown (File … Help): items `{id, params?, label, shortcut?, enabled, checked?}`, separators, submenus — the model behind the native macOS menu bar and the in-window menus || `ui.inspect` | — | UI state, window, `loupe` (`source`, `pending`, `failed` = why its render failed, else `null`, and `region: {full, window, pending}` when a zoomed view also renders the window on screen at no more than 100 % — `full` is the frame it is cut from, `window` its `[x, y, w, h]` — and `regionBefore` for the Before side of a Before/After view), canvas/image rects, `scroll: {grid, filmstrip}` (scroll offsets in points, `null` until drawn), active photo, selection, perf (`frameMs` = layout, `logicMs` = per-frame logic before it, `updateMs` = both, `maxUpdateMs`, `fps`, render queue …, `gpu` = adapter in use, `gpuReason` = why renders don't use the GPU, `gpuFallback` = latest render redone on the CPU and why — see `docs/gpu-pipeline.md`), status, memory (bytes per cache, see `library.memory`; plus stage caches — `budgetBytes`, `trimmed`, `sharedSourceBytes` (the one device copy of a big original) — and textures), `export: {running: {total, done, current} \| null, last}`, `notices` (warnings waiting to be shown, e.g. a damaged settings file; OK = `button:noticeOk`), `quitPrompt` (why quitting was stopped: tasks that would be cut short are running — `button:quitAnyway` cancels them and quits, `button:quitCancel` keeps working — or unsaved changes: `button:quitRetry` / `button:quitAnyway` / `button:quitCancel`), `import: {done, total, imported, cancelled} \| null` (an import runs on a worker thread), `tasks` (other background work: `Find Missing Photos`, `Auto Import`), `activity` (every long-running task in flight as the activity stack in the top-left corner shows it, same shape as `activity.list`; a row appears once its task is 0.5 s old, ids `activity:row:<id>`, ✕ = `activity:cancel:<id>`, `activity:more` expands past 3 rows), `fileDialogs` (commands waiting on a native file dialog, which runs off the UI thread; they run again with the answer when it closes), `copied` (the text the UI last put on the clipboard, `null` until something is copied) || `ui.widgets` | `{filter?}` | On-screen widgets `{id, rect: [x, y, w, h]}` (screen points) |-| `ui.clickWidget` / `ui.dragWidget` / `ui.hoverWidget` | `{id, count?, button?, fx?, fy?}` (`button: "right"` right-clicks) / `{id, toX?, toY?, dx?, dy?, steps?}` / `{id, fx?, fy?}` | Real egui input on a widget (hover: the pointer rests on it, e.g. for preset/profile previews) |-| `ui.move` / `ui.click` / `ui.drag` | `{x, y, count?, button?}` / `{x, y, toX, toY, steps?}` | Raw pointer input, screen points |+| `ui.clickWidget` / `ui.dragWidget` / `ui.hoverWidget` | `{id, count?, button?, fx?, fy?}` (`button: "right"` right-clicks; `count` is capped at 16) / `{id, toX?, toY?, dx?, dy?, steps?}` (steps are capped at 1000) / `{id, fx?, fy?}` | Real egui input on a widget (hover: the pointer rests on it, e.g. for preset/profile previews). `fx`/`fy` are fractions of the registered rect and may lie outside `[0,1]`; the resulting point must still be inside egui's clipped interaction rect, and a non-finite fraction or resolved point is rejected before any input is queued. Geometry comes from the latest completed layout; if the widget moves before the first event or before a press, or its latest clipped rect no longer contains the point, the request fails with an error instead of clicking another widget or retargeting. A target below an ordinary modal dialog may succeed as a no-op or a backdrop click, because egui routes that input to the dialog; a target covered by a non-modal overlay fails. The blocking library-problem/launch-list window is explicit: its dim takes the modal layer, but a background target fails instead of reporting a no-op success, and only that window's own controls (`button:library…`) pass. Its creation frame is shielded and redrawn with empty input like a prompt's, so background text/pointer input cannot act while the new modal areas settle. A quit prompt or settings notice is a real egui modal scope with a foreground backdrop. Only its own buttons (`button:quit…`, `button:noticeOk`) accept a `ui.clickWidget`; background targets fail, and background keystrokes, text/clipboard input, wheel/zoom input and AccessKit actions are dropped before panels see them. The prompt itself takes Tab/Shift+Tab, Enter/Space on the focused button, and Escape/Enter for the safe default Cancel; AccessKit Focus/Click works when targeted at a prompt button. Its first creation frame (including a Tasks→Unsaved or notice→next-notice transition) is shielded and redrawn with empty input, so a press/release in that frame, or a held press from before it, cannot act underneath it; a synthetic drag already in progress is canceled. Once settled, raw `ui.click`/`ui.drag`/`ui.pointer` and backdrop clicks are still delivered to the prompt backdrop as no-ops, and the prompt's own button clicks work normally. The area/layer check cannot see a different widget covering the point in the same layer. A `ui.clickWidget` whose widget disappears before its release also fails, after canceling the pointer press without a click or drag (the same rules apply when a click spans several host frames) |+| `ui.move` / `ui.click` / `ui.drag` | `{x, y, count?, button?}` / `{x, y, toX, toY, steps?}` | Raw pointer input, screen points (the same click and step caps apply) || `ui.pointer` | `{events: [{kind: down\|drag\|up, x, y}], alt?, shift?, cmd?}` | Gesture in normalized image coordinates (Detail view) |-| `ui.key` | `{key, cmd?, shift?, alt?, ctrl?}` | Key press |+| `ui.key` | `{key, cmd?, shift?, alt?, ctrl?}` | Key press; while a prompt is up only its Tab/Shift+Tab, Enter, Space and Escape are delivered, every other key is dropped || `ui.text` | `{text}` | Text input |-| `ui.clipboard` | `{action: cut\|copy\|paste, text?}` | Cut, copy or paste in the focused text field, as the system does for ⌘X / ⌘C / ⌘V; `paste` pastes `text`, or the system clipboard without it. Refused when no text field has the focus (outside one, ⌘C / ⌘V are the commands `develop.copy` / `develop.paste`). In the desktop app cut and copy write the system clipboard. `ui.inspect` → `copied` is the text the UI last put on the clipboard |+| `ui.clipboard` | `{action: cut\|copy\|paste, text?}` | Cut, copy or paste in the focused text field, as the system does for ⌘X / ⌘C / ⌘V; `paste` pastes `text`, or the system clipboard without it. Refused when no text field has the focus (outside one, ⌘C / ⌘V are the commands `develop.copy` / `develop.paste`). In the desktop app cut and copy write the system clipboard. Refused while a prompt or the blocking library window owns input, including a window in its creation frame. A `paste` without `text` queues egui's `RequestPaste` viewport command for the host: egui 0.37 gives that command no completion/correlation id, and egui-winit emits a later `Event::Paste` only for non-empty text (or a `PasteImage` fallback; asynchronous clipboard reads finish later), so the reply confirms the request was queued in egui, not that the host dispatched it or that it was delivered; a barrier created after the request can drop that later event. `paste` with `text` is synthetic and is canceled like other injected input. `ui.inspect` → `copied` is the text the UI last put on the clipboard || `ui.scroll` | `{dx, dy, source?, unit?, phase?, cmd?, ctrl?, shift?, alt?}` | Wheel / two-finger scroll at the current pointer; pans over the image, modifier-scroll zooms. `source` is `unknown` (default), `wheel`, `trackpad` or `momentum`; `unit` is `point` (default), `line` or `page`; `phase` is `move` (default), `start`, `end` or `cancel`. Wheel/line events drive the grid/filmstrip one-third wheel step and the loupe's notch zoom; trackpad/momentum phases drive kinetic scrolling and rubber-band boundaries. Invalid values are refused and queue nothing || `ui.zoom` | `{factor}` | Pinch zoom at the current pointer (positive scale multiplier; 1 = unchanged). Position it first with `ui.move` or `ui.hoverWidget` || `ui.set` | partial UI state, e.g. `{"view": "detail"}` | Resulting UI state |@@ -332,8 +334,9 @@ lightcraft-cli snapshot --library DIR --script tour.jsonl -o shot.pngHeadless screenshot dimensions must be finite and at least one logical point, with a finite,positive scale. Rounded output must be at least one pixel per edge, at most 16,384 pixels-per edge and 64 million pixels in total. `snapshot` and `ui.resize` reject requests outside-these limits before layout or rasterization; supplied resize dimensions must be numbers.+per edge and 33,554,432 pixels in total (128 MiB of RGBA, the per-image screenshot+budget). `snapshot` and `ui.resize` reject requests outside these limits before layout or+rasterization; supplied resize dimensions must be numbers.An interface zoom (egui's zoom factor; the keyboard never changes it — ⌘= / ⌘− / ⌘0 zoom thephoto, issue #566) changes text and control sizes while preserving the snapshot viewport's requestedphysical pixel dimensions. Later `ui.resize` requests use current egui points; validationdiff --git a/docs/egui-037-migration-plan.md b/docs/egui-037-migration-plan.mdindex 3e08f106b..6606d4e88 100644--- a/docs/egui-037-migration-plan.md+++ b/docs/egui-037-migration-plan.md@@ -10,6 +10,20 @@ The review packet separately records inherited default-font notice coverage andCurrent status note (2026-10-25): `flake.nix` now points at craft-fonts `b076417b5880bd4154bd22f00695b1d28c6bea83`, matching CI, the release workflow and the standalone packaging helpers, and `flake.lock` was regenerated by Nix 2.26.3 using `nix flake update craft-fonts` against the canonical GitHub revision. Only the craft-fonts node changed; nixpkgs stayed pinned. Linux x86_64 flake evaluation passed with `nix flake check --no-build --no-write-lock-file` (job `egui037-lightcraft-nix-eval-20261025-0495`). No Nix package build, executed formatting derivation, or other architecture is claimed. The inherited gaps above (egui default-font licence coverage for Hack, Ubuntu-Light and NotoEmoji-Regular; the Inter OFL packaging omission) are not migration-introduced, and this landing updates the craft-fonts notices and attribution text only.+Font notice and Inter staging follow-up (2026-10-25): the inherited gaps above are now addressed at+source level only. `NOTICE` reproduces the pinned upstream texts verbatim for Hack Regular (MIT and the+Bitstream Vera License), Ubuntu Light (Ubuntu Font Licence 1.0) and Noto Emoji Regular (SIL OFL 1.1),+next to the existing egui-icons/emoji-icon-font block; `assets/ATTRIBUTION.md` gains rows for+`epaint_default_fonts::HACK_REGULAR`, `UBUNTU_LIGHT` and `NOTO_EMOJI_REGULAR`; `packaging/env.sh`+`copy_font_licences` now always stages `assets/fonts/OFL-Inter.txt` as `OFL-Inter.txt` before the optional+craft-fonts OFLs (Linux, macOS app and CLI, FreeBSD and web use it), and the Flatpak from-source manifest+installs it directly. The release Flatpak bundle repackages the Linux tarball and so inherits its documents;+Windows and Nix already staged Inter. Managed staging checks verified the three upstream licence texts+byte-for-byte in `NOTICE`, copied Inter with and without an optional craft-fonts input, and confirmed+that a missing Inter licence makes staging fail. These checks exercise the shared document-copy helper;+actual release artifacts (deb/rpm/tar, macOS app and CLI, FreeBSD, web zip, Flatpak, MSI/portable zip, Nix)+and their installed notice contents remain unverified.+Library-check results now remain visible for the frame in which they arrive, so a zero-delay refresh cannot immediately replace a fresh missing-library answer. The scheduling fence uses the root UI frame number across all layout passes; focused regressions cover the single-pass and forced-multipass cases with isolated temporary directories. Fresh static review accepted the delivery-frame behavior.The original planning and earlier qualification record follows. Its pins, hashes, paths and passing counts are historical.diff --git a/packaging/env.sh b/packaging/env.shindex 56920839e..591cdfb86 100644--- a/packaging/env.sh+++ b/packaging/env.sh@@ -46,21 +46,24 @@ warn() {return 0}-# Copy licence and readme files that exist into a package directory (plus the craft-fonts licences-# when building with CRAFT_FONTS_DIR).+# Copy licence and readme files that exist into a package directory, plus the font licence texts+# (Inter's OFL always; the craft-fonts OFLs when building with CRAFT_FONTS_DIR).copy_docs() {local dest="$1" ffor f in README.md LICENSE LICENSE-MIT LICENSE-APACHE COPYRIGHT NOTICE; doif [[ -f "$ROOT/$f" ]]; then cp "$ROOT/$f" "$dest/"; fidonecopy_font_licences "$dest"- return 0+ return $?}-# Builds made with CRAFT_FONTS_DIR (storytold/craft-fonts, an optional build input) embed its fonts;-# their OFL licences go with the package as OFL-<family-dir>.txt. Nothing to do without it.+# Inter is embedded in every build (crates/ui-egui/src/theme.rs), so its OFL always ships with the+# package as OFL-Inter.txt. Builds made with CRAFT_FONTS_DIR (storytold/craft-fonts, an optional+# build input) also embed its fonts; their OFL licences go with the package as OFL-<family-dir>.txt.copy_font_licences() {local dest="$1" lic family+ local inter="$ROOT/assets/fonts/OFL-Inter.txt"+ cp "$inter" "$dest/OFL-Inter.txt" || return $?[[ -n "${CRAFT_FONTS_DIR:-}" ]] || return 0for lic in "$CRAFT_FONTS_DIR"/fonts/*/OFL.txt; do[[ -f "$lic" ]] || continuediff --git a/packaging/linux/flatpak/ai.storyteller.lightcraft.yml b/packaging/linux/flatpak/ai.storyteller.lightcraft.ymlindex c983daae8..4e03df005 100644--- a/packaging/linux/flatpak/ai.storyteller.lightcraft.yml+++ b/packaging/linux/flatpak/ai.storyteller.lightcraft.yml@@ -54,6 +54,7 @@ modules:- mkdir -p /app/share/icons && cp -R assets/app-icon/hicolor /app/share/icons/- install -Dm644 NOTICE /app/share/doc/lightcraft/NOTICE- install -Dm644 assets/ATTRIBUTION.md /app/share/doc/lightcraft/ATTRIBUTION.md+ - install -Dm644 assets/fonts/OFL-Inter.txt /app/share/doc/lightcraft/OFL-Inter.txt- >-version=$(awk '/^\[/{p=($0=="[workspace.package]");next} p&&$1=="version"{gsub(/[" ]/,"",$3);print $3;exit}' Cargo.toml);install -d /app/share/metainfo;