mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-20 17:37:10 +01:00
Transform: Rectangle Properties corner edits send the rectangles as one ids list
The Corner menus and the unlinked Corner Radius fields sent one object.setLiveShape item per selected live rectangle, each with the same corners, and the command looks each id up in that list, so an edit took time quadratic in the number of selected rectangles. They now send the rectangles as ids with one shared corners list. With no live rectangle selected the edit leaves the document and its undo history as they are. The Properties panel test for a Direct-Selected rectangle corner now expects the Rectangle Properties Corner menu once.
This commit is contained in:
1 parent
21cd8069e7
commit
db6e491c56
4 files changed
+25
-7
No files matched your search
@@ -140,16 +140,17 @@ fn set_rectangle_kinds(app: &mut VectorcraftApp, kind: CornerKind, corner: Optio
|
||||
/// None) of each selected live rectangle, leaving other selected objects as they are: one undo
|
||||
/// step, or none when nothing changes.
|
||||
fn set_rectangle_corners(app: &mut VectorcraftApp, mut p: Value, corner: Option<usize>) {
|
||||
let corners = corner.map_or(json!([0, 1, 2, 3]), |k| json!([k]));
|
||||
p["corners"] = corner.map_or(json!([0, 1, 2, 3]), |k| json!([k]));
|
||||
match app.session.active() {
|
||||
// The command refuses the selection, with its message, while part of a symbol's art is
|
||||
// selected.
|
||||
Some(st) if st.selection.symbol_part.is_some() => p["corners"] = corners,
|
||||
Some(st) if st.selection.symbol_part.is_some() => {}
|
||||
// The selected live rectangles as `ids`, all sharing `corners`.
|
||||
Some(st) => {
|
||||
let is_rectangle = |n: &Node| matches!(&n.kind, NodeKind::Path { live: Some(l), .. } if matches!(**l, LiveShape::Rectangle { .. }));
|
||||
let rectangle = |id: &&NodeId| st.doc.node(**id).is_some_and(is_rectangle);
|
||||
let items: Vec<Value> = st.selection.objects.iter().filter(rectangle).map(|id| json!({"id": id.0, "corners": corners})).collect();
|
||||
p["items"] = json!(items);
|
||||
let ids: Vec<u64> = st.selection.objects.iter().filter(rectangle).map(|id| id.0).collect();
|
||||
p["ids"] = json!(ids);
|
||||
}
|
||||
None => return,
|
||||
}
|
||||
|
||||
@@ -1555,11 +1555,11 @@ fn direct_selected_corners_show_their_kind_and_radius() {
|
||||
// The whole path selected.
|
||||
app.run("select.set", json!({"ids": [star]})).unwrap();
|
||||
assert!(!shows(&tall(&mut app, &ctx, vec![]), "Corner:"), "no corner selected");
|
||||
// A live rectangle's corner: its own Corner Radius row, once.
|
||||
// A live rectangle's corner: its own Corner Radius row and Corner menu, once each.
|
||||
let r = rect(&mut app, 20.0, 20.0, 60.0, 40.0).as_u64().unwrap();
|
||||
app.run("select.anchors", json!({"id": r, "anchors": [[0, 1]], "mode": "set"})).unwrap();
|
||||
let texts = tall(&mut app, &ctx, vec![]);
|
||||
assert!(!shows(&texts, "Corner:"), "{texts:?}");
|
||||
assert_eq!(texts.iter().filter(|(t, _)| t == "Corner:").count(), 1, "{texts:?}");
|
||||
assert_eq!(texts.iter().filter(|(t, _)| t == "Corner Radius:").count(), 1, "{texts:?}");
|
||||
}
|
||||
|
||||
|
||||
@@ -167,6 +167,23 @@ fn a_rectangle_shows_linked_and_unlinked_corner_types() {
|
||||
}
|
||||
}
|
||||
|
||||
/// A corner kind set with no live rectangle selected leaves the selected polygon, the document and
|
||||
/// its undo history as they are.
|
||||
#[test]
|
||||
fn a_rectangle_corner_kind_without_a_selected_rectangle_changes_nothing() {
|
||||
use vectorcraft_geom::shapes::CornerKind::Chamfer;
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 300})).unwrap();
|
||||
app.run("shape.polygon", json!({"cx": 150, "cy": 150, "radius": 40, "sides": 6})).unwrap();
|
||||
let st = app.session.active().unwrap();
|
||||
let (before, steps) = (st.doc.clone(), st.history.undo.len());
|
||||
crate::panels::set_rectangle_kinds(&mut app, Chamfer, None);
|
||||
crate::panels::set_rectangle_kinds(&mut app, Chamfer, Some(2));
|
||||
let st = app.session.active().unwrap();
|
||||
assert!(st.doc == before, "the document changed");
|
||||
assert_eq!(st.history.undo.len(), steps);
|
||||
}
|
||||
|
||||
/// #3451: a live ellipse shows pie start/end angles and Invert Pie in the Transform panel and
|
||||
/// the Properties panel's Transform section; typed angles update the shape.
|
||||
#[test]
|
||||
|
||||
@@ -1322,7 +1322,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
With Direct Selection, Shift pressed during the drag of a curved segment keeps both of its handles at right angles to the line between its anchors, on the same side and at the same length (`path.reshapeSegment {perpendicular}`). Shift held while any segment is dragged with the Anchor Point tool or the Pen with Alt does the same. With the Anchor Point tool, Shift held at the press on an anchor (or a selected blend's spine point) moves it, handles and all, instead of pulling out handles; Shift kept down keeps the move at 45° steps, and a Shift-click that doesn't move leaves the anchor as it was (`path.moveAnchor`). A selected blend spine's segment dragged with the Anchor Point tool, or a curved one dragged with Direct Selection, bends the same way (`object.blend.spine.reshapeSegment`).
|
||||
- **Live Corners:** drag a live rectangle's corner widgets (Selection or Direct Selection) to round all corners, with a radius readout; with Direct Selection, select corner anchors to show and round just those corners (#381). Each corner keeps its own radius and kind (Round, Inverted Round, Chamfer): Alt-click a widget to cycle the kind, double-click it for the Corners dialog, and the Properties and Transform radius fields set the selected corners (`object.setLiveShape {corners, radius, kind}`). A link toggle behind Corner Radius (the `singleCornerRadius` preference) switches the panels to a field for each corner of a live rectangle: Top Left, Top Right, Bottom Right and Bottom Left. Corners stay circular when the rectangle is scaled unevenly or along its own sides when rotated (the radius keeps its size, or scales by the mean scale with Scale Corners on); only a shear distorts them. On a rectangle that isn't square every corner is the same circle: a radius past half the shorter side stops there for all of them, the widgets sit on the corners as drawn and turn the edited corners red at that limit, CSS export writes the drawn radii, and rectangles saved stretched by older versions get circular corners when their corners are next set (#442). Live Corners work on any path's corners too, as on a rectangle's (#511): a star's, a live polygon's (which also shows them to the Selection tool, has a Corner Radius field in the Properties and Transform panels and keeps its radius as its sides change) and a pen path's, wherever two sides meet at an angle at an anchor that isn't smooth: curved sides too, trimmed to what the cut leaves of them (#1144). Direct Selection shows the widgets of every corner, or of the corners holding selected anchors; each corner is a circle tangent to both sides, drawn no larger than takes its cut halfway along its shorter side; a path keeps its uncut outline so its corners stay editable, and the same command, dialog, angle preference and View › Hide Corner Widget apply. With Direct Selection a click on a widget (no drag) selects its corner, as a click on the corner's anchor does, so the next drag on it rounds that corner alone; Shift-click toggles it (#1239). While a corner widget is dragged with the Selection tool the bounding box hides, so the rounding shows against the path alone (#1229). A round corner next to a curved side curves smoothly instead of sticking out of the shape (#1547, fixes #1512).
|
||||
View › Hide Edges hides the Live Corners widgets, the bounding box and the type widget, and the selection tools then do not answer a press on them or change the cursor over them.
|
||||
- **Rectangle Properties corner type:** a live rectangle's Rectangle Properties (Transform panel, the Properties panel's Transform section and the Contextual Task Bar's Shape Properties) have a Corner menu with Round, Inverted Round and Chamfer. With Corner Radius linked, one menu sets the kind of every corner of each selected rectangle, also corners with no radius, and shows blank when the shown rectangle's kinds differ; unlinked, each corner's row has its own menu beside its radius field, or under it in a panel too narrow for both; the unlinked radius fields and menus leave other selected paths and polygons as they are. A pick is one undo step, and picking the kind the corners already have adds none (`object.setLiveShape {kind, items}`). The help page says a rectangle's corner type can be set for each corner or for all of them at once ([the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/live-shape-properties.html)); tying the number of menus to the Corner Radius link, the blank value and the undo steps are VectorCraft's own rules (`a_rectangle_shows_linked_and_unlinked_corner_types`, `the_shape_properties_popup_changes_a_rectangle_corner_type`, `the_linked_corner_menu_sets_every_selected_rectangle`, `the_unlinked_corner_menus_fit_a_narrow_panel`, `an_unlinked_corner_radius_leaves_other_selected_shapes`, `rectangle_kind_menu_targets_all_or_one_corner_and_skips_noop_undo`).
|
||||
- **Rectangle Properties corner type:** a live rectangle's Rectangle Properties (Transform panel, the Properties panel's Transform section and the Contextual Task Bar's Shape Properties) have a Corner menu with Round, Inverted Round and Chamfer. With Corner Radius linked, one menu sets the kind of every corner of each selected rectangle, also corners with no radius, and shows blank when the shown rectangle's kinds differ; unlinked, each corner's row has its own menu beside its radius field, or under it in a panel too narrow for both; the unlinked radius fields and menus leave other selected paths and polygons as they are. A pick is one undo step, and picking the kind the corners already have adds none (`object.setLiveShape {kind, ids, corners}`). The help page says a rectangle's corner type can be set for each corner or for all of them at once ([the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-live-shapes/live-shape-properties.html)); tying the number of menus to the Corner Radius link, the blank value and the undo steps are VectorCraft's own rules (`a_rectangle_shows_linked_and_unlinked_corner_types`, `the_shape_properties_popup_changes_a_rectangle_corner_type`, `the_linked_corner_menu_sets_every_selected_rectangle`, `the_unlinked_corner_menus_fit_a_narrow_panel`, `an_unlinked_corner_radius_leaves_other_selected_shapes`, `a_rectangle_corner_kind_without_a_selected_rectangle_changes_nothing`, `rectangle_kind_menu_targets_all_or_one_corner_and_skips_noop_undo`).
|
||||
- **Blend spine Anchor Point tool (#2544):** on a selected blend, dragging a spine corner makes symmetric Smooth handles; the tool displays and picks existing spine handles when switched to, drags one independently or retracts it on click, and clicking a point with handles retracts both. The spine is edited live without moving its key objects. Windows native canvas checks and screenshots reviewed: symmetric and independent handles, corner/retraction, Shift constraints and perpendicular reshaping, tool switching, key preservation, Undo/Redo, save/reopen, hidden handles and overlapping Path/Blend priority (PR #2643). Behaviour reference: [public path-editing documentation](https://helpx.adobe.com/illustrator/using/adjust-path-segments.html).
|
||||
- **Blend spine points by marquee:** with Direct Selection, a marquee picks the spine points inside it on a selected blend, the topmost one when several are selected, and the picked points drag together as Shift-clicked ones do; Shift-marquee adds points or takes picked ones away, a plain marquee around none of them drops the picks, and Escape during the marquee keeps them. Unselected, locked and hidden blends are skipped. The spine's points are anchor points edited with Direct Selection ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/modify-spine-of-blended-objects.html)), and a boundary drag with the tool selects anchor points ([the help page](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/modify-paths/select-anchor-points-in-paths.html)); the rules for selected, topmost and Shift are VectorCraft's own (`crates/tools/src/direct/tests.rs`, `marquee_picks_selected_blend_spine_points_which_drag_together`, `shift_marquee_toggles_selected_blend_spine_points`, `marquee_skips_unselected_locked_and_hidden_blend_spines`, `escape_cancels_a_marquee_and_keeps_the_picked_spine_points`).
|
||||
- **Blend steps of brushed strokes:** the steps interpolate the pen pressure, tilt, bearing and rotation recorded with the Paintbrush, so a Calligraphic, Scatter or Art brush that varies with the pen changes gradually from one key to the next. A key without a recording counts as half pressure, half tilt and 0°, as brushes read it, and angles turn the shorter way round. When the blend starts a key's path at another anchor (an open path run from its end, a closed one turned to another start), the key's recordings, width profile, arrowheads, dashes and a gradient along or across the stroke turn with the path. Different brushes still switch halfway (VectorCraft's own rule; strokes blend their options, as [Blended objects overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blended-objects-overview.html) describes; `crates/doc/src/blend.rs`, `pen_pressure_tilt_and_angles_interpolate_for_brushes`, `stroke_profiles_turn_with_a_key_path_started_elsewhere`, `stroke_gradients_and_dashes_turn_with_a_key_path_started_elsewhere`).
|
||||
|
||||
Reference in new issue
Block a user