mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-18 20:43:36 +00:00
Direct Selection: saved moves without interpolate keep their rigid handles
A journal entry or action step recorded before the preference existed has no `interpolate` key. On replay it now moves the handles as it did when it was recorded, instead of following the live preference. A command run directly still defaults to the preference, and an explicit value is still used as given.
This commit is contained in:
@@ -267,9 +267,11 @@ pub(crate) fn move_anchors(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
/// Interpolate Control Points: does a move of direct-selected anchors re-map the handles of the
|
||||
/// segments beside them (`interpolate` param, else General › Interpolate Control Points When
|
||||
/// Moving Anchors)? Noted in the journal, so a replay re-maps them alike whatever the preference
|
||||
/// is then.
|
||||
/// is then. A saved step without `interpolate` ([`Session::replay`]) was recorded before the
|
||||
/// preference existed, so it moves the handles as it did then, without re-mapping them.
|
||||
pub(crate) fn interpolates_handles(s: &mut Session, p: &Value, cmd: &str) -> Result<bool> {
|
||||
let on = switch_or(p, "interpolate", s.prefs.interpolate_control_points, cmd)?;
|
||||
let default = s.prefs.interpolate_control_points && !s.replaying();
|
||||
let on = switch_or(p, "interpolate", default, cmd)?;
|
||||
s.note_journal("interpolate", json!(on));
|
||||
Ok(on)
|
||||
}
|
||||
|
||||
@@ -263,6 +263,26 @@ fn a_replayed_move_re_maps_the_handles_as_it_did_whatever_the_preference_is_then
|
||||
assert_eq!(path_of(&s, id), moved);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_saved_step_without_interpolate_moves_the_handles_rigidly_whatever_the_preference() {
|
||||
// A step recorded before the preference existed has no `interpolate`; with the preference on,
|
||||
// it still plays as it did when it was recorded.
|
||||
for cmd in ["path.moveAnchors", "object.nudge", "object.move"] {
|
||||
let mut s = session();
|
||||
interpolate(&mut s, true);
|
||||
let id = curve(&mut s);
|
||||
select(&mut s, id, json!([[0, 0]]));
|
||||
s.replay(cmd, &json!({"dx": 1, "dy": 1})).unwrap();
|
||||
let (a, b) = (anchor(&s, id, 0), anchor(&s, id, 1));
|
||||
assert_ne!(a.p, Point::new(100.0, 100.0), "{cmd}: the anchor moves");
|
||||
assert_eq!((a.h_out.x - a.p.x, a.h_out.y - a.p.y), (50.0, 0.0), "{cmd}: the moved anchor's handle moves with it");
|
||||
assert_eq!(b.h_in, Point::new(250.0, 100.0), "{cmd}: the other end's handle stays");
|
||||
// Run directly, the same params follow the preference.
|
||||
s.execute(cmd, &json!({"dx": 1, "dy": 1})).unwrap();
|
||||
assert_ne!(anchor(&s, id, 1).h_in, Point::new(250.0, 100.0), "{cmd}: executed, the handles are re-mapped");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transform_again_keeps_the_setting_its_move_used() {
|
||||
let mut s = session();
|
||||
|
||||
+3
-1
@@ -6754,7 +6754,9 @@ The Selection & Anchor Display and General preferences apply to `pointer_gesture
|
||||
preference off. A smooth anchor keeps its handles in line: its re-mapped handle takes the new length and stays in
|
||||
line with the other handle, and when both of its handles were re-mapped they point along the mean of their
|
||||
directions. When the two point the same way, both move with the anchor as with the preference off. A retracted
|
||||
handle stays retracted. The value used joins the command's journal entry and Transform Again's options. Align and
|
||||
handle stays retracted. The value used joins the command's journal entry and Transform Again's options; a saved step
|
||||
without `interpolate` (an action or journal entry recorded before it) moves the handles as with the preference off,
|
||||
as it did when it was recorded. Align and
|
||||
Distribute, and the anchors of type paths and area type frames (`text.reshapePath`, `text.reshapeArea`), move as
|
||||
before. Off, the handles of a moved anchor move with it and the other handles stay where they are.
|
||||
- `hideCornerWidgetAbove` (177° by default): corners wider than this show no Live Corners widget (a rectangle's right
|
||||
|
||||
Reference in New Issue
Block a user