VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Brushes: a brush dropped on a compound path's part applies to the compound (review of #298)
bflatastic5e0c91163343
diff --git a/ROADMAP.md b/ROADMAP.mdindex 895f0e2a0..0ec2a9d25 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -114,7 +114,7 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist- **Other:** Eyedropper, Gradient annotator, Artboard (Alt-drag duplicates an artboard, and its art with Move/Copy Artwork with Artboard on), Measure, Type, Hand, Zoom, Rotate View.- **Editing type:** double-clicking type with a selection tool switches to the Type tool with the caret where it was clicked.- **Temporary tools:** Cmd with any other tool drags with the selection tool used last (Selection, Direct Selection or Group Selection). Held Space pans and Cmd+Space zooms (Cmd+Alt+Space out) whatever the tool.- - **Panel drag and drop:** art dragged off the canvas onto the Symbols panel becomes a symbol, and a symbol dragged onto the canvas places an instance where it is dropped.+ - **Panel drag and drop:** art dragged off the canvas onto the Symbols panel becomes a symbol, onto the Swatches panel a pattern swatch and onto the Brushes panel an Art brush; a symbol dragged onto the canvas places an instance where it is dropped, and a brush dragged onto a path is applied to it.- **Tool double-clicks:** double-clicking a tool's button opens its options: Hand fits the artboard in the window, Zoom shows 100 %, Rotate, Scale, Reflect and Shear open their Object › Transform dialogs, Gradient, Eyedropper, Blend and the Liquify tools their panels or options.- **Layers panel:** every layer, sublayer, group and object is a clickable row at any depth: a click highlights it and makes its layer current (new art goes there), Shift-click a range, Ctrl/Cmd-click toggles. Sublayers are no longer treated as objects: clicks, marquees, Select All and the Select menu take the art inside them, and each sublayer selects in its own colour. Selection squares on rows with selected art (click selects a row's art, Shift adds or removes; dragging the square moves the selection to another row, Alt copies), the eye and lock on every row with drag-down-the-column (one undo step), Ctrl/Cmd-click an eye for per-layer Outline, Alt-click an eye or lock to hide or lock the other layers (again: show or unlock them all), triangles with Alt to open or close everything inside, drag and drop rows above, below or into layers and groups with a drop line (Alt copies, the trash deletes), inline rename, Delete key on highlighted rows. Buttons and the full panel menu: New Layer/Sublayer (Alt: options, Ctrl: on top), Duplicate, Delete, Options for Selection, clipping mask, isolation, Locate Object, Merge Selected, Flatten Artwork, Collect in New Layer, Release to Layers (Sequence and Build), Reverse Order, Template, Hide/Outline/Lock Others and Show/Preview/Unlock All, Paste Remembers Layers, Panel Options (row size, thumbnails per kind, Show Layers Only). Layer Options: name, colour (presets or custom), Template, Lock, Show, Print, Preview (outline drawing and clicking) and Dim Images to %. Every operation is a command (`layer.move`, `layer.highlight`, `layer.merge`…) with validation against cycles and invalid nesting.- **Drawing aids:** Smart Guides and snapping, guides dragged out of the rulers, and Draw Normal / Behind / Inside modes.diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 18ced610f..7c6c7df40 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -966,8 +966,10 @@ fn panel_drop(app: &mut VectorcraftApp, ui: &Ui, resp: &egui::Response, xf: &Xf)let add = ui.input(|i| i.modifiers.alt);("graphicStyle.apply", json!({"name": name, "ids": [hit.top_object(st.isolation).0], "add": add}))}- // A brush from the Brushes panel: the path it lands on takes it.- widgets::PanelDrag::Brush { name, .. } => ("brush.apply", json!({"name": name, "ids": [hit.leaf.0]})),+ // A brush from the Brushes panel: the path it lands on takes it (a compound path as a whole).+ widgets::PanelDrag::Brush { name, .. } => {+ ("brush.apply", json!({"name": name, "ids": [vectorcraft_tools::xform::paint_owner(&st.doc, hit.leaf).0]}))+ }// Art dragged back onto the canvas: its move was already dropped. (A symbol was placed// above.)widgets::PanelDrag::Art(_) | widgets::PanelDrag::Symbol(_) => return,diff --git a/crates/ui-egui/src/panels/asset_export.rs b/crates/ui-egui/src/panels/asset_export.rsindex dad16612f..2d5b416c0 100644--- a/crates/ui-egui/src/panels/asset_export.rs+++ b/crates/ui-egui/src/panels/asset_export.rs@@ -21,7 +21,7 @@ use super::{pstate, set_pstate};use crate::dialogs::{EXPORT_FOR_SCREENS, open_export_for_screens_assets, screen_formats, screen_saved_rows};use crate::state::Dialog;use crate::theme::Tokens;-use crate::widgets::{self, PanelDrag, menu_item};+use crate::widgets::{self, menu_item};use crate::{VectorcraftApp, io};pub const ID: &str = "assetExport";@@ -158,11 +158,8 @@ fn tiles(ui: &mut Ui, st: &DocState, sel: &[u64], ev: &mut Events) {/// Art dragged off the canvas over the list: outline it; dropped, it becomes assets.fn drop_zone(ui: &Ui, zone: &egui::Response, ev: &mut Events) {- let Some(drag) = zone.dnd_hover_payload::<PanelDrag>() else { return };- let PanelDrag::Art(ids) = &*drag else { return };- ui.painter().rect_stroke(zone.rect, 0.0, Stroke::new(1.5, Tokens::get(ui.ctx()).accent), StrokeKind::Inside);- if zone.dnd_release_payload::<PanelDrag>().is_some() {- ev.drop = Some((ids.clone(), ui.input(|i| i.modifiers.alt)));+ if let Some(ids) = widgets::art_drop(ui, zone) {+ ev.drop = Some((ids.into_iter().map(NodeId).collect(), ui.input(|i| i.modifiers.alt)));}}