PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Fix #1271, fix #1316: Preferences › Interface › System Title Bar (#1344)
BFlat83936bdcee4a
diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rsindex 390df88f7..152531a85 100644--- a/apps/photocraft/src/main.rs+++ b/apps/photocraft/src/main.rs@@ -54,11 +54,20 @@ const APP_ID: &str = "ai.storyteller.photocraft";/// keeps its traffic lights over the integrated title strip.const CUSTOM_TITLEBAR: bool = !cfg!(target_os = "macos");+/// Whether this start draws its own title bar: Windows and Linux do, unless Preferences ›+/// Interface › System Title Bar asks for the system's (#1271, #1316). Read from the saved+/// preferences before the window opens; a missing or unreadable file keeps the default.+fn custom_titlebar(prefs_file: Option<&std::path::Path>) -> bool {+ let prefs: photocraft_engine::prefs::Preferences =+ prefs_file.and_then(|p| std::fs::read_to_string(p).ok()).and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default();+ CUSTOM_TITLEBAR && !prefs.interface.system_title_bar+}+/// The main window: 1440 × 900 (shrunk to fit the monitor, and maximized on the first frame/// when it still doesn't fit, `work_area::fit_window`), centred on the main monitor. Without/// `centered`, Windows cascades each new window from the top-left corner, so it opened at a/// different offset every launch (#419). Wayland compositors place windows themselves.-fn native_options() -> eframe::NativeOptions {+fn native_options(custom_titlebar: bool) -> eframe::NativeOptions {eframe::NativeOptions {viewport: egui::ViewportBuilder::default().with_icon(app_icon::window_icon())@@ -67,7 +76,7 @@ fn native_options() -> eframe::NativeOptions {.with_inner_size([1440.0, 900.0]).with_min_inner_size([760.0, 480.0]).with_drag_and_drop(true)- .with_decorations(!CUSTOM_TITLEBAR)+ .with_decorations(!custom_titlebar).with_fullsize_content_view(true).with_titlebar_shown(false).with_title_shown(false),@@ -240,7 +249,8 @@ fn main() -> eframe::Result {let monitor = monitor_profile::detect_async();// Brush presets load in the background; the app attaches them when they arrive.let presets = services::presets_dir().map(photocraft_engine::preset_store::open_dir_async);- let mut options = native_options();+ let custom_titlebar = custom_titlebar(services::prefs_file().as_deref());+ let mut options = native_options(custom_titlebar);// eframe restores the saved window layout before our code runs; drop values that would crash it.ui_state::sanitize(options.persistence_path.as_deref());// Crash-safe GPU startup (#4): pick the backend (a marker left by a start that died in the@@ -293,7 +303,7 @@ fn main() -> eframe::Result {}let mut app = PhotocraftApp::new(Session::new(), services);app.integrated_titlebar = cfg!(target_os = "macos");- app.custom_titlebar = CUSTOM_TITLEBAR;+ app.custom_titlebar = custom_titlebar;// Only the title bar's free gap drags the window, never the menus (mac_window.rs).#[cfg(target_os = "macos")]mac_window::disable_native_title_drag();@@ -447,7 +457,7 @@ fn main() -> eframe::Result {mod tests {#[test]fn window_and_panel_geometry_survive_a_restart() {- let options = super::native_options();+ let options = super::native_options(super::CUSTOM_TITLEBAR);assert!(options.persist_window);assert_eq!(options.persistence_path, super::services::config_dir().map(|dir| dir.join("ui.ron")));@@ -485,10 +495,31 @@ mod tests {#[test]fn the_window_opens_centred_at_its_default_size() {- let o = super::native_options();+ let o = super::native_options(super::CUSTOM_TITLEBAR);assert!(o.centered, "#419: centred, not cascaded from the top-left corner");assert_eq!(o.viewport.inner_size, Some(egui::vec2(1440.0, 900.0)));// eframe shrinks the start size to the monitor, so the centred position is on-screen.assert_ne!(o.viewport.clamp_size_to_monitor_size, Some(false));}++ #[test]+ fn the_system_title_bar_preference_keeps_the_window_decorations() {+ // #1271, #1316: Preferences › Interface › System Title Bar gives the window back its+ // system decorations on Windows and Linux; macOS always has them.+ let dir = std::env::temp_dir().join(format!("pc-titlebar-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let file = dir.join("prefs.json");+ assert_eq!(super::custom_titlebar(None), super::CUSTOM_TITLEBAR, "no preferences file: the default");+ std::fs::write(&file, "not json").unwrap();+ assert_eq!(super::custom_titlebar(Some(&file)), super::CUSTOM_TITLEBAR, "an unreadable file: the default");+ std::fs::write(&file, r#"{"interface":{"systemTitleBar":true}}"#).unwrap();+ assert!(!super::custom_titlebar(Some(&file)));+ assert_eq!(super::native_options(false).viewport.decorations, Some(true));+ std::fs::write(&file, r#"{"interface":{"systemTitleBar":false}}"#).unwrap();+ assert_eq!(super::custom_titlebar(Some(&file)), super::CUSTOM_TITLEBAR);+ if super::CUSTOM_TITLEBAR {+ assert_eq!(super::native_options(true).viewport.decorations, Some(false));+ }+ let _ = std::fs::remove_dir_all(&dir);+ }}diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex ecf10a6c5..f4bb48505 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -219,6 +219,10 @@ pub struct Interface {/// Move tool drags show only the layer's outline and an arrow, leaving its pixels in place/// until release. Off (the default), the pixels follow the pointer live inside the outline.pub show_bounding_box_when_dragging_layer: bool,+ /// Windows and Linux: use the system's title bar and window buttons instead of PhotoCraft's+ /// own one-row title bar (tiling window managers, desktops that draw their own decorations;+ /// #1271, #1316). Read when the app starts. macOS always uses the system's.+ pub system_title_bar: bool,}impl Default for Interface {@@ -236,6 +240,7 @@ impl Default for Interface {show_menu_colors: true,show_tooltips: true,show_bounding_box_when_dragging_layer: false,+ system_title_bar: false,}}}diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 8e1490eef..93ec28862 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -1859,6 +1859,7 @@Show slice numbers Zobrazit čísla řezůShow tooltips Zobrazit popisky nástrojůShow bounding box when dragging layer Při přetahování vrstvy zobrazit ohraničovací rámeček+ System title bar Systémové záhlaví oknaShow transformation values Zobrazit hodnoty transformaceSlice color Barva řezůSmart guide color Barva chytrých vodítekdiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex 707d381c9..881d887d0 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -1836,6 +1836,7 @@Show slice numbers Slice-Nummern anzeigenShow tooltips Tooltips anzeigenShow bounding box when dragging layer Begrenzungsrahmen beim Ziehen einer Ebene anzeigen+ System title bar System-TitelleisteShow transformation values Transformationswerte anzeigenSlice color Slice-FarbeSmart guide color Smart-Hilfslinienfarbediff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex 96d7a7061..42f3c87a7 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -1845,6 +1845,7 @@Show slice numbers Mostrar los números de secciónShow tooltips Mostrar las descripciones emergentesShow bounding box when dragging layer Mostrar el cuadro delimitador al arrastrar la capa+ System title bar Barra de título del sistemaShow transformation values Mostrar los valores de transformaciónSlice color Color de las seccionesSmart guide color Color de las guías inteligentesdiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 142fa35cd..7c46f1862 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -2463,6 +2463,7 @@Invalid {mode} profile Profil {mode} non valideUnnamed {mode} profile Profil {mode} sans nomShow bounding box when dragging layer Afficher le cadre de sélection lors du déplacement du calque+ System title bar Barre de titre du systèmeFreeze Lasso: drag to freeze an area, Alt-drag to thaw it (L) Lasso de figeage : faites glisser pour figer une zone, Alt+glisser pour la libérer (L)Rendering Mode Mode de renduAutomatic (recommended) Automatique (recommandé)diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 7b51bfd1d..54acbb759 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -2452,6 +2452,7 @@Invalid {mode} profile Profil {mode} tidak validUnnamed {mode} profile Profil {mode} tanpa namaShow bounding box when dragging layer Tampilkan kotak pembatas saat menyeret layer+ System title bar Bilah judul sistemFreeze Lasso: drag to freeze an area, Alt-drag to thaw it (L) Lasso Bekukan: seret untuk membekukan area, seret dengan Alt untuk mencairkannya (L)Shadow Clipping Warning (U) Peringatan Clipping Bayangan (U)Highlight Clipping Warning (O) Peringatan Clipping Highlight (O)diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex e5af7eb23..b8d17eac8 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -1842,6 +1842,7 @@Show slice numbers Mostra numeri sezioniShow tooltips Mostra tooltipShow bounding box when dragging layer Mostra riquadro selezione al trascinamento livello+ System title bar Barra del titolo di sistemaShow transformation values Mostra valori trasformazioneSlice color Colore sezioniSmart guide color Colore guide intelligentidiff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 4f1bc752b..59f5541b7 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -1850,6 +1850,7 @@Show slice numbers スライス番号を表示Show tooltips ツールチップを表示Show bounding box when dragging layer レイヤーのドラッグ中にバウンディングボックスを表示+ System title bar システムのタイトルバーShow transformation values 変形値を表示Slice color スライスの色Smart guide color スマートガイドの色diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex e9901017f..e7ecb6fa5 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -1992,6 +1992,7 @@Invalid {mode} profile 유효하지 않은 {mode} 프로파일Unnamed {mode} profile 이름 없는 {mode} 프로파일Show bounding box when dragging layer 레이어를 드래그할 때 테두리 상자 표시+ System title bar 시스템 제목 표시줄Mixer Brush Tool 혼합 브러시 도구Rendering Mode 렌더링 모드Automatic (recommended) 자동(권장)diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 14ec627f6..d94360e00 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -2459,6 +2459,7 @@Invalid {mode} profile Perfil {mode} inválidoUnnamed {mode} profile Perfil {mode} sem nomeShow bounding box when dragging layer Mostrar caixa delimitadora ao arrastar a camada+ System title bar Barra de título do sistemaFreeze Lasso: drag to freeze an area, Alt-drag to thaw it (L) Laço de congelamento: arraste para congelar uma área, Alt-arraste para descongelá-la (L)Rendering Mode Modo de renderizaçãoAutomatic (recommended) Automático (recomendado)diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 4e3d244ad..d3c1231e7 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2247,6 +2247,7 @@Show slice numbers Показывать номера фрагментовShow tooltips Показывать подсказкиShow bounding box when dragging layer Показывать рамку при перетаскивании слоя+ System title bar Системная строка заголовкаShow transformation values Показывать значения трансформацииSlice color Цвет фрагментаSmart guide color Цвет умных направляющихdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex bc468720b..5b76a1348 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -1852,6 +1852,7 @@Show slice numbers 显示切片编号Show tooltips 显示工具提示Show bounding box when dragging layer 拖动图层时显示边界框+ System title bar 系统标题栏Show transformation values 显示变换值Slice color 切片颜色Smart guide color 智能参考线颜色diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex a09392f71..b5bcd13ff 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -1845,6 +1845,7 @@Show slice numbers 顯示切片編號Show tooltips 顯示工具提示Show bounding box when dragging layer 拖曳圖層時顯示邊界框+ System title bar 系統標題列Show transformation values 顯示變形數值Slice color 切片顏色Smart guide color 智慧型參考線顏色diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 7d3d69820..a7bc125bc 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 | 13 | 47 scenarios: 3 within budget, 22 over budget or failing, 15 tracked only, 6 not run, 7 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 3 | 10 | 14 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 229/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 || [Tools](#tools) | 6 | 15 | 9 | |-| [Workspace and UI](#workspace-and-ui) | 0 | 5 | 18 | settings that do nothing: 57 of 137 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 0 | 5 | 18 | settings that do nothing: 57 of 138 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) || [Reliability](#reliability) | 4 | 1 | 2 | never-crash lints on 27 of 27 crates; panic_hunt present |@@ -154,7 +154,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 57 of 137** (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: 57 of 138** (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`, `general.beep_when_done`, `general.export_clipboard`, `general.resize_image_during_place`, `general.always_create_smart_objects_when_placing`, `general.animated_zoom`, `general.zoom_resizes_windows`, `interface.show_channels_in_color`, `interface.dynamic_color_sliders`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.open_documents_as_tabs`, `workspace.enable_floating_document_window_docking`, `workspace.large_tabs`, `workspace.enable_narrow_options_bar`, `tools.zoom_clicked_point_to_center`, `tools.enable_flick_panning`, `tools.vary_round_brush_hardness_on_hud`, `tools.show_transformation_values`, `tools.double_click_layer_mask_launches_select_and_mask`, `file_handling.image_previews`, `file_handling.lowercase_extension`, `file_handling.save_in_background`, `file_handling.ignore_exif_profile_tag`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `cursors.brush_preview_color`, `units_and_rulers.type_units`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `units_and_rulers.print_resolution`, `units_and_rulers.screen_resolution`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.smart_quotes`, `type_.missing_glyph_protection`, `type_.show_font_names_in_english`, `type_.use_esc_to_commit`, `type_.text_engine`, `type_.font_preview`, `type_.fill_new_type_layers_with_placeholder`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `enhanced_controls.zoom_with_trackpad_pinch`, `enhanced_controls.rotate_view_with_trackpad`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.