mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 12:38:18 +00:00
Reflect tool: Enter or a dropped press ends a press not yet a drag
Enter between the press and the release of a click now ends that press, so the release sets no reference point and starts no Reflect axis behind the dialog. A press the engine drops ends whether or not it became a drag, and drops a waiting axis, so the release sent after it starts no axis. A press whose document or selection changes before it becomes a drag is dropped, so the reference point or axis set for one selection is never applied to another. The engine test checks that the Alt copy is reflected across y = 300. The docs state that the first click is a plain click, that the 3 px check compares the snapped points, and what a double-click does while an axis waits.
This commit is contained in:
@@ -506,6 +506,10 @@ fn two_reflect_clicks_reflect_across_their_line_as_one_undo_step() {
|
||||
click(&mut s, 350.0, 300.0, true);
|
||||
assert_eq!(children(&s), 2);
|
||||
assert!(close(bounds(&s, a), Rect::new(100.0, 100.0, 200.0, 150.0)));
|
||||
// The copy is selected and reflected across y = 300.
|
||||
let copy = s.doc().unwrap().selection.objects.clone();
|
||||
assert!(copy.len() == 1 && copy[0] != a, "{copy:?}");
|
||||
assert!(close(bounds(&s, copy[0]), Rect::new(100.0, 450.0, 200.0, 500.0)), "{:?}", bounds(&s, copy[0]));
|
||||
assert_eq!(undo_len(&s), n + 1);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert_eq!(children(&s), 1);
|
||||
|
||||
@@ -87,6 +87,9 @@ struct Drag {
|
||||
pointer: Point,
|
||||
shift: bool,
|
||||
last: Affine,
|
||||
/// The document revision at the press: a press whose document or selection changes before it
|
||||
/// becomes a drag is dropped, so its reference point is never applied to other objects.
|
||||
revision: (u64, u64),
|
||||
}
|
||||
|
||||
impl Drag {
|
||||
@@ -350,6 +353,7 @@ impl Tool for TransformTool {
|
||||
pointer: p,
|
||||
shift: false,
|
||||
last: Affine::IDENTITY,
|
||||
revision: cx.revision,
|
||||
});
|
||||
vec![]
|
||||
}
|
||||
@@ -360,6 +364,12 @@ impl Tool for TransformTool {
|
||||
if p.distance(d.start) < cx.tol(3.0) {
|
||||
return out;
|
||||
}
|
||||
// The document or the selection changed since the press: its reference point
|
||||
// (or Reflect axis) belongs to the selection as it was, so the press is dropped.
|
||||
if d.revision != cx.revision {
|
||||
self.end_drag();
|
||||
return out;
|
||||
}
|
||||
d.began = true;
|
||||
// The selection moves, so only the other objects are targets. The Scale tool's
|
||||
// drag scales; the others move the art about the reference point.
|
||||
@@ -460,7 +470,12 @@ impl Tool for TransformTool {
|
||||
self.drop_axis();
|
||||
vec![]
|
||||
}
|
||||
// Enter opens the dialog. A press not yet a drag ends with it, so its release sets no
|
||||
// reference point or Reflect axis behind the dialog.
|
||||
ToolKey::Enter => {
|
||||
if !self.busy() {
|
||||
self.end_drag();
|
||||
}
|
||||
self.drop_axis();
|
||||
self.reference_point(cx).map(|o| vec![self.dialog(o)]).unwrap_or_default()
|
||||
}
|
||||
@@ -468,6 +483,14 @@ impl Tool for TransformTool {
|
||||
}
|
||||
}
|
||||
|
||||
/// A dropped press ends whether or not it became a drag, so the release the engine sends after
|
||||
/// it sets no reference point or Reflect axis; a Reflect axis waiting for its second point is
|
||||
/// dropped too, as with Escape.
|
||||
fn drop_press(&mut self, _cx: &ToolContext) -> Vec<Action> {
|
||||
self.drop_axis();
|
||||
if self.end_drag().is_some_and(|d| d.began) { vec![Action::Cancel] } else { vec![] }
|
||||
}
|
||||
|
||||
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
|
||||
let mut o = vec![];
|
||||
let reference = match self.drag {
|
||||
@@ -998,6 +1021,60 @@ mod tests {
|
||||
assert!(click(&mut t, &c, 200.0, 200.0, none).is_empty());
|
||||
}
|
||||
|
||||
/// Enter between the press and the release of the second click opens the dialog at the first
|
||||
/// point and ends the press: the release sets no point and starts no axis. A press the engine
|
||||
/// drops ends the same way, with or without an axis waiting, and a dropped drag is canceled. A
|
||||
/// press whose document or selection changes before it becomes a drag is dropped.
|
||||
#[test]
|
||||
fn enter_or_a_dropped_press_during_a_reflect_click_ends_that_press() {
|
||||
let (d, id) = doc_with_rect();
|
||||
let mut s = Selection::default();
|
||||
s.add(id);
|
||||
let p = paint();
|
||||
let mut c = cx(&d, &s, &p);
|
||||
(c.smart_guides, c.snap_to_point) = (false, false);
|
||||
let none = Mods::default();
|
||||
let first = Point::new(100.0, 100.0);
|
||||
let mut t = TransformTool::new(TransformKind::Reflect);
|
||||
assert!(click(&mut t, &c, 100.0, 100.0, none).is_empty());
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Down, 200.0, 200.0)).is_empty());
|
||||
assert_eq!(t.key(&c, ToolKey::Enter, none), vec![Action::Dialog("reflect".into(), json!({"axis": "vertical", "origin": [100.0, 100.0]}))]);
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Up, 200.0, 200.0)).is_empty());
|
||||
assert!(!t.ends_on_escape(&c));
|
||||
assert_eq!(t.reference_point(&c), Some(first));
|
||||
|
||||
// A dropped first press: its release sets no point and starts no axis.
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Down, 200.0, 200.0)).is_empty());
|
||||
assert!(t.drop_press(&c).is_empty());
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Up, 200.0, 200.0)).is_empty());
|
||||
assert!(!t.ends_on_escape(&c));
|
||||
assert_eq!(t.reference_point(&c), Some(first));
|
||||
// A dropped second press drops the axis too, so the next click is a first click.
|
||||
assert!(click(&mut t, &c, 100.0, 100.0, none).is_empty());
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Down, 200.0, 200.0)).is_empty());
|
||||
assert!(t.drop_press(&c).is_empty());
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Up, 200.0, 200.0)).is_empty());
|
||||
assert!(!t.ends_on_escape(&c));
|
||||
assert!(click(&mut t, &c, 150.0, 300.0, none).is_empty());
|
||||
// A dropped drag is canceled, and its release commits nothing.
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Down, 300.0, 300.0)).is_empty());
|
||||
assert_eq!(t.pointer(&c, &ev(PointerKind::Drag, 100.0, 250.0))[0], Action::Begin("Reflect".into()));
|
||||
assert_eq!(t.drop_press(&c), vec![Action::Cancel]);
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Up, 100.0, 250.0)).is_empty());
|
||||
assert!(!t.ends_on_escape(&c));
|
||||
|
||||
// The selection changes between the press and the first drag event: the press is dropped,
|
||||
// and neither the drag nor its release transforms anything.
|
||||
assert!(click(&mut t, &c, 100.0, 100.0, none).is_empty());
|
||||
assert!(t.pointer(&c, &ev(PointerKind::Down, 200.0, 200.0)).is_empty());
|
||||
let mut moved = cx(&d, &s, &p);
|
||||
(moved.smart_guides, moved.snap_to_point) = (false, false);
|
||||
moved.revision = (c.revision.0, c.revision.1 + 1);
|
||||
assert!(t.pointer(&moved, &ev(PointerKind::Drag, 100.0, 250.0)).is_empty());
|
||||
assert!(!t.busy());
|
||||
assert!(t.pointer(&moved, &ev(PointerKind::Up, 100.0, 250.0)).is_empty());
|
||||
}
|
||||
|
||||
/// After a click sets the first point, a drag draws the axis from it (Shift in 45° steps from a
|
||||
/// turned box), and its release uses the axis up. With the selection turned, two clicks still
|
||||
/// reflect across the line through the clicked points on the page.
|
||||
|
||||
+5
-4
@@ -6883,10 +6883,11 @@ records the `basis` used, so a recorded action replays in the same frame; a save
|
||||
journal entry recorded before it) plays along the page's axes, as it did when it was recorded. `object.transformAgain` repeats the transform's page matrix, also after Reset Bounding Box. The Scale
|
||||
and Reflect dialogs, the Transform and Properties panels' flips, the Scale tool and the Reflect tool's default axis
|
||||
and Shift steps follow the box the same way; a Reflect axis drawn with the tool is the line drawn on the page.
|
||||
With the Reflect tool, a click (a `pointer_gesture` `down` and `up`) sets the first point of an axis, and a second
|
||||
click reflects the selection across the line through both points as one `object.transform` and one undo step. With
|
||||
Alt held when the second click is released, the transform has `copy: true` and reflects a copy. A second click within 3 px of the
|
||||
first point does nothing.
|
||||
With the Reflect tool, a plain click (a `pointer_gesture` `down` and `up` without Alt) sets the first point of an axis, and a second
|
||||
click reflects the selection across the line through both points as one `object.transform` and one undo step. An
|
||||
Alt-click opens the Reflect dialog and sets no axis, so the plain click after it sets a first point. With
|
||||
Alt held when the second click is released, the transform has `copy: true` and reflects a copy. A second click whose snapped
|
||||
point is within 3 screen pixels of the first point's snapped point does nothing.
|
||||
|
||||
```json
|
||||
{"name":"run_command","arguments":{"command":"object.scale","params":{"sx":200,"sy":100}}}
|
||||
|
||||
@@ -1118,7 +1118,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- Object › Transform › Rotate Bounding Box… turns the selection's bounding box by the angle typed in its dialog without moving the art (`object.rotateBoundingBox`, `absolute: true` to set the angle). Objects with different angles get one shared angle, and the objects inside a group and the art of a linked opacity mask turn with it. A path of a compound path selected on its own turns only its own box, and Reset Bounding Box squares only that path's box too (VectorCraft's own behavior; `bboxrotate::rotate_bounding_box_turns_the_box_and_leaves_the_art`, `rotate_bounding_box_back_to_zero_stores_zero`, `rotate_bounding_box_gives_a_mixed_selection_one_angle`, `rotate_bounding_box_turns_the_objects_inside_a_group_with_it`, `rotate_bounding_box_turns_a_linked_masks_art_only`, `reset_bounding_box_squares_every_box_rotate_bounding_box_turned`, `rotate_bounding_box_refuses_bad_params`, `tests::rotate_bounding_box_of_a_compound_paths_member_turns_only_that_path`, ui-egui `panels::transform::tests::rotate_bounding_box_menu_item_turns_the_box_by_the_dialog_angle`).
|
||||
- After a rotation the Free Transform tool shows and drags the same turned bounding box as the Selection tool: its handles, their cursors and its rotate zone sit on the selection's own sides, a handle scales along those sides from the opposite handle ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/scale-objects.html)), Cmd/Ctrl on a side handle shears along that side, and Perspective Distort and Free Distort start from the turned box's corners (`object.distort` takes `angle` with `from`) (`bboxrotate::free_transform_handles_turn_with_the_object_and_scale_along_its_axes`, `free_transform_shears_along_the_turned_side`, `free_transform_distort_starts_from_the_turned_box`, `xform::distort_reads_from_in_a_turned_frame_and_rejects_a_bad_angle`, tools `xform::free::tests::the_box_and_its_handles_turn_with_the_selection`).
|
||||
- After a rotation the Scale and Reflect tools, the Scale and Reflect dialogs, `object.scale`, `object.reflect` with a named axis and the Transform and Properties panels' flips act along the selection's turned bounding box until Reset Bounding Box: the horizontal and vertical scale stretch along its own width and height, and the vertical and horizontal reflection axes are its own. The Reflect tool's default axis and its Shift steps start from the box's axes, and an axis drawn with the tool is the line drawn on the page. `basis: "page"` keeps the page's axes (VectorCraft's own rules; `bboxrotate::scale_and_reflect_follow_the_turned_box`, tools `xform::transform::tests::scale_and_reflect_drags_follow_a_turned_bounding_box`).
|
||||
- The Reflect tool sets an axis with two clicks: a click sets the first point (and the reference point), and a second click reflects the selection across the line through both points as one undo step; Alt/Option on the second click reflects a copy, and a drag after the first click draws the axis from it ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/reflect-or-flip-objects.html)). A dashed line runs from the first point to the pointer until the second click. VectorCraft's own rules: a second click within 3 px of the first point does nothing and the axis keeps waiting; Shift does not constrain a plain second click; Escape, Enter, a double-click, a changed selection, an edit made outside the tool or another tool drops the waiting axis (tools `xform::transform::tests::a_second_reflect_click_reflects_across_the_line_through_both_points` and the three tests after it; engine `xform::two_reflect_clicks_reflect_across_their_line_as_one_undo_step`).
|
||||
- The Reflect tool sets an axis with two clicks: a click sets the first point (and the reference point), and a second click reflects the selection across the line through both points as one undo step; Alt/Option on the second click reflects a copy, and a drag after the first click draws the axis from it ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/reflect-or-flip-objects.html)). A dashed line runs from the first point to the pointer until the second click. VectorCraft's own rules: an Alt-click opens the dialog and sets no axis; a second click whose snapped point is within 3 screen pixels of the first point's snapped point does nothing and the axis keeps waiting; Shift does not constrain a plain second click; Escape, Enter, a changed selection, an edit made outside the tool or another tool drops the waiting axis. A double-click arrives as two clicks: its first click is the second point, so a double-click away from the first point reflects the selection, and the double-click then opens the dialog with no axis waiting (tools `xform::transform::tests::a_second_reflect_click_reflects_across_the_line_through_both_points` and the four tests after it; engine `xform::two_reflect_clicks_reflect_across_their_line_as_one_undo_step`).
|
||||
- Perspective Distort and Free Distort (`object.distort`) turn each warped object's bounding box as the warp turns the object at its own center, the objects inside groups, compound paths and clip groups and the art of linked opacity masks included, so the next Selection or Free Transform drag uses the tilted box; Object › Transform › Reset Bounding Box squares it again, and corners left where they are add no undo step (VectorCraft's own rule; `bboxrotate::distort_turns_an_upright_box_with_the_warp_at_its_center`, `distort_turns_each_member_and_linked_mask_by_its_own_warp`, `mirrored_and_collapsing_distorts_keep_valid_angles`, `distort_angles_undo_redo_and_reopen_together`, `xform::unchanged_distort_records_no_history`).
|
||||
- The Free Transform widget's Constrain works in Free Distort as well as in Free Transform ([the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/free-transform-tool.html)). With Constrain on, or Shift held, a corner dragged in Free Distort moves only along the line through the opposite corner, in the box's own proportions, and the other three corners stay in place; on a turned box the line runs through the box's own corners. The line is VectorCraft's own rule. Cmd/Ctrl+Alt+Shift on a corner still drags in Perspective Distort, where Constrain stays unavailable (tools `xform::free::tests::free_distort_corner_keeps_to_its_diagonal_with_shift_or_constrain`, `shift_pressed_during_a_free_distort_drag_constrains_it`, `a_turned_box_is_constrained_along_its_own_diagonal`, `along_diagonal_of_a_degenerate_box`; engine `xform::free_transform_constrained_distort_keeps_the_corner_on_its_diagonal`; ui-egui `free_transform::tests::the_widget_sets_the_mode_and_a_corner_drag_then_distorts`).
|
||||
- With Smart Guides › Transform Tools on, a Free Transform shear (Cmd/Ctrl on a side handle) shows its angle next to the pointer, as the Shear tool does, and a handle drag that turns from a scale into a shear and back shows only the current operation's value ([the help page](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/smart-guides-options.html)). The angle's sign and its one decimal place are VectorCraft's own rule, the same as the Shear tool's label (tools `xform::free::tests::shear_drag_shows_its_angle_with_transform_tools_guides`, `a_handle_drag_that_changes_operation_relabels_it`).
|
||||
|
||||
+1
-1
@@ -301,7 +301,7 @@ tools, never checked side by side) isn't captured row by row.
|
||||
| Free Transform, Scale and Reflect along a rotated box | done | The Scale and Reflect tools, dialogs and commands and the Transform and Properties panels' flips act along the turned box until Reset Bounding Box; `basis: "page"` keeps the page's axes |
|
||||
| Free Transform widget: constrain, free distort, perspective distort; the key-held variants | done | |
|
||||
| Transform tools: click sets the reference point (snaps to anchors/centres), Alt-click opens the dialog, Alt-release copies | done | with anchors selected with Direct Selection, the tools, the dialogs and Move transform those anchors alone, about the centre of their box by default (#1408; the default point and whole-object copies are our choices) |
|
||||
| Reflect tool: a second click reflects across the line through both clicked points; Alt on it reflects a copy | done | [the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/reflect-or-flip-objects.html); one undo step; a second click within 3 px of the first, Escape or a changed selection leaves nothing reflected (our choices) |
|
||||
| Reflect tool: a second click reflects across the line through both clicked points; Alt on it reflects a copy | done | [the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/reflect-or-flip-objects.html); one undo step; a second click whose snapped point is within 3 screen pixels of the first one's, Escape or a changed selection leaves nothing reflected (our choices) |
|
||||
| Move, Rotate, Scale, Reflect and Shear dialogs: live Preview; Up/Down step angles and percentages by 1, Shift by 10 | done | #1412; Preview starts off (our choice: the public documentation gives no default), Move's as it was last confirmed; OK is one undo step and Transform Again repeats it |
|
||||
| Transform Again, Transform Each, Scale Strokes & Effects, Scale Corners | done | |
|
||||
| The Transform effect dialog previews valid typed scale, move, rotation, and Copies values while fields remain focused. Preview off defers the artwork change until OK; Cancel restores the original artwork. | done | `crates/ui-egui/src/panels/tests_appearance.rs` covers numeric input, sliders, artwork targets, preview, and undo. |
|
||||
|
||||
Reference in New Issue
Block a user