From 3c7f03f62df17be4e8b133bddc18e82becd0ae37 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 00:00:19 -0800 Subject: [PATCH 1/2] Stroke: the Profile list is dimmed while the stroke's brush keeps its own size Brush art does not follow a stroke's width profile, so picking a profile for a brushed stroke changed nothing on the canvas. - While every stroke the Profile list edits draws with a brush, the list in the Stroke panel, the Properties panel and the Control bar is dimmed and says why when hovered. It opens no list while those strokes are uniform, and offers only Uniform, which removes the profiles, while one has a profile. The Flip Along and Flip Across buttons beside it are off. The strokes are the ones stroke.set edits: the active Appearance stroke row, a selected group's or compound shape's own stroke, or the objects' top strokes. Images and symbol instances do not count. A selection where one stroke has no brush keeps the full list. - The Width tool adds, edits and deletes no width points on a brushed stroke; a press or double-click on one, or Delete with its width points selected, shows the same reason in the status bar. Without Shift, the press deselects the width points of other strokes. A plain stroke under a selected brushed one stays reachable, and width points selected before their stroke took a brush show no handles. - The reason has a row in every complete catalog. --- crates/brush/src/lib.rs | 8 + crates/engine/src/cmd/stroke.rs | 45 +++ crates/engine/src/tests/appearance.rs | 106 +++++++ crates/engine/src/tooling.rs | 1 + crates/tools/src/distort/width.rs | 260 +++++++++++++++++- crates/tools/src/input.rs | 4 + crates/ui-egui/src/chrome/control_bar.rs | 2 +- crates/ui-egui/src/i18n/bg.tsv | 2 + crates/ui-egui/src/i18n/bs.tsv | 2 + crates/ui-egui/src/i18n/ca.tsv | 2 + crates/ui-egui/src/i18n/cs.tsv | 2 + crates/ui-egui/src/i18n/da.tsv | 2 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/el.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fi.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/gu.tsv | 2 + crates/ui-egui/src/i18n/hi.tsv | 2 + crates/ui-egui/src/i18n/hu.tsv | 2 + crates/ui-egui/src/i18n/id.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ka.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/nl.tsv | 2 + crates/ui-egui/src/i18n/pl.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/sv.tsv | 2 + crates/ui-egui/src/i18n/tr.tsv | 2 + crates/ui-egui/src/i18n/uk.tsv | 2 + crates/ui-egui/src/i18n/vi.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 2 + crates/ui-egui/src/i18n/zh-hant.tsv | 2 + crates/ui-egui/src/panels/properties.rs | 2 +- crates/ui-egui/src/panels/properties/tests.rs | 20 ++ crates/ui-egui/src/panels/stroke.rs | 66 ++++- .../ui-egui/src/panels/tests_strokedepth.rs | 195 ++++++++++++- docs/target-app-parity.md | 1 + 40 files changed, 739 insertions(+), 27 deletions(-) diff --git a/crates/brush/src/lib.rs b/crates/brush/src/lib.rs index 0b48f586cd..04ebd41b10 100644 --- a/crates/brush/src/lib.rs +++ b/crates/brush/src/lib.rs @@ -1008,6 +1008,14 @@ pub fn has_brush(n: &Node) -> bool { n.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(s) if s.brush.is_some() && s.visible)) } +/// Does `stroke` draw with a brush of `lib` (the document's [`library`])? [`stroke_pieces`] sizes +/// brush art from the brush and the stroke weight and does not read the stroke's width profile, so +/// the profile does not change what such a stroke draws. A stroke without a brush, or one that +/// names a brush `lib` lacks, draws a plain stroke, which follows the profile. +pub fn keeps_brush_size(lib: &[Brush], stroke: &StrokeLayer) -> bool { + stroke.brush.as_deref().is_some_and(|name| lib.iter().any(|b| b.name == name)) +} + /// How far brush art can paint past the visual box of `n`: `16 × w + 8`, where `w` is the widest /// stroke of `n` (at least 1), when `n` has a visible brushed stroke with a paint; 0 when it has /// none, as a brushed stroke without a paint draws no brush art. This is the room the renderer and diff --git a/crates/engine/src/cmd/stroke.rs b/crates/engine/src/cmd/stroke.rs index e8fb1349c3..038483182f 100644 --- a/crates/engine/src/cmd/stroke.rs +++ b/crates/engine/src/cmd/stroke.rs @@ -429,6 +429,51 @@ impl Session { painted(first, true, &mut nodes); node_stroke(nodes.first()?) } + + /// Do all the strokes that `stroke.set` edits without `ids` or `item` draw with a brush + /// ([`vectorcraft_brush::keeps_brush_size`])? If they do, a width profile changes none of + /// them, and the result is `Some`, holding whether any of them has a width profile. The result + /// is `None` when a profile changes at least one of them. + /// + /// The strokes are the ones `stroke.set` edits: + /// - the Appearance panel's active stroke row in each target that has an equal row + /// ([`ItemTarget::per_target`]), and the top stroke in the others; + /// - else a selected group's own stroke; + /// - else the top strokes of the objects it paints ([`own_stroke_or_leaves`]). + /// + /// The art of graph designs is left out, and so are images and symbol instances without an + /// active row. The result is also `None` with nothing selected, with an object inside a symbol + /// instance selected, with type among the targets, and with a target that has no stroke row, + /// since `stroke.set` gives such a target a plain stroke. + pub fn brushed_strokes_profiled(&self) -> Option { + const C: &str = "stroke.set"; + let st = self.active()?; + if st.selected_symbol_part().is_some() { + return None; + } + let p = json!({}); + let item = item_target(self, &p, C).ok()?.of_kind(self, false); + let ids = if item == ItemTarget::Top { own_stroke_or_leaves(self, &p).ok()? } else { item.targets(self, &p).ok()? }; + let mut ids = super::appearance::drop_design_art_rows(self, ids, item, false, C).ok()?; + if item == ItemTarget::Top { + ids.retain(|id| !matches!(st.doc.node(*id).map(|n| &n.kind), Some(NodeKind::Image(_) | NodeKind::SymbolInstance { .. }))); + } + let mut strokes = vec![]; + for (id, each) in ids.iter().zip(item.per_target(self, &ids)) { + let n = st.doc.node(*id)?; + let row = each?.resolve(&n.appearance, false, C).ok()?; + if row.is_none() && matches!(n.kind, NodeKind::Text(_)) { + return None; + } + strokes.push(n.appearance.stroke_at(row).filter(|s| s.brush.is_some())?); + } + if strokes.is_empty() { + return None; + } + // The library is read only when every stroke names a brush. + let lib = vectorcraft_brush::library(&st.doc); + strokes.iter().all(|s| vectorcraft_brush::keeps_brush_size(&lib, s)).then(|| strokes.iter().any(|s| s.profile.is_some())) + } } impl DocState { diff --git a/crates/engine/src/tests/appearance.rs b/crates/engine/src/tests/appearance.rs index 53cbb42ca9..a04bb89b4a 100644 --- a/crates/engine/src/tests/appearance.rs +++ b/crates/engine/src/tests/appearance.rs @@ -227,6 +227,112 @@ fn stroke_options_on_a_group_with_its_own_stroke_edit_that_stroke() { assert_eq!((st.paint, st.width), (Paint::solid(Color::BLACK), 3.0)); } +/// `brushed_strokes_profiled` reads the strokes `stroke.set` edits: a group's own stroke when it +/// has one, else its members'. It answers only while each of them draws with a brush, and not +/// while an object has no stroke row, which `stroke.set` would give a plain stroke. +#[test] +fn brushed_strokes_profiled_reads_the_strokes_stroke_set_edits() { + let mut s = session(); + let (a, b) = (rect(&mut s, 100.0), rect(&mut s, 250.0)); + run(&mut s, "brush.apply", json!({"ids": [a.0, b.0], "name": "3 pt. Round"})); + run(&mut s, "select.set", json!({"ids": [a.0, b.0]})); + assert_eq!(s.brushed_strokes_profiled(), Some(false), "both draw with a brush, neither has a profile"); + run(&mut s, "stroke.set", json!({"ids": [b.0], "profile": "lens"})); + run(&mut s, "select.set", json!({"ids": [a.0, b.0]})); + assert_eq!(s.brushed_strokes_profiled(), Some(true), "one has a profile"); + let g = NodeId(run(&mut s, "object.group", json!({"ids": [a.0, b.0]}))["id"].as_u64().unwrap()); + run(&mut s, "select.set", json!({"ids": [g.0]})); + assert_eq!(s.brushed_strokes_profiled(), Some(true), "a group without its own stroke: its members'"); + run(&mut s, "appearance.addStroke", json!({"ids": [g.0]})); + run(&mut s, "select.set", json!({"ids": [g.0]})); + assert_eq!(s.brushed_strokes_profiled(), None, "the group's own plain stroke takes the profile"); + let c = rect(&mut s, 400.0); + run(&mut s, "appearance.removeItem", json!({"ids": [c.0], "index": 1})); + assert!(node(&s, c).appearance.stroke().is_none()); + run(&mut s, "select.set", json!({"ids": [a.0, c.0]})); + assert_eq!(s.brushed_strokes_profiled(), None, "an object without a stroke row takes a plain stroke"); +} + +/// A compound shape's own stroke is the one `stroke.set` edits: brushed members do not count. +#[test] +fn brushed_strokes_profiled_reads_a_compound_shapes_own_stroke() { + let mut s = session(); + let (a, b) = (rect(&mut s, 100.0), rect(&mut s, 120.0)); + run(&mut s, "select.set", json!({"ids": [a.0, b.0]})); + let c = NodeId(run(&mut s, "object.compoundShape.make", json!({"mode": "add"}))["id"].as_u64().unwrap()); + assert!(node(&s, c).appearance.stroke().is_some_and(|st| st.brush.is_none()), "the compound shape's own plain stroke"); + s.edit("Brush", |d, _| { + for id in [a, b] { + if let Some(st) = d.node_mut(id).and_then(|n| n.appearance.stroke_mut()) { + st.brush = Some("3 pt. Round".into()); + } + } + Ok(()) + }) + .unwrap(); + run(&mut s, "select.set", json!({"ids": [c.0]})); + assert_eq!(s.brushed_strokes_profiled(), None); + s.edit("Brush", |d, _| { + d.node_mut(c).unwrap().appearance.stroke_mut().unwrap().brush = Some("3 pt. Round".into()); + Ok(()) + }) + .unwrap(); + run(&mut s, "select.set", json!({"ids": [c.0]})); + assert_eq!(s.brushed_strokes_profiled(), Some(false)); +} + +/// A targeted layer with its own plain Stroke row active: `stroke.set` edits that row, so the +/// brushed path inside the layer does not count. +#[test] +fn brushed_strokes_profiled_reads_a_targeted_layers_active_stroke_row() { + let mut s = session(); + let a = rect(&mut s, 100.0); + run(&mut s, "brush.apply", json!({"ids": [a.0], "name": "3 pt. Round"})); + let layer = s.doc().unwrap().doc.layers[0].id; + run(&mut s, "layer.target", json!({"id": layer.0})); + run(&mut s, "appearance.addStroke", json!({})); + let rows = &node(&s, layer).appearance.items; + let index = rows.iter().position(|it| matches!(it, AppearanceItem::Stroke(st) if st.brush.is_none())).expect("the layer's own stroke row"); + run(&mut s, "appearance.setActiveItem", json!({"index": index})); + assert_eq!(s.brushed_strokes_profiled(), None, "the layer's plain stroke takes the profile"); + run(&mut s, "stroke.set", json!({"profile": "lens"})); + assert!(node(&s, layer).appearance.items.get(index).is_some_and(|it| matches!(it, AppearanceItem::Stroke(st) if st.profile.is_some()))); + assert!(node(&s, a).appearance.stroke().is_some_and(|st| st.profile.is_none()), "the brushed path is left as it was"); +} + +/// A symbol instance selected with a brushed path takes no stroke from `stroke.set`, so it does +/// not count; the brushed path alone decides. +#[test] +fn brushed_strokes_profiled_leaves_out_symbol_instances() { + let mut s = session(); + let a = rect(&mut s, 100.0); + run(&mut s, "brush.apply", json!({"ids": [a.0], "name": "3 pt. Round"})); + let r = rect(&mut s, 300.0); + run(&mut s, "select.set", json!({"ids": [r.0]})); + let inst = NodeId(run(&mut s, "symbol.new", json!({"name": "Dot"}))["id"].as_u64().unwrap()); + assert!(matches!(node(&s, inst).kind, NodeKind::SymbolInstance { .. })); + run(&mut s, "select.set", json!({"ids": [a.0, inst.0]})); + assert_eq!(s.brushed_strokes_profiled(), Some(false)); +} + +/// With the active row a stroke of the first object that another selected object has no equal +/// row for, `stroke.set` edits that object's top stroke, so its top stroke decides. +#[test] +fn brushed_strokes_profiled_falls_back_to_the_top_stroke_where_the_active_row_has_no_match() { + let mut s = session(); + let (a, b) = (rect(&mut s, 100.0), rect(&mut s, 250.0)); + run(&mut s, "select.set", json!({"ids": [a.0]})); + run(&mut s, "appearance.addStroke", json!({})); + run(&mut s, "brush.apply", json!({"ids": [a.0, b.0], "name": "3 pt. Round"})); + run(&mut s, "stroke.set", json!({"ids": [b.0], "weight": 5})); + let rows = &node(&s, a).appearance.items; + let index = rows.iter().position(|it| matches!(it, AppearanceItem::Stroke(st) if st.brush.is_some())).expect("a's brushed stroke"); + assert!(index >= node(&s, b).appearance.items.len() || node(&s, b).appearance.items[index].is_fill(), "{rows:?}"); + run(&mut s, "select.set", json!({"ids": [a.0, b.0]})); + run(&mut s, "appearance.setActiveItem", json!({"index": index})); + assert_eq!(s.brushed_strokes_profiled(), Some(false), "b's top stroke has the brush too"); +} + #[test] fn text_items_take_item_paint() { let mut s = session(); diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index 9250cf8030..542ee871d3 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -1530,6 +1530,7 @@ impl Session { } Action::Dialog(k, p) => ui.push(UiRequest::Dialog(k, p)), Action::SwitchTool(t) => ui.push(UiRequest::SwitchTool(t)), + Action::Status(msg) => ui.push(UiRequest::Status(msg)), Action::Notify(what) => { let view = self.last_view; self.with_tool_cx(view, |t, cx| t.notify(cx, &what)); diff --git a/crates/tools/src/distort/width.rs b/crates/tools/src/distort/width.rs index 4ebbac4981..7eda93305e 100644 --- a/crates/tools/src/distort/width.rs +++ b/crates/tools/src/distort/width.rs @@ -19,8 +19,18 @@ //! A compound path's stroke is the compound's: its members are edited through it, and the width //! points show on every subpath of the stroke (one profile runs along each). The cursor says what a //! drag does: add a width point on a stroke, or move or widen the one under it. +//! +//! A stroke drawn with a brush is left alone, as a width profile does not change it: a press or a +//! double-click on it, and Delete/Backspace with its width points selected, send no command and +//! show why in the status bar ([`KEEPS_SIZE`]). A press or double-click on it deselects the +//! width points, the cursor over it offers no edit, and its width points selected before it took +//! the brush show no handles. + +use std::cell::Cell; +use std::sync::Arc; use serde_json::json; +use vectorcraft_brush::Brush; use vectorcraft_doc::{Document, NodeId, NodeKind, StrokeLayer}; use vectorcraft_geom::{Point, Vec2}; @@ -107,8 +117,14 @@ pub struct WidthTool { selected: Option<(NodeId, Vec)>, /// The selected width points when the button went down: a dropped press puts them back. before_press: Option<(NodeId, Vec)>, + /// The document's brush library as it was at a revision, so pointer moves and overlays do not + /// parse it again ([`Self::keeps_size`]). + brushes: Cell>, } +/// A document revision and its brush library ([`WidthTool::keeps_size`]). +type BrushesAt = ((u64, u64), Arc>); + /// The object whose stroke path `id` draws with: its compound path, if it is a member of one. pub fn stroke_owner(doc: &Document, id: NodeId) -> NodeId { doc.parent_of(id).filter(|p| doc.node(*p).is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. }))).unwrap_or(id) @@ -132,6 +148,9 @@ fn paths_of(doc: &Document, owner: NodeId) -> Vec { out } +/// The status message for a press on a stroke the tool leaves alone ([`WidthTool::keeps_size`]). +pub const KEEPS_SIZE: &str = "The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile."; + /// Side widths (points) of a stroke at fraction `t`. pub fn sides_at(st: &StrokeLayer, t: f64) -> (f64, f64) { let (l, r) = st.profile.as_ref().map(|p| p.at(t)).unwrap_or((1.0, 1.0)); @@ -139,8 +158,46 @@ pub fn sides_at(st: &StrokeLayer, t: f64) -> (f64, f64) { } impl WidthTool { - /// The stroked path nearest to `p` within reach (stroke half-width + a few pixels). - fn spot_at(cx: &ToolContext, p: Point) -> Option { + /// Does `owner`'s stroke draw with a brush ([`vectorcraft_brush::keeps_brush_size`])? A width + /// profile does not change it, so the tool adds and edits no width points on it. The library is + /// parsed once per document revision. + fn keeps_size(&self, cx: &ToolContext, owner: NodeId) -> bool { + let Some(st) = stroke_of(cx.doc, owner).filter(|s| s.brush.is_some()) else { return false }; + let lib = self + .brushes + .take() + .filter(|(rev, _)| *rev == cx.revision) + .map(|(_, lib)| lib) + .unwrap_or_else(|| Arc::new(vectorcraft_brush::library(cx.doc))); + let keeps = vectorcraft_brush::keeps_brush_size(&lib, st); + self.brushes.set(Some((cx.revision, lib))); + keeps + } + + /// Where a press at `p` lands: the nearest stroke the tool edits ([`Self::spot_at`] without + /// brushed strokes), so a plain stroke under a selected brushed one stays reachable. `Err(true)` + /// when only brushed strokes are within reach, `Err(false)` when no stroke is. + fn edit_spot_at(&self, cx: &ToolContext, p: Point) -> Result { + // `spot_at` asks `skip` only about strokes within reach, so one search tells both apart. + let passed_over = Cell::new(false); + let skip = |owner| { + let keeps = self.keeps_size(cx, owner); + passed_over.set(passed_over.get() || keeps); + keeps + }; + Self::spot_at(cx, p, &skip).ok_or_else(|| passed_over.get()) + } + + /// The hovered stroke while the tool still edits it: a brush applied since the last pointer + /// move takes away its handles and its edit cursor. + fn live_hover(&self, cx: &ToolContext) -> Option { + self.hover.filter(|s| !self.keeps_size(cx, s.owner)) + } + + /// The stroked path nearest to `p` within reach (stroke half-width + a few pixels), passing over + /// the strokes whose owner `skip` returns true for. `skip` is asked only about strokes within + /// reach. + fn spot_at(cx: &ToolContext, p: Point, skip: &dyn Fn(NodeId) -> bool) -> Option { let editable = cx.doc.editable(); let consider = |id: NodeId| -> Option<(f64, Spot)> { if !editable(id) { @@ -156,7 +213,7 @@ impl WidthTool { return None; } let (sub, t, q, tan, d) = nearest_fraction(path, p)?; - if d > reach { + if d > reach || skip(owner) { return None; } let (left, right) = sides_at(st, t); @@ -297,12 +354,22 @@ impl Tool for WidthTool { let p = ev.pos; match ev.kind { PointerKind::Move => { - self.hover = Self::spot_at(cx, p); + // A brushed stroke takes no width points, so the cursor offers no edit over it. + self.hover = self.edit_spot_at(cx, p).ok(); vec![] } PointerKind::TripleClick => vec![], PointerKind::DoubleClick => { - let Some(spot) = Self::spot_at(cx, p) else { return vec![] }; + let spot = match self.edit_spot_at(cx, p) { + Ok(spot) => spot, + Err(false) => return vec![], + Err(true) => { + if !ev.mods.shift { + self.selected = None; + } + return vec![Action::Status(KEEPS_SIZE.into())]; + } + }; let Some((w, _)) = Self::hit(cx, &spot, p) else { self.selected = Some((spot.owner, vec![spot.t])); return vec![Action::Dialog("widthPoint".into(), json!({"id": spot.owner.0, "t": spot.t}))]; @@ -312,11 +379,14 @@ impl Tool for WidthTool { } PointerKind::Down => { self.before_press = self.selected.clone(); - let Some(spot) = Self::spot_at(cx, p) else { - if !ev.mods.shift { - self.selected = None; + let spot = match self.edit_spot_at(cx, p) { + Ok(spot) => spot, + Err(brushed) => { + if !ev.mods.shift { + self.selected = None; + } + return if brushed { vec![Action::Status(KEEPS_SIZE.into())] } else { vec![] }; } - return vec![]; }; let drag = match Self::hit(cx, &spot, p) { Some((w, part)) => { @@ -426,12 +496,16 @@ impl Tool for WidthTool { return vec![]; } self.selected = None; + if self.keeps_size(cx, id) { + return vec![Action::Status(KEEPS_SIZE.into())]; + } vec![Action::Exec("stroke.widthPoint.remove".into(), json!({"id": id.0, "indices": indices}))] } fn overlays(&self, cx: &ToolContext) -> Vec { let mut out = vec![]; let r = cx.tol(4.0); - let focus = self.drag.as_ref().map(|d| d.spot).or(self.hover); + let hover = self.live_hover(cx); + let focus = self.drag.as_ref().map(|d| d.spot).or(hover); // Every subpath's width points of the stroke under the pointer, and of the selected ones'. let show = |owner: NodeId, out: &mut Vec| { for w in Self::all_points(cx, owner) { @@ -445,8 +519,11 @@ impl Tool for WidthTool { if let Some(s) = focus { show(s.owner, &mut out); } + // Width points selected before their stroke took a brush show no handles: the tool no + // longer edits them. if let Some((owner, _)) = &self.selected && focus.is_none_or(|s| s.owner != *owner) + && !self.keeps_size(cx, *owner) { show(*owner, &mut out); } @@ -457,7 +534,7 @@ impl Tool for WidthTool { if cx.measurement_labels { out.push(Overlay::Measure { p: q + d.spot.n * (d.left + r * 3.0), text: format!("W: {}", cx.stroke_unit.readout(d.left + d.right)) }); } - } else if let Some(h) = &self.hover { + } else if let Some(h) = &hover { out.push(Overlay::Line { a: h.p + h.n * h.left, b: h.p - h.n * h.right, color: BLUE, dashed: true }); out.push(Overlay::Path { path: diamond(h.p, r), color: BLUE, width: 1.0, dashed: false }); } @@ -468,7 +545,7 @@ impl Tool for WidthTool { return Cursor::WidthPoint; } // The stroke under the pointer, as the last move found it (no search every frame). - match self.hover { + match self.live_hover(cx) { Some(spot) if Self::hit(cx, &spot, p).is_some() => Cursor::WidthPoint, Some(_) => Cursor::WidthAdd, None => Cursor::Width, @@ -538,6 +615,165 @@ mod tests { assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 150.0, 220.0)), vec![Action::Commit]); } + /// A stroke drawn with a brush of the library (the 3 pt. Round calligraphic brush) is left + /// alone: a press or a double-click sends no command and says why. A brush name the library + /// lacks draws a plain stroke, which the tool edits as usual. + #[test] + fn brushed_stroke_is_left_alone_with_a_reason() { + let (mut d, id) = doc_line(); + d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().brush = Some("3 pt. Round".into()); + let (s, p) = (Selection::default(), paint()); + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + let refused = vec![Action::Status(KEEPS_SIZE.into())]; + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 201.0)), refused); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Drag, 150.0, 220.0)), vec![], "no drag began"); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Up, 150.0, 220.0)), vec![]); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::DoubleClick, 150.0, 201.0)), refused); + + d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().brush = Some("No Such Brush".into()); + let c = cx(&d, &s, &p); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 201.0)), vec![Action::Begin("Width Point".into())]); + } + + /// A selected brushed stroke lying on a plain one does not hide the plain one: a press there + /// edits the plain stroke. + #[test] + fn a_plain_stroke_under_a_selected_brushed_one_stays_reachable() { + let (mut d, _) = doc_line(); + let l = d.layers[0].id; + let brushed = d.alloc_id(); + let mut ap = Appearance::default_art(); + let st = ap.stroke_mut().unwrap(); + st.width = 10.0; + st.brush = Some("3 pt. Round".into()); + let path = PathData::single(SubPath::polyline(&[Point::new(100.0, 200.0), Point::new(300.0, 200.0)], false)); + d.insert(Some(l), 0, Node::path(brushed, path, ap)).unwrap(); + let (s, p) = (Selection { objects: vec![brushed], ..Default::default() }, paint()); + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + t.pointer(&c, &PointerEvent::new(PointerKind::Move, 150.0, 201.0)); + assert_eq!(t.cursor(&c, Point::new(150.0, 201.0), Mods::default()), Cursor::WidthAdd); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 201.0)), vec![Action::Begin("Width Point".into())]); + } + + /// A brush applied to the hovered stroke, with the pointer still, takes away its handles and its + /// edit cursor before the next pointer move. + #[test] + fn a_brush_applied_under_a_still_pointer_takes_away_the_hover() { + let (mut d, id) = doc_line(); + let (s, p) = (Selection::default(), paint()); + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + t.pointer(&c, &PointerEvent::new(PointerKind::Move, 150.0, 201.0)); + assert_eq!(t.cursor(&c, Point::new(150.0, 201.0), Mods::default()), Cursor::WidthAdd); + assert!(!t.overlays(&c).is_empty()); + d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().brush = Some("3 pt. Round".into()); + let c = ToolContext { revision: (0, 1), ..cx(&d, &s, &p) }; + assert_eq!(t.cursor(&c, Point::new(150.0, 201.0), Mods::default()), Cursor::Width); + assert!(t.overlays(&c).is_empty()); + } + + /// The brush library is read once per document revision: a brush added to the library under a + /// new revision is seen, so a stroke naming it is then left alone. + #[test] + fn a_brush_added_to_the_library_is_seen_at_the_next_revision() { + let (mut d, id) = doc_line(); + d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().brush = Some("Added Later".into()); + let (s, p) = (Selection::default(), paint()); + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 201.0)), vec![Action::Begin("Width Point".into())]); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 150.0, 201.0)); + let mut lib = vectorcraft_brush::library(&d); + let mut added = lib[0].clone(); + added.name = "Added Later".into(); + lib.push(added); + vectorcraft_brush::store(&mut d, &lib); + let c = ToolContext { revision: (0, 1), ..cx(&d, &s, &p) }; + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 201.0)), vec![Action::Status(KEEPS_SIZE.into())]); + } + + /// Width points selected before the stroke took a brush: Delete removes none and says why. + #[test] + fn delete_leaves_the_width_points_of_a_brushed_stroke() { + let (mut d, id) = doc_line(); + d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().profile = + Some(WidthProfile { points: vec![(0.0, 1.0, 1.0), (0.5, 2.0, 2.0), (1.0, 1.0, 1.0)] }); + let (s, p) = (Selection::default(), paint()); + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 200.0, 200.0)); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 200.0, 200.0)); + assert!(t.claims_key(&c, ToolKey::Delete), "a width point is selected"); + assert!(!t.overlays(&c).is_empty(), "the selected point shows its handles"); + d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().brush = Some("3 pt. Round".into()); + let c = ToolContext { revision: (0, 1), ..cx(&d, &s, &p) }; + assert!(t.overlays(&c).is_empty(), "no handles show on a stroke the tool no longer edits"); + assert_eq!(t.key(&c, ToolKey::Delete, Mods::default()), vec![Action::Status(KEEPS_SIZE.into())]); + assert!(t.selected.is_none()); + } + + /// With Shift held, a press or a double-click on a brushed stroke keeps the width points of + /// another stroke selected, as a Shift-press that misses every stroke does. + #[test] + fn shift_on_a_brushed_stroke_keeps_the_selected_width_points() { + let (mut d, _) = doc_three_points(); + let l = d.layers[0].id; + let other = d.alloc_id(); + let mut ap = Appearance::default_art(); + let st = ap.stroke_mut().unwrap(); + st.width = 10.0; + st.brush = Some("3 pt. Round".into()); + let path = PathData::single(SubPath::polyline(&[Point::new(100.0, 400.0), Point::new(300.0, 400.0)], false)); + d.insert(Some(l), 0, Node::path(other, path, ap)).unwrap(); + let (s, p) = (Selection::default(), paint()); + let shift = Mods { shift: true, ..Default::default() }; + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 200.0, 200.0)); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 200.0, 200.0)); + let kept = t.selected.clone(); + assert!(kept.is_some(), "the plain stroke's width point is selected"); + for kind in [PointerKind::Down, PointerKind::DoubleClick] { + assert_eq!(t.pointer(&c, &ev(kind, 200.0, 401.0, shift)), vec![Action::Status(KEEPS_SIZE.into())]); + assert_eq!(t.selected, kept, "{kind:?} with Shift keeps the selection"); + } + assert_eq!(t.pointer(&c, &ev(PointerKind::DoubleClick, 200.0, 401.0, Mods::default())), vec![Action::Status(KEEPS_SIZE.into())]); + assert!(t.selected.is_none(), "a double-click without Shift deselects"); + } + + /// A press on a brushed stroke deselects the width points of another stroke, as a press that + /// misses every stroke does, so a later Delete does not edit that other stroke. The cursor over + /// a brushed stroke offers no edit. + #[test] + fn a_press_on_a_brushed_stroke_deselects_and_its_cursor_offers_no_edit() { + let (mut d, _) = doc_three_points(); + let l = d.layers[0].id; + let other = d.alloc_id(); + let mut ap = Appearance::default_art(); + let st = ap.stroke_mut().unwrap(); + st.width = 10.0; + st.brush = Some("3 pt. Round".into()); + let path = PathData::single(SubPath::polyline(&[Point::new(100.0, 400.0), Point::new(300.0, 400.0)], false)); + d.insert(Some(l), 0, Node::path(other, path, ap)).unwrap(); + let (s, p) = (Selection::default(), paint()); + let mut t = WidthTool::default(); + let c = cx(&d, &s, &p); + t.pointer(&c, &PointerEvent::new(PointerKind::Down, 200.0, 200.0)); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 200.0, 200.0)); + assert!(t.claims_key(&c, ToolKey::Delete), "the plain stroke's width point is selected"); + assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 200.0, 401.0)), vec![Action::Status(KEEPS_SIZE.into())]); + t.pointer(&c, &PointerEvent::new(PointerKind::Up, 200.0, 401.0)); + assert!(!t.claims_key(&c, ToolKey::Delete), "nothing is left to delete"); + assert_eq!(t.key(&c, ToolKey::Delete, Mods::default()), vec![]); + + t.pointer(&c, &PointerEvent::new(PointerKind::Move, 200.0, 401.0)); + assert_eq!(t.cursor(&c, Point::new(200.0, 401.0), Mods::default()), Cursor::Width); + t.pointer(&c, &PointerEvent::new(PointerKind::Move, 220.0, 201.0)); + assert_eq!(t.cursor(&c, Point::new(220.0, 201.0), Mods::default()), Cursor::WidthAdd, "the plain stroke still offers one"); + } + #[test] fn alt_drag_changes_one_side_and_move_slides() { let (mut d, id) = doc_line(); diff --git a/crates/tools/src/input.rs b/crates/tools/src/input.rs index 5362147b97..629970b066 100644 --- a/crates/tools/src/input.rs +++ b/crates/tools/src/input.rs @@ -218,4 +218,8 @@ pub enum Action { SwitchTool(String), /// Call the tool's `notify` after the preceding actions ran (e.g. to pick up a created object). Notify(String), + /// Show this English message in the status bar (e.g. why a Shape Builder gesture built + /// nothing); an empty message clears the status bar. It changes nothing in the document and + /// records no undo step. + Status(String), } diff --git a/crates/ui-egui/src/chrome/control_bar.rs b/crates/ui-egui/src/chrome/control_bar.rs index 71b737dbfc..f73a39a269 100644 --- a/crates/ui-egui/src/chrome/control_bar.rs +++ b/crates/ui-egui/src/chrome/control_bar.rs @@ -710,7 +710,7 @@ fn fill_and_stroke(app: &mut VectorcraftApp, ui: &mut Ui, reserve: f32) { stroke_panel::weight_field(app, ui, "cb-stroke", weight, WEIGHT_FIELD_WIDTH); if ui.available_width() < row_width(ui, &[stroke_panel::PROFILE_DROPDOWN_WIDTH]) + reserve { left_out(ui); - } else if let Some(id) = stroke_panel::profile_dropdown(app, ui, shown_stroke.as_ref().and_then(|s| s.profile.as_ref())) { + } else if let Some(id) = stroke_panel::profile_dropdown(app, ui, shown_stroke.as_ref()) { app.run("stroke.set", json!({"profile": id})).ok(); } } else { diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index bb039bb08e..3321a9b9d7 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -4045,6 +4045,8 @@ digits Malayalam Малаялам V Spacing: В. разстояние: V: В: Variable Width Profile Профил с променлива ширина + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Четката на щриха запазва собствения си размер, затова профилът на ширината не го променя. Премахнете четката, за да използвате профил. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Четката на щриха запазва собствения си размер, затова профилът на ширината не го променя. Премахнете четката, за да използвате профил. Variables Променливи New Variable Нова променлива Delete Variable Изтриване на променлива diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 99f23d313c..bda7d72d7d 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -2237,6 +2237,8 @@ digits Malayalam Malajalam Tip extends past the end point Vrh prelazi preko krajnje tačke Tip on the end point Vrh na krajnjoj tački Variable Width Profile Profil promjenjive širine + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Četkica poteza zadržava vlastitu veličinu, pa je profil širine ne mijenja. Uklonite četkicu da biste koristili profil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Četkica poteza zadržava vlastitu veličinu, pa je profil širine ne mijenja. Uklonite četkicu da biste koristili profil. Weight: Debljina: Art using a deleted global swatch keeps its colour. Crtež koji koristi izbrisani globalni uzorak boje zadržava svoju boju. Color Group: {name} Grupa boja: {name} diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index c54311799d..3870e51a82 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -5303,6 +5303,8 @@ digits Malayalam Malaiàlam Variable Options Opcions de variable Variable Options… Opcions de variable… Variable Width Profile Perfil d’amplada variable + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. El pinzell del traç manté la seva pròpia mida, de manera que un perfil d’amplada no el canvia. Traieu el pinzell per fer servir un perfil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. El pinzell del traç manté la seva pròpia mida, de manera que un perfil d’amplada no el canvia. Traieu el pinzell per fer servir un perfil. Variables Variables Variation Variació Variation: Variació: diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index a5d7bb948a..b1956d0b6c 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2310,6 +2310,8 @@ digits Malayalam Malajálamské Tip extends past the end point Hrot přesahuje koncový bod Tip on the end point Hrot na koncovém bodu Variable Width Profile Profil proměnné šířky + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Štětec tahu si zachovává vlastní velikost, takže ho profil šířky nemění. Chcete-li použít profil, odeberte štětec. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Štětec tahu si zachovává vlastní velikost, takže ho profil šířky nemění. Chcete-li použít profil, odeberte štětec. Weight: Tloušťka: Art using a deleted global swatch keeps its colour. Kresba, která používá odstraněnou globální položku vzorníku, si barvu ponechá. Color Group: {name} Skupina barev: {name} diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 08100f593f..d1bac3c370 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -4801,6 +4801,8 @@ digits Malayalam Malayalam Tip extends past the end point Spidsen rager ud over endepunktet Tip on the end point Spidsen på endepunktet Variable Width Profile Variabel breddeprofil + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Stregens pensel beholder sin egen størrelse, så et breddeprofil ændrer den ikke. Fjern penslen for at bruge et profil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Stregens pensel beholder sin egen størrelse, så et breddeprofil ændrer den ikke. Fjern penslen for at bruge et profil. Weight: Vægt: Art using a deleted global swatch keeps its colour. Grafik, der bruger en slettet global farveprøve, bevarer sin farve. Color Group: {name} Farvegruppe: {name} diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 10147b2d45..36a0423689 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4139,6 +4139,8 @@ effect Points Punkte V Spacing: V-Abstand: V: V: Variable Width Profile Variables Breitenprofil + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Der Pinsel der Kontur behält seine eigene Größe, daher ändert ein Breitenprofil die Kontur nicht. Entfernen Sie den Pinsel, um ein Profil zu verwenden. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Der Pinsel der Kontur behält seine eigene Größe, daher ändert ein Breitenprofil die Kontur nicht. Entfernen Sie den Pinsel, um ein Profil zu verwenden. Variables Variablen Variation: Variation: Vector Effects Vektoreffekte diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 1ebf6e5684..9f4974d355 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -4672,6 +4672,8 @@ digits Malayalam Μαλαγιάλαμ V Spacing: Κατακόρυφη απόσταση: V: Κατακόρυφα: Variable Width Profile Προφίλ μεταβλητού πλάτους + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Το πινέλο του περιγράμματος διατηρεί το δικό του μέγεθος, οπότε ένα προφίλ πλάτους δεν το αλλάζει. Αφαιρέστε το πινέλο για να χρησιμοποιήσετε προφίλ. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Το πινέλο του περιγράμματος διατηρεί το δικό του μέγεθος, οπότε ένα προφίλ πλάτους δεν το αλλάζει. Αφαιρέστε το πινέλο για να χρησιμοποιήσετε προφίλ. New Variable Νέα μεταβλητή Delete Variable Διαγραφή μεταβλητής Lock Variables Κλείδωμα μεταβλητών diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index a456910a16..f00b32d379 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -4190,6 +4190,8 @@ digits Malayalam Malayálam V Spacing: Espaciado V: V: V: Variable Width Profile Perfil de anchura variable + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. El pincel del trazo mantiene su propio tamaño, así que un perfil de anchura no lo cambia. Quite el pincel para usar un perfil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. El pincel del trazo mantiene su propio tamaño, así que un perfil de anchura no lo cambia. Quite el pincel para usar un perfil. Variables Variables New Variable Nueva variable Delete Variable Eliminar variable diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index bff46fc0d7..acbe85c0e5 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -2271,6 +2271,8 @@ digits Malayalam Malajalam Tip extends past the end point Kärki ulottuu päätepisteen yli Tip on the end point Kärki päätepisteessä Variable Width Profile Muuttuvan leveyden profiili + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Viivan sivellin säilyttää oman kokonsa, joten leveysprofiili ei muuta sitä. Poista sivellin, jos haluat käyttää profiilia. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Viivan sivellin säilyttää oman kokonsa, joten leveysprofiili ei muuta sitä. Poista sivellin, jos haluat käyttää profiilia. Weight: Paksuus: Art using a deleted global swatch keeps its colour. Poistettua globaalia värimallia käyttävä kuvitus säilyttää värinsä. Color Group: {name} Väriryhmä: {name} diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3be3497f97..229fbd9901 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -4177,6 +4177,8 @@ digits Malayalam Malayalam V Spacing: Espacement V : V: V : Variable Width Profile Profil de largeur variable + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. La forme du contour garde sa propre taille, donc un profil de largeur ne la modifie pas. Supprimez la forme pour utiliser un profil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. La forme du contour garde sa propre taille, donc un profil de largeur ne la modifie pas. Supprimez la forme pour utiliser un profil. Variables Variables New Variable Nouvelle variable Delete Variable Supprimer la variable diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index c427fc527c..1464a51892 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -4320,6 +4320,8 @@ Variable Font વેરિએબલ ફૉન્ટ Variable Options… વેરિએબલ વિકલ્પો… Variable Width Profile વેરિએબલ પહોળાઈ પ્રોફાઇલ + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. સ્ટ્રોકનું બ્રશ પોતાનું કદ જાળવે છે, તેથી પહોળાઈ પ્રોફાઇલ તેને બદલતી નથી. પ્રોફાઇલ વાપરવા માટે બ્રશ દૂર કરો. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. સ્ટ્રોકનું બ્રશ પોતાનું કદ જાળવે છે, તેથી પહોળાઈ પ્રોફાઇલ તેને બદલતી નથી. પ્રોફાઇલ વાપરવા માટે બ્રશ દૂર કરો. Variables વેરિએબલ્સ Variation: વેરિએશન: Vector Effects વેક્ટર અસરો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index cbfb4f51d1..09119c407f 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -5722,6 +5722,8 @@ antiAlias Sharp शार्प Variable Options वेरिएबल ऑप्शन्स Variable Options… वेरिएबल ऑप्शन्स… Variable Width Profile वेरिएबल चौड़ाई प्रोफ़ाइल + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. स्ट्रोक का ब्रश अपना आकार बनाए रखता है, इसलिए चौड़ाई प्रोफ़ाइल उसे नहीं बदलती। प्रोफ़ाइल का उपयोग करने के लिए ब्रश निकालें। +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. स्ट्रोक का ब्रश अपना आकार बनाए रखता है, इसलिए चौड़ाई प्रोफ़ाइल उसे नहीं बदलती। प्रोफ़ाइल का उपयोग करने के लिए ब्रश निकालें। Variables वेरिएबल्स Variation वैरिएशन Variation: भिन्नता: diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 0f81a72036..1024d5a1a9 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -4940,6 +4940,8 @@ mark-style Japanese Japán Variable Options Változó beállításai Variable Options… Változó beállításai… Variable Width Profile Változó szélességprofil + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. A körvonal ecsetje megtartja a saját méretét, ezért a szélességprofil nem változtatja meg. Profil használatához távolítsa el az ecsetet. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. A körvonal ecsetje megtartja a saját méretét, ezért a szélességprofil nem változtatja meg. Profil használatához távolítsa el az ecsetet. Variables Változók Variation Ingadozás Variation: Ingadozás: diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 28ea2b5ab3..b9b39831e0 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -2060,6 +2060,8 @@ digits Malayalam Malayalam Tip extends past the end point Ujung melewati titik akhir Tip on the end point Ujung pada titik akhir Variable Width Profile Profil lebar variabel + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Kuas pada guratan mempertahankan ukurannya sendiri, sehingga profil lebar tidak mengubahnya. Hapus kuas untuk menggunakan profil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Kuas pada guratan mempertahankan ukurannya sendiri, sehingga profil lebar tidak mengubahnya. Hapus kuas untuk menggunakan profil. Weight: Ketebalan: Art using a deleted global swatch keeps its colour. Karya seni yang memakai swatch global terhapus tetap mempertahankan warnanya. Color Group: {name} Grup warna: {name} diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 8f2ed3216c..deebb1e5ed 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4239,6 +4239,8 @@ digits Malayalam Malayalam V Spacing: Spaziatura verticale: V: V: Variable Width Profile Profilo larghezza variabile + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Il pennello della traccia mantiene la propria dimensione, quindi un profilo di larghezza non la modifica. Rimuovi il pennello per usare un profilo. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Il pennello della traccia mantiene la propria dimensione, quindi un profilo di larghezza non la modifica. Rimuovi il pennello per usare un profilo. Variables Variabili New Variable Nuova variabile Delete Variable Elimina variabile diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index c429f204a1..f04be71521 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -3783,6 +3783,8 @@ mark-style Japanese 日本式 User Swatch Library 9 ユーザースウォッチライブラリ 9 V Spacing: 垂直方向の間隔: Variable Width Profile 可変幅プロファイル + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 線のブラシは独自のサイズを保つため、幅プロファイルでは変わりません。プロファイルを使うにはブラシを削除してください。 +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 線のブラシは独自のサイズを保つため、幅プロファイルでは変わりません。プロファイルを使うにはブラシを削除してください。 Variation: バリエーション: Vector Halftone ベクトルハーフトーン Vector illustration — fast, open, scriptable. ベクターイラスト — 高速・オープン・スクリプト対応 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 414f45171c..1f5bcbaf4f 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -4229,6 +4229,8 @@ digits Malayalam მალაიალამური Tip extends past the end point წვერი ბოლო წერტილს სცდება Tip on the end point წვერი ბოლო წერტილზე Variable Width Profile ცვლადი სიგანის პროფილი + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. კონტურის ფუნჯი საკუთარ ზომას ინარჩუნებს, ამიტომ სიგანის პროფილი მას არ ცვლის. პროფილის გამოსაყენებლად მოხსენით ფუნჯი. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. კონტურის ფუნჯი საკუთარ ზომას ინარჩუნებს, ამიტომ სიგანის პროფილი მას არ ცვლის. პროფილის გამოსაყენებლად მოხსენით ფუნჯი. Weight: სისქე: Art using a deleted global swatch keeps its colour. წაშლილი გლობალური ფერის ნიმუშის მქონე ნახატი თავის ფერს ინარჩუნებს. Color Group: {name} ფერთა ჯგუფი: {name} diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index dbda53243f..8635287711 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -3772,6 +3772,8 @@ mark-style Japanese 일본식 User Swatch Library 9 사용자 견본 라이브러리 9 V Spacing: 세로 간격: Variable Width Profile 가변 너비 프로파일 + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 선의 브러시는 고유한 크기를 유지하므로 너비 프로파일로 바뀌지 않습니다. 프로파일을 사용하려면 브러시를 제거하세요. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 선의 브러시는 고유한 크기를 유지하므로 너비 프로파일로 바뀌지 않습니다. 프로파일을 사용하려면 브러시를 제거하세요. Variation: 변형: Vector Halftone 벡터 하프톤 Vector illustration — fast, open, scriptable. 벡터 일러스트레이션 — 빠르고 개방적이며 스크립트 지원. diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 69aef91cfc..880c7fd1fe 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -2675,6 +2675,8 @@ digits Malayalam Malayalam Tip extends past the end point Punt steekt uit voorbij het eindpunt Tip on the end point Punt op het eindpunt Variable Width Profile Variabel breedteprofiel + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Het penseel van de contour behoudt zijn eigen grootte, dus een breedteprofiel verandert de contour niet. Verwijder het penseel om een profiel te gebruiken. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Het penseel van de contour behoudt zijn eigen grootte, dus een breedteprofiel verandert de contour niet. Verwijder het penseel om een profiel te gebruiken. Weight: Dikte: Art using a deleted global swatch keeps its colour. Artwork met een verwijderd globaal staal behoudt zijn kleur. Color Group: {name} Kleurgroep: {name} diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 0147515ffe..92348fce2a 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -2228,6 +2228,8 @@ digits Malayalam Malajalam Tip extends past the end point Czubek wystaje poza punkt końcowy Tip on the end point Czubek na punkcie końcowym Variable Width Profile Profil zmiennej szerokości + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Pędzel obrysu zachowuje własny rozmiar, więc profil szerokości go nie zmienia. Usuń pędzel, aby użyć profilu. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Pędzel obrysu zachowuje własny rozmiar, więc profil szerokości go nie zmienia. Usuń pędzel, aby użyć profilu. Weight: Grubość: Art using a deleted global swatch keeps its colour. Kompozycja używająca usuniętej próbki globalnej zachowa swój kolor. Color Group: {name} Grupa kolorów: {name} diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 8201db7ab6..66461106ce 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -3426,6 +3426,8 @@ digits Malayalam Malaiala V Spacing: Espaçamento V: V: V: Variable Width Profile Perfil de Largura Variável + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. O pincel do traçado mantém o próprio tamanho, então um perfil de largura não o altera. Remova o pincel para usar um perfil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. O pincel do traçado mantém o próprio tamanho, então um perfil de largura não o altera. Remova o pincel para usar um perfil. Variables Variáveis New Variable… Nova variável… Unbind Variable Desassociar variável diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index d1593508d3..014f2e9b9e 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -4222,6 +4222,8 @@ digits Malayalam Малаялам V Spacing: Интервал по вертикали: V: В: Variable Width Profile Профиль переменной ширины + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Кисть обводки сохраняет собственный размер, поэтому профиль ширины её не меняет. Чтобы использовать профиль, уберите кисть. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Кисть обводки сохраняет собственный размер, поэтому профиль ширины её не меняет. Чтобы использовать профиль, уберите кисть. Variables Переменные New Variable Новая переменная Delete Variable Удалить переменную diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 5c0420fcd3..949fd0f502 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -4107,6 +4107,8 @@ digits Malayalam Malayalam V Spacing: V-avstånd: V: V: Variable Width Profile Profil för variabel bredd + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Konturens pensel behåller sin egen storlek, så en breddprofil ändrar inte konturen. Ta bort penseln för att använda en profil. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Konturens pensel behåller sin egen storlek, så en breddprofil ändrar inte konturen. Ta bort penseln för att använda en profil. Variables Variabler New Variable Ny variabel Delete Variable Radera variabel diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 910a7fc5b1..1d20b5d72a 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -3961,6 +3961,8 @@ digits Malayalam Malayalam V Spacing: V Aralığı: V: V: Variable Width Profile Değişken Genişlik Profili + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Konturun fırçası kendi boyutunu korur, bu yüzden genişlik profili konturu değiştirmez. Profil kullanmak için fırçayı kaldırın. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Konturun fırçası kendi boyutunu korur, bu yüzden genişlik profili konturu değiştirmez. Profil kullanmak için fırçayı kaldırın. Variables Değişkenler New Variable Yeni Değişken Delete Variable Değişkeni Sil diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index dbd6d2609e..b5ce19eab1 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -4232,6 +4232,8 @@ effect Points Точки V Spacing: Інтервал по вертикалі: V: В: Variable Width Profile Профіль змінної ширини + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Пензель обведення зберігає власний розмір, тому профіль ширини його не змінює. Щоб використати профіль, заберіть пензель. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Пензель обведення зберігає власний розмір, тому профіль ширини його не змінює. Щоб використати профіль, заберіть пензель. Variables Змінні New Variable Нова змінна Delete Variable Видалити змінну diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 519c5d8f0d..989fa6c393 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -4641,6 +4641,8 @@ mark-style Japanese Kiểu Nhật Variable Options Tùy chọn biến Variable Options… Tùy chọn biến số… Variable Width Profile Hồ sơ chiều rộng biến đổi + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Cọ của nét giữ kích thước riêng, nên hồ sơ chiều rộng không thay đổi nét. Gỡ cọ để dùng hồ sơ. +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. Cọ của nét giữ kích thước riêng, nên hồ sơ chiều rộng không thay đổi nét. Gỡ cọ để dùng hồ sơ. Variables Biến số Variation: Biến thể: Vector Effects Hiệu ứng vector diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index c6696a9ec6..34636b6f63 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -4061,6 +4061,8 @@ digits Malayalam 马拉雅拉姆数字 V Spacing: 垂直间距: V: V: Variable Width Profile 变量宽度配置文件 + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 描边的画笔保持其自身大小,因此宽度配置文件不会改变它。移除画笔即可使用配置文件。 +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 描边的画笔保持其自身大小,因此宽度配置文件不会改变它。移除画笔即可使用配置文件。 Variables 变量 New Variable 新建变量 Delete Variable 删除变量 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 1480422931..f1fa194422 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -5385,6 +5385,8 @@ digits Malayalam 馬來亞拉姆數字 V Spacing: 垂直間距: V: V: Variable Width Profile 可變寬度描述檔 + The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 筆畫的筆刷會保持自身大小,因此寬度描述檔不會改變它。移除筆刷即可使用描述檔。 +@msg The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile. 筆畫的筆刷會保持自身大小,因此寬度描述檔不會改變它。移除筆刷即可使用描述檔。 Variables 變數 New Variable 新增變數 Delete Variable 刪除變數 diff --git a/crates/ui-egui/src/panels/properties.rs b/crates/ui-egui/src/panels/properties.rs index 5dede1697b..05db9d9cfd 100644 --- a/crates/ui-egui/src/panels/properties.rs +++ b/crates/ui-egui/src/panels/properties.rs @@ -985,7 +985,7 @@ fn width_profile_row(app: &mut VectorcraftApp, ui: &mut Ui) { } ui.horizontal(|ui| { dim_label(ui, tl!("Profile:")); - if let Some(id) = super::stroke::profile_dropdown(app, ui, profile) { + if let Some(id) = super::stroke::profile_dropdown(app, ui, stroke.as_ref()) { app.run("stroke.set", json!({"profile": id})).ok(); } }); diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index c91d01a2bf..613eb73793 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -1515,6 +1515,26 @@ fn the_width_profile_shows_for_a_variable_width_or_the_width_tool() { assert_eq!(WidthProfile::id_of(profile.as_ref()), "taperStart"); } +/// A brushed stroke with a variable width: the Width Profile list lists only Uniform, which removes +/// the profile. +#[test] +fn the_width_profile_of_a_brushed_stroke_offers_only_uniform() { + let mut app = new_app(); + let line = app.run("shape.line", json!({"x1": 20, "y1": 100, "x2": 300, "y2": 100})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [line]})).unwrap(); + app.run("stroke.set", json!({"profile": "lens"})).unwrap(); + app.run("brush.apply", json!({"ids": [line], "name": "3 pt. Round"})).unwrap(); + let ctx = egui::Context::default(); + let texts = tall(&mut app, &ctx, vec![]); + let spacing = ctx.global_style().spacing.item_spacing.x; + let texts = press(&mut app, &ctx, text_at(&texts, "Profile:").right_center() + vec2(spacing + 50.0, 0.0)); + assert!(!shows(&texts, "Taper Start"), "{texts:?}"); + press(&mut app, &ctx, text_at(&texts, "Uniform").center()); + let profile = + app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(line.as_u64().unwrap())).unwrap().appearance.stroke().unwrap().profile.clone(); + assert_eq!(profile, None); +} + /// With Direct Selection, a path whose corner is selected shows that corner's kind and radius; /// each edit sets that corner alone in one undo step. Not with the Selection tool, nor with the /// whole path selected; a live rectangle keeps its own Corner Radius row instead. diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index c667f01200..25c32db77e 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -355,10 +355,10 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { // Profile. ui.horizontal(|ui| { row_label(ui, tl!("Profile:")); - if let Some(id) = profile_dropdown(app, ui, st.as_ref().and_then(|s| s.profile.as_ref())) { + if let Some(id) = profile_dropdown(app, ui, st.as_ref()) { set(app, json!({"profile": id})); } - let can_flip = st.as_ref().is_some_and(|s| s.profile.is_some()); + let can_flip = st.as_ref().is_some_and(|s| s.profile.is_some()) && brush_keeps_size(app, ui.ctx(), st.as_ref()).is_none(); // Lucide names these icons for their mirror line: the vertical-line icon flips the // profile along the path, while the horizontal-line icon flips it across the path. if widgets::icon_button_enabled(ui, "flip-vertical-2", tl!("Flip Along"), false, can_flip, 22.0).clicked() { @@ -498,24 +498,66 @@ pub fn paint_profile(ui: &Ui, r: Rect, points: Option<&[(f64, f64, f64)]>, color /// The width of the [`profile_dropdown`] button. pub(crate) const PROFILE_DROPDOWN_WIDTH: f32 = 100.0; -/// The Profile dropdown (Stroke panel, Control bar): the stroke's own silhouette on the button -/// (a custom profile too), the built-in profiles and then the saved ones in the list. Returns the -/// id or name picked. -pub(crate) fn profile_dropdown(app: &VectorcraftApp, ui: &mut Ui, cur: Option<&WidthProfile>) -> Option { +/// While a width profile changes none of the strokes the Profile list edits, because each draws +/// with a brush: whether any of them has a profile. None while a profile changes one of them. +/// With nothing selected the list sets up the next object drawn, whose stroke is `shown` (the +/// stroke the panels show). Otherwise it edits the strokes `stroke.set` targets +/// ([`vectorcraft_engine::Session::brushed_strokes_profiled`], cached per document revision and +/// active Appearance row), such as a selected group's own stroke while `shown` is its first +/// member's. +pub(crate) fn brush_keeps_size(app: &VectorcraftApp, ctx: &egui::Context, shown: Option<&StrokeLayer>) -> Option { + let st = app.session.active()?; + if st.selection.objects.is_empty() && st.selection.subjects().is_empty() { + let s = shown?; + let name = s.brush.as_deref()?; + return super::brushes::document_brushes(st).iter().any(|b| b.name == name).then_some(s.profile.is_some()); + } + let key = (st.uid, st.revision, app.session.appearance_item()); + match pstate::), Option)>>(ctx, "stroke-brushed") { + Some((k, v)) if k == key => v, + _ => { + let v = app.session.brushed_strokes_profiled(); + set_pstate(ctx, "stroke-brushed", Some((key, v))); + v + } + } +} + +/// The Profile dropdown (Stroke panel, Properties panel, Control bar): the stroke's own silhouette +/// on the button (a custom profile too), the built-in profiles and then the saved ones in the list. +/// Returns the id or name picked. While the strokes draw with a brush ([`brush_keeps_size`]), the +/// button is dimmed and says why when hovered; it opens no list while every one is uniform, and +/// only the Uniform row, which removes the profiles, while one has a profile. +pub(crate) fn profile_dropdown(app: &VectorcraftApp, ui: &mut Ui, shown: Option<&StrokeLayer>) -> Option { let t = Tokens::get(ui.ctx()); - let (r, resp) = ui.allocate_exact_size(vec2(PROFILE_DROPDOWN_WIDTH, 24.0), Sense::click()); + let cur = shown.and_then(|s| s.profile.as_ref()); + let brushed = brush_keeps_size(app, ui.ctx(), shown); + let keeps_size = brushed.is_some(); + let uniform = brushed == Some(false); + let sense = if uniform { Sense::hover() } else { Sense::click() }; + let (r, resp) = ui.allocate_exact_size(vec2(PROFILE_DROPDOWN_WIDTH, 24.0), sense); ui.painter().rect_filled(r, 2, t.input); - ui.painter().rect_stroke(r, 2, Stroke::new(1.0, if resp.hovered() { t.text } else { t.input_border }), StrokeKind::Inside); + let border = if resp.hovered() && !keeps_size { t.text } else { t.input_border }; + ui.painter().rect_stroke(r, 2, Stroke::new(1.0, border), StrokeKind::Inside); let body = Rect::from_min_max(r.min + vec2(6.0, 5.0), pos2(r.right() - 20.0, r.bottom() - 5.0)); - paint_profile(ui, body, cur.and_then(|p| silhouette(&p.points)), t.text_strong); - icons::paint(ui, "chevron-down", Rect::from_center_size(pos2(r.right() - 9.0, r.center().y), vec2(10.0, 10.0)), t.icon); - let resp = resp.on_hover_text(tl!("Variable Width Profile")); + let (shape, icon) = if keeps_size { (t.text_disabled, t.text_disabled) } else { (t.text_strong, t.icon) }; + paint_profile(ui, body, cur.and_then(|p| silhouette(&p.points)), shape); + icons::paint(ui, "chevron-down", Rect::from_center_size(pos2(r.right() - 9.0, r.center().y), vec2(10.0, 10.0)), icon); + let tip = if keeps_size { + tl!("The stroke's brush keeps its own size, so a width profile does not change it. Remove the brush to use a profile.") + } else { + tl!("Variable Width Profile") + }; + let resp = resp.on_hover_text(tip); + if uniform { + return None; + } let mut out = None; egui::Popup::menu(&resp).show(|ui| { egui::ScrollArea::vertical().max_height(360.0).show(ui, |ui| { // A divider between the built-in profiles and the saved ones. let mut divide = true; - for e in app.session.profile_entries() { + for e in app.session.profile_entries().filter(|e| !keeps_size || e.matches(None)) { if !e.built_in && std::mem::take(&mut divide) { ui.separator(); } diff --git a/crates/ui-egui/src/panels/tests_strokedepth.rs b/crates/ui-egui/src/panels/tests_strokedepth.rs index 1d80cc1c66..aa4dfb9fa1 100644 --- a/crates/ui-egui/src/panels/tests_strokedepth.rs +++ b/crates/ui-egui/src/panels/tests_strokedepth.rs @@ -1,5 +1,6 @@ //! Headless frames of the Stroke panel's width profile library: the ≡ menu's Add to Profiles…, -//! Delete Profile and Reset Profiles, and the Profile dropdown listing saved profiles. +//! Delete Profile and Reset Profiles, and the Profile dropdown listing saved profiles and dimmed +//! while the strokes draw with a brush. use serde_json::json; use vectorcraft_doc::WidthProfile; @@ -88,6 +89,198 @@ fn dropdown_lists_saved_profiles_and_applies_them() { assert_eq!(profile_points(&app), Some(custom().points)); } +/// The Stroke panel's Profile dropdown button, right of the "Profile:" label. +fn profile_button(ctx: &egui::Context, app: &mut VectorcraftApp) -> egui::Pos2 { + let t = frame_events(ctx, app, vec![], stroke::show); + let label = text_rect(&t, "Profile:"); + egui::pos2(label.right() + ctx.global_style().spacing.item_spacing.x + 50.0, label.center().y) +} + +/// Is the Profile dropdown dimmed for the stroke the panels show? +fn dimmed(ctx: &egui::Context, app: &VectorcraftApp) -> bool { + stroke::brush_keeps_size(app, ctx, current_stroke(app).as_ref()).is_some() +} + +/// The rows the Profile dropdown lists after a click on it. +fn listed(ctx: &egui::Context, app: &mut VectorcraftApp) -> Vec<&'static str> { + let button = profile_button(ctx, app); + click(ctx, app, button, stroke::show); + let t = frame_events(ctx, app, vec![], stroke::show); + let out = WidthProfile::PRESETS.iter().map(|p| p.label).filter(|l| t.iter().any(|(s, _)| s == l)).collect(); + // Close the list. + let escape = egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() }; + frame_events(ctx, app, vec![escape], stroke::show); + out +} + +/// A stroke drawn with a brush (here the 3 pt. Round calligraphic brush) keeps the brush's size, +/// so a width profile does not change it: the Profile dropdown is dimmed, opens no list on a +/// uniform stroke, and lists only Uniform on a stroke that has a profile (which resets it). +/// Without the brush, the full list comes back. +#[test] +fn dropdown_is_dimmed_while_the_brush_keeps_its_size() { + let ctx = egui::Context::default(); + let mut app = app_with_line(); + let id = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "brush.apply", json!({"ids": [id], "name": "3 pt. Round"})); + assert!(dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app), Vec::<&str>::new(), "no list on a uniform stroke"); + + set_profile(&mut app, custom()); + assert_eq!(listed(&ctx, &mut app), ["Uniform"]); + let button = profile_button(&ctx, &mut app); + click(&ctx, &mut app, button, stroke::show); + let t = frame_events(&ctx, &mut app, vec![], stroke::show); + click(&ctx, &mut app, text_rect(&t, "Uniform").center(), stroke::show); + assert_eq!(profile_points(&app), None, "Uniform resets the profile"); + + run(&mut app, "brush.remove", json!({"ids": [id]})); + assert!(!dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app).len(), WidthProfile::PRESETS.len()); +} + +/// With an Appearance panel stroke row active, the dropdown follows that row: a brushed row below +/// a plain top stroke dims it, and the plain row does not. +#[test] +fn the_active_stroke_row_decides_whether_the_dropdown_is_dimmed() { + let ctx = egui::Context::default(); + let mut app = app_with_line(); + let id = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "brush.apply", json!({"ids": [id], "name": "3 pt. Round"})); + run(&mut app, "appearance.addStroke", json!({})); + let items = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().appearance.items.clone(); + let rows: Vec<(usize, bool)> = items + .iter() + .enumerate() + .filter_map(|(i, it)| if let vectorcraft_doc::AppearanceItem::Stroke(s) = it { Some((i, s.brush.is_some())) } else { None }) + .collect(); + let [(lower, true), (top, false)] = rows[..] else { panic!("{rows:?}") }; + assert!(!dimmed(&ctx, &app), "the top stroke has no brush"); + run(&mut app, "appearance.setActiveItem", json!({"index": lower})); + assert!(dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app), Vec::<&str>::new()); + run(&mut app, "appearance.setActiveItem", json!({"index": top})); + assert!(!dimmed(&ctx, &app)); +} + +/// A selected group with a brushed stroke of its own dims the dropdown, though the panel shows its +/// first member's plain stroke: the list edits the group's stroke. +#[test] +fn a_groups_own_brushed_stroke_dims_the_dropdown() { + let ctx = egui::Context::default(); + let mut app = app_with_line(); + let a = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "shape.line", json!({"x1": 10, "y1": 150, "x2": 150, "y2": 150})); + let b = app.session.active().unwrap().selection.objects[0].0; + let g = run(&mut app, "object.group", json!({"ids": [a, b]}))["id"].as_u64().unwrap(); + run(&mut app, "appearance.addStroke", json!({"ids": [g]})); + app.session + .edit("Brush", |d, _| { + d.node_mut(vectorcraft_doc::NodeId(g)).unwrap().appearance.stroke_mut().unwrap().brush = Some("3 pt. Round".into()); + Ok(()) + }) + .unwrap(); + run(&mut app, "select.set", json!({"ids": [g]})); + assert!(current_stroke(&app).is_some_and(|s| s.brush.is_none()), "the panel shows a member's plain stroke"); + assert!(dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app), Vec::<&str>::new()); +} + +/// A selection change with no edit between decides whether the dropdown is dimmed: from a brushed +/// line to a plain one and back. +#[test] +fn selecting_another_object_without_an_edit_updates_the_dimming() { + let ctx = egui::Context::default(); + let mut app = app_with_line(); + let a = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "shape.line", json!({"x1": 10, "y1": 150, "x2": 150, "y2": 150})); + let b = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "brush.apply", json!({"ids": [a], "name": "3 pt. Round"})); + run(&mut app, "select.set", json!({"ids": [a]})); + assert!(dimmed(&ctx, &app)); + run(&mut app, "select.set", json!({"ids": [b]})); + assert!(!dimmed(&ctx, &app), "the plain line follows a profile"); + run(&mut app, "select.set", json!({"ids": [a]})); + assert!(dimmed(&ctx, &app)); +} + +/// The Flip Along and Flip Across buttons beside a dimmed dropdown do not flip a brushed stroke's +/// profile, which does not change what the stroke draws. +#[test] +fn flip_buttons_leave_a_brushed_strokes_profile_alone() { + let ctx = egui::Context::default(); + let mut app = app_with_line(); + set_profile(&mut app, custom()); + let spacing = ctx.global_style().spacing.item_spacing.x; + // The dropdown is 100 pt wide and the Flip Along button, 22 pt wide, follows it. + let flip = |ctx: &egui::Context, app: &mut VectorcraftApp| { + let button = profile_button(ctx, app); + let at = egui::pos2(button.x + stroke::PROFILE_DROPDOWN_WIDTH / 2.0 + spacing + 11.0, button.y); + click(ctx, app, at, stroke::show); + }; + flip(&ctx, &mut app); + let flipped = profile_points(&app); + assert_ne!(flipped, Some(custom().points), "Flip Along flips a plain stroke's profile"); + let id = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "brush.apply", json!({"ids": [id], "name": "3 pt. Round"})); + assert!(dimmed(&ctx, &app)); + let before = profile_points(&app); + assert!(before.is_some()); + flip(&ctx, &mut app); + assert_eq!(profile_points(&app), before, "the buttons are off on a brushed stroke"); +} + +/// With several objects selected, the dropdown is dimmed only while every one of their strokes +/// draws with a brush: a profile still changes the strokes without one. A brush name the +/// document's brushes lack draws a plain stroke, which follows the profile. +#[test] +fn mixed_selection_dims_the_dropdown_only_when_every_stroke_has_a_brush() { + let ctx = egui::Context::default(); + let mut app = app_with_line(); + let a = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "shape.line", json!({"x1": 10, "y1": 150, "x2": 150, "y2": 150})); + let b = app.session.active().unwrap().selection.objects[0].0; + run(&mut app, "brush.apply", json!({"ids": [a], "name": "3 pt. Round"})); + // The first selected object is the brushed one, whose stroke the panel shows. + run(&mut app, "select.set", json!({"ids": [a, b]})); + assert!(current_stroke(&app).and_then(|s| s.brush).is_some()); + assert!(!dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app).len(), WidthProfile::PRESETS.len()); + + run(&mut app, "brush.apply", json!({"ids": [b], "name": "3 pt. Round"})); + run(&mut app, "select.set", json!({"ids": [a, b]})); + assert!(dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app), Vec::<&str>::new()); + + // The shown stroke is uniform and the other has a profile: Uniform still removes it. + let edit = |app: &mut VectorcraftApp, f: &dyn Fn(&mut vectorcraft_doc::Appearance)| { + app.session + .edit("Edit", |d, _| { + f(&mut d.node_mut(vectorcraft_doc::NodeId(b)).unwrap().appearance); + Ok(()) + }) + .unwrap(); + }; + edit(&mut app, &|ap| ap.stroke_mut().unwrap().profile = Some(custom())); + assert_eq!(current_stroke(&app).and_then(|s| s.profile), None); + assert_eq!(listed(&ctx, &mut app), ["Uniform"]); + let button = profile_button(&ctx, &mut app); + click(&ctx, &mut app, button, stroke::show); + let t = frame_events(&ctx, &mut app, vec![], stroke::show); + click(&ctx, &mut app, text_rect(&t, "Uniform").center(), stroke::show); + let node = |app: &VectorcraftApp| app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(b)).unwrap().clone(); + assert_eq!(node(&app).appearance.stroke().unwrap().profile, None, "Uniform reset the other stroke"); + + edit(&mut app, &|ap| ap.stroke_mut().unwrap().brush = Some("No Such Brush".into())); + assert!(!dimmed(&ctx, &app)); + + // An object without a stroke item takes a plain stroke from a profile. + edit(&mut app, &|ap| ap.items.retain(|i| !matches!(i, vectorcraft_doc::AppearanceItem::Stroke(_)))); + assert!(node(&app).appearance.stroke().is_none()); + assert!(!dimmed(&ctx, &app)); + assert_eq!(listed(&ctx, &mut app).len(), WidthProfile::PRESETS.len()); +} + #[test] fn every_arrowhead_preview_draws_its_head() { use vectorcraft_doc::Arrowhead; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index eb8aae5389..046a1b2ffd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -775,6 +775,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Width-point finite-arithmetic follow-up (G1/M3):** Adjoining adjustments avoid intermediate overflow; non-finite normalized or resulting factors are rejected before committing. Engine regressions in `tests/widthpoints.rs` cover finite extremes, small nonzero results, atomic rejection, Undo/Redo and native save/reopen. Historical focused validation on the `a3357121` integration observed 2 expected RED failures with 11 passing controls, then all 13 tests passing with the repair; none were ignored. All three added regressions passed in current full CI. A full CI retry on the five-unit combined source at `a0671777` passed all seven stages with 6,613 test outcomes on 2026-10-14. An earlier full-CI run on the identical source panicked in the randomized `ai_mutated_save_never_panics` test; the cause remains unresolved. This five-fix batch does not claim to repair that failure. Scores and hours unchanged. - **Width-point creation (G1):** double-click a stroked segment with the Width tool to open Width Point Edit using sampled side widths. OK creates the point and optionally adjusts adjoining widths in one undo step. Cancel or Delete discards a prospective point without changing the document or redo history. Command and pointer tests cover profiles, compound paths, adjoining adjustment, existing-point editing and Undo/Redo. Message-catalog checks and full CI passed; the original capture verifies opening and Cancel, and the dialog layout was reviewed (2026-10-13: 28 focused Width tests, all seven cargo xtask ci stages, and a headless opening/Cancel capture with original PNG review). [Variable-width strokes](https://helpx.adobe.com/illustrator/using/stroke-object.html). - **Escape deselects width points:** with the Width tool, Escape deselects the selected width points, on the key the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for deselecting a width point. The path, its widths and the undo history do not change. With no width point selected, Escape does what it does with the other tools, such as leaving isolation mode. +- **Width profiles on brushed strokes:** brush art does not follow a stroke's width profile, so while every stroke the list edits draws with a brush, the Profile list in the Stroke panel, the Properties panel and the Control bar is dimmed and says why when hovered (VectorCraft's own rule). It opens no list while every one of those strokes is uniform, and only Uniform, which removes the profiles, while one has a profile. The Flip Along and Flip Across buttons beside it are off. The strokes are the ones `stroke.set` edits: the active Appearance stroke row in each selected object that has an equal row and the top stroke in the others, else a selected group's or compound shape's own stroke, else the objects' strokes. Images and symbol instances, which take no stroke from the list, do not count. A selection where some of them have no brush, or an object has no stroke, keeps the full list. The Width tool adds, edits and deletes no width points on a brushed stroke, and a press on one, or Delete with its width points selected, says why in the status bar; without Shift the press deselects the width points of other strokes, and the cursor over a brushed stroke offers no edit. A plain stroke under a selected brushed one stays reachable, and width points selected before their stroke took a brush show no handles. Tests: `panels::tests_strokedepth::{dropdown_is_dimmed_while_the_brush_keeps_its_size, the_active_stroke_row_decides_whether_the_dropdown_is_dimmed, a_groups_own_brushed_stroke_dims_the_dropdown, selecting_another_object_without_an_edit_updates_the_dimming, flip_buttons_leave_a_brushed_strokes_profile_alone, mixed_selection_dims_the_dropdown_only_when_every_stroke_has_a_brush}`, `panels::properties::tests::the_width_profile_of_a_brushed_stroke_offers_only_uniform`, `tests::appearance::{brushed_strokes_profiled_reads_the_strokes_stroke_set_edits, brushed_strokes_profiled_reads_a_compound_shapes_own_stroke, brushed_strokes_profiled_reads_a_targeted_layers_active_stroke_row, brushed_strokes_profiled_leaves_out_symbol_instances, brushed_strokes_profiled_falls_back_to_the_top_stroke_where_the_active_row_has_no_match}`, `distort::width::tests::{brushed_stroke_is_left_alone_with_a_reason, delete_leaves_the_width_points_of_a_brushed_stroke, a_press_on_a_brushed_stroke_deselects_and_its_cursor_offers_no_edit, shift_on_a_brushed_stroke_keeps_the_selected_width_points, a_plain_stroke_under_a_selected_brushed_one_stays_reachable, a_brush_applied_under_a_still_pointer_takes_away_the_hover, a_brush_added_to_the_library_is_seen_at_the_next_revision}`. - **Smooth widths between width points (#5714):** a variable-width stroke changes width along a smooth curve from one width point to the next, where it used to run in a straight line and turn a corner at each point. The public description is that the path "gradually gets wider or narrower from one point to the next" in "a flowing, continuous curve", and that stacked points make a sharp break ([Peachpit, Expressive Strokes](https://www.peachpit.com/articles/article.aspx?p=2979069)); the exact curve is not documented, so each side follows a monotone cubic (Fritsch–Carlson): no kink at a point, flat where a point is wider or narrower than both neighbours, never past the points either side, points on one line kept on it. The outline samples straight runs between width points closely enough to follow the curve to the drawing tolerance (at most 64 samples per span and 4,096 per piece). Presets with a middle point (Lens, Pinch, Teardrop, Wave) look softer; two-point tapers are unchanged. Tests: `appearance::profile::tests::{widths_run_smoothly_through_width_points, widths_never_pass_the_points_either_side, a_step_ends_the_curve_on_each_side, widest_covers_every_width_along_the_profile}`, `stroke::width::tests::{a_straight_run_follows_the_curve_between_width_points, samples_between_width_points_are_capped}`. - **Stroke gradients where a variable-width stroke meets itself (#5960):** with a gradient along or across a stroke that has a width profile, where the stroke crosses itself the later part paints over the earlier one only where the two overlap, and a narrow part running close beside a wide one leaves its edge alone. Each slice of the gradient reaches as far as the stroke is wide where it sits (for a dashed stroke, as wide as it gets within the reach of a cap or dot, found in one pass along the path, so a densely flattened path costs no more per point), where it used to reach as far as the stroke is wide anywhere and paint a square of its colour over the wider part. Strokes without a profile are unchanged. Tests: `stroke::tests_gradient::a_narrow_pass_over_a_wide_one_paints_only_where_they_overlap`, `a_narrow_pass_beside_a_wide_one_leaves_its_edge_alone`, `a_densely_flattened_dashed_pass_beside_a_wide_one_leaves_its_edge_alone` and `widest_ahead_is_the_widest_within_the_window`, with the existing coverage tests (joins, caps, arrowheads, profiles, dashes, aligned strokes). - **Width strokes zoomed out (#995):** a stroke with a width profile keeps its shape while the view zooms out. The canvas keeps a hairline visible (at least half a device pixel); for a profiled stroke it is the profile's widest point that gets that minimum, not the weight, so a 1 pt stroke with a 6x width point is no longer drawn twice as thick at 25% zoom than at 100%. Plain strokes are unchanged. Test: `render::tests::widthzoom`. From bbf11feac38f760053b417bbf65d7d8a4848f89e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 10:45:44 -0800 Subject: [PATCH 2/2] Stroke: Delete and Escape skip width points hidden on a brushed stroke Width points selected before their stroke took a brush show no handles, but the Width tool still took Delete, Backspace and Escape for them. The tool now leaves those keys to the app, as it does with no width points selected. - The Profile list shows its hover border whenever a click opens it, including on a brushed stroke with a profile, where it lists Uniform. - A test checks that the list's hover text and the Width tool's status message are the same string, so the two share their catalog rows. - An engine test checks that a press or a double-click on a brushed compound path puts the message in the status bar and runs no command. - The doc comment of Session::brushed_strokes_profiled says when type counts, and the progress-doc line names the double-click and says that art and pattern brushes do not follow a width profile yet. --- crates/engine/src/cmd/stroke.rs | 5 ++-- crates/engine/src/tests/widthtool.rs | 18 +++++++++++++++ crates/tools/src/distort.rs | 2 +- crates/tools/src/distort/width.rs | 23 +++++++++++-------- crates/ui-egui/src/panels/stroke.rs | 2 +- .../ui-egui/src/panels/tests_strokedepth.rs | 8 +++++++ docs/target-app-parity.md | 2 +- 7 files changed, 46 insertions(+), 14 deletions(-) diff --git a/crates/engine/src/cmd/stroke.rs b/crates/engine/src/cmd/stroke.rs index 038483182f..25095da32c 100644 --- a/crates/engine/src/cmd/stroke.rs +++ b/crates/engine/src/cmd/stroke.rs @@ -443,8 +443,9 @@ impl Session { /// /// The art of graph designs is left out, and so are images and symbol instances without an /// active row. The result is also `None` with nothing selected, with an object inside a symbol - /// instance selected, with type among the targets, and with a target that has no stroke row, - /// since `stroke.set` gives such a target a plain stroke. + /// instance selected, with type among the targets while no Appearance row is active for it, + /// and with a target that has no stroke row, since `stroke.set` gives such a target a plain + /// stroke. pub fn brushed_strokes_profiled(&self) -> Option { const C: &str = "stroke.set"; let st = self.active()?; diff --git a/crates/engine/src/tests/widthtool.rs b/crates/engine/src/tests/widthtool.rs index fda761de61..6b2ed12c54 100644 --- a/crates/engine/src/tests/widthtool.rs +++ b/crates/engine/src/tests/widthtool.rs @@ -40,6 +40,24 @@ fn the_width_tool_edits_a_compound_paths_stroke() { assert_eq!(s.journal.last().unwrap().1["id"], json!(c.0)); } +/// A compound path whose stroke draws with a brush: a press or a double-click on a member puts the +/// tool's reason in the status bar and leaves the stroke and the undo history as they were. +#[test] +fn the_width_tool_says_why_it_leaves_a_brushed_compound_path_alone() { + let (mut s, c, _) = compound(); + s.execute("brush.apply", &json!({"ids": [c.0], "name": "3 pt. Round"})).unwrap(); + let steps = s.journal.len(); + let v = ViewInfo::default(); + s.select_tool("width", v).unwrap(); + for (kind, reason) in [(PointerKind::Down, true), (PointerKind::Drag, false), (PointerKind::Up, false), (PointerKind::DoubleClick, true)] { + let ui = s.pointer(&PointerEvent::new(kind, 200.0, 301.0), v).unwrap(); + let said = ui.iter().any(|r| matches!(r, UiRequest::Status(m) if m == vectorcraft_tools::distort::KEEPS_SIZE)); + assert_eq!(said, reason, "{kind:?}: {ui:?}"); + } + assert_eq!(profile(&s, c), None); + assert_eq!(s.journal.len(), steps, "no command ran"); +} + #[test] fn width_point_commands_given_a_member_edit_the_compound() { let (mut s, c, members) = compound(); diff --git a/crates/tools/src/distort.rs b/crates/tools/src/distort.rs index 30cb1cd4c5..b4cd0a957c 100644 --- a/crates/tools/src/distort.rs +++ b/crates/tools/src/distort.rs @@ -27,7 +27,7 @@ use crate::Tool; pub use liquify::LiquifyTool; pub use perspective::{PerspectiveGridTool, PerspectiveSelectionTool}; pub use puppet::{PinSet, PuppetWarpTool, mesh_for, mesh_input, rest_and_pins, warp_from_rest}; -pub use width::{WidthTool, stroke_owner}; +pub use width::{KEEPS_SIZE, WidthTool, stroke_owner}; /// Create a distortion tool by id (None = not one of ours). pub fn create(id: &str) -> Option> { diff --git a/crates/tools/src/distort/width.rs b/crates/tools/src/distort/width.rs index 7eda93305e..005b8e9473 100644 --- a/crates/tools/src/distort/width.rs +++ b/crates/tools/src/distort/width.rs @@ -21,10 +21,10 @@ //! drag does: add a width point on a stroke, or move or widen the one under it. //! //! A stroke drawn with a brush is left alone, as a width profile does not change it: a press or a -//! double-click on it, and Delete/Backspace with its width points selected, send no command and -//! show why in the status bar ([`KEEPS_SIZE`]). A press or double-click on it deselects the -//! width points, the cursor over it offers no edit, and its width points selected before it took -//! the brush show no handles. +//! double-click on it sends no command and shows why in the status bar ([`KEEPS_SIZE`]). Without +//! Shift, the press or double-click deselects the width points, and the cursor over it offers no +//! edit. Its width points selected before it took the brush show no handles, and Delete, +//! Backspace and Escape do what they do with no width points selected. use std::cell::Cell; use std::sync::Arc; @@ -469,11 +469,12 @@ impl Tool for WidthTool { } /// Delete/Backspace remove the selected width points and Escape deselects them; with none /// selected the keys do what they do with other tools (Clear deletes the selected objects, and - /// Escape leaves isolation mode, for one). + /// Escape leaves isolation mode, for one). Width points of a brushed stroke, which show no + /// handles, count as none selected. fn claims_key(&self, cx: &ToolContext, key: ToolKey) -> bool { matches!(key, ToolKey::Delete | ToolKey::Backspace | ToolKey::Escape) && self.drag.is_none() - && self.selected.as_ref().is_some_and(|(id, _)| !self.selected_indices(cx, *id).is_empty()) + && self.selected.as_ref().is_some_and(|(id, _)| !self.selected_indices(cx, *id).is_empty() && !self.keeps_size(cx, *id)) } /// A dropped press ends the drag, and the width points selected when the button went down are /// selected again. @@ -497,7 +498,7 @@ impl Tool for WidthTool { } self.selected = None; if self.keeps_size(cx, id) { - return vec![Action::Status(KEEPS_SIZE.into())]; + return vec![]; } vec![Action::Exec("stroke.widthPoint.remove".into(), json!({"id": id.0, "indices": indices}))] } @@ -694,7 +695,8 @@ mod tests { assert_eq!(t.pointer(&c, &PointerEvent::new(PointerKind::Down, 150.0, 201.0)), vec![Action::Status(KEEPS_SIZE.into())]); } - /// Width points selected before the stroke took a brush: Delete removes none and says why. + /// Width points selected before the stroke took a brush show no handles and count as none + /// selected: the tool leaves Delete and Escape to the app, and removes none. #[test] fn delete_leaves_the_width_points_of_a_brushed_stroke() { let (mut d, id) = doc_line(); @@ -710,7 +712,10 @@ mod tests { d.node_mut(id).unwrap().appearance.stroke_mut().unwrap().brush = Some("3 pt. Round".into()); let c = ToolContext { revision: (0, 1), ..cx(&d, &s, &p) }; assert!(t.overlays(&c).is_empty(), "no handles show on a stroke the tool no longer edits"); - assert_eq!(t.key(&c, ToolKey::Delete, Mods::default()), vec![Action::Status(KEEPS_SIZE.into())]); + for key in [ToolKey::Delete, ToolKey::Backspace, ToolKey::Escape] { + assert!(!t.claims_key(&c, key), "{key:?} is the app's"); + } + assert_eq!(t.key(&c, ToolKey::Delete, Mods::default()), vec![]); assert!(t.selected.is_none()); } diff --git a/crates/ui-egui/src/panels/stroke.rs b/crates/ui-egui/src/panels/stroke.rs index 25c32db77e..edf4af5428 100644 --- a/crates/ui-egui/src/panels/stroke.rs +++ b/crates/ui-egui/src/panels/stroke.rs @@ -537,7 +537,7 @@ pub(crate) fn profile_dropdown(app: &VectorcraftApp, ui: &mut Ui, shown: Option< let sense = if uniform { Sense::hover() } else { Sense::click() }; let (r, resp) = ui.allocate_exact_size(vec2(PROFILE_DROPDOWN_WIDTH, 24.0), sense); ui.painter().rect_filled(r, 2, t.input); - let border = if resp.hovered() && !keeps_size { t.text } else { t.input_border }; + let border = if resp.hovered() && !uniform { t.text } else { t.input_border }; ui.painter().rect_stroke(r, 2, Stroke::new(1.0, border), StrokeKind::Inside); let body = Rect::from_min_max(r.min + vec2(6.0, 5.0), pos2(r.right() - 20.0, r.bottom() - 5.0)); let (shape, icon) = if keeps_size { (t.text_disabled, t.text_disabled) } else { (t.text_strong, t.icon) }; diff --git a/crates/ui-egui/src/panels/tests_strokedepth.rs b/crates/ui-egui/src/panels/tests_strokedepth.rs index aa4dfb9fa1..c4f2a9fff4 100644 --- a/crates/ui-egui/src/panels/tests_strokedepth.rs +++ b/crates/ui-egui/src/panels/tests_strokedepth.rs @@ -281,6 +281,14 @@ fn mixed_selection_dims_the_dropdown_only_when_every_stroke_has_a_brush() { assert_eq!(listed(&ctx, &mut app).len(), WidthProfile::PRESETS.len()); } +/// The dimmed dropdown's hover text is the Width tool's status message, word for word, so the two +/// share their catalog rows. +#[test] +fn the_hover_text_is_the_width_tools_status_message() { + let literal = format!("tl!(\"{}\")", vectorcraft_tools::distort::KEEPS_SIZE); + assert!(include_str!("stroke.rs").contains(&literal), "panels/stroke.rs has no {literal}"); +} + #[test] fn every_arrowhead_preview_draws_its_head() { use vectorcraft_doc::Arrowhead; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 046a1b2ffd..931f7b1d06 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -775,7 +775,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Width-point finite-arithmetic follow-up (G1/M3):** Adjoining adjustments avoid intermediate overflow; non-finite normalized or resulting factors are rejected before committing. Engine regressions in `tests/widthpoints.rs` cover finite extremes, small nonzero results, atomic rejection, Undo/Redo and native save/reopen. Historical focused validation on the `a3357121` integration observed 2 expected RED failures with 11 passing controls, then all 13 tests passing with the repair; none were ignored. All three added regressions passed in current full CI. A full CI retry on the five-unit combined source at `a0671777` passed all seven stages with 6,613 test outcomes on 2026-10-14. An earlier full-CI run on the identical source panicked in the randomized `ai_mutated_save_never_panics` test; the cause remains unresolved. This five-fix batch does not claim to repair that failure. Scores and hours unchanged. - **Width-point creation (G1):** double-click a stroked segment with the Width tool to open Width Point Edit using sampled side widths. OK creates the point and optionally adjusts adjoining widths in one undo step. Cancel or Delete discards a prospective point without changing the document or redo history. Command and pointer tests cover profiles, compound paths, adjoining adjustment, existing-point editing and Undo/Redo. Message-catalog checks and full CI passed; the original capture verifies opening and Cancel, and the dialog layout was reviewed (2026-10-13: 28 focused Width tests, all seven cargo xtask ci stages, and a headless opening/Cancel capture with original PNG review). [Variable-width strokes](https://helpx.adobe.com/illustrator/using/stroke-object.html). - **Escape deselects width points:** with the Width tool, Escape deselects the selected width points, on the key the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) page lists for deselecting a width point. The path, its widths and the undo history do not change. With no width point selected, Escape does what it does with the other tools, such as leaving isolation mode. -- **Width profiles on brushed strokes:** brush art does not follow a stroke's width profile, so while every stroke the list edits draws with a brush, the Profile list in the Stroke panel, the Properties panel and the Control bar is dimmed and says why when hovered (VectorCraft's own rule). It opens no list while every one of those strokes is uniform, and only Uniform, which removes the profiles, while one has a profile. The Flip Along and Flip Across buttons beside it are off. The strokes are the ones `stroke.set` edits: the active Appearance stroke row in each selected object that has an equal row and the top stroke in the others, else a selected group's or compound shape's own stroke, else the objects' strokes. Images and symbol instances, which take no stroke from the list, do not count. A selection where some of them have no brush, or an object has no stroke, keeps the full list. The Width tool adds, edits and deletes no width points on a brushed stroke, and a press on one, or Delete with its width points selected, says why in the status bar; without Shift the press deselects the width points of other strokes, and the cursor over a brushed stroke offers no edit. A plain stroke under a selected brushed one stays reachable, and width points selected before their stroke took a brush show no handles. Tests: `panels::tests_strokedepth::{dropdown_is_dimmed_while_the_brush_keeps_its_size, the_active_stroke_row_decides_whether_the_dropdown_is_dimmed, a_groups_own_brushed_stroke_dims_the_dropdown, selecting_another_object_without_an_edit_updates_the_dimming, flip_buttons_leave_a_brushed_strokes_profile_alone, mixed_selection_dims_the_dropdown_only_when_every_stroke_has_a_brush}`, `panels::properties::tests::the_width_profile_of_a_brushed_stroke_offers_only_uniform`, `tests::appearance::{brushed_strokes_profiled_reads_the_strokes_stroke_set_edits, brushed_strokes_profiled_reads_a_compound_shapes_own_stroke, brushed_strokes_profiled_reads_a_targeted_layers_active_stroke_row, brushed_strokes_profiled_leaves_out_symbol_instances, brushed_strokes_profiled_falls_back_to_the_top_stroke_where_the_active_row_has_no_match}`, `distort::width::tests::{brushed_stroke_is_left_alone_with_a_reason, delete_leaves_the_width_points_of_a_brushed_stroke, a_press_on_a_brushed_stroke_deselects_and_its_cursor_offers_no_edit, shift_on_a_brushed_stroke_keeps_the_selected_width_points, a_plain_stroke_under_a_selected_brushed_one_stays_reachable, a_brush_applied_under_a_still_pointer_takes_away_the_hover, a_brush_added_to_the_library_is_seen_at_the_next_revision}`. +- **Width profiles on brushed strokes:** brush art does not follow a stroke's width profile, so while every stroke the list edits draws with a brush, the Profile list in the Stroke panel, the Properties panel and the Control bar is dimmed and says why when hovered (VectorCraft's own rule while brushes ignore width profiles; art and pattern brushes that follow one are still missing). It opens no list while every one of those strokes is uniform, and only Uniform, which removes the profiles, while one has a profile. The Flip Along and Flip Across buttons beside it are off. The strokes are the ones `stroke.set` edits: the active Appearance stroke row in each selected object that has an equal row and the top stroke in the others, else a selected group's or compound shape's own stroke, else the objects' strokes. Images and symbol instances, which take no stroke from the list, do not count. A selection where some of them have no brush, or an object has no stroke, keeps the full list. The Width tool adds, edits and deletes no width points on a brushed stroke, and a press or a double-click on one says why in the status bar; without Shift it deselects the width points of other strokes, and the cursor over a brushed stroke offers no edit. A plain stroke under a selected brushed one stays reachable. Width points selected before their stroke took a brush show no handles, and Delete, Backspace and Escape act as if none were selected. Tests: `panels::tests_strokedepth::{dropdown_is_dimmed_while_the_brush_keeps_its_size, the_active_stroke_row_decides_whether_the_dropdown_is_dimmed, a_groups_own_brushed_stroke_dims_the_dropdown, selecting_another_object_without_an_edit_updates_the_dimming, flip_buttons_leave_a_brushed_strokes_profile_alone, mixed_selection_dims_the_dropdown_only_when_every_stroke_has_a_brush, the_hover_text_is_the_width_tools_status_message}`, `panels::properties::tests::the_width_profile_of_a_brushed_stroke_offers_only_uniform`, `tests::appearance::{brushed_strokes_profiled_reads_the_strokes_stroke_set_edits, brushed_strokes_profiled_reads_a_compound_shapes_own_stroke, brushed_strokes_profiled_reads_a_targeted_layers_active_stroke_row, brushed_strokes_profiled_leaves_out_symbol_instances, brushed_strokes_profiled_falls_back_to_the_top_stroke_where_the_active_row_has_no_match}`, `tests::widthtool::the_width_tool_says_why_it_leaves_a_brushed_compound_path_alone`, `distort::width::tests::{brushed_stroke_is_left_alone_with_a_reason, delete_leaves_the_width_points_of_a_brushed_stroke, a_press_on_a_brushed_stroke_deselects_and_its_cursor_offers_no_edit, shift_on_a_brushed_stroke_keeps_the_selected_width_points, a_plain_stroke_under_a_selected_brushed_one_stays_reachable, a_brush_applied_under_a_still_pointer_takes_away_the_hover, a_brush_added_to_the_library_is_seen_at_the_next_revision}`. - **Smooth widths between width points (#5714):** a variable-width stroke changes width along a smooth curve from one width point to the next, where it used to run in a straight line and turn a corner at each point. The public description is that the path "gradually gets wider or narrower from one point to the next" in "a flowing, continuous curve", and that stacked points make a sharp break ([Peachpit, Expressive Strokes](https://www.peachpit.com/articles/article.aspx?p=2979069)); the exact curve is not documented, so each side follows a monotone cubic (Fritsch–Carlson): no kink at a point, flat where a point is wider or narrower than both neighbours, never past the points either side, points on one line kept on it. The outline samples straight runs between width points closely enough to follow the curve to the drawing tolerance (at most 64 samples per span and 4,096 per piece). Presets with a middle point (Lens, Pinch, Teardrop, Wave) look softer; two-point tapers are unchanged. Tests: `appearance::profile::tests::{widths_run_smoothly_through_width_points, widths_never_pass_the_points_either_side, a_step_ends_the_curve_on_each_side, widest_covers_every_width_along_the_profile}`, `stroke::width::tests::{a_straight_run_follows_the_curve_between_width_points, samples_between_width_points_are_capped}`. - **Stroke gradients where a variable-width stroke meets itself (#5960):** with a gradient along or across a stroke that has a width profile, where the stroke crosses itself the later part paints over the earlier one only where the two overlap, and a narrow part running close beside a wide one leaves its edge alone. Each slice of the gradient reaches as far as the stroke is wide where it sits (for a dashed stroke, as wide as it gets within the reach of a cap or dot, found in one pass along the path, so a densely flattened path costs no more per point), where it used to reach as far as the stroke is wide anywhere and paint a square of its colour over the wider part. Strokes without a profile are unchanged. Tests: `stroke::tests_gradient::a_narrow_pass_over_a_wide_one_paints_only_where_they_overlap`, `a_narrow_pass_beside_a_wide_one_leaves_its_edge_alone`, `a_densely_flattened_dashed_pass_beside_a_wide_one_leaves_its_edge_alone` and `widest_ahead_is_the_widest_within_the_window`, with the existing coverage tests (joins, caps, arrowheads, profiles, dashes, aligned strokes). - **Width strokes zoomed out (#995):** a stroke with a width profile keeps its shape while the view zooms out. The canvas keeps a hairline visible (at least half a device pixel); for a profiled stroke it is the profile's widest point that gets that minimum, not the weight, so a 1 pt stroke with a 6x width point is no longer drawn twice as thick at 25% zoom than at 100%. Plain strokes are unchanged. Test: `render::tests::widthzoom`.