diff --git a/Cargo.lock b/Cargo.lock index 062e725..988cd44 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,7 @@ dependencies = [ [[package]] name = "canvas-pilot" -version = "0.9.33" +version = "0.9.34" dependencies = [ "base64", "craft-dwg", diff --git a/Cargo.toml b/Cargo.toml index 4d01a56..4be7d33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"] resolver = "3" [workspace.package] -version = "0.9.33" +version = "0.9.34" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot" diff --git a/crates/canvas-pilot/locales/en.json b/crates/canvas-pilot/locales/en.json index 695a801..8dee7f3 100644 --- a/crates/canvas-pilot/locales/en.json +++ b/crates/canvas-pilot/locales/en.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "Snap movement & resizing", "ui.pixel-edges": "Pixel edges", "ui.screen-edges-center-quarters": "Screen edges, center & quarters", - "ui.visible-layer-edges": "Visible layer edges", + "ui.visible-layer-edges": "Layer borders", "ui.outline-only-layers-this-project": "Outline-only layers (this project)", "ui.show-toolbar-icon-names": "Show toolbar icon names", "ui.show-source-patterns-on-other-layers-while-cropping": "Show source patterns on other layers while cropping", diff --git a/crates/canvas-pilot/locales/eo.json b/crates/canvas-pilot/locales/eo.json index 656e380..d239f56 100644 --- a/crates/canvas-pilot/locales/eo.json +++ b/crates/canvas-pilot/locales/eo.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "Algluiĝo dum movo kaj regrandigo", "ui.pixel-edges": "Bilderaj randoj", "ui.screen-edges-center-quarters": "Ekranaj randoj, centro kaj kvaronoj", - "ui.visible-layer-edges": "Randoj de videblaj tavoloj", + "ui.visible-layer-edges": "Tavolaj randoj", "ui.outline-only-layers-this-project": "Nur konturoj de tavoloj (ĉi tiu projekto)", "ui.show-toolbar-icon-names": "Montri nomojn de ilobretaj piktogramoj", "ui.show-source-patterns-on-other-layers-while-cropping": "Montri fontajn ŝablonojn sur aliaj tavoloj dum tondado", diff --git a/crates/canvas-pilot/locales/es.json b/crates/canvas-pilot/locales/es.json index 309ad7d..9b041c9 100644 --- a/crates/canvas-pilot/locales/es.json +++ b/crates/canvas-pilot/locales/es.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "Ajustar movimiento y tamaño", "ui.pixel-edges": "Bordes de píxeles", "ui.screen-edges-center-quarters": "Bordes, centro y cuartos de pantalla", - "ui.visible-layer-edges": "Bordes de capas visibles", + "ui.visible-layer-edges": "Bordes de capa", "ui.outline-only-layers-this-project": "Solo contornos de capas (este proyecto)", "ui.show-toolbar-icon-names": "Mostrar nombres de iconos", "ui.show-source-patterns-on-other-layers-while-cropping": "Mostrar patrones de otras capas al recortar", diff --git a/crates/canvas-pilot/locales/fr.json b/crates/canvas-pilot/locales/fr.json index d51e01a..03770d3 100644 --- a/crates/canvas-pilot/locales/fr.json +++ b/crates/canvas-pilot/locales/fr.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "Aimantation du déplacement et du redimensionnement", "ui.pixel-edges": "Bords des pixels", "ui.screen-edges-center-quarters": "Bords, centre et quarts de l’écran", - "ui.visible-layer-edges": "Bords des calques visibles", + "ui.visible-layer-edges": "Bords des calques", "ui.outline-only-layers-this-project": "Contours seuls (ce projet)", "ui.show-toolbar-icon-names": "Afficher les noms des outils", "ui.show-source-patterns-on-other-layers-while-cropping": "Afficher les mires des autres calques pendant le recadrage", diff --git a/crates/canvas-pilot/locales/grc.json b/crates/canvas-pilot/locales/grc.json index 51b0914..94fc41e 100644 --- a/crates/canvas-pilot/locales/grc.json +++ b/crates/canvas-pilot/locales/grc.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "Ἐνέργει πρόσφυσιν κινήσεως καὶ μεγέθους", "ui.pixel-edges": "Ὅρια ψηφίδων", "ui.screen-edges-center-quarters": "Ὅρια, κέντρον καὶ τεταρτημόρια πετάσματος", - "ui.visible-layer-edges": "Ὅρια ὁρατῶν στρωμάτων", + "ui.visible-layer-edges": "Ἄκρα στρωμάτων", "ui.outline-only-layers-this-project": "Μόνα περιγράμματα στρωμάτων (τόδε τὸ σχέδιον)", "ui.show-toolbar-icon-names": "Δεῖξον τὰ ὀνόματα τῶν εἰκονιδίων", "ui.show-source-patterns-on-other-layers-while-cropping": "Ἐν τῇ ἀποτομῇ δεῖξον τὰ ὑποδείγματα πηγῶν τῶν ἄλλων στρωμάτων", diff --git a/crates/canvas-pilot/locales/hi.json b/crates/canvas-pilot/locales/hi.json index b73d7c9..6c67d32 100644 --- a/crates/canvas-pilot/locales/hi.json +++ b/crates/canvas-pilot/locales/hi.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "स्थान और आकार बदलते समय स्नैप करें", "ui.pixel-edges": "पिक्सेल के किनारे", "ui.screen-edges-center-quarters": "स्क्रीन के किनारे, केंद्र और चौथाई", - "ui.visible-layer-edges": "दृश्यमान परतों के किनारे", + "ui.visible-layer-edges": "लेयर की सीमाएँ", "ui.outline-only-layers-this-project": "केवल परतों की रूपरेखा (इस परियोजना में)", "ui.show-toolbar-icon-names": "टूलबार आइकन के नाम दिखाएँ", "ui.show-source-patterns-on-other-layers-while-cropping": "क्रॉप करते समय अन्य परतों पर स्रोत पैटर्न दिखाएँ", diff --git a/crates/canvas-pilot/locales/ja.json b/crates/canvas-pilot/locales/ja.json index bf2aa08..72c60f4 100644 --- a/crates/canvas-pilot/locales/ja.json +++ b/crates/canvas-pilot/locales/ja.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "移動とサイズ変更をスナップ", "ui.pixel-edges": "ピクセル境界", "ui.screen-edges-center-quarters": "画面の端、中央、四分点", - "ui.visible-layer-edges": "表示レイヤーの端", + "ui.visible-layer-edges": "レイヤーの境界", "ui.outline-only-layers-this-project": "レイヤーを輪郭のみ表示(このプロジェクト)", "ui.show-toolbar-icon-names": "ツールバーのアイコン名を表示", "ui.show-source-patterns-on-other-layers-while-cropping": "クロップ中に他レイヤーのソースパターンを表示", diff --git a/crates/canvas-pilot/locales/ne.json b/crates/canvas-pilot/locales/ne.json index d94e08a..1745fff 100644 --- a/crates/canvas-pilot/locales/ne.json +++ b/crates/canvas-pilot/locales/ne.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "सार्दा र आकार बदल्दा स्न्याप गर्नुहोस्", "ui.pixel-edges": "पिक्सेलका किनाराहरू", "ui.screen-edges-center-quarters": "स्क्रिनका किनारा, केन्द्र र चौथाइ", - "ui.visible-layer-edges": "देखिने तहका किनाराहरू", + "ui.visible-layer-edges": "तहका किनाराहरू", "ui.outline-only-layers-this-project": "तहको रूपरेखा मात्र (यो परियोजना)", "ui.show-toolbar-icon-names": "उपकरणपट्टीका आइकन नाम देखाउनुहोस्", "ui.show-source-patterns-on-other-layers-while-cropping": "क्रप गर्दा अन्य तहहरूमा स्रोत ढाँचा देखाउनुहोस्", diff --git a/crates/canvas-pilot/locales/pt-PT.json b/crates/canvas-pilot/locales/pt-PT.json index cee496c..80ba675 100644 --- a/crates/canvas-pilot/locales/pt-PT.json +++ b/crates/canvas-pilot/locales/pt-PT.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "Encaixar movimento e tamanho", "ui.pixel-edges": "Limites dos píxeis", "ui.screen-edges-center-quarters": "Limites, centro e quartos do ecrã", - "ui.visible-layer-edges": "Limites das camadas visíveis", + "ui.visible-layer-edges": "Bordas das camadas", "ui.outline-only-layers-this-project": "Só contornos das camadas (neste projeto)", "ui.show-toolbar-icon-names": "Mostrar nomes dos ícones", "ui.show-source-patterns-on-other-layers-while-cropping": "Mostrar padrões nas outras camadas durante o recorte", diff --git a/crates/canvas-pilot/locales/th.json b/crates/canvas-pilot/locales/th.json index 226de8f..84db606 100644 --- a/crates/canvas-pilot/locales/th.json +++ b/crates/canvas-pilot/locales/th.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "ดูดตำแหน่งเมื่อย้ายและปรับขนาด", "ui.pixel-edges": "ขอบพิกเซล", "ui.screen-edges-center-quarters": "ขอบ กึ่งกลาง และหนึ่งในสี่ของหน้าจอ", - "ui.visible-layer-edges": "ขอบเลเยอร์ที่มองเห็น", + "ui.visible-layer-edges": "ขอบเลเยอร์", "ui.outline-only-layers-this-project": "แสดงเฉพาะเส้นขอบเลเยอร์ (โครงการนี้)", "ui.show-toolbar-icon-names": "แสดงชื่อไอคอนแถบเครื่องมือ", "ui.show-source-patterns-on-other-layers-while-cropping": "แสดงลวดลายต้นทางบนเลเยอร์อื่นขณะครอบตัด", diff --git a/crates/canvas-pilot/locales/tok.json b/crates/canvas-pilot/locales/tok.json index 7f51c7b..0a6f4d2 100644 --- a/crates/canvas-pilot/locales/tok.json +++ b/crates/canvas-pilot/locales/tok.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "o awen e tawa e suli lon linja", "ui.pixel-edges": "poka pi poki sitelen", "ui.screen-edges-center-quarters": "poka supa en insa en kipisi tu tu", - "ui.visible-layer-edges": "poka pi lipu lukin", + "ui.visible-layer-edges": "poka pi sitelen supa", "ui.outline-only-layers-this-project": "linja lipu taso (pali ni)", "ui.show-toolbar-icon-names": "o lukin e nimi ilo", "ui.show-source-patterns-on-other-layers-while-cropping": "o lukin e sitelen tan lon lipu ante lon tenpo kipisi", diff --git a/crates/canvas-pilot/locales/zh-CN.json b/crates/canvas-pilot/locales/zh-CN.json index 07ccfdd..f786c70 100644 --- a/crates/canvas-pilot/locales/zh-CN.json +++ b/crates/canvas-pilot/locales/zh-CN.json @@ -78,7 +78,7 @@ "ui.snap-movement-resizing": "移动和缩放吸附", "ui.pixel-edges": "像素边缘", "ui.screen-edges-center-quarters": "屏幕边缘、中心和四分点", - "ui.visible-layer-edges": "可见图层边缘", + "ui.visible-layer-edges": "图层边框", "ui.outline-only-layers-this-project": "仅显示图层轮廓(此项目)", "ui.show-toolbar-icon-names": "显示工具栏图标名称", "ui.show-source-patterns-on-other-layers-while-cropping": "裁剪时显示其他图层的源图案", diff --git a/crates/canvas-pilot/src/gui.rs b/crates/canvas-pilot/src/gui.rs index 1e7bcaa..a49f151 100644 --- a/crates/canvas-pilot/src/gui.rs +++ b/crates/canvas-pilot/src/gui.rs @@ -6069,7 +6069,7 @@ mod tests { let mut app = Editor::default(); app.snapping.enabled = enabled; app.snapping.pixels = false; - app.snapping.layer_edges = false; + app.snapping.layer_edges = true; let before = app.layout.layers().clone(); let saved = app.snapping; let point = if resize { @@ -6166,7 +6166,7 @@ mod tests { for label in [ "Pixel edges", "Screen edges, center & quarters", - "Visible layer edges", + "Layer borders", ] { click_text(&mut app, &ctx, label); } @@ -8583,7 +8583,7 @@ mod tests { }; app.snapping.enabled = true; app.snapping.pixels = false; - app.snapping.layer_edges = false; + app.snapping.layer_edges = true; let before = app.layout.layers().clone(); let output = frame(&mut app, &ctx, vec![]); let rect = layer_rects(&output)[1]; diff --git a/crates/canvas-pilot/src/menu_ui.rs b/crates/canvas-pilot/src/menu_ui.rs index ff0b717..9e4e63f 100644 --- a/crates/canvas-pilot/src/menu_ui.rs +++ b/crates/canvas-pilot/src/menu_ui.rs @@ -112,10 +112,7 @@ impl Editor { &mut self.snapping.layer_edges, tr(ui.ctx(), "ui.visible-layer-edges"), ) - .on_hover_text(tr( - ui.ctx(), - "ui.includes-contact-between-mirrored-opposite-resizing-layers", - )); + .on_hover_text("Snap moving outer borders and use other layers’ borders as targets. Independent of masks. Also controls mirrored/opposite resize contact; center and direct resize-handle snapping remain available."); ui.checkbox(&mut self.snapping.mask_edges, tr(ui.ctx(), "ui.mask-edges")); }); ui.weak(tr( @@ -484,10 +481,18 @@ mod tests { click_label(&mut app, &ctx, "Snap movement & resizing"); click_label(&mut app, &ctx, "Mask edges & centers"); assert!(app.snapping.mask_edges); + click_label(&mut app, &ctx, "Layer borders"); + assert!(!app.snapping.layer_edges); + assert!(app.snapping.mask_edges); + click_label(&mut app, &ctx, "Mask edges & centers"); + assert!(!app.snapping.mask_edges); + assert!(!app.snapping.layer_edges); + click_label(&mut app, &ctx, "Mask edges & centers"); assert_eq!(*app.layout.layers(), before); let (store, saved) = settings::Store::at(path); assert!(store.error.is_none()); assert!(saved.snapping.mask_edges); + assert!(!saved.snapping.layer_edges); assert!(saved.snapping.enabled); } diff --git a/crates/canvas-pilot/src/snapping.rs b/crates/canvas-pilot/src/snapping.rs index 9dfcf0e..e113ee2 100644 --- a/crates/canvas-pilot/src/snapping.rs +++ b/crates/canvas-pilot/src/snapping.rs @@ -237,8 +237,11 @@ impl Layout { .mask_edges .then(|| mask_geometry(&before.formats, i, *g)) .flatten(); - for (is_center, moving) in edge(*g, axis) + for (is_center, moving) in options + .layer_edges + .then_some(*g) .into_iter() + .flat_map(|g| edge(g, axis)) .chain(mask.into_iter().flat_map(|g| edge(g, axis))) .map(|v| (false, v)) .chain(std::iter::once((true, g.center()[axis]))) diff --git a/crates/canvas-pilot/tests/snapping.rs b/crates/canvas-pilot/tests/snapping.rs index 04bd793..16a0120 100644 --- a/crates/canvas-pilot/tests/snapping.rs +++ b/crates/canvas-pilot/tests/snapping.rs @@ -3,11 +3,12 @@ use canvas_pilot::{Layout, snapping::Snapping}; #[test] fn screen_snapping_recomputes_from_original_and_is_one_undo_step() { let mut layout = Layout::default(); + layout.set_visible(0, false); let before = layout.layers().clone(); let formats = layout.formats().clone(); let options = Snapping { enabled: true, - layer_edges: false, + layer_edges: true, ..Default::default() }; layout.start_drag([1200.0, 200.0]); @@ -563,12 +564,13 @@ fn screen_quarters_snap_moving_edges_and_centers_and_survive_release() { let options = Snapping { enabled: true, pixels: false, - layer_edges: false, + layer_edges: true, ..Default::default() }; for fraction in [0.25, 0.5, 0.75] { for anchor in [0.0, 0.5, 1.0] { let mut layout = Layout::default(); + layout.set_visible(0, false); let g = layout.layers()[1]; let target = [1920.0 * fraction, 1080.0 * fraction]; let point = [ @@ -647,7 +649,7 @@ fn overlay_grid_snaps_moves_resizes_and_pivots_with_fractional_divisions() { enabled: true, pixels: false, screen_edges: false, - layer_edges: false, + layer_edges: true, grid: true, show_grid: false, grid_divisions: [7, 5], @@ -710,7 +712,7 @@ fn mask_options() -> Snapping { enabled: true, pixels: false, screen_edges: false, - layer_edges: false, + layer_edges: true, mask_edges: true, ..Default::default() } @@ -1085,3 +1087,56 @@ fn moving_mask_center_aligns_to_masks_screen_and_grid_with_rigid_groups_and_undo assert_eq!(*layout.formats(), formats); } } + +#[test] +fn layer_borders_and_mask_anchors_can_be_disabled_independently() { + use canvas_pilot::formats::Mask; + for borders in [false, true] { + for masks in [false, true] { + let mut layout = Layout::default(); + layout.select(Some(1)); + layout + .set_mask( + 1, + Mask { + left: 0.25, + right: 0.1, + ..Default::default() + }, + ) + .unwrap(); + let g = layout.layers()[1]; + let formats = layout.formats().clone(); + let options = Snapping { + enabled: true, + pixels: false, + screen_edges: true, + layer_edges: borders, + mask_edges: masks, + ..Default::default() + }; + // Outer border near screen edge; masked edges and both centers are far away. + layout.start_drag([g.x, g.y]); + let guides = layout.drag_to_snapped([2.0, g.y + 17.0], options, 6.0); + assert_eq!(guides[0], borders.then_some(0.0)); + assert_eq!(layout.layers()[1].x, if borders { 0.0 } else { 2.0 }); + layout.cancel_drag(); + // Mask's left edge near screen edge; outer border is far from guides. + layout.start_drag([g.x, g.y]); + let guides = layout.drag_to_snapped( + [-158.0, g.y + 17.0], + Snapping { + screen_edges: true, + layer_edges: false, + ..options + }, + 6.0, + ); + assert_eq!(guides[0], masks.then_some(0.0)); + assert_eq!(layout.layers()[1].x, if masks { -160.0 } else { -158.0 }); + layout.cancel_drag(); + assert_eq!(layout.layers()[1], g); + assert_eq!(*layout.formats(), formats); + } + } +} diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index fd60652..3932900 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,13 @@ ## Unreleased +### v0.9.34 + +- Renamed Visible layer edges to Layer borders and made disabling it exclude moving + outer borders as well as stationary border targets. Mask edges & centers remains + independently selectable, with both choices preserved in preferences/projects. + Center alignment and direct resize-handle snapping retain their existing behavior. + ### v0.9.33 - Device mapping/transfer and import now use wider solid scrollbars whenever their diff --git a/docs/canvas-pilot/guide/canvas.md b/docs/canvas-pilot/guide/canvas.md index 6ce956c..6553230 100644 --- a/docs/canvas-pilot/guide/canvas.md +++ b/docs/canvas-pilot/guide/canvas.md @@ -154,10 +154,19 @@ Navigation tool choice survives selection changes and project loads in the curre session; a new launch starts with Select. Pan/Zoom do not alter geometry, crop values or document history. Existing project saves still preserve zoom/pan values. +### Layer border snapping + +**Layer borders** is independent of **Mask edges & centers**. Turn it off to stop +using outer layer borders as movement anchors or stationary snapping targets. +You can leave mask snapping on to position the visible masked picture, or disable +both options. Neither checkbox changes the other. Screen/grid center alignment, +pixel rounding and directly dragged resize handles retain their own behavior; +mirrored/opposite border-contact snapping follows **Layer borders**. + ### Snap to masks Enable **Mask edges & centers** in the snapping options to add the visible mask boundaries -and their centers as targets, independently of **Visible layer edges**. Movement can align either +and their centers as targets, independently of **Layer borders**. Movement can align either outer layer edges or mask edges to those targets, screen guides and grid lines. The center of a moving visible masked area can align to screen interior guides, overlay grid lines and other masked-area centers. Whole-layer centers can also diff --git a/docs/interfaces/canvas-pilot-settings.md b/docs/interfaces/canvas-pilot-settings.md index 0628c28..c9b90f5 100644 --- a/docs/interfaces/canvas-pilot-settings.md +++ b/docs/interfaces/canvas-pilot-settings.md @@ -143,6 +143,10 @@ fixed six-logical-pixel proximity radius converted by viewport scale. It affects layer movement, resize handles and pivot placement; numeric entry, nudges and crop-content gestures bypass it. Resize snapping preserves anchors and proportions and shows guides only when the resulting edge actually reaches its target. +`layer_edges` independently controls outer borders as movement anchors and +stationary targets, including mirrored/opposite resize contact. Disabling it does +not change `mask_edges`. Centers, pixel rounding and directly dragged resize handles +retain their existing behavior. The serialized field and default remain unchanged. `mask_edges` adds the nonempty intersection of mask reveal, layer aperture and fitted picture as edge and center targets. Hidden layers are skipped, locked layers included. Movement also adds selected mask edges and centers as anchors; resize handles remain on the