PhotoCraft: An open-source, photo editor written by scratch in pure Rust
feat(ui): allow disabling Studio canvas background dots (#2317)
Nigel Ihza Firdausye59bb2909b22
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex ac5f62b16..902e89bf9 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -221,6 +221,9 @@ pub struct Interface {/// Pasteboard colour in standard screen mode (`canvasCustomColor` when "custom").pub canvas_color: CanvasColor,pub canvas_custom_color: String,+ /// Show the repeating dot pattern on the canvas surround (including the empty workspace).+ /// Disable for a uniform background, for example on OLED displays (#2264).+ pub show_canvas_dots: bool,/// Document border in standard screen mode.pub canvas_border: CanvasBorder,pub ui_scale: UiScale,@@ -257,6 +260,7 @@ impl Default for Interface {light_theme: LightTheme::StudioLight,canvas_color: CanvasColor::Default,canvas_custom_color: "#282828".into(),+ show_canvas_dots: true,canvas_border: CanvasBorder::DropShadow,ui_scale: UiScale::Auto,language: "auto".into(),diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rsindex bee5a082a..ed78dcaa0 100644--- a/crates/engine/src/prefs/tests.rs+++ b/crates/engine/src/prefs/tests.rs@@ -22,6 +22,33 @@ fn defaults_match_photoshop() {}}+/// #2264: the Studio workspace dot pattern can be hidden without changing themes.+#[test]+fn canvas_dot_grid_can_be_disabled_persisted_and_reset() {+ let mut s = Session::new();+ assert!(s.prefs().interface.show_canvas_dots, "existing Studio appearance stays unchanged by default");+ assert_eq!(s.execute("prefs.get", json!({"path": "interface.showCanvasDots"})).unwrap(), json!(true));++ s.execute("prefs.set", json!({"path": "interface.showCanvasDots", "value": false})).unwrap();+ assert!(!s.prefs().interface.show_canvas_dots);+ assert_eq!(s.execute("prefs.get", json!({"path": "interface.showCanvasDots"})).unwrap(), json!(false));++ let mut restored = Session::new();+ restored.load_prefs_json(&s.prefs_to_json()).unwrap();+ assert!(!restored.prefs().interface.show_canvas_dots, "disabling the pattern must survive restart");++ // Older preference files without the new key retain the original dotted workspace.+ let mut legacy = Session::new();+ legacy.load_prefs_json(r#"{"interface": {"theme": "studio"}}"#).unwrap();+ assert!(legacy.prefs().interface.show_canvas_dots);++ assert!(s.execute("prefs.set", json!({"path": "interface.showCanvasDots", "value": "no"})).is_err());+ assert!(!s.prefs().interface.show_canvas_dots, "an invalid type must not change the preference");++ s.execute("prefs.reset", json!({"path": "interface.showCanvasDots"})).unwrap();+ assert!(s.prefs().interface.show_canvas_dots);+}+#[test]fn appearance_defaults_and_legacy_theme_migrate() {let p = Preferences::default();diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex a04e299f1..e9227d756 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -1610,7 +1610,7 @@ fn documents(app: &mut PhotocraftApp, ui: &mut egui::Ui) {}if n == 0 && !opening {// Auto show the Home Screen is off: an empty workspace, like Photoshop.- paint_dots(ui, ui.available_rect_before_wrap());+ paint_dots(ui, ui.available_rect_before_wrap(), app.session.prefs().interface.show_canvas_dots);return;}if !app.ui.view.hides_tabs() || opening {@@ -2156,7 +2156,10 @@ fn dots(ctx: &egui::Context, t: &crate::theme::Tokens) -> Option<egui::TextureIdSome(id)}-fn paint_dots(ui: &egui::Ui, rect: Rect) {+fn paint_dots(ui: &egui::Ui, rect: Rect, enabled: bool) {+ if !enabled {+ return;+ }let t = crate::theme::Tokens::get(ui.ctx());if let Some(id) = dots(ui.ctx(), &t) {let uv = Rect::from_min_max(Pos2::ZERO, pos2(rect.width() / 22.0, rect.height() / 22.0));@@ -2180,7 +2183,7 @@ pub fn mode_label(doc: &Document) -> &'static str {fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {let t = crate::theme::Tokens::get(ui.ctx());let area = ui.available_rect_before_wrap();- paint_dots(ui, area);+ paint_dots(ui, area, app.session.prefs().interface.show_canvas_dots);// File › Open Recent, newest first (on the web there are no paths to reopen).let recent: Vec<String> = if cfg!(target_arch = "wasm32") { Vec::new() } else { app.ui.recent_files.iter().take(HOME_RECENT).cloned().collect() };let recent_h = if recent.is_empty() { 0.0 } else { 34.0 + recent.len() as f32 * HOME_RECENT_ROW };@@ -2424,7 +2427,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:Some(c) => {ui.painter_at(rect).rect_filled(rect, 0.0, c);}- None => paint_dots(ui, rect),+ None => paint_dots(ui, rect, app.session.prefs().interface.show_canvas_dots),}let border = app.session.prefs().interface.canvas_border;let drop_shadow = border == photocraft_engine::prefs::CanvasBorder::DropShadow;diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex a506161e6..5d512872d 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -1814,6 +1814,7 @@Cache tile size Velikost dlaždice mezipamětiCamera Raw Defaults Výchozí nastavení Camera RawCanvas border Okraj plátna+ Show canvas dots Zobrazit tečky plátnaCanvas color Barva plátnaCanvas custom color Vlastní barva plátnaColor picker Výběr barvydiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex dba14c693..07c6e9e49 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -1785,6 +1785,7 @@Cache tile size Cache-KachelgrößeCamera Raw Defaults Camera-Raw-StandardeinstellungenCanvas border Zeichenflächenrand+ Show canvas dots Punkte der Zeichenfläche anzeigenCanvas color ZeichenflächenfarbeCanvas custom color Benutzerdefinierte ZeichenflächenfarbeColor picker Farbwählerdiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex bc85440b1..d154de7ff 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -1583,6 +1583,7 @@Cache tile size Μέγεθος πλακιδίου προσωρινής μνήμηςCamera Raw Defaults Προεπιλογές Camera RawCanvas border Περίγραμμα καμβά+ Show canvas dots Εμφάνιση κουκκίδων καμβάCanvas color Χρώμα καμβάCanvas custom color Προσαρμοσμένο χρώμα καμβάColor picker Επιλογέας χρώματοςdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex a9281a120..7dbe065bc 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -1797,6 +1797,7 @@Cache tile size Tamaño de tesela de cachéCamera Raw Defaults Valores predeterminados de Camera RawCanvas border Borde del lienzo+ Show canvas dots Mostrar puntos del lienzoCanvas color Color del lienzoCanvas custom color Color personalizado del lienzoColor picker Selector de colordiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 2d340befd..91b3010ed 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -1769,6 +1769,7 @@Cache tile size Taille des tuiles du cacheCamera Raw Defaults Valeurs par défaut de Camera RawCanvas border Bordure du canevas+ Show canvas dots Afficher les points du canevasCanvas color Couleur du canevasCanvas custom color Couleur personnalisée du canevasColor picker Sélecteur de couleursdiff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex 25fd766db..1e20656c9 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -1763,6 +1763,7 @@Cache tile size Ukuran tile cacheCamera Raw Defaults Default Camera RawCanvas border Border kanvas+ Show canvas dots Tampilkan titik kanvasCanvas color Warna kanvasCanvas custom color Warna kustom kanvasColor picker Pemilih warnadiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex fb1bc73b2..77cfe99e4 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -1795,6 +1795,7 @@Cache tile size Dimensione tile cacheCamera Raw Defaults Default Camera RawCanvas border Bordo quadro+ Show canvas dots Mostra punti del quadroCanvas color Colore quadroCanvas custom color Colore personalizzato quadroColor picker Selettore colorediff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 3614d38be..240897c93 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -1800,6 +1800,7 @@Cache tile size キャッシュタイルのサイズCamera Raw Defaults Camera Raw の既定値Canvas border カンバスの境界+ Show canvas dots カンバスのドットを表示Canvas color カンバスの色Canvas custom color カンバスのカスタム色Color picker カラーピッカーdiff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex 0f11c22f5..d162f5b7a 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -1762,6 +1762,7 @@Cache tile size 캐시 타일 크기Camera Raw Defaults Camera Raw 기본값Canvas border 캔버스 테두리+ Show canvas dots 캔버스 점 표시Canvas color 캔버스 색상Canvas custom color 캔버스 사용자 정의 색상Color picker 색상 피커diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex f9e2ccdc0..145532cd0 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -1775,6 +1775,7 @@Cache tile size Tegelgrootte cacheCamera Raw Defaults Standaardwaarden Camera RawCanvas border Canvasrand+ Show canvas dots Canvasstippen tonenCanvas color CanvaskleurCanvas custom color Aangepaste canvaskleurColor picker Kleurkiezerdiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 08fa9c9fd..b66d95096 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -1793,6 +1793,7 @@Cache tile size Rozmiar kafla pamięci podręcznejCamera Raw Defaults Domyślne ustawienia Camera RawCanvas border Obramowanie płótna+ Show canvas dots Pokaż kropki płótnaCanvas color Kolor płótnaCanvas custom color Własny kolor płótnaColor picker Próbnik kolorówdiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex ac6a0d71c..3821f6cf1 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -1768,6 +1768,7 @@Cache tile size Tamanho do bloco do cacheCamera Raw Defaults Padrões do Camera RawCanvas border Borda da tela de pintura+ Show canvas dots Mostrar pontos da tela de pinturaCanvas color Cor da tela de pinturaCanvas custom color Cor personalizada da tela de pinturaColor picker Seletor de coresdiff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex fde0abc57..0af1516a6 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2205,6 +2205,7 @@Cache tile size Размер блока кэшаCamera Raw Defaults Значения Camera Raw по умолчаниюCanvas border Рамка холста+ Show canvas dots Показывать точки холстаCanvas color Цвет холстаCanvas custom color Свой цвет холстаClassic Классическаяdiff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex 9a76d6836..28beeab34 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -2182,6 +2182,7 @@Cache tile size Розмір плитки кешуCamera Raw Defaults Типові параметри Camera RawCanvas border Межа полотна+ Show canvas dots Показувати крапки полотнаCanvas color Колір полотнаCanvas custom color Довільний колір полотнаClassic Класичнаdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex 06a73fa0d..0283ca3c5 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -1806,6 +1806,7 @@Cache tile size 缓存图块大小Camera Raw Defaults Camera Raw 默认设置Canvas border 画布边框+ Show canvas dots 显示画布圆点Canvas color 画布颜色Canvas custom color 画布自定颜色Color picker 拾色器diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex 4256b8ffc..42948b8d9 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -1800,6 +1800,7 @@Cache tile size 快取拼貼大小Camera Raw Defaults Camera Raw 預設值Canvas border 畫布邊框+ Show canvas dots 顯示畫布圓點Canvas color 畫布顏色Canvas custom color 畫布自訂顏色Color picker 檢色器diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 6c7f54000..665f82fcb 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 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 15 not run, 7 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 5 | 11 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 || [Tools](#tools) | 21 | 16 | 5 | |-| [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 43 of 150 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 6 | 7 | 10 | settings that do nothing: 43 of 151 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 3 | 2 | 6 | 630 of 630 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -175,7 +175,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 43 of 150** (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: 43 of 151** (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.always_create_smart_objects_when_placing`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `tools.enable_flick_panning`, `tools.vary_round_brush_hardness_on_hud`, `tools.show_transformation_values`, `file_handling.image_previews`, `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`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.missing_glyph_protection`, `type_.show_font_names_in_english`, `type_.text_engine`, `type_.font_preview`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `enhanced_controls.zoom_with_trackpad_pinch`, `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`.