From 3e4a37583f161c10683377d1a904ec0e0bb36cf9 Mon Sep 17 00:00:00 2001 From: seam0s Date: Sun, 11 May 2025 21:01:29 +0300 Subject: [PATCH 1/7] Add hash sets to hold ignored points in SelectedLayerState --- .../tool/common_functionality/shape_editor.rs | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index 7fa761acdc..47161135cc 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -43,7 +43,9 @@ pub enum ManipulatorAngle { pub struct SelectedLayerState { selected_points: HashSet, ignore_handles: bool, + ignored_handle_points: HashSet, ignore_anchors: bool, + ignored_anchor_points: HashSet, } impl SelectedLayerState { @@ -54,33 +56,45 @@ impl SelectedLayerState { self.selected_points.contains(&point) } pub fn select_point(&mut self, point: ManipulatorPointId) { - if (point.as_handle().is_some() && self.ignore_handles) || (point.as_anchor().is_some() && self.ignore_anchors) { - return; + if point.as_handle().is_some() && self.ignore_handles { + self.ignored_handle_points.insert(point); + } else if point.as_anchor().is_some() && self.ignore_anchors { + self.ignored_anchor_points.insert(point); } self.selected_points.insert(point); } pub fn deselect_point(&mut self, point: ManipulatorPointId) { - if (point.as_handle().is_some() && self.ignore_handles) || (point.as_anchor().is_some() && self.ignore_anchors) { - return; + if point.as_handle().is_some() && self.ignore_handles { + self.ignored_handle_points.remove(&point); + } else if point.as_anchor().is_some() && self.ignore_anchors { + self.ignored_anchor_points.remove(&point); } self.selected_points.remove(&point); } pub fn set_handles_status(&mut self, ignore: bool) { self.ignore_handles = ignore; + + if ignore { + self.ignored_handle_points.extend(self.selected_points.iter().copied().filter(|point| point.as_handle().is_some())); + } else { + self.selected_points.extend(self.ignored_handle_points.iter().copied()); + self.ignored_handle_points.clear(); + } } pub fn set_anchors_status(&mut self, ignore: bool) { self.ignore_anchors = ignore; - } - pub fn clear_points_force(&mut self) { - self.selected_points.clear(); - self.ignore_handles = false; - self.ignore_anchors = false; + + if ignore { + self.ignored_anchor_points.extend(self.selected_points.iter().copied().filter(|point| point.as_anchor().is_some())); + } else { + self.selected_points.extend(self.ignored_anchor_points.iter().copied()); + self.ignored_anchor_points.clear(); + } } pub fn clear_points(&mut self) { - if self.ignore_handles || self.ignore_anchors { - return; - } self.selected_points.clear(); + self.ignored_handle_points.clear(); + self.ignored_anchor_points.clear(); } pub fn selected_points_count(&self) -> usize { self.selected_points.len() @@ -1563,7 +1577,7 @@ impl ShapeState { pub fn select_all_in_shape(&mut self, network_interface: &NodeNetworkInterface, selection_shape: SelectionShape, selection_change: SelectionChange) { for (&layer, state) in &mut self.selected_shape_state { if selection_change == SelectionChange::Clear { - state.clear_points_force() + state.clear_points() } let vector_data = network_interface.compute_modified_vector(layer); From f9932d320ee49be38a69e4af14800968dcc51e6d Mon Sep 17 00:00:00 2001 From: seam0s Date: Sun, 11 May 2025 22:28:28 +0300 Subject: [PATCH 2/7] Fix non selected anchor dragging --- .../tool/common_functionality/shape_editor.rs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index 47161135cc..a23ade7eaa 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -55,19 +55,24 @@ impl SelectedLayerState { pub fn is_selected(&self, point: ManipulatorPointId) -> bool { self.selected_points.contains(&point) } - pub fn select_point(&mut self, point: ManipulatorPointId) { + pub fn is_point_ignored(&mut self, point: ManipulatorPointId) -> bool { if point.as_handle().is_some() && self.ignore_handles { - self.ignored_handle_points.insert(point); + return true; } else if point.as_anchor().is_some() && self.ignore_anchors { - self.ignored_anchor_points.insert(point); + return true; + } else { + return false; + } + } + pub fn select_point(&mut self, point: ManipulatorPointId) { + if self.is_point_ignored(point) { + return; } self.selected_points.insert(point); } pub fn deselect_point(&mut self, point: ManipulatorPointId) { - if point.as_handle().is_some() && self.ignore_handles { - self.ignored_handle_points.remove(&point); - } else if point.as_anchor().is_some() && self.ignore_anchors { - self.ignored_anchor_points.remove(&point); + if self.is_point_ignored(point) { + return; } self.selected_points.remove(&point); } @@ -92,9 +97,10 @@ impl SelectedLayerState { } } pub fn clear_points(&mut self) { + if self.ignore_handles || self.ignore_anchors { + return; + } self.selected_points.clear(); - self.ignored_handle_points.clear(); - self.ignored_anchor_points.clear(); } pub fn selected_points_count(&self) -> usize { self.selected_points.len() @@ -519,8 +525,9 @@ impl ShapeState { } else { // Select all connected points while let Some(point) = selected_stack.pop() { - if !state.is_selected(ManipulatorPointId::Anchor(point)) { - state.select_point(ManipulatorPointId::Anchor(point)); + let anchor_point = ManipulatorPointId::Anchor(point); + if !state.is_selected(anchor_point) && !state.is_point_ignored(anchor_point) { + state.select_point(anchor_point); selected_stack.extend(vector_data.connected_points(point)); } } From 50c46d253fd5c1c539340ab895cc44f33d7f9969 Mon Sep 17 00:00:00 2001 From: seam0s Date: Mon, 12 May 2025 19:33:29 +0300 Subject: [PATCH 3/7] Update selected points when ignoring handles or anchors --- .../src/messages/tool/common_functionality/shape_editor.rs | 5 ++--- editor/src/messages/tool/tool_messages/path_tool.rs | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index a23ade7eaa..e752d3812c 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -81,6 +81,7 @@ impl SelectedLayerState { if ignore { self.ignored_handle_points.extend(self.selected_points.iter().copied().filter(|point| point.as_handle().is_some())); + self.selected_points.retain(|point| !self.ignored_handle_points.contains(point)); } else { self.selected_points.extend(self.ignored_handle_points.iter().copied()); self.ignored_handle_points.clear(); @@ -91,15 +92,13 @@ impl SelectedLayerState { if ignore { self.ignored_anchor_points.extend(self.selected_points.iter().copied().filter(|point| point.as_anchor().is_some())); + self.selected_points.retain(|point| !self.ignored_anchor_points.contains(point)); } else { self.selected_points.extend(self.ignored_anchor_points.iter().copied()); self.ignored_anchor_points.clear(); } } pub fn clear_points(&mut self) { - if self.ignore_handles || self.ignore_anchors { - return; - } self.selected_points.clear(); } pub fn selected_points_count(&self) -> usize { diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index 41e5f1f1c7..268ad17bae 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -962,11 +962,13 @@ impl Fsm for PathToolFsmState { (_, PathToolMessage::Overlays(mut overlay_context)) => { let display_anchors = overlay_context.visibility_settings.anchors(); let display_handles = overlay_context.visibility_settings.handles(); + if !display_handles { shape_editor.ignore_selected_handles(); } else { shape_editor.mark_selected_handles(); } + if !display_anchors { shape_editor.ignore_selected_anchors(); } else { @@ -974,7 +976,6 @@ impl Fsm for PathToolFsmState { } // TODO: find the segment ids of which the selected points are a part of - match tool_options.path_overlay_mode { PathOverlayMode::AllHandles => { path_overlays(document, DrawHandles::All, shape_editor, &mut overlay_context); From 606709ff02fc4a4d97989dbd984aa296d05d3bcc Mon Sep 17 00:00:00 2001 From: seam0s Date: Thu, 15 May 2025 10:56:23 +0300 Subject: [PATCH 4/7] Refactor selected points status logic --- .../tool/common_functionality/shape_editor.rs | 40 ++++++++----------- .../messages/tool/tool_messages/path_tool.rs | 22 +++++----- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index e752d3812c..fd5eac3ea0 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -55,7 +55,7 @@ impl SelectedLayerState { pub fn is_selected(&self, point: ManipulatorPointId) -> bool { self.selected_points.contains(&point) } - pub fn is_point_ignored(&mut self, point: ManipulatorPointId) -> bool { + pub fn is_point_ignored(&self, point: ManipulatorPointId) -> bool { if point.as_handle().is_some() && self.ignore_handles { return true; } else if point.as_anchor().is_some() && self.ignore_anchors { @@ -76,10 +76,13 @@ impl SelectedLayerState { } self.selected_points.remove(&point); } - pub fn set_handles_status(&mut self, ignore: bool) { - self.ignore_handles = ignore; + pub fn set_handles_status(&mut self, status: bool) { + if self.ignore_handles == !status { + return; + } + self.ignore_handles = !status; - if ignore { + if !status { self.ignored_handle_points.extend(self.selected_points.iter().copied().filter(|point| point.as_handle().is_some())); self.selected_points.retain(|point| !self.ignored_handle_points.contains(point)); } else { @@ -87,10 +90,13 @@ impl SelectedLayerState { self.ignored_handle_points.clear(); } } - pub fn set_anchors_status(&mut self, ignore: bool) { - self.ignore_anchors = ignore; + pub fn set_anchors_status(&mut self, status: bool) { + if self.ignore_anchors == !status { + return; + } + self.ignore_anchors = !status; - if ignore { + if !status { self.ignored_anchor_points.extend(self.selected_points.iter().copied().filter(|point| point.as_anchor().is_some())); self.selected_points.retain(|point| !self.ignored_anchor_points.contains(point)); } else { @@ -566,27 +572,15 @@ impl ShapeState { } } - pub fn mark_selected_anchors(&mut self) { - for state in self.selected_shape_state.values_mut() { - state.set_anchors_status(false); - } - } - - pub fn mark_selected_handles(&mut self) { - for state in self.selected_shape_state.values_mut() { - state.set_handles_status(false); - } - } - - pub fn ignore_selected_anchors(&mut self) { + pub fn update_selected_anchors_status(&mut self, status: bool) { for state in self.selected_shape_state.values_mut() { - state.set_anchors_status(true); + state.set_anchors_status(status); } } - pub fn ignore_selected_handles(&mut self) { + pub fn update_selected_handles_status(&mut self, status: bool) { for state in self.selected_shape_state.values_mut() { - state.set_handles_status(true); + state.set_handles_status(status); } } diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index 268ad17bae..d2948935f8 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -99,6 +99,9 @@ pub enum PathToolMessage { }, SwapSelectedHandles, UpdateOptions(PathOptionsUpdate), + UpdateSelectedPointsStatus { + overlay_context: OverlayContext, + }, } #[derive(PartialEq, Eq, Hash, Copy, Clone, Debug, Default, serde::Serialize, serde::Deserialize, specta::Type)] @@ -959,22 +962,16 @@ impl Fsm for PathToolFsmState { responses.add(PathToolMessage::SelectedPointUpdated); self } - (_, PathToolMessage::Overlays(mut overlay_context)) => { + (_, PathToolMessage::UpdateSelectedPointsStatus { overlay_context }) => { let display_anchors = overlay_context.visibility_settings.anchors(); let display_handles = overlay_context.visibility_settings.handles(); - if !display_handles { - shape_editor.ignore_selected_handles(); - } else { - shape_editor.mark_selected_handles(); - } - - if !display_anchors { - shape_editor.ignore_selected_anchors(); - } else { - shape_editor.mark_selected_anchors(); - } + shape_editor.update_selected_anchors_status(display_anchors); + shape_editor.update_selected_handles_status(display_handles); + self + } + (_, PathToolMessage::Overlays(mut overlay_context)) => { // TODO: find the segment ids of which the selected points are a part of match tool_options.path_overlay_mode { PathOverlayMode::AllHandles => { @@ -1099,6 +1096,7 @@ impl Fsm for PathToolFsmState { } } + responses.add(PathToolMessage::UpdateSelectedPointsStatus { overlay_context }); responses.add(PathToolMessage::SelectedPointUpdated); self } From 88c18c63ed553f734a9baac1f608558aa5dea08c Mon Sep 17 00:00:00 2001 From: seam0s Date: Fri, 16 May 2025 21:17:50 +0300 Subject: [PATCH 5/7] Refactor ignore_handles and ignore_anchors bools to ShapeState --- .../tool/common_functionality/shape_editor.rs | 57 ++++++++----------- .../messages/tool/tool_messages/path_tool.rs | 4 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index fd5eac3ea0..062ae45acf 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -42,9 +42,8 @@ pub enum ManipulatorAngle { #[derive(Clone, Debug, Default)] pub struct SelectedLayerState { selected_points: HashSet, - ignore_handles: bool, + /// Points that are selected but ignored (when their overlays are disabled) are stored here. ignored_handle_points: HashSet, - ignore_anchors: bool, ignored_anchor_points: HashSet, } @@ -55,33 +54,14 @@ impl SelectedLayerState { pub fn is_selected(&self, point: ManipulatorPointId) -> bool { self.selected_points.contains(&point) } - pub fn is_point_ignored(&self, point: ManipulatorPointId) -> bool { - if point.as_handle().is_some() && self.ignore_handles { - return true; - } else if point.as_anchor().is_some() && self.ignore_anchors { - return true; - } else { - return false; - } - } + pub fn select_point(&mut self, point: ManipulatorPointId) { - if self.is_point_ignored(point) { - return; - } self.selected_points.insert(point); } pub fn deselect_point(&mut self, point: ManipulatorPointId) { - if self.is_point_ignored(point) { - return; - } self.selected_points.remove(&point); } - pub fn set_handles_status(&mut self, status: bool) { - if self.ignore_handles == !status { - return; - } - self.ignore_handles = !status; - + pub fn ignore_handles(&mut self, status: bool) { if !status { self.ignored_handle_points.extend(self.selected_points.iter().copied().filter(|point| point.as_handle().is_some())); self.selected_points.retain(|point| !self.ignored_handle_points.contains(point)); @@ -90,12 +70,7 @@ impl SelectedLayerState { self.ignored_handle_points.clear(); } } - pub fn set_anchors_status(&mut self, status: bool) { - if self.ignore_anchors == !status { - return; - } - self.ignore_anchors = !status; - + pub fn ignore_anchors(&mut self, status: bool) { if !status { self.ignored_anchor_points.extend(self.selected_points.iter().copied().filter(|point| point.as_anchor().is_some())); self.selected_points.retain(|point| !self.ignored_anchor_points.contains(point)); @@ -118,6 +93,8 @@ pub type SelectedShapeState = HashMap; pub struct ShapeState { // The layers we can select and edit manipulators (anchors and handles) from pub selected_shape_state: SelectedShapeState, + ignore_handles: bool, + ignore_anchors: bool, } #[derive(Debug)] @@ -278,6 +255,16 @@ impl ClosestSegment { // TODO Consider keeping a list of selected manipulators to minimize traversals of the layers impl ShapeState { + pub fn is_point_ignored(&self, point: &ManipulatorPointId) -> bool { + if point.as_handle().is_some() && self.ignore_handles { + return true; + } else if point.as_anchor().is_some() && self.ignore_anchors { + return true; + } else { + return false; + } + } + pub fn close_selected_path(&self, document: &DocumentMessageHandler, responses: &mut VecDeque) { // First collect all selected anchor points across all layers let all_selected_points: Vec<(LayerNodeIdentifier, PointId)> = self @@ -531,7 +518,7 @@ impl ShapeState { // Select all connected points while let Some(point) = selected_stack.pop() { let anchor_point = ManipulatorPointId::Anchor(point); - if !state.is_selected(anchor_point) && !state.is_point_ignored(anchor_point) { + if !state.is_selected(anchor_point) { state.select_point(anchor_point); selected_stack.extend(vector_data.connected_points(point)); } @@ -574,13 +561,15 @@ impl ShapeState { pub fn update_selected_anchors_status(&mut self, status: bool) { for state in self.selected_shape_state.values_mut() { - state.set_anchors_status(status); + self.ignore_anchors = !status; + state.ignore_anchors(status); } } pub fn update_selected_handles_status(&mut self, status: bool) { for state in self.selected_shape_state.values_mut() { - state.set_handles_status(status); + self.ignore_handles = !status; + state.ignore_handles(status); } } @@ -687,6 +676,10 @@ impl ShapeState { layer: LayerNodeIdentifier, responses: &mut VecDeque, ) -> Option<()> { + if self.is_point_ignored(point) { + return None; + } + let vector_data = network_interface.compute_modified_vector(layer)?; let transform = network_interface.document_metadata().transform_to_document(layer).inverse(); let position = transform.transform_point2(new_position); diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index d2948935f8..5bf625818e 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -958,8 +958,6 @@ impl Fsm for PathToolFsmState { shape_editor.set_selected_layers(target_layers); responses.add(OverlaysMessage::Draw); - - responses.add(PathToolMessage::SelectedPointUpdated); self } (_, PathToolMessage::UpdateSelectedPointsStatus { overlay_context }) => { @@ -1096,8 +1094,8 @@ impl Fsm for PathToolFsmState { } } - responses.add(PathToolMessage::UpdateSelectedPointsStatus { overlay_context }); responses.add(PathToolMessage::SelectedPointUpdated); + responses.add(PathToolMessage::UpdateSelectedPointsStatus { overlay_context }); self } From c7c9dde6c3ec460677bb4d01d984a233099de1ca Mon Sep 17 00:00:00 2001 From: seam0s Date: Sat, 17 May 2025 11:50:29 +0300 Subject: [PATCH 6/7] Add back in ignore_anchors and ignore_handles in SelectedLayerState --- .../tool/common_functionality/shape_editor.rs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index 062ae45acf..5c463dee95 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -42,6 +42,9 @@ pub enum ManipulatorAngle { #[derive(Clone, Debug, Default)] pub struct SelectedLayerState { selected_points: HashSet, + /// Keeps track of the current state; helps avoid unnecessary computation when called by ShapeState + ignore_handles: bool, + ignore_anchors: bool, /// Points that are selected but ignored (when their overlays are disabled) are stored here. ignored_handle_points: HashSet, ignored_anchor_points: HashSet, @@ -62,7 +65,12 @@ impl SelectedLayerState { self.selected_points.remove(&point); } pub fn ignore_handles(&mut self, status: bool) { - if !status { + if self.ignore_handles == !status { + return; + } + + self.ignore_handles = !status; + if self.ignore_handles { self.ignored_handle_points.extend(self.selected_points.iter().copied().filter(|point| point.as_handle().is_some())); self.selected_points.retain(|point| !self.ignored_handle_points.contains(point)); } else { @@ -71,7 +79,12 @@ impl SelectedLayerState { } } pub fn ignore_anchors(&mut self, status: bool) { - if !status { + if self.ignore_anchors == !status { + return; + } + + self.ignore_anchors = !status; + if self.ignore_anchors { self.ignored_anchor_points.extend(self.selected_points.iter().copied().filter(|point| point.as_anchor().is_some())); self.selected_points.retain(|point| !self.ignored_anchor_points.contains(point)); } else { @@ -898,6 +911,10 @@ impl ShapeState { let delta = delta_transform.inverse().transform_vector2(delta); for &point in state.selected_points.iter() { + if self.is_point_ignored(&point) { + continue; + } + let handle = match point { ManipulatorPointId::Anchor(point) => { self.move_anchor(point, &vector_data, delta, layer, Some(state), responses); From 7cae9372008d9d08e6694ed3501157aceb903285 Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sun, 18 May 2025 13:50:26 -0700 Subject: [PATCH 7/7] Code review --- .../tool/common_functionality/shape_editor.rs | 20 ++++++++++--------- .../messages/tool/tool_messages/path_tool.rs | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/shape_editor.rs b/editor/src/messages/tool/common_functionality/shape_editor.rs index 98349be57f..39053e93ac 100644 --- a/editor/src/messages/tool/common_functionality/shape_editor.rs +++ b/editor/src/messages/tool/common_functionality/shape_editor.rs @@ -44,7 +44,7 @@ pub enum ManipulatorAngle { #[derive(Clone, Debug, Default)] pub struct SelectedLayerState { selected_points: HashSet, - /// Keeps track of the current state; helps avoid unnecessary computation when called by ShapeState + /// Keeps track of the current state; helps avoid unnecessary computation when called by [`ShapeState`]. ignore_handles: bool, ignore_anchors: bool, /// Points that are selected but ignored (when their overlays are disabled) are stored here. @@ -56,6 +56,7 @@ impl SelectedLayerState { pub fn selected(&self) -> impl Iterator + '_ { self.selected_points.iter().copied() } + pub fn is_selected(&self, point: ManipulatorPointId) -> bool { self.selected_points.contains(&point) } @@ -63,15 +64,18 @@ impl SelectedLayerState { pub fn select_point(&mut self, point: ManipulatorPointId) { self.selected_points.insert(point); } + pub fn deselect_point(&mut self, point: ManipulatorPointId) { self.selected_points.remove(&point); } + pub fn ignore_handles(&mut self, status: bool) { if self.ignore_handles == !status { return; } self.ignore_handles = !status; + if self.ignore_handles { self.ignored_handle_points.extend(self.selected_points.iter().copied().filter(|point| point.as_handle().is_some())); self.selected_points.retain(|point| !self.ignored_handle_points.contains(point)); @@ -80,12 +84,14 @@ impl SelectedLayerState { self.ignored_handle_points.clear(); } } + pub fn ignore_anchors(&mut self, status: bool) { if self.ignore_anchors == !status { return; } self.ignore_anchors = !status; + if self.ignore_anchors { self.ignored_anchor_points.extend(self.selected_points.iter().copied().filter(|point| point.as_anchor().is_some())); self.selected_points.retain(|point| !self.ignored_anchor_points.contains(point)); @@ -94,9 +100,11 @@ impl SelectedLayerState { self.ignored_anchor_points.clear(); } } + pub fn clear_points(&mut self) { self.selected_points.clear(); } + pub fn selected_points_count(&self) -> usize { self.selected_points.len() } @@ -106,7 +114,7 @@ pub type SelectedShapeState = HashMap; #[derive(Debug, Default)] pub struct ShapeState { - // The layers we can select and edit manipulators (anchors and handles) from + /// The layers we can select and edit manipulators (anchors and handles) from. pub selected_shape_state: SelectedShapeState, ignore_handles: bool, ignore_anchors: bool, @@ -271,13 +279,7 @@ impl ClosestSegment { // TODO Consider keeping a list of selected manipulators to minimize traversals of the layers impl ShapeState { pub fn is_point_ignored(&self, point: &ManipulatorPointId) -> bool { - if point.as_handle().is_some() && self.ignore_handles { - return true; - } else if point.as_anchor().is_some() && self.ignore_anchors { - return true; - } else { - return false; - } + (point.as_handle().is_some() && self.ignore_handles) || (point.as_anchor().is_some() && self.ignore_anchors) } pub fn close_selected_path(&self, document: &DocumentMessageHandler, responses: &mut VecDeque) { diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index 24a29cbb8e..5d9f622860 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -1005,6 +1005,7 @@ impl Fsm for PathToolFsmState { } (_, PathToolMessage::Overlays(mut overlay_context)) => { // TODO: find the segment ids of which the selected points are a part of + match tool_options.path_overlay_mode { PathOverlayMode::AllHandles => { path_overlays(document, DrawHandles::All, shape_editor, &mut overlay_context);