PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Preferences › Interface: Show bounding box when dragging layer (#484)
sommerper08e3e610c09f
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex 6b2530dc7..70e3316b0 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -216,6 +216,9 @@ pub struct Interface {/// Draw menu item colours set with Edit › Menus.pub show_menu_colors: bool,pub show_tooltips: bool,+ /// 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,}impl Default for Interface {@@ -232,6 +235,7 @@ impl Default for Interface {dynamic_color_sliders: true,show_menu_colors: true,show_tooltips: true,+ show_bounding_box_when_dragging_layer: false,}}}diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex 7640c5a69..99346ece2 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -1841,6 +1841,7 @@Show only crosshair while painting Při malování zobrazit jen nitkový kříž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čekShow transformation values Zobrazit hodnoty transformaceSlice color Barva řezůSmart guide color Barva chytrých vodítekdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex cc335b326..edfb7078d 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -1827,6 +1827,7 @@Show only crosshair while painting Mostrar solo la retícula al pintarShow slice numbers Mostrar los números de secciónShow tooltips Mostrar las descripciones emergentes+ Show bounding box when dragging layer Mostrar el cuadro delimitador al arrastrar la capaShow 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/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 8350f1291..9ad086d48 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -1832,6 +1832,7 @@Show only crosshair while painting 描画中は十字線のみ表示Show slice numbers スライス番号を表示Show tooltips ツールチップを表示+ Show bounding box when dragging layer レイヤーのドラッグ中にバウンディングボックスを表示Show transformation values 変形値を表示Slice color スライスの色Smart guide color スマートガイドの色diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex dfb34f248..a0515c33d 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2230,6 +2230,7 @@Show only crosshair while painting Только перекрестье при рисованииShow slice numbers Показывать номера фрагментовShow tooltips Показывать подсказки+ Show bounding box when dragging layer Показывать рамку при перетаскивании слоя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 f51d48ab9..c2d93c006 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -1836,6 +1836,7 @@Show only crosshair while painting 绘画时仅显示十字线Show slice numbers 显示切片编号Show tooltips 显示工具提示+ Show bounding box when dragging layer 拖动图层时显示边界框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 45ca384ee..cf2eea741 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -1827,6 +1827,7 @@Show only crosshair while painting 繪圖時僅顯示十字線Show slice numbers 顯示切片編號Show tooltips 顯示工具提示+ Show bounding box when dragging layer 拖曳圖層時顯示邊界框Show transformation values 顯示變形數值Slice color 切片顏色Smart guide color 智慧型參考線顏色diff --git a/crates/ui-egui/src/move_ui.rs b/crates/ui-egui/src/move_ui.rsindex f6f0cc9ed..7854b532f 100644--- a/crates/ui-egui/src/move_ui.rs+++ b/crates/ui-egui/src/move_ui.rs@@ -59,7 +59,8 @@ fn drag_offset(app: &PhotocraftApp) -> Option<(i32, i32)> {/// the pointer. `None` without a drag (or when the layers can't move: locked, say; the drag then/// shows its arrow and the release reports why).pub(crate) fn display_doc(app: &mut PhotocraftApp, idx: usize) -> Option<(Arc<Document>, u64)> {- if app.session.active_index() != Some(idx) {+ // Preferences › Interface › Show bounding box when dragging layer: outline and arrow only.+ if app.session.active_index() != Some(idx) || app.session.prefs().interface.show_bounding_box_when_dragging_layer {return None;}let Some(offset) = drag_offset(app) else {@@ -183,4 +184,29 @@ mod tests {let r = super::damage(&app, st.doc.id, st.revision, keys[0], keys[1]).unwrap();assert_eq!(r, Rect::new(0, 0, 64, 64));}++ /// Mid-drag on a painted layer: is the layer shown at the pointer?+ fn live(outline: bool) -> bool {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.session.execute("file.new", json!({"width": 64, "height": 64})).unwrap();+ app.sync_views();+ app.session.execute("layer.new.layer", json!({})).unwrap();+ app.session.execute("select.rect", json!({"x": 8, "y": 8, "width": 16, "height": 16})).unwrap();+ app.session.execute("edit.fill", json!({"color": "#ff0000"})).unwrap();+ app.session.execute("select.deselect", json!({})).unwrap();+ app.session.edit_prefs(|p| p.interface.show_bounding_box_when_dragging_layer = outline);+ app.ui.tool = Tool::Move;+ let m = egui::Modifiers::NONE;+ crate::canvas::tool_event(&mut app, ToolEvent::Down { x: 16.0, y: 16.0, pressure: 1.0 }, m);+ crate::canvas::tool_event(&mut app, ToolEvent::Move { x: 30.0, y: 20.0, pressure: 1.0 }, m);+ let shown = super::display_doc(&mut app, 0).is_some();+ assert_eq!(shown, super::showing(&app));+ shown+ }++ #[test]+ fn bounding_box_preference_turns_the_live_drag_off() {+ assert!(live(false), "by default the layer follows the pointer");+ assert!(!live(true), "with the preference on, only the outline and arrow move");+ }}diff --git a/docs/scorecard.md b/docs/scorecard.mdindex b97750ba4..8cc2640de 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 | 12 | 46 scenarios: 3 within budget, 22 over budget or failing, 13 tracked only, 4 not run, 8 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 1 | 8 | 18 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 229/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 132/256, round trip ≥ 258/256 || [Tools](#tools) | 5 | 13 | 12 | |-| [Workspace and UI](#workspace-and-ui) | 0 | 4 | 19 | settings that do nothing: 60 of 134 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 0 | 4 | 19 | settings that do nothing: 60 of 135 (target 0) || [Type](#type) | 0 | 3 | 6 | || [Automation](#automation) | 1 | 3 | 7 | 626 of 626 menu items live (100.0%) || [Reliability](#reliability) | 3 | 1 | 3 | never-crash lints on 26 of 26 crates; panic_hunt present |@@ -153,7 +153,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 60 of 134** (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: 60 of 135** (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`, `general.use_legacy_free_transform`, `interface.ui_font_size`, `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.ask_before_saving_layered_tiff`, `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`.