mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 12:27:37 +00:00
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.
This commit is contained in:
@@ -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<bool> {
|
||||
const C: &str = "stroke.set";
|
||||
let st = self.active()?;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<Box<dyn Tool>> {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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) };
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user