Layer and grid snapping systems (#1521)

* Grid overlays

* Rectangle tool basic snapping

* Fix bezier demos

* Fix bézier crate tests

* Constrained snapping for circle & shape tool

* Line tool snapping

* Pen tool snapping

* Path tool snapping

* Snapping whilst dragging layers (not constrained)

* Constrained drag

* Resize snapping

* Normal and tangent

* Cleanup

* Grid snapping

* Grid snapping

* Fix imports

* Fix bug in artboard tool

* Fix hang on 0 size grid spacing

* Fix NaN when scaling

* Polishing

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2024-01-13 14:32:10 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent 78a1bb17cd
commit 456ca170a4
40 changed files with 2170 additions and 475 deletions
@@ -146,7 +146,7 @@ pub fn default_mapping() -> Mapping {
entry!(KeyUp(Lmb); action_dispatch=RectangleToolMessage::DragStop),
entry!(KeyDown(Rmb); action_dispatch=RectangleToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=RectangleToolMessage::Abort),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=RectangleToolMessage::Resize { center: Alt, lock_ratio: Shift }),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=RectangleToolMessage::PointerMove { center: Alt, lock_ratio: Shift }),
//
// ImaginateToolMessage
entry!(KeyDown(Lmb); action_dispatch=ImaginateToolMessage::DragStart),
@@ -160,21 +160,21 @@ pub fn default_mapping() -> Mapping {
entry!(KeyUp(Lmb); action_dispatch=EllipseToolMessage::DragStop),
entry!(KeyDown(Rmb); action_dispatch=EllipseToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=EllipseToolMessage::Abort),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=EllipseToolMessage::Resize { center: Alt, lock_ratio: Shift }),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=EllipseToolMessage::PointerMove { center: Alt, lock_ratio: Shift }),
//
// PolygonToolMessage
entry!(KeyDown(Lmb); action_dispatch=PolygonToolMessage::DragStart),
entry!(KeyUp(Lmb); action_dispatch=PolygonToolMessage::DragStop),
entry!(KeyDown(Rmb); action_dispatch=PolygonToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=PolygonToolMessage::Abort),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=PolygonToolMessage::Resize { center: Alt, lock_ratio: Shift }),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=PolygonToolMessage::PointerMove { center: Alt, lock_ratio: Shift }),
//
// LineToolMessage
entry!(KeyDown(Lmb); action_dispatch=LineToolMessage::DragStart),
entry!(KeyUp(Lmb); action_dispatch=LineToolMessage::DragStop),
entry!(KeyDown(Rmb); action_dispatch=LineToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=LineToolMessage::Abort),
entry!(PointerMove; refresh_keys=[Alt, Shift, Control], action_dispatch=LineToolMessage::Redraw { center: Alt, lock_angle: Control, snap_angle: Shift }),
entry!(PointerMove; refresh_keys=[Alt, Shift, Control], action_dispatch=LineToolMessage::PointerMove { center: Alt, lock_angle: Control, snap_angle: Shift }),
//
// PathToolMessage
entry!(KeyDown(Lmb); action_dispatch=PathToolMessage::DragStart { add_to_selection: Shift }),