From 307761b4424a00c034a3b3f9697bbdc09329aee9 Mon Sep 17 00:00:00 2001 From: David Mann Date: Thu, 26 Nov 2026 16:49:20 +0100 Subject: [PATCH] Preferences: the Appearance Size row keeps Comfortable (#17096) The Appearance page's Size pick was dropped: appearance_row copied back only the mode and the theme slots, so the row showed Compact again on the next frame. PhotoCraft also kept no size, sent none to the suite and never gave the root a density. Add interface.density (compact/comfortable), drawn by the Appearance page, kept in step with the suite's shared size like the mode and themes, and set as the root's density each frame. Co-Authored-By: Claude Opus 5.5 --- crates/engine-core/src/prefs.rs | 7 ++++ crates/engine-core/src/prefs/validate.rs | 5 ++- crates/ui-egui/src/app/framework.rs | 39 ++++++++++++++++--- crates/ui-egui/src/control/tests.rs | 15 +++++++ .../ui-egui/src/prefs/prefs_ui/custom_rows.rs | 15 ++++++- crates/ui-egui/src/prefs/prefs_ui/fields.rs | 5 ++- crates/ui-egui/src/prefs/prefs_ui/tests.rs | 26 +++++++++++++ docs/scorecard.md | 4 +- 8 files changed, 103 insertions(+), 13 deletions(-) diff --git a/crates/engine-core/src/prefs.rs b/crates/engine-core/src/prefs.rs index 82402498e8..9103110859 100644 --- a/crates/engine-core/src/prefs.rs +++ b/crates/engine-core/src/prefs.rs @@ -59,6 +59,10 @@ choice!(PointSize { PostScript = "postScript", Traditional = "traditional" } def choice!(Interpolation { BicubicAutomatic = "bicubicAutomatic", Nearest = "nearestNeighbor", Bilinear = "bilinear", Bicubic = "bicubic", BicubicSmoother = "bicubicSmoother", BicubicSharper = "bicubicSharper", PreserveDetails = "preserveDetails" } default BicubicAutomatic); choice!(ColorPicker { Adobe = "adobe", System = "system" } default Adobe); choice!(AppearanceMode { Auto = "auto", Dark = "dark", Light = "light" } default Dark); +choice!( + /// The interface density the Craft suite shares (Preferences › Interface › Size). + UiDensity { Compact = "compact", Comfortable = "comfortable" } default Compact +); choice!(CanvasColor { Default = "default", Black = "black", DarkGray = "darkGray", MediumGray = "mediumGray", LightGray = "lightGray", Custom = "custom" } default Default); choice!(CanvasBorder { DropShadow = "dropShadow", Line = "line", None = "none" } default DropShadow); choice!(UiScale { Auto = "auto", P75 = "75", P80 = "80", P85 = "85", P90 = "90", P95 = "95", P100 = "100", P105 = "105", P110 = "110", P115 = "115", P120 = "120", P125 = "125", P150 = "150", P175 = "175", P200 = "200", P250 = "250", P300 = "300" } default Auto); @@ -348,6 +352,8 @@ pub struct Interface { /// Theme ids starred in Preferences › Interface; #13581 decides where they show. #[serde(deserialize_with = "theme_ids::themes")] pub favorite_themes: Vec, + /// Compact or Comfortable controls, shared with the other Craft apps like the mode and themes (#17096). + pub density: UiDensity, /// Pasteboard colour in standard screen mode (`canvasCustomColor` when "custom"). pub canvas_color: CanvasColor, pub canvas_custom_color: String, @@ -435,6 +441,7 @@ impl Default for Interface { dark_theme: "craft.artcraft".into(), light_theme: "craft.pro".into(), favorite_themes: Vec::new(), + density: UiDensity::Compact, canvas_color: CanvasColor::Default, canvas_custom_color: "#282828".into(), show_canvas_dots: true, diff --git a/crates/engine-core/src/prefs/validate.rs b/crates/engine-core/src/prefs/validate.rs index 74b8000247..e05658dc1f 100644 --- a/crates/engine-core/src/prefs/validate.rs +++ b/crates/engine-core/src/prefs/validate.rs @@ -2,8 +2,8 @@ use super::shortcuts::normalize_shortcut; use super::{ AppearanceMode, Ask, CanvasBorder, CanvasColor, CheckerColors, CheckerSize, ColorPicker, ExportLocation, ExportMetadata, FontPreview, GpuBackend, Interpolation, LineStyle, LinuxDisplayServer, LogDestination, LogDetail, OtherCursor, PaintingCursor, PlaybackPerformance, PointSize, PressureCurve, - QuickExportFormat, RawColorSpace, RawDemosaic, RawDepth, RawSharpen, RenderingMode, RightClickPaint, TabletInput, TextEngine, TypeUnit, UiFontSize, - UiScale, Unit, Value, WhenAppClosed, + QuickExportFormat, RawColorSpace, RawDemosaic, RawDepth, RawSharpen, RenderingMode, RightClickPaint, TabletInput, TextEngine, TypeUnit, UiDensity, + UiFontSize, UiScale, Unit, Value, WhenAppClosed, }; /// Preferences dialog sections in Photoshop's order: (id, title). @@ -70,6 +70,7 @@ pub fn choices(path: &str) -> Option<&'static [&'static str]> { "general.colorPicker" => ColorPicker::NAMES, "general.imageInterpolation" => Interpolation::NAMES, "interface.appearanceMode" => AppearanceMode::NAMES, + "interface.density" => UiDensity::NAMES, "interface.canvasColor" => CanvasColor::NAMES, "interface.canvasBorder" => CanvasBorder::NAMES, "interface.uiScale" => UiScale::NAMES, diff --git a/crates/ui-egui/src/app/framework.rs b/crates/ui-egui/src/app/framework.rs index bfa6c349ae..f9cd4c1b8b 100644 --- a/crates/ui-egui/src/app/framework.rs +++ b/crates/ui-egui/src/app/framework.rs @@ -37,7 +37,7 @@ use craft::window::system::NoWindows as Desktop; #[cfg(not(test))] use craft::window::system::SystemWindows as Desktop; use photocraft_engine::Session; -use photocraft_engine::prefs::{AppearanceMode, Preferences}; +use photocraft_engine::prefs::{AppearanceMode, Preferences, UiDensity}; use serde_json::Value; use super::PhotocraftApp; @@ -182,25 +182,31 @@ impl ThemeUnavailable { } } -/// The preferences that choose the theme: the appearance mode and the theme id of each slot. +/// The preferences that choose the theme: the appearance mode, the theme id of each slot and the size. #[derive(Clone, Debug, PartialEq)] struct ThemePrefs { mode: AppearanceMode, dark: String, light: String, + size: UiDensity, } impl ThemePrefs { fn of(prefs: &Preferences) -> Self { let i = &prefs.interface; - ThemePrefs { mode: i.appearance_mode, dark: i.dark_theme.clone(), light: i.light_theme.clone() } + ThemePrefs { mode: i.appearance_mode, dark: i.dark_theme.clone(), light: i.light_theme.clone(), size: i.density } } /// What the suite shows: its chosen fields, else PhotoCraft's defaults. fn of_suite(choice: &SuiteChoice) -> Self { let defaults = defaults(); let shown = choice.with_defaults(&defaults); - ThemePrefs { mode: app_mode(shown.mode), dark: shown.theme.dark.as_str().to_owned(), light: shown.theme.light.as_str().to_owned() } + ThemePrefs { + mode: app_mode(shown.mode), + dark: shown.theme.dark.as_str().to_owned(), + light: shown.theme.light.as_str().to_owned(), + size: app_density(shown.size), + } } /// The suite fields that differ between `self` and `before`. @@ -210,6 +216,7 @@ impl ThemePrefs { theme_dark: (self.dark != before.dark).then(|| id(&self.dark)).flatten(), theme_light: (self.light != before.light).then(|| id(&self.light)).flatten(), mode: (self.mode != before.mode).then(|| mode_choice(self.mode)), + size: (self.size != before.size).then(|| suite_size(self.size)), ..SelectionChange::default() } } @@ -231,6 +238,21 @@ fn mode_choice(mode: AppearanceMode) -> ModeChoice { } } +fn app_density(size: Size) -> UiDensity { + match size { + Size::Comfortable => UiDensity::Comfortable, + _ => UiDensity::Compact, + } +} + +/// The suite's size for PhotoCraft's density preference; the root resolves its tokens under it. +fn suite_size(density: UiDensity) -> Size { + match density { + UiDensity::Compact => Size::Compact, + UiDensity::Comfortable => Size::Comfortable, + } +} + /// PhotoCraft's theme in the dark mode when nobody chose one: Pro (Medium Gray). const DEFAULT_DARK: &str = "craft.artcraft"; /// PhotoCraft's theme in the light mode when nobody chose one: Pro (Light). @@ -378,7 +400,8 @@ impl Framework { let mut root = root .mode(if theme.is_dark() { ModeChoice::Dark } else { ModeChoice::Light }) .scale(Scale::new(crate::prefs_ui::interface_zoom(session.prefs().interface.ui_scale, ctx))) - .direction(if rtl { Direction::Rtl } else { Direction::Ltr }); + .direction(if rtl { Direction::Rtl } else { Direction::Ltr }) + .density(suite_size(session.prefs().interface.density)); // Read each frame, so a preference change shows at once. root.canvas_pattern = session.prefs().interface.show_canvas_dots; root.values.set(craft::ui::canvas::ShowReadouts(session.prefs().tools.show_transformation_values)); @@ -450,6 +473,11 @@ impl Framework { None if mine.mode != blank.mode => change.mode = Some(mode_choice(mine.mode)), None => {} } + match chosen.size { + Some(size) => start.size = app_density(size), + None if mine.size != blank.size => change.size = Some(suite_size(mine.size)), + None => {} + } self.suite.change(change); start } @@ -468,6 +496,7 @@ impl Framework { p.interface.appearance_mode = agreed.mode; p.interface.dark_theme = agreed.dark.clone(); p.interface.light_theme = agreed.light.clone(); + p.interface.density = agreed.size; }); } let changed = moved || previous.as_ref() != Some(&agreed); diff --git a/crates/ui-egui/src/control/tests.rs b/crates/ui-egui/src/control/tests.rs index 8c29e48c14..eee99e152f 100644 --- a/crates/ui-egui/src/control/tests.rs +++ b/crates/ui-egui/src/control/tests.rs @@ -959,6 +959,21 @@ fn ui_set_theme_picks_a_library_theme_the_suite_has_not_loaded() { assert!(app.ui.theme.is_dark()); } +/// #17096: a size another Craft app writes to the suite becomes PhotoCraft's density preference, which the root reads. +#[test] +fn a_size_another_app_picks_becomes_the_density_preference() { + use craft::theme_store::{Op, SelectionChange}; + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.framework.sync_theme(&mut app.session); + assert_eq!(app.session.prefs().interface.density, photocraft_engine::prefs::UiDensity::Compact); + let base = app.framework.suite().accepted().clone(); + app.framework.suite().watch().request(Op::Update { base, change: SelectionChange::size(craft::theme::Size::Comfortable) }); + for _ in 0..4 { + app.framework.sync_theme(&mut app.session); + } + assert_eq!(app.session.prefs().interface.density, photocraft_engine::prefs::UiDensity::Comfortable); +} + /// A slot naming a theme the suite doesn't know (a deleted library theme) shows the mode's /// default, and once settled a frame resolves nothing. #[test] diff --git a/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs b/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs index 0a56787cba..8381580941 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs @@ -4,7 +4,7 @@ //! written before Apply or OK. use craft::theme::variant::Tone; -use craft::theme::{ModeChoice, ThemeId}; +use craft::theme::{ModeChoice, Size, ThemeId}; use craft::theme_store::ui::AppearancePage; use craft::theme_store::{SelectionChange, SuiteView}; use craft::ui::buttons::Button; @@ -36,6 +36,7 @@ const APPEARANCE_MODE: &str = "interface.appearanceMode"; const LIGHT_THEME: &str = "interface.lightTheme"; const DARK_THEME: &str = "interface.darkTheme"; const FAVORITE_THEMES: &str = "interface.favoriteThemes"; +const DENSITY: &str = "interface.density"; /// The page agents' settings live on, drawn whole by [`craft::automation::ui::agents::AgentsPage`]. #[cfg(not(target_arch = "wasm32"))] pub(super) const AGENTS_PAGE: &str = "integrations"; @@ -263,7 +264,12 @@ impl PrefsCustom { Some("dark") => ModeChoice::Dark, _ => ModeChoice::System, }; - let shown = SelectionChange { mode: Some(mode), theme_light: theme(LIGHT_THEME), theme_dark: theme(DARK_THEME), ..Default::default() }; + let size = match draft.get::(DENSITY).as_deref() { + Some("comfortable") => Size::Comfortable, + _ => Size::Compact, + }; + let shown = + SelectionChange { mode: Some(mode), theme_light: theme(LIGHT_THEME), theme_dark: theme(DARK_THEME), size: Some(size), ..Default::default() }; let mut change = shown.clone(); let favorites: Vec = draft.get::>(FAVORITE_THEMES).unwrap_or_default().iter().filter_map(|s| ThemeId::parse(s).ok()).collect(); // Unknown OS answer previews light, which is what Auto resolves to then. @@ -288,6 +294,11 @@ impl PrefsCustom { { draft.set(DARK_THEME, &id.as_str()); } + if change.size != shown.size + && let Some(size) = change.size + { + draft.set(DENSITY, &if size == Size::Comfortable { "comfortable" } else { "compact" }); + } } if let Some(id) = out.favorite_toggled { let mut saved: Vec = draft.get(FAVORITE_THEMES).unwrap_or_default(); diff --git a/crates/ui-egui/src/prefs/prefs_ui/fields.rs b/crates/ui-egui/src/prefs/prefs_ui/fields.rs index 2e84e030ef..851e49dfea 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/fields.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/fields.rs @@ -132,13 +132,14 @@ pub(super) fn rules(ctx: &egui::Context) -> Vec { } } - // Drawn elsewhere or not at all: the theme keys follow the Appearance row, View › Rulers sets showRulers, and the + // Drawn elsewhere or not at all: the theme and size keys follow the Appearance row, View › Rulers sets showRulers, and the // GPU row draws the adapter, backend and GPU switch together. for path in [ "interface.theme", "interface.lightTheme", "interface.darkTheme", "interface.favoriteThemes", + "interface.density", "unitsAndRulers.showRulers", "performance.useGpu", "performance.gpuBackend", @@ -199,7 +200,7 @@ pub(super) fn rules(ctx: &egui::Context) -> Vec { /// `prefs::Interface` lists its fields in this order. fn interface_group(key: &str) -> &'static str { match key { - "appearanceMode" | "darkTheme" | "lightTheme" | "favoriteThemes" | "canvasColor" | "canvasCustomColor" | "canvasBorder" => "Appearance", + "appearanceMode" | "darkTheme" | "lightTheme" | "favoriteThemes" | "density" | "canvasColor" | "canvasCustomColor" | "canvasBorder" => "Appearance", "language" | "uiFontSize" | "uiScale" => "Presentation", _ => "Options", } diff --git a/crates/ui-egui/src/prefs/prefs_ui/tests.rs b/crates/ui-egui/src/prefs/prefs_ui/tests.rs index 23201f20ba..79223c28bb 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/tests.rs @@ -509,6 +509,32 @@ fn theme_star_saves_favorite_and_menu_groups_it() { assert_eq!(listed.len(), 2, "the settings row and the one favourite: {listed:?}"); } +/// #17096: Comfortable picked in the Appearance page's Size row stays picked, is saved and goes to the suite; before, +/// the page dropped the pick and showed Compact again on the next frame. +#[test] +fn appearance_size_row_keeps_comfortable_and_shares_it_with_the_suite() { + use egui::accesskit::Role; + use egui_kittest::kittest::{NodeT, Queryable}; + let (_, files) = app_with_store(); + let mut h = prefs_harness(&files, "interface", vec2(1280.0, 800.0), |_| {}); + let size = |h: &egui_kittest::Harness<'static, Box>| { + h.get_by_role_and_label(Role::ComboBox, "Size").accesskit_node().value().map(|v| v.to_string()) + }; + assert_eq!(size(&h).as_deref(), Some("Compact")); + h.get_by_role_and_label(Role::ComboBox, "Size").click(); + h.run_steps(2); + h.get_by_label("Comfortable").click(); + h.run_steps(4); + assert_eq!(size(&h).as_deref(), Some("Comfortable"), "the row keeps the pick"); + apply_window(h.state_mut()).unwrap(); + h.run_steps(4); + let app = h.state_mut(); + assert_eq!(app.session.prefs().interface.density, prefs::UiDensity::Comfortable); + assert_eq!(stored(&files)["interface"]["density"], "comfortable"); + app.framework.sync_theme(&mut app.session); + assert_eq!(app.framework.suite().shown().size, Some(craft::theme::Size::Comfortable), "the suite has it"); +} + // --- the settings store ------------------------------------------------------------------------------------------- #[test] diff --git a/docs/scorecard.md b/docs/scorecard.md index 89db4a53c0..98360898f2 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 | 59 | 93 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 55 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: 9 of 203 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 204 (target 0) | | [Type](#type) | 5 | 5 | 0 | | | [Automation](#automation) | 6 | 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 | @@ -217,7 +217,7 @@ Corpus floors (`crates/io/tests/it/corpus.rs`): the enforced minimums; the corpu ## Workspace and UI -**Settings that do nothing: 9 of 203** (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 204** (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`, `workspace.enable_narrow_options_bar`, `performance.legacy_compositing`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`.