mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-13 13:52:34 +00:00
Rotation field: a relative edit turns a selected parent before its child (#2200 review)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium
This commit is contained in:
1 parent
7e68a5b891
commit
7e748d4af8
2 files changed
+24
-1
No files matched your search
@@ -485,6 +485,24 @@ fn the_rotation_field_shows_and_sets_the_rotation_on_the_page() {
|
||||
assert_eq!(undo_steps(&u), steps + 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_relative_rotation_edit_turns_a_selected_parent_before_its_child_whatever_the_selection_order() {
|
||||
let mut s = Session::new();
|
||||
let f = id(s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 400, "height": 400})).unwrap());
|
||||
let c = id(s.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 120, "height": 80, "parent": f})).unwrap());
|
||||
s.execute("node.set", &json!({"ids": [f], "props": {"rotation": 10}})).unwrap();
|
||||
s.execute("node.set", &json!({"ids": [c], "props": {"absoluteRotation": 30}})).unwrap();
|
||||
// The child first, then its parent.
|
||||
s.execute("select.set", &json!({"ids": [c, f]})).unwrap();
|
||||
let mut u = Ui::new(s);
|
||||
u.ctx.enable_accesskit();
|
||||
u.frame(vec![]);
|
||||
let page = |u: &Ui, n: NodeId| figcraft_geom::rotation_degrees(u.app.session.doc().unwrap().world_transform(n));
|
||||
assert_eq!(field(&mut u, "Rotation").1, "Mixed");
|
||||
type_into(&mut u, "Rotation", "+10", Key::Enter);
|
||||
assert!((page(&u, f) - 20.0).abs() < 1e-6 && (page(&u, c) - 40.0).abs() < 1e-6, "{} {}", page(&u, f), page(&u, c));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn arithmetic_commits_tab_moves_on_and_escape_restores() {
|
||||
let (mut u, a, _) = setup();
|
||||
|
||||
@@ -75,7 +75,12 @@ impl FigApp {
|
||||
None => return,
|
||||
};
|
||||
let Ok(doc) = self.session.doc() else { return };
|
||||
let values: Vec<(NodeId, f64)> = ids.iter().filter_map(|i| Some((*i, rel.apply(shown(doc.node(*i)?))?))).collect();
|
||||
let mut values: Vec<(NodeId, f64)> = ids.iter().filter_map(|i| Some((*i, rel.apply(shown(doc.node(*i)?))?))).collect();
|
||||
if key == "absoluteRotation" {
|
||||
// A page angle depends on the parents': turn a selected parent before the layers in it
|
||||
// (as `node.set` orders a multi-id call), whatever order the selection is in.
|
||||
values.sort_by_key(|(i, _)| doc.ancestors(*i).len());
|
||||
}
|
||||
if values.is_empty() || self.session.begin_interaction("Edit").is_err() {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user