diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 86ce38741be..d193d89c34e 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -343,7 +343,7 @@ pub struct Interface { /// The theme id of the light slot. #[serde(deserialize_with = "theme_ids::theme")] pub light_theme: String, - /// Theme ids shown in the appearance button's context menu. + /// Theme ids starred in Preferences › Interface; #13581 decides where they show. #[serde(deserialize_with = "theme_ids::themes")] pub favorite_themes: Vec, /// Pasteboard colour in standard screen mode (`canvasCustomColor` when "custom"). diff --git a/crates/ui-egui/src/menus/workspace_ui.rs b/crates/ui-egui/src/menus/workspace_ui.rs index 7afffbd3fb9..36a9e7974d6 100644 --- a/crates/ui-egui/src/menus/workspace_ui.rs +++ b/crates/ui-egui/src/menus/workspace_ui.rs @@ -10,7 +10,7 @@ use craft::keymap::{CommandRef, Mods}; use craft::ui::contract::{Bind, CommandSet as _}; use craft::ui::dialog::DialogResult; use craft::ui::docking::{WorkspaceAsk, WorkspaceCommands, run_workspace, workspace_states}; -use craft::ui::patterns::dock::{HostedDeleteWorkspace, HostedNewWorkspace, NewWorkspace, WorkspaceSwitcher}; +use craft::ui::patterns::dock::{HostedDeleteWorkspace, HostedNewWorkspace, NewWorkspace}; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, Param, ParamDialog, ParamKind, ParamLayout, ParamResult}; use craft::ui::runtime::commands::CommandState; use craft::ui::value_drag::SliderScale; @@ -315,17 +315,6 @@ pub fn take(app: &mut PhotocraftApp, _ctx: &egui::Context) { } } -/// The workspace switcher of the title bar. -pub fn switcher(app: &mut PhotocraftApp, ui: &mut egui::Ui) { - let out = WorkspaceSwitcher::new(&app.workspaces.set).show(ui); - if let Some(id) = out.switched - && let Err(message) = select(app, &id) - { - app.ui.status = message; - app.ui.status_error = true; - } -} - /// The state of each workspace command, for the command source. pub fn states(app: &PhotocraftApp) -> Vec<(CommandRef, CommandState)> { workspace_states(&app.workspaces.set).into_iter().map(|(command, state)| (CommandRef::from(command), state)).collect() diff --git a/crates/ui-egui/src/panels/title_bar.rs b/crates/ui-egui/src/panels/title_bar.rs index a921464ad40..5d991004195 100644 --- a/crates/ui-egui/src/panels/title_bar.rs +++ b/crates/ui-egui/src/panels/title_bar.rs @@ -1,50 +1,32 @@ -use std::cell::RefCell; - -use craft::behavior::IconId; -use craft::ui::buttons::IconButton; -use craft::ui::contract::{Props as _, Show as _, TooltipSpec}; +use craft::ui::contract::Show as _; use craft::ui::shell::{Title, TitleBar}; use super::{PhotocraftApp, brand}; // ----------------------------------------------------------------------------- title bar -/// The app's top bar, in the shell's title slot: brand mark, menus, the document title and the workspace controls. +/// The app's top bar, in the shell's title slot: brand mark, menus and the document title. Nothing else sits at its +/// far end, as in the reference application: the workspace switcher, command search and appearance mode live in +/// Window › Workspace, Edit › Search and Window › Appearance (#13577). /// The framework `TitleBar` follows the window's frame: with the app's own frame (Windows and Linux) it is also the /// window's title bar and the caption buttons take its ends; with the system's frame it shows the content and no title. pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let title = title_text(app); - // The bar runs `leading` in its body and `trailing` in its end region, one after the other, so the two borrows - // of the app never overlap. - let app = RefCell::new(app); let out = TitleBar::new().show_titled( ui, Title::new(title), |ui, _| { - let mut guard = app.borrow_mut(); - let app = &mut **guard; brand::mark().show(ui); // With the macOS menu bar the menus are at the top of the screen instead. if app.services.native_menu.is_none() { crate::menus::menu_bar(app, ui); } }, - |ui, _| { - let mut guard = app.borrow_mut(); - let app = &mut **guard; - crate::prefs_ui::appearance_button(app, ui); - let tip = crate::shortcuts::tip_label(app, "Search commands", "edit.search"); - let search = IconButton::new(IconId::new("search")).label(tip.clone()).tooltip(TooltipSpec::new(tip)).selected(app.ui.palette.open).show(ui); - if search.clicked() { - app.ui.palette.open = !app.ui.palette.open; - } - crate::workspace_ui::switcher(app, ui); - }, + |_, _| {}, ); // The bar never closes the window: File › Exit asks about unsaved work first. if out.close_requested { - let mut guard = app.borrow_mut(); - let _ = crate::menus::invoke(&mut guard, ui.ctx(), "file.exit", serde_json::json!({})); + let _ = crate::menus::invoke(app, ui.ctx(), "file.exit", serde_json::json!({})); } } diff --git a/crates/ui-egui/src/panels/title_bar/tests.rs b/crates/ui-egui/src/panels/title_bar/tests.rs index 2ef95540290..9080287958a 100644 --- a/crates/ui-egui/src/panels/title_bar/tests.rs +++ b/crates/ui-egui/src/panels/title_bar/tests.rs @@ -82,3 +82,16 @@ fn the_menu_bar_follows_its_panel_flag() { assert!(h.query_all_by_label("Layers").next().is_some(), "the dock itself stays (menu bar {menu_bar})"); } } + +/// The top bar holds the brand mark, the menus, the title and the caption buttons, and nothing at its far end, as in +/// the reference application: no appearance button, no command search and no workspace switcher (#13577). Each of +/// them stays in a menu: Window › Appearance, Edit › Search and Window › Workspace. +#[test] +fn the_top_bar_has_no_appearance_search_or_workspace_controls() { + let h = integrated_app(|_| {}); + assert!(h.query_by_label("File").is_some(), "the menus are drawn"); + assert!(h.query_by_label("Close").is_some(), "the caption buttons are drawn"); + assert!(h.query_by_label("Appearance").is_none(), "no appearance button"); + assert!(h.query_by_label_contains("Search commands").is_none(), "no command search button"); + assert!(h.query_by_label("Choose a workspace").is_none(), "no workspace switcher"); +} diff --git a/crates/ui-egui/src/prefs/prefs_ui.rs b/crates/ui-egui/src/prefs/prefs_ui.rs index d7c97708afb..8af5b767713 100644 --- a/crates/ui-egui/src/prefs/prefs_ui.rs +++ b/crates/ui-egui/src/prefs/prefs_ui.rs @@ -57,9 +57,9 @@ mod save; pub(crate) mod shortcuts; mod startup; -// PLAN: assumed top-w18's appearance file keeps `display_scale` and `selected_theme` and exports `appearance_button` and `theme_menu`. -pub(crate) use appearance::{appearance_button, cycle_appearance, interface_zoom, show_selected_theme, step_brightness, sync_appearance, theme_menu}; +// PLAN: assumed top-w18's appearance file keeps `display_scale` and `selected_theme` and exports `theme_menu`. pub use appearance::{canvas_style, pasteboard_color}; +pub(crate) use appearance::{cycle_appearance, interface_zoom, show_selected_theme, step_brightness, sync_appearance, theme_menu}; #[cfg(test)] pub(crate) use dialogs::set_draft; pub use dialogs::{apply_window, invoke, open_preferences, window_open}; diff --git a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs index 9cd4bc18f7e..a51de3739de 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/appearance.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/appearance.rs @@ -1,12 +1,7 @@ use super::{AppearanceMode, Color32, PhotocraftApp, json, prefs}; use crate::theme::AppTheme; -use craft::keymap::CommandRef; -use craft::menu::{ThemeChoice, ThemeLabels, ThemeMenu, ThemeRow}; +use craft::menu::{ThemeChoice, ThemeMenu, ThemeRow}; use craft::theme::{Mode, ThemeId}; -use craft::ui::buttons::IconButton; -use craft::ui::contract::{Props as _, Show as _, ShowContainer as _}; -use craft::ui::menu::Menu; -use craft::ui::primitives::IconSpec; use craft::ui::runtime::env::system_appearance; /// The GPU canvas's gamut warning colours from Preferences › Transparency & Gamut. @@ -98,26 +93,6 @@ pub fn theme_menu(app: &PhotocraftApp) -> ThemeMenu { ThemeMenu::new(rows, current).favorites(&favorites) } -/// The title bar's appearance button: the icon of the mode, a click that cycles Auto → Light → Dark, and a context -/// menu with the settings row and the favourite themes. -pub(crate) fn appearance_button(app: &mut PhotocraftApp, ui: &mut egui::Ui) { - let (icon, name) = match app.session.prefs().interface.appearance_mode { - AppearanceMode::Auto => ("monitor", tl!("Auto")), - AppearanceMode::Dark => ("moon", tl!("Dark")), - AppearanceMode::Light => ("sun", tl!("Light")), - }; - // PLAN: assumed `IconButton::label`, `.tooltip(..)` and the output's `clicked()` / `response()`. - let out = IconButton::new(IconSpec::svg(craft::behavior::IconId::new(icon))) - .label(tl!("Appearance")) - .tooltip(crate::i18n::fmt(tl!("Appearance Mode: {mode}"), &[("mode", name)])) - .show(ui); - if out.clicked() { - cycle_appearance(app, ui.ctx()); - } - let nodes = theme_menu(app).favorite_items(&ThemeLabels::default(), CommandRef::new("edit.preferences.interface")); - Menu::context(tl!("Appearance"), &out.response).show(ui, |ui, _| craft::menu::context::rows(ui, &nodes)); -} - /// The OS's light or dark mode, `None` where it gives no answer. pub(super) fn system_theme(_app: &PhotocraftApp, ctx: &egui::Context) -> Option { system_appearance(ctx).appearance.mode.map(|mode| match mode { diff --git a/crates/ui-egui/src/prefs/prefs_ui/tests.rs b/crates/ui-egui/src/prefs/prefs_ui/tests.rs index 4f15e951663..fe6902bb931 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/tests.rs @@ -246,7 +246,7 @@ fn auto_uses_native_system_theme_when_egui_does_not_report_one() { } #[test] -fn appearance_button_cycles_modes_without_losing_theme_choices() { +fn next_appearance_mode_cycles_modes_without_losing_theme_choices() { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); let ctx = app.ctx().clone(); app.run("prefs.set", json!({"values": {"interface.darkTheme": "studio", "interface.lightTheme": "classic"}})).unwrap(); diff --git a/docs/ui-design.md b/docs/ui-design.md index 860540de9d0..72e42e99fe3 100644 --- a/docs/ui-design.md +++ b/docs/ui-design.md @@ -19,7 +19,7 @@ Both Breeze themes are our own values close to Plasma's (not a copy of its colour schemes) and put text readability first: every text colour holds 4.5:1 on every surface and on hovered, pressed and selected states (`theme.rs` tests), so their secondary text, accent and status colours are darker (Light) or lighter (Dark) than Breeze's own, and the primary button is a deeper blue with white text. -Edit → Preferences → Interface shows an Appearance Mode selector (Sync with system, Dark, Light) above separate light and dark theme cards with PhotoCraft editor previews and radio choices. Auto is opt-in and follows the operating system while the app is running. On Linux it reads the desktop portal once and then listens for its `SettingChanged` signal (no polling, and the UI repaints only when the value changes); `gsettings` runs at most once at start-up, by absolute path, when the portal gives no answer. A missing system appearance falls back to Dark. New installs keep Photoshop's default: Dark mode with Pro Medium (Pro Light is the saved light theme). Existing saved single-theme preferences migrate to a fixed Dark or Light mode with their chosen theme. The header appearance button cycles Auto → Light → Dark; its icon shows a monitor, moon or sun for the selected mode. Window → Theme and `ui.set {"theme":"classic"}` select a theme and fix the mode to its light or dark family. +Edit → Preferences → Interface shows an Appearance Mode selector (Sync with system, Dark, Light) above separate light and dark theme cards with PhotoCraft editor previews and radio choices. Auto is opt-in and follows the operating system while the app is running. On Linux it reads the desktop portal once and then listens for its `SettingChanged` signal (no polling, and the UI repaints only when the value changes); `gsettings` runs at most once at start-up, by absolute path, when the portal gives no answer. A missing system appearance falls back to Dark. New installs keep Photoshop's default: Dark mode with Pro Medium (Pro Light is the saved light theme). Existing saved single-theme preferences migrate to a fixed Dark or Light mode with their chosen theme. Window → Appearance → Next Mode cycles Auto → Light → Dark. Window → Theme and `ui.set {"theme":"classic"}` select a theme and fix the mode to its light or dark family. Window → Theme and macOS PhotoCraft → Appearance also offer Sync with system. Its checkmark follows the saved Auto mode rather than the displayed palette; choosing a manual theme selects its fixed appearance mode. @@ -100,11 +100,10 @@ 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 › Appearance. -- **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). ## Compact tool controls