Snapping system improvements and refactor (#621)

* Snap to points and refactor

* Improve dot position on bounds

* Add snap matrix

* Cleanup

* Code review

* Half axis fade rather than increase it

* Fix fmt

* Hide snap to point overlay when active

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2022-05-09 04:13:57 +01:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 4b7d8b7ab0
commit e3e506ecfb
14 changed files with 303 additions and 183 deletions
@@ -18,15 +18,15 @@ pub struct Resize {
impl Resize {
/// Starts a resize, assigning the snap targets and snapping the starting position.
pub fn start(&mut self, responses: &mut VecDeque<Message>, viewport_bounds: DVec2, document: &DocumentMessageHandler, mouse_position: DVec2) {
pub fn start(&mut self, responses: &mut VecDeque<Message>, document: &DocumentMessageHandler, mouse_position: DVec2) {
self.snap_handler.start_snap(document, document.bounding_boxes(None, None), true, true);
self.drag_start = self.snap_handler.snap_position(responses, viewport_bounds, document, mouse_position);
self.snap_handler.add_all_document_handles(document, &[], &[]);
self.drag_start = self.snap_handler.snap_position(responses, document, mouse_position);
}
pub fn calculate_transform(
&mut self,
responses: &mut VecDeque<Message>,
viewport_bounds: DVec2,
document: &DocumentMessageHandler,
center: Key,
lock_ratio: Key,
@@ -35,7 +35,7 @@ impl Resize {
if let Some(path) = &self.path {
let mut start = self.drag_start;
let stop = self.snap_handler.snap_position(responses, viewport_bounds, document, ipp.mouse.position);
let stop = self.snap_handler.snap_position(responses, document, ipp.mouse.position);
let mut size = stop - start;
if ipp.keyboard.get(lock_ratio as usize) {