From f86d06c71d70579eccd89bc2fcb0e253d65d599f Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 13 Nov 2026 01:31:39 +0100 Subject: [PATCH 1/5] Top bar: drop the workspace switcher, search and appearance buttons (#13577) The reference application's top bar holds the menus, the title and the window buttons only. Each removed control stays in a menu: Window > Workspace, Edit > Search, Window > Theme. The title now centres in the room up to the bar's far end. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas/zoom_field.rs | 13 ++- crates/ui-egui/src/menus/workspace_ui.rs | 21 ----- crates/ui-egui/src/panels/title_bar.rs | 85 +++++-------------- crates/ui-egui/src/prefs/prefs_ui.rs | 4 +- .../ui-egui/src/prefs/prefs_ui/appearance.rs | 35 -------- crates/ui-egui/src/prefs/prefs_ui/tests.rs | 5 +- crates/ui-egui/src/text/direction/tests.rs | 23 +++-- 7 files changed, 46 insertions(+), 140 deletions(-) diff --git a/crates/ui-egui/src/canvas/zoom_field.rs b/crates/ui-egui/src/canvas/zoom_field.rs index 48a26afac0d..3cd563f8e5c 100644 --- a/crates/ui-egui/src/canvas/zoom_field.rs +++ b/crates/ui-egui/src/canvas/zoom_field.rs @@ -10,8 +10,7 @@ //! * Alt (tapped) does only that alert: it neither puts the keyboard on the menu bar nor leaves //! the field. //! * A click, with either button, on the pasteboard (the canvas around the image), anywhere on the -//! title bar (menu titles, the empty drag area, the workspace switcher, search, the theme -//! button, Minimise / Maximise / Close), or on an open menu or dropdown (Help's "Search menus" +//! title bar (menu titles, the empty drag area, Minimise / Maximise / Close), or on an open menu or dropdown (Help's "Search menus" //! field included), keeps the typed number unapplied, rewritten and selected as Tab does it. //! * Whatever the key or click, a typed number is never applied while the window is not focused. //! * Only digits, `/` and the system's decimal separator ([`crate::i18n::decimal_separator`]: `,` on @@ -469,8 +468,8 @@ pub(crate) fn alert_pending(ctx: &Context) -> bool { ctx.data(|d| d.get_temp::(alert_id())).unwrap_or(false) } -/// Remembers the rectangle of the whole title bar (menus, the empty drag area, workspace switcher, -/// search and theme buttons, the caption buttons) for [`on_title_bar`]. +/// Remembers the rectangle of the whole title bar (menus, the empty drag area, the caption buttons) +/// for [`on_title_bar`]. pub(crate) fn set_title_bar_rect(ctx: &Context, rect: egui::Rect) { let pass = ctx.cumulative_pass_nr(); ctx.data_mut(|d| d.insert_temp(title_bar_rect_id(), (rect, pass))); @@ -534,8 +533,8 @@ pub fn tick(app: &mut crate::PhotocraftApp, ctx: &Context) { track_pasteboard(ctx, press.is_some_and(|pos| on_pasteboard(app, ctx, pos) || on_menu_bar(ctx, pos) || on_title_bar(ctx, pos) || on_open_popup(ctx, pos))); } -/// Is screen point `pos` anywhere on the title bar: the menu titles and the gaps between them, the -/// workspace switcher (Essentials), search, the theme button, Minimise / Maximise / Close? +/// Is screen point `pos` anywhere on the title bar: the menu titles and the gaps between them, +/// Minimise / Maximise / Close? fn on_title_bar(ctx: &Context, pos: egui::Pos2) -> bool { fresh_rect_contains(ctx, title_bar_rect_id(), pos) } @@ -645,7 +644,7 @@ mod tests { let bar = egui::Rect::from_min_size(egui::pos2(0.0, 0.0), egui::vec2(800.0, 32.0)); assert!(!on_title_bar(&ctx, egui::pos2(10.0, 10.0)), "nothing drawn yet"); set_title_bar_rect(&ctx, bar); - assert!(on_title_bar(&ctx, egui::pos2(790.0, 10.0)), "the far end: Essentials, Minimise, Close"); + assert!(on_title_bar(&ctx, egui::pos2(790.0, 10.0)), "the far end: Minimise, Close"); assert!(on_title_bar(&ctx, egui::pos2(400.0, 10.0)), "the empty drag area between the menus and them"); assert!(!on_title_bar(&ctx, egui::pos2(10.0, 100.0)), "below the bar is the app"); } diff --git a/crates/ui-egui/src/menus/workspace_ui.rs b/crates/ui-egui/src/menus/workspace_ui.rs index d58f039786f..9a4197a521e 100644 --- a/crates/ui-egui/src/menus/workspace_ui.rs +++ b/crates/ui-egui/src/menus/workspace_ui.rs @@ -64,23 +64,6 @@ fn saved_name(app: &PhotocraftApp, id: &str) -> Option { app.session.prefs().workspaces.keys().nth(i).cloned() } -/// The top-bar workspace switcher's options as (key, label): the presets, then saved workspaces. -pub fn switcher_options(app: &PhotocraftApp) -> Vec<(String, String)> { - // Keys stay English (`apply_workspace` matches them); the dropdown shows the preset labels - // in the UI language. - let presets = [ - ("Essentials", tl!("Essentials")), - ("Photography", tl!("Photography")), - ("Painting", tl!("Painting")), - ("Graphic and Web", tl!("Graphic and Web")), - ("Pixel Art", tl!("Pixel Art")), - ("Motion", tl!("Motion")), - ]; - let mut opts: Vec<(String, String)> = presets.iter().map(|(k, l)| ((*k).to_string(), (*l).to_string())).collect(); - opts.extend(saved_names(app).into_iter().map(|n| (n.clone(), n))); - opts -} - pub fn checked(app: &PhotocraftApp, id: &str) -> Option { match id { i if i.starts_with(SAVED) => Some(saved_name(app, i).is_some_and(|n| n == app.ui.workspace)), @@ -684,10 +667,6 @@ mod tests { for bad in ["9", "-1", "x", ""] { assert!(crate::menus::invoke(&mut app, &ctx, &format!("{SAVED}{bad}"), json!({})).is_err(), "{bad}"); } - // The top-bar switcher lists them after the presets. - let keys: Vec = switcher_options(&app).into_iter().map(|(k, _)| k).collect(); - assert_eq!(keys[6..], ["Comp", "Retouch"]); - assert!(keys.contains(&app.ui.workspace)); } #[test] diff --git a/crates/ui-egui/src/panels/title_bar.rs b/crates/ui-egui/src/panels/title_bar.rs index 7da215f3940..1889aa9b956 100644 --- a/crates/ui-egui/src/panels/title_bar.rs +++ b/crates/ui-egui/src/panels/title_bar.rs @@ -1,12 +1,12 @@ -use super::{PhotocraftApp, Sense, Tokens, icons, theme, vec2, widgets}; +use super::{PhotocraftApp, Sense, Tokens, theme, vec2}; // ----------------------------------------------------------------------------- title bar -/// The app's top bar: brand mark, menus, the document title and the workspace controls. With +/// The app's top bar: brand mark, menus and the document title. With /// [`PhotocraftApp::custom_titlebar`] (Windows and Linux) it is also the window's title bar, as in /// Photoshop on Windows: the caption buttons take its ends (`titlebar`). With the system /// title bar (Windows and Linux, `system_title_bar`) the OS draws its own icon and title, so the -/// in-app bar shows menus and workspace controls only: no brand mark, no centred title. +/// in-app bar shows the menus only: no brand mark, no centred title. pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let t = Tokens::get(ui.ctx()); let custom = app.custom_titlebar; @@ -26,7 +26,7 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { .frame(egui::Frame::NONE.fill(t.chrome).inner_margin(egui::Margin { left, right, top: 0, bottom: 0 })) .show(ui, |ui| { let full = ui.max_rect(); - // Only the free gap between the menus and the far-end controls drags the window: a + // Only the free gap between the menus and the far end drags the window: a // press on a menu title must open the menu, never move the window. The gap is last // frame's, as the menus are laid out after this. let span_id = ui.scope_id().with("titledrag-span"); @@ -50,10 +50,9 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { .active() .map(|d| format!("{}{}", if show_name { d.doc.name.as_str() } else { "PhotoCraft" }, if d.is_dirty() { " •" } else { "" })) .unwrap_or_else(|| "PhotoCraft".into()); - // The menus and the far-end controls are laid out first; the title is centred in - // whatever room is left between them (`free`, left to right: menus then controls, or - // controls then menus in a right-to-left UI), shortened or dropped rather than drawn - // over them. + // The menus are laid out first; the title is centred in whatever room is left between + // them and the bar's far end (`free`, left to right: menus then far end, or far end + // then menus in a right-to-left UI), shortened or dropped rather than drawn over them. let rtl = crate::direction::is_rtl(); let mut free = (full.left(), full.right()); crate::direction::horizontal_centered(ui, |ui| { @@ -75,59 +74,18 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } else { crate::menus::menu_bar(app, ui) }; - // The menu bar takes the whole row, so the far-end group gets its own rect: from - // the menus to the bar's end, or to the caption buttons. - let group = if rtl { - let left_edge = if caption_left > 0.0 { full.left() + caption_left + 4.0 } else { full.left() }; - egui::Rect::from_min_max(egui::pos2(left_edge, full.top()), egui::pos2((menus_end - TITLE_GAP).max(left_edge), full.bottom())) + // The bar's far end, or the caption buttons' inner edge: nothing else sits there, + // as in the reference application. The workspace switcher, command search and + // appearance button live in Window › Workspace, Edit › Search and Preferences + // instead (#13577). + let far_end = if rtl { + if caption_left > 0.0 { full.left() + caption_left + 4.0 } else { full.left() } + } else if caption_right > 0.0 { + full.right() - caption_right - 4.0 } else { - let right_edge = if caption_right > 0.0 { full.right() - caption_right - 4.0 } else { full.right() }; - egui::Rect::from_min_max(egui::pos2((menus_end + TITLE_GAP).min(right_edge), full.top()), egui::pos2(right_edge, full.bottom())) + full.right() }; - let mut group_ui = ui.new_child(egui::UiBuilder::new().max_rect(group).layout(crate::direction::trailing())); - let controls_end = { - let ui = &mut group_ui; - ui.spacing_mut().item_spacing.x = 6.0; - let mut ws = app.ui.workspace.clone(); - let options = crate::workspace_ui::switcher_options(app); - let opts: Vec<(String, &str)> = options.iter().map(|(k, l)| (k.clone(), l.as_str())).collect(); - // A narrow bar drops what is also in a menu, the theme toggle first - // (Preferences), then search (Edit › Search), and narrows the switcher - // (Window › Workspace) before anything runs over. - let room = ui.available_width(); - let icons_shown: u8 = if room >= WORKSPACE_MIN + 2.0 * ICON_SLOT { - 2 - } else if room >= WORKSPACE_MIN + ICON_SLOT { - 1 - } else { - 0 - }; - let ws_width = (room - f32::from(icons_shown) * ICON_SLOT - 6.0).clamp(WORKSPACE_MIN, 130.0); - if room >= WORKSPACE_MIN && widgets::dropdown(ui, "workspace", tl!("Workspace"), &mut ws, &opts, ws_width) { - app.ui.workspace = ws; - crate::menus::apply_workspace(app); - } - if icons_shown >= 1 - && icons::button(ui, "search", 28.0, app.ui.palette_open, &crate::shortcuts::tip_label(app, "Search commands", "edit.search")).clicked() - { - app.ui.palette_open = !app.ui.palette_open; - } - let (theme_icon, appearance_label) = match app.session.prefs().interface.appearance_mode { - photocraft_engine::prefs::AppearanceMode::Auto => ("monitor", tl!("Auto")), - photocraft_engine::prefs::AppearanceMode::Dark => ("moon", tl!("Dark")), - photocraft_engine::prefs::AppearanceMode::Light => ("sun", tl!("Light")), - }; - let appearance_tip = format!("{}: {}", tl!("Appearance Mode"), appearance_label); - if icons_shown >= 2 { - let button = icons::button(ui, theme_icon, 28.0, false, &appearance_tip); - if button.clicked() { - crate::prefs_ui::cycle_appearance(app, ui.ctx()); - } - button.context_menu(|ui| crate::prefs_ui::appearance_context_menu(app, ui)); - } - if rtl { ui.min_rect().right() } else { ui.min_rect().left() } - }; - free = if rtl { (controls_end, menus_end) } else { (menus_end, controls_end) }; + free = if rtl { (far_end, menus_end) } else { (menus_end, far_end) }; }); ui.ctx().data_mut(|d| d.insert_temp(span_id, free)); if system { @@ -193,16 +151,11 @@ pub(crate) fn title_job(title: &str, font: egui::FontId, color: egui::Color32) - job } -/// Minimum space kept between the window title and the menus or controls beside it. +/// Minimum space kept between the window title and the menus or the bar's far end beside it. const TITLE_GAP: f32 = 16.0; -/// The workspace switcher's narrowest width, and one 28 pt title-bar icon with its spacing. -const WORKSPACE_MIN: f32 = 90.0; - -const ICON_SLOT: f32 = 34.0; - /// Left edge for a title `width` wide: centred on `center` when it fits in the free gap from -/// `left` to `right` (the menus' and the controls' facing edges, whichever side each is on), +/// `left` to `right` (the menus' inner edge and the bar's far end, whichever side each is on), /// else slid into that gap; None when the gap is too small for the whole title. pub(super) fn title_x(center: f32, left: f32, right: f32, width: f32) -> Option { let (lo, hi) = (left + TITLE_GAP, right - TITLE_GAP - width); diff --git a/crates/ui-egui/src/prefs/prefs_ui.rs b/crates/ui-egui/src/prefs/prefs_ui.rs index 3af37664b2e..ca89b23b245 100644 --- a/crates/ui-egui/src/prefs/prefs_ui.rs +++ b/crates/ui-egui/src/prefs/prefs_ui.rs @@ -73,9 +73,9 @@ mod shortcuts; mod startup; #[cfg(test)] -use appearance::{DARK_THEME_OPTIONS, LIGHT_THEME_OPTIONS, display_scale, favorite_theme_groups, selected_theme}; -pub(crate) use appearance::{appearance_context_menu, cycle_appearance, step_brightness, sync_appearance}; +use appearance::{DARK_THEME_OPTIONS, LIGHT_THEME_OPTIONS, display_scale, selected_theme}; pub use appearance::{canvas_style, pasteboard_color}; +pub(crate) use appearance::{cycle_appearance, step_brightness, sync_appearance}; pub use dialogs::{ PREFERENCES_SIZE, apply, confirm, invoke, is_preferences, open_mismatch, open_preferences, open_shortcuts, owns, preferences_changed, width, }; diff --git a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs index 69bb9261420..592a544c183 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs @@ -116,41 +116,6 @@ pub(super) const DARK_THEME_OPTIONS: &[(&str, ThemeKind)] = &[ ("softDark", ThemeKind::SoftDark), ]; -pub(super) fn favorite_theme_groups(favorites: &[SavedTheme]) -> (Vec, Vec) { - let group = |options: &[(&str, ThemeKind)]| { - options.iter().filter_map(|(id, kind)| SavedTheme::parse(id).filter(|theme| favorites.contains(theme)).map(|_| *kind)).collect() - }; - (group(LIGHT_THEME_OPTIONS), group(DARK_THEME_OPTIONS)) -} - -/// Right-click menu on the top-right appearance button. A plain click still cycles modes. -pub(crate) fn appearance_context_menu(app: &mut PhotocraftApp, ui: &mut egui::Ui) { - if ui.button(tl!("Appearance Settings…")).clicked() { - open_preferences(app, "interface"); - ui.close(); - } - let (light, dark) = favorite_theme_groups(&app.session.prefs().interface.favorite_themes); - let has_light = !light.is_empty(); - if !light.is_empty() || !dark.is_empty() { - ui.separator(); - } - for kind in light { - if ui.selectable_label(app.ui.theme == kind, tl!(kind.label())).clicked() { - app.set_theme(ui.ctx(), kind); - ui.close(); - } - } - if has_light && !dark.is_empty() { - ui.separator(); - } - for kind in dark { - if ui.selectable_label(app.ui.theme == kind, tl!(kind.label())).clicked() { - app.set_theme(ui.ctx(), kind); - ui.close(); - } - } -} - pub(super) fn system_theme(app: &PhotocraftApp, ctx: &egui::Context) -> Option { app.services.system_theme.as_ref().and_then(|read| read(ctx)).or_else(|| ctx.system_theme()) } diff --git a/crates/ui-egui/src/prefs/prefs_ui/tests.rs b/crates/ui-egui/src/prefs/prefs_ui/tests.rs index a0ed41a491a..5249c4c33a4 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/tests.rs @@ -494,7 +494,7 @@ fn preferences_interface_offers_and_applies_sync_with_system() { } #[test] -fn theme_star_saves_favorite_and_menu_groups_it() { +fn theme_star_saves_favorite() { use egui_kittest::{Harness, kittest::Queryable}; let (mut app, _) = app_with_store(); open_preferences(&mut app, "interface"); @@ -511,9 +511,6 @@ fn theme_star_saves_favorite_and_menu_groups_it() { h.run_steps(2); assert_eq!(h.state().session.prefs().interface.favorite_themes, vec![SavedTheme::Classic]); assert!(h.query_by_label("Remove from favorites: Classic").is_some()); - let (light, dark) = favorite_theme_groups(&[SavedTheme::Studio, SavedTheme::Classic, SavedTheme::Adwaita]); - assert_eq!(light, vec![ThemeKind::Classic, ThemeKind::Adwaita]); - assert_eq!(dark, vec![ThemeKind::Studio]); } /// The favourite star badge overhangs its swatch; showing it on hover must not move the swatches diff --git a/crates/ui-egui/src/text/direction/tests.rs b/crates/ui-egui/src/text/direction/tests.rs index 58dcce991d4..abf6ad4ba29 100644 --- a/crates/ui-egui/src/text/direction/tests.rs +++ b/crates/ui-egui/src/text/direction/tests.rs @@ -84,7 +84,7 @@ fn x_of(h: &Harness<'static, PhotocraftApp>, label: &str) -> f32 { } /// Left x of the text `text` where it is painted (for widgets without an accessible label). -fn text_x(h: &Harness<'static, PhotocraftApp>, text: &str) -> f32 { +fn painted_x(h: &Harness<'static, PhotocraftApp>, text: &str) -> Option { fn find(shape: &egui::Shape, text: &str) -> Option { match shape { egui::Shape::Text(t) if t.galley.job.text == text => Some(t.pos.x), @@ -92,7 +92,7 @@ fn text_x(h: &Harness<'static, PhotocraftApp>, text: &str) -> f32 { _ => None, } } - h.output().shapes.iter().find_map(|s| find(&s.shape, text)).unwrap_or_else(|| panic!("`{text}` painted")) + h.output().shapes.iter().find_map(|s| find(&s.shape, text)) } fn dock_x(h: &Harness<'static, PhotocraftApp>) -> f32 { @@ -106,19 +106,32 @@ fn the_shell_mirrors_in_a_right_to_left_ui() { let _dir = direction_scope(dir); let h = harness(); let mid = 600.0; - let (file, help, toolbar, dock, workspace) = (x_of(&h, "File"), x_of(&h, "Help"), x_of(&h, "Toolbar"), dock_x(&h), text_x(&h, "Essentials")); + let (file, help, toolbar, dock) = (x_of(&h, "File"), x_of(&h, "Help"), x_of(&h, "Toolbar"), dock_x(&h)); if dir == Dir::Rtl { assert!(file > help, "File starts the menu bar at the right: {file} vs {help}"); assert!(toolbar > mid && dock < mid, "toolbox right, dock left: {toolbar}, {dock}"); - assert!(workspace < help, "the workspace switcher is at the far (left) end: {workspace}"); } else { assert!(file < help, "{file} vs {help}"); assert!(toolbar < mid && dock > mid, "{toolbar}, {dock}"); - assert!(workspace > help, "{workspace}"); } } } +/// The top bar holds the menus, the title and the window buttons only, as in the reference +/// application: no workspace switcher, command search or appearance button at its far end. Each is +/// in a menu instead: Window › Workspace, Edit › Search, Window › Theme (#13577). +#[test] +fn the_top_bar_has_no_workspace_search_or_appearance_controls() { + let _lang = i18n::language_scope(Lang::EN); + for dir in [Dir::Ltr, Dir::Rtl] { + let _dir = direction_scope(dir); + let h = harness(); + assert!(painted_x(&h, "Essentials").is_none(), "{dir:?}: no workspace switcher"); + assert!(h.query_by_label_contains("Search commands").is_none(), "{dir:?}: no search button"); + assert!(h.query_by_label_contains("Appearance Mode:").is_none(), "{dir:?}: no appearance button"); + } +} + /// Choosing a right-to-left catalog (not just forcing the direction) mirrors the shell, and the /// shell's fonts draw its letters; English mirrors back. Panel interiors and dialogs stay /// left-to-right for now (module docs), so only the dock side is checked. From 69e12dfcdebffa3399fd23628be54d0d5fc8f914 Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 13 Nov 2026 01:43:56 +0100 Subject: [PATCH 2/5] Drop the now-unused open_preferences import (#13577) Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/prefs/prefs_ui/appearance.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs index 592a544c183..adf4f20a4c8 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs @@ -1,4 +1,3 @@ -use super::dialogs::open_preferences; use super::fields::{choice_label, color_of, preference_matches}; use super::{AppearanceMode, Color32, DarkTheme, LightTheme, Map, PhotocraftApp, RichText, SavedTheme, Sense, ThemeKind, Tokens, Value, json, prefs, vec2}; From bdd2b69e1e17246359b4de813b1d625e6a5f9bc7 Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 13 Nov 2026 01:46:46 +0100 Subject: [PATCH 3/5] docs: the top bar has no far-end controls (#13577) Co-Authored-By: Claude Opus 5.5 --- docs/ui-design.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/ui-design.md b/docs/ui-design.md index ad8a0a35d51..06a194fa449 100644 --- a/docs/ui-design.md +++ b/docs/ui-design.md @@ -100,11 +100,11 @@ missing-glyph boxes. Check every new panel with the offscreen snapshot tool (`do ## Title bar -The app's top bar (`panels::title_bar`) starts with the brand mark (the app icon, `brand.rs`), then the menus, the document title and the workspace controls, like Photoshop's Ps tile and menu row. +The app's top bar (`panels::title_bar`) starts with the brand mark (the app icon, `brand.rs`), then the menus and the document title, like Photoshop's Ps tile and menu row. Nothing else sits at its far end: the workspace switcher, command search and appearance mode live in Window › Workspace, Edit › Search and Window › Theme. -- **Windows and Linux:** the window has no OS decorations, so there is one bar, not two stacked. The top bar is the title bar (`titlebar.rs`): Minimize, Maximize/Restore and Close (red on hover, `caption_close` tokens) sit flush in the window's top-right corner, the free gap between the menus and the controls drags the window and a double-click there maximizes it, and invisible 5 pt edges (12 pt corners) resize it. Close runs File › Exit, so unsaved documents are asked about first. +- **Windows and Linux:** the window has no OS decorations, so there is one bar, not two stacked. The top bar is the title bar (`titlebar.rs`): Minimize, Maximize/Restore and Close (red on hover, `caption_close` tokens) sit flush in the window's top-right corner, the free gap between the menus and the caption buttons drags the window and a double-click there maximizes it, and invisible 5 pt edges (12 pt corners) resize it. Close runs File › Exit, so unsaved documents are asked about first. - **macOS:** the traffic lights sit over the integrated title strip (`integrated_titlebar`). -- **Narrow windows** drop controls that are also in a menu before anything overlaps: the theme toggle (Preferences), then search (Edit › Search), then the workspace switcher narrows (Window › Workspace). +- **Narrow windows** shorten the title, then drop it, before it overlaps the menus. ## Compact tool controls From 40cf966764d3c86807293875cb2f3df35ed3038a Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 13 Nov 2026 01:59:27 +0100 Subject: [PATCH 4/5] Drop the title-bar workspace picker test (#13577) Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/tests/it/workspace_presets.rs | 33 -------------------- 1 file changed, 33 deletions(-) diff --git a/crates/ui-egui/tests/it/workspace_presets.rs b/crates/ui-egui/tests/it/workspace_presets.rs index a26006f3288..3dcf7ad6c98 100644 --- a/crates/ui-egui/tests/it/workspace_presets.rs +++ b/crates/ui-egui/tests/it/workspace_presets.rs @@ -179,36 +179,3 @@ fn presets_preserve_shell_preferences_and_workspace_lock() { assert!(app.session.prefs().workspace_locked); } } - -#[test] -fn titlebar_picker_displays_every_selected_preset() { - fn collect_text(shape: &egui::Shape, texts: &mut Vec) { - match shape { - egui::Shape::Text(text) => texts.push(text.galley.text().to_string()), - egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| collect_text(shape, texts)), - _ => {} - } - } - - let mut missing = Vec::new(); - for (suffix, name, _, _) in PRESETS { - let mut app = app(); - select(&mut app, suffix); - let ctx = egui::Context::default(); - PhotocraftApp::setup_context(&ctx, Default::default()); - let mut texts = Vec::new(); - for _ in 0..3 { - let input = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1280.0, 900.0))), ..Default::default() }; - let mut output = ctx.run_ui(input, |ui| photocraft_ui_egui::panels::title_bar(&mut app, ui)); - output.textures_delta.clear(); - texts.clear(); - for shape in output.shapes { - collect_text(&shape.shape, &mut texts); - } - } - if !texts.iter().any(|text| text == name) { - missing.push(name); - } - } - assert!(missing.is_empty(), "selected presets missing from titlebar picker: {missing:?}"); -} From dc831fd22309ae53c96c4aac4cd63a2df73e4539 Mon Sep 17 00:00:00 2001 From: David Mann Date: Fri, 13 Nov 2026 16:47:03 +0100 Subject: [PATCH 5/5] Hide the favourite themes preference now that nothing lists them The top bar's appearance button menu was the only place that listed the favourite themes. With the button gone, the star badges on the Preferences theme swatches saved a list nothing read, and the prefs audit failed. Drop the badges, hide interface.favoriteThemes (kept in the model so older settings files still load) and regenerate docs/scorecard.md. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/prefs/validate.rs | 3 ++ crates/ui-egui/src/prefs/prefs_ui.rs | 2 +- .../ui-egui/src/prefs/prefs_ui/appearance.rs | 43 +++---------------- crates/ui-egui/src/prefs/prefs_ui/tests.rs | 41 ------------------ docs/scorecard.md | 6 +-- 5 files changed, 14 insertions(+), 81 deletions(-) diff --git a/crates/engine/src/prefs/validate.rs b/crates/engine/src/prefs/validate.rs index 57b89ff73f7..6619775152e 100644 --- a/crates/engine/src/prefs/validate.rs +++ b/crates/engine/src/prefs/validate.rs @@ -44,6 +44,9 @@ pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &[ "plugIns.allowScriptsToConnect", "type.textEngine", "enhancedControls.scrubbySliderAcceleration", + // Only the top bar's appearance button menu listed the favourite themes, and the top bar no + // longer has that button (#13577). Kept in the model so older settings files still load. + "interface.favoriteThemes", ]; /// Is the preference at `path` (`"section.key"`) hidden from the Preferences dialog? diff --git a/crates/ui-egui/src/prefs/prefs_ui.rs b/crates/ui-egui/src/prefs/prefs_ui.rs index ca89b23b245..a13de48d859 100644 --- a/crates/ui-egui/src/prefs/prefs_ui.rs +++ b/crates/ui-egui/src/prefs/prefs_ui.rs @@ -14,7 +14,7 @@ use photocraft_doc::DocId; use photocraft_engine::jobs::{JobEvent, JobId, JobOutcome, Started}; #[cfg(test)] use photocraft_engine::prefs::Theme; -use photocraft_engine::prefs::{self, AppearanceMode, DarkTheme, LightTheme, SECTIONS, Theme as SavedTheme}; +use photocraft_engine::prefs::{self, AppearanceMode, DarkTheme, LightTheme, SECTIONS}; use photocraft_engine::snap::{SnapLine, SnapOptions, SnapTargets}; use serde_json::{Map, Value, json}; diff --git a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs index adf4f20a4c8..628f03f5488 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs @@ -1,5 +1,5 @@ use super::fields::{choice_label, color_of, preference_matches}; -use super::{AppearanceMode, Color32, DarkTheme, LightTheme, Map, PhotocraftApp, RichText, SavedTheme, Sense, ThemeKind, Tokens, Value, json, prefs, vec2}; +use super::{AppearanceMode, Color32, DarkTheme, LightTheme, Map, PhotocraftApp, RichText, Sense, ThemeKind, Tokens, Value, json, prefs, vec2}; /// The GPU canvas colours from Preferences › Transparency & Gamut. pub fn canvas_style(app: &PhotocraftApp) -> crate::gpu_canvas::CanvasStyle { @@ -161,11 +161,8 @@ pub(crate) fn sync_appearance(app: &mut PhotocraftApp, ctx: &egui::Context) { } /// One theme as a Color Theme swatch: its panel colour under a chrome strip with an accent dot, -/// outlined when chosen. The name is the tooltip and the accessible label. A star badge on its -/// corner adds the theme to (or removes it from) the favourites listed by the appearance -/// button's menu; it shows while the swatch is hovered, and stays for a favourite. -fn theme_swatch(ui: &mut egui::Ui, kind: ThemeKind, id: &str, selected: &mut String, favorites: &mut Vec) { - const BADGE: f32 = 7.0; +/// outlined when chosen. The name is the tooltip and the accessible label. +fn theme_swatch(ui: &mut egui::Ui, kind: ThemeKind, id: &str, selected: &mut String) { let t = Tokens::get(ui.ctx()); let p = Tokens::for_kind(kind); let label = tl!(&choice_label(id)).to_string(); @@ -188,40 +185,16 @@ fn theme_swatch(ui: &mut egui::Ui, kind: ThemeKind, id: &str, selected: &mut Str if resp.on_hover_text(&label).clicked() { *selected = id.to_string(); } - let Some(theme) = SavedTheme::parse(id) else { return }; - let favorite = favorites.contains(&theme); - let center = rect.right_top() + vec2(-3.0, 3.0); - let badge = egui::Rect::from_center_size(center, vec2(BADGE * 2.0, BADGE * 2.0)); - if !(favorite || ui.rect_contains_pointer(rect.union(badge))) { - return; - } - ui.painter().circle(center, BADGE, t.card, egui::Stroke::new(1.0, t.card_border)); - let (icon, tint) = if favorite { ("star-filled", t.accent) } else { ("star", t.text_dim) }; - let action = if favorite { tl!("Remove from favorites") } else { tl!("Add to favorites") }; - // Interact and paint without allocating: a widget placed at `badge` would grow the row by the - // 4 px the badge overhangs the swatch, re-centring the swatches after this one whenever the - // pointer arrives, and oscillating when that moves the swatch out from under it. - let response = ui.interact(badge, ui.scope_id().with((id, "favorite")), Sense::click()).on_hover_text(action); - crate::icons::paint(ui, badge, icon, 10.0, tint); - response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, format!("{action}: {label}"))); - if response.clicked() { - if favorite { - favorites.retain(|saved| *saved != theme); - } else { - favorites.push(theme); - } - } } /// A grid row of theme swatches, marked Active when the appearance mode shows this family. -fn theme_row(ui: &mut egui::Ui, title: &str, active: bool, selected: &mut String, favorites: &mut Vec, options: &[(&str, ThemeKind)]) { +fn theme_row(ui: &mut egui::Ui, title: &str, active: bool, selected: &mut String, options: &[(&str, ThemeKind)]) { let t = Tokens::get(ui.ctx()); ui.label(RichText::new(tl!(title)).color(t.text_dim)); ui.horizontal(|ui| { - // Room for the favourite star badges on the swatch corners. ui.spacing_mut().item_spacing.x = 6.0; for (id, kind) in options { - theme_swatch(ui, *kind, id, selected, favorites); + theme_swatch(ui, *kind, id, selected); } if active { ui.add_space(6.0); @@ -266,14 +239,12 @@ pub(super) fn appearance_rows(ui: &mut egui::Ui, obj: &mut Map, s obj.insert("appearanceMode".into(), json!(mode)); let mut light = obj.get("lightTheme").and_then(Value::as_str).unwrap_or("studioLight").to_string(); let mut dark = obj.get("darkTheme").and_then(Value::as_str).unwrap_or("proMedium").to_string(); - let mut favorites: Vec = obj.get("favoriteThemes").cloned().and_then(|v| serde_json::from_value(v).ok()).unwrap_or_default(); if rows.light { - theme_row(ui, "Light Theme", light_active, &mut light, &mut favorites, LIGHT_THEME_OPTIONS); + theme_row(ui, "Light Theme", light_active, &mut light, LIGHT_THEME_OPTIONS); } if rows.dark { - theme_row(ui, "Dark Theme", !light_active, &mut dark, &mut favorites, DARK_THEME_OPTIONS); + theme_row(ui, "Dark Theme", !light_active, &mut dark, DARK_THEME_OPTIONS); } obj.insert("lightTheme".into(), json!(light)); obj.insert("darkTheme".into(), json!(dark)); - obj.insert("favoriteThemes".into(), json!(favorites)); } diff --git a/crates/ui-egui/src/prefs/prefs_ui/tests.rs b/crates/ui-egui/src/prefs/prefs_ui/tests.rs index 5249c4c33a4..35aca26ac99 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/tests.rs @@ -493,47 +493,6 @@ fn preferences_interface_offers_and_applies_sync_with_system() { assert_eq!(reloaded.lock().unwrap().as_ref(), Some(&saved)); } -#[test] -fn theme_star_saves_favorite() { - use egui_kittest::{Harness, kittest::Queryable}; - let (mut app, _) = app_with_store(); - open_preferences(&mut app, "interface"); - let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).build_eframe(move |cc| { - PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); - app - }); - h.run_steps(4); - h.get_by_label("Classic").hover(); - h.run_steps(2); - h.get_by_label("Add to favorites: Classic").click(); - h.run_steps(2); - h.get_by_label("Apply").click(); - h.run_steps(2); - assert_eq!(h.state().session.prefs().interface.favorite_themes, vec![SavedTheme::Classic]); - assert!(h.query_by_label("Remove from favorites: Classic").is_some()); -} - -/// The favourite star badge overhangs its swatch; showing it on hover must not move the swatches -/// after it, or the row would shift under the pointer. -#[test] -fn theme_star_badge_on_hover_does_not_move_the_next_swatch() { - use egui_kittest::{Harness, kittest::Queryable}; - let (mut app, _) = app_with_store(); - open_preferences(&mut app, "interface"); - let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).build_eframe(move |cc| { - PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); - app - }); - h.run_steps(4); - let first = h.get_by_label("Classic").rect(); - let next = h.get_by_label("Adwaita").rect(); - h.hover_at(first.right_top() + vec2(-3.0, 3.0)); - h.run_steps(3); - assert!(h.query_by_label("Add to favorites: Classic").is_some(), "the badge shows while the swatch is hovered"); - assert_eq!(h.get_by_label("Classic").rect(), first); - assert_eq!(h.get_by_label("Adwaita").rect(), next); -} - #[test] fn preferences_interface_shows_language_without_scrolling() { // #2532: in a small window the theme cards filled the page and Language sat out of view diff --git a/docs/scorecard.md b/docs/scorecard.md index 9dd11e638f5..2a34b91df1c 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [Performance](#performance) | 3 | 22 | 56 | 90 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 52 not run, 4 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 11 | 14 | 2 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 | | [Tools](#tools) | 36 | 9 | 0 | | -| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 8 of 199 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 199 (target 0) | | [Type](#type) | 5 | 5 | 0 | | | [Automation](#automation) | 5 | 4 | 2 | 664 of 664 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | @@ -214,9 +214,9 @@ Corpus floors (`crates/io/tests/it/corpus.rs`): the enforced minimums; the corpu ## Workspace and UI -**Settings that do nothing: 8 of 199** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 9 of 199** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. -Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `performance.legacy_compositing`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`. +Unread: `general.color_picker`, `interface.favorite_themes`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `performance.legacy_compositing`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`. | Id | Target | Status | Issue | Note | |---|---|---|---|---|