Overhaul Path Tool (#498)

* First pass cleanup omw to handles

* Handles dragging with anchors, handles still not draggable and some bugs

* Dragging single side of handle works, need to create mirror case

* In progress addition of improved anchor / handle representation

* partially working

* Handle dragging working for non-end points, normal anchor drag bugged

* Fixed corner cases, fixed anchors without handles bug

* Add snapping

* Change path tool selection by clicking on shape

* Fixed path close point being draggable

* Variable length handle, firstpass of alt to stop mirroring

* Alt improved, not done. Only update structures when needed. Added snapping for selected shapes

* Can now undo path edits

* Do not maintain angle between non-mirrored handles

* Replaced segment based overlay setup with anchor based setup

* Cleanup, handle angle comparison bug remains. Investigating.

* Added OverlayPooler. May closely associate overlays to VectorManipulatorAnchors instead.

* Moved anchor / segment creation logic out of document_message_handler

* Overlays are now managed by VectorManipulatorShapes

* Fixed inconsistent handle mirroring.

* Clearly shows which point you have selected

* Removed OverlayPooler system

* Added more comments

* Removed all clones of the vector structures. A little uglier but better.

* Resolved Text path initialization bug with a workaround.

* Cleaned up comments

* More comment cleanup

* Fixed issue with quad handle dragging unwanted behavior, renamed VectorShapeManipulator

* In progress refactor to allow multi-selection

* In progress dragging multiple points, selection works, transform still has issues

* Added Multiselect, major refactor

* Commented out progress for selection change, bug with hop back on multiple shapes

* Removed debug og

* Resolved issue with merge

* Minor cleanup, added a few comments

* Review changes

* Resolved unclear comment

* Fixed snap back for now

* Add todo comment for future snap back fix

* Working situations where curve paths do not close. Thanks for points it out  @pkupper

* Tweaked selection size

* Fix curve start point dragability, renames, cleanup

* Separated into multiple files, applied @TrueDoctor review feedback

* Resolved tests failing due to doc generation

* Re-added closed, added concept of distance mirroring

* Added shift distance mirroring, removed debounce from anchor

Co-authored-by: Keavon Chambers <keavon@keavon.com>
Thank you for the reviews @TrueDoctor and @pkupper
This commit is contained in:
Oliver Davies
2022-02-09 12:49:14 -08:00
committed by Keavon Chambers
parent 99bf6c496f
commit e51bb6b6c6
17 changed files with 1407 additions and 526 deletions
+13
View File
@@ -108,6 +108,19 @@ impl SnapHandler {
}
}
/// Add arbitrary snapping points
/// This should be called after start_snap
pub fn add_snap_points(&mut self, document_message_handler: &DocumentMessageHandler, snap_points: Vec<DVec2>) {
if document_message_handler.snapping_enabled {
let (mut x_targets, mut y_targets): (Vec<f64>, Vec<f64>) = snap_points.into_iter().map(|vec| vec.into()).unzip();
if let Some((new_x_targets, new_y_targets)) = &mut self.snap_targets {
x_targets.append(new_x_targets);
y_targets.append(new_y_targets);
self.snap_targets = Some((x_targets, y_targets));
}
}
}
/// Finds the closest snap from an array of layers to the specified snap targets in viewport coords.
/// Returns 0 for each axis that there is no snap less than the snap tolerance.
pub fn snap_layers(