mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
* Fix #1271, fix #1316: Preferences › Interface › System Title Bar Since #986, Windows and Linux draw PhotoCraft's own one-row title bar with its own window buttons. On tiling window managers those buttons do nothing, and some Linux desktops look better with their own decorations. The new System Title Bar preference (off by default) gives the window the system's title bar and buttons back; it is read when the app starts. macOS always uses the system's. Translated in every shipped language. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UHgFEHEsefoQoBParH47JA * Scorecard: count the System Title Bar preference Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UHgFEHEsefoQoBParH47JA --------- Co-authored-by: Claude <[email protected]>
This commit is contained in:
1 parent
84b76a8c9c
commit
83936bdcee
15 files changed
+56
-8
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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í okna
|
||||
Show transformation values Zobrazit hodnoty transformace
|
||||
Slice color Barva řezů
|
||||
Smart guide color Barva chytrých vodítek
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1836,6 +1836,7 @@
|
||||
Show slice numbers Slice-Nummern anzeigen
|
||||
Show tooltips Tooltips anzeigen
|
||||
Show bounding box when dragging layer Begrenzungsrahmen beim Ziehen einer Ebene anzeigen
|
||||
System title bar System-Titelleiste
|
||||
Show transformation values Transformationswerte anzeigen
|
||||
Slice color Slice-Farbe
|
||||
Smart guide color Smart-Hilfslinienfarbe
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1845,6 +1845,7 @@
|
||||
Show slice numbers Mostrar los números de sección
|
||||
Show tooltips Mostrar las descripciones emergentes
|
||||
Show bounding box when dragging layer Mostrar el cuadro delimitador al arrastrar la capa
|
||||
System title bar Barra de título del sistema
|
||||
Show transformation values Mostrar los valores de transformación
|
||||
Slice color Color de las secciones
|
||||
Smart guide color Color de las guías inteligentes
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -2463,6 +2463,7 @@
|
||||
Invalid {mode} profile Profil {mode} non valide
|
||||
Unnamed {mode} profile Profil {mode} sans nom
|
||||
Show 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ème
|
||||
Freeze 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 rendu
|
||||
Automatic (recommended) Automatique (recommandé)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2452,6 +2452,7 @@
|
||||
Invalid {mode} profile Profil {mode} tidak valid
|
||||
Unnamed {mode} profile Profil {mode} tanpa nama
|
||||
Show bounding box when dragging layer Tampilkan kotak pembatas saat menyeret layer
|
||||
System title bar Bilah judul sistem
|
||||
Freeze 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)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -1842,6 +1842,7 @@
|
||||
Show slice numbers Mostra numeri sezioni
|
||||
Show tooltips Mostra tooltip
|
||||
Show bounding box when dragging layer Mostra riquadro selezione al trascinamento livello
|
||||
System title bar Barra del titolo di sistema
|
||||
Show transformation values Mostra valori trasformazione
|
||||
Slice color Colore sezioni
|
||||
Smart guide color Colore guide intelligenti
|
||||
|
||||
|
@@ -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 スマートガイドの色
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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) 자동(권장)
|
||||
|
||||
|
@@ -2459,6 +2459,7 @@
|
||||
Invalid {mode} profile Perfil {mode} inválido
|
||||
Unnamed {mode} profile Perfil {mode} sem nome
|
||||
Show bounding box when dragging layer Mostrar caixa delimitadora ao arrastar a camada
|
||||
System title bar Barra de título do sistema
|
||||
Freeze 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ção
|
||||
Automatic (recommended) Automático (recomendado)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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 Цвет умных направляющих
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -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 智能参考线颜色
|
||||
|
||||
|
@@ -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 智慧型參考線顏色
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
+2
-2
@@ -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`.
|
||||
|
||||
|
||||
Reference in new issue
Block a user