mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 22:35:26 +00:00
Place: the grid tool sends the gutter it previews
The preview's 6 pt duplicated place.grid's default, so changing one would leave the preview out of step with what lands. The tool now sends its gutter with the command.
This commit is contained in:
1 parent
92d3e74a39
commit
391e0881b4
2 files changed
+4
-3
No files matched your search
@@ -155,7 +155,7 @@ impl Tool for PlaceGun {
|
||||
if !grid_cells(r, self.columns, self.rows).is_empty() {
|
||||
return vec![Action::Exec(
|
||||
"place.grid".into(),
|
||||
json!({"spread": crate::spread_json(sr), "rect": [r.x0, r.y0, r.x1, r.y1], "columns": self.columns, "rows": self.rows}),
|
||||
json!({"spread": crate::spread_json(sr), "rect": [r.x0, r.y0, r.x1, r.y1], "columns": self.columns, "rows": self.rows, "gutter": PLACE_GRID_GUTTER}),
|
||||
)];
|
||||
}
|
||||
// The frame the drag drew: at the graphic's proportions from where it started.
|
||||
@@ -239,7 +239,8 @@ Y: {pct}"
|
||||
}
|
||||
}
|
||||
|
||||
/// The gutter between place-grid cells, in points: `place.grid`'s default.
|
||||
/// The gutter between place-grid cells, in points. The tool sends it with `place.grid`, so the
|
||||
/// preview and what lands can't disagree if the command's default changes.
|
||||
const PLACE_GRID_GUTTER: f64 = 6.0;
|
||||
|
||||
/// The cells of a `columns` × `rows` place grid drawn over `rect`, [`PLACE_GRID_GUTTER`] apart, as
|
||||
|
||||
@@ -2459,7 +2459,7 @@ fn place_gun_grid_preview_matches_the_release_on_a_rotated_spread() {
|
||||
assert_eq!(t.key(&cx, ToolKey::Right, Mods::default()), vec![Action::Handled]);
|
||||
let shown = t.overlays(&cx);
|
||||
let out = t.pointer(&cx, &PointerEvent::new(PointerKind::Up, end.x, end.y));
|
||||
assert!(matches!(out.as_slice(), [Action::Exec(cmd, p)] if cmd == "place.grid" && p["columns"] == 2), "{out:?}");
|
||||
assert!(matches!(out.as_slice(), [Action::Exec(cmd, p)] if cmd == "place.grid" && p["columns"] == 2 && p["gutter"] == 6.0), "{out:?}");
|
||||
// Two columns on the spread, 6 pt apart, each shown where its corners land on the canvas.
|
||||
let r = Rect::from_points(a, b);
|
||||
let w = (r.width() - 6.0) / 2.0;
|
||||
|
||||
Reference in new issue
Block a user