PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Type: wire Fill New Type Layers with Placeholder Text (#1935)
Reynold Hu23c56c659e7a
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex 77969677a..8bf184767 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -870,7 +870,6 @@ pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &["type.useEscToCommit","type.textEngine","type.fontPreview",- "type.fillNewTypeLayersWithPlaceholder","type.recentFonts","enhancedControls.scrubbySliderAcceleration","enhancedControls.touchGestures",diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rsindex 79aec0d8a..c96c52552 100644--- a/crates/ui-egui/src/prefs_ui.rs+++ b/crates/ui-egui/src/prefs_ui.rs@@ -1848,9 +1848,13 @@ mod tests {assert!(has_visible_fields(&values, "general"));assert!(has_visible_fields(&values, "fileHandling"));// Every setting of these sections is still unimplemented.- for section in ["type", "integrations", "scratchDisks"] {+ for section in ["integrations", "scratchDisks"] {assert!(!has_visible_fields(&values, section), "{section}");}+ // "Fill new type layers with placeholder text" is live; other Type rows stay hidden.+ assert!(has_visible_fields(&values, "type"));+ assert!(!prefs::is_hidden("type.fillNewTypeLayersWithPlaceholder"));+ assert!(prefs::is_hidden("type.smartQuotes"));// Rotate View with Trackpad is live; the other Enhanced Controls rows stay hidden.assert!(has_visible_fields(&values, "enhancedControls"));assert!(!prefs::is_hidden("enhancedControls.rotateViewWithTrackpad"));diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rsindex 784ba7f1a..5dfc14abd 100644--- a/crates/ui-egui/src/type_tool.rs+++ b/crates/ui-egui/src/type_tool.rs@@ -256,8 +256,10 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {let (w, h) = ((end[0] - start[0]).abs(), (end[1] - start[1]).abs());let min = 4.0 / app.current_zoom().max(0.01) as f64;let o = app.ui.tool_options.clone();+ // Preferences ▸ Type: "Fill new type layers with placeholder text" (on by default).+ let text = if app.session.prefs().type_.fill_new_type_layers_with_placeholder { PLACEHOLDER } else { "" };let mut p = json!({- "text": PLACEHOLDER,+ "text": text,"orientation": if app.ui.tool == crate::state::Tool::VerticalType { "vertical" } else { "horizontal" },"font": o.type_font,"fontStyle": o.type_style,@@ -280,7 +282,7 @@ pub fn pointer_up(app: &mut PhotocraftApp, start: [f64; 2], end: [f64; 2]) {let _ = app.run("type.edit", json!({"layer": id, "antialias": o.type_aa, "coalesce": key}));}// Like Photoshop: the placeholder is selected, so typing replaces it.- let n = PLACEHOLDER.chars().count();+ let n = text.chars().count();app.ui.text_edit = Some(TextEdit { layer: id, caret: n, anchor: 0, session: key, created: true, dragging: false, resize: None, preedit: None });}}@@ -1531,6 +1533,22 @@ mod tests {assert!(app.ui.text_edit.is_none());}+ /// Preferences ▸ Type ▸ Fill new type layers with placeholder text: off, a click creates an+ /// empty layer (nothing selected) and committing without typing removes it again.+ #[test]+ fn placeholder_preference_controls_new_type_layer_text() {+ let mut app = app();+ app.run("prefs.set", json!({"path": "type.fillNewTypeLayersWithPlaceholder", "value": false})).unwrap();+ pointer_up(&mut app, [50.0, 100.0], [50.0, 100.0]);+ let ed = app.ui.text_edit.clone().unwrap();+ assert_eq!((ed.anchor, ed.caret), (0, 0), "nothing to select");+ assert_eq!(layer_text(&app), "");+ assert_eq!(app.session.active().unwrap().doc.layers.len(), 2, "the layer was created");+ commit(&mut app);+ assert_eq!(app.session.active().unwrap().doc.layers.len(), 1, "an empty type layer is removed on commit");+ assert!(app.ui.text_edit.is_none());+ }+#[test]fn a_name_from_text_after_blank_lines_keeps_following_the_text() {let mut app = app();diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 9e2655e51..c2bbd41ff 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 | 14 | 48 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 7 not run, 7 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 4 | 12 | 11 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 || [Tools](#tools) | 13 | 14 | 8 | |-| [Workspace and UI](#workspace-and-ui) | 5 | 6 | 12 | settings that do nothing: 54 of 141 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 5 | 6 | 12 | settings that do nothing: 53 of 141 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 3 | 2 | 6 | 627 of 627 menu items live (100.0%) || [Reliability](#reliability) | 5 | 0 | 2 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -160,9 +160,9 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 54 of 141** (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: 53 of 141** (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.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`, `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`, `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`.+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.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`, `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_.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`.| Id | Target | Status | Issue | Note ||---|---|---|---|---|