Merge pull request #13579 from davidmann4/fix/title-bar-controls-13577

Top bar: drop the appearance button, search and workspace switcher (#13577)
This commit is contained in:
David Mann authored and GitHub committed 2026-11-19 00:34:08 +01:00
commit c66a95dee2
8 files changed
+28 -70

No files matched your search

+1 -1
View File
@@ -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<String>,
/// Pasteboard colour in standard screen mode (`canvasCustomColor` when "custom").
+1 -12
View File
@@ -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()
+6 -24
View File
@@ -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!({}));
}
}
@@ -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");
}
+2 -2
View File
@@ -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};
@@ -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<egui::Theme> {
system_appearance(ctx).appearance.mode.map(|mode| match mode {
+1 -1
View File
@@ -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();
+3 -4
View File
@@ -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