Add handle visualization during point insertion in the Path tool (#2197)

* added_handle_overlays

* changed color to yellow

* Rename color parameter

* Change the color to blue

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0SlowPoke0
2025-01-15 10:39:41 +00:00
committed by GitHub
co-authored by Keavon Chambers
parent 0a496ee452
commit 5aedda0ce8
7 changed files with 37 additions and 15 deletions
@@ -116,6 +116,20 @@ impl ClosestSegment {
(stroke_width_sq + tolerance_sq) < dist_sq
}
pub fn handle_positions(&self, document_metadata: &DocumentMetadata) -> (Option<DVec2>, Option<DVec2>) {
// Transform to viewport space
let transform = document_metadata.transform_to_viewport(self.layer);
// Split the Bezier at the parameter `t`
let [first, second] = self.bezier.split(TValue::Parametric(self.t));
// Transform the handle positions to viewport space
let first_handle = first.handle_end().map(|handle| transform.transform_point2(handle));
let second_handle = second.handle_start().map(|handle| transform.transform_point2(handle));
(first_handle, second_handle)
}
pub fn adjusted_insert(&self, responses: &mut VecDeque<Message>) -> PointId {
let layer = self.layer;
let [first, second] = self.bezier.split(TValue::Parametric(self.t));
@@ -461,10 +461,10 @@ impl SnapManager {
overlay_context.line(viewport, target, None);
}
for &target in align.iter().flatten() {
overlay_context.manipulator_handle(target, false);
overlay_context.manipulator_handle(target, false, None);
}
if any_align {
overlay_context.manipulator_handle(viewport, false);
overlay_context.manipulator_handle(viewport, false, None);
}
if !any_align && ind.distribution_equal_distance_x.is_none() && ind.distribution_equal_distance_y.is_none() {