mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 19:28:12 +08:00
Fix path tool
This commit is contained in:
committed by
Keavon Chambers
parent
4cd72edb64
commit
0d6bec837b
@@ -130,18 +130,15 @@ impl OverlayRenderer {
|
||||
responses.add(OverlaysMessage::Rerender);
|
||||
}
|
||||
|
||||
pub fn clear_subpath_overlays(&mut self, _document: &Document, layer: LayerNodeIdentifier, responses: &mut VecDeque<Message>) {
|
||||
// Remove the shape outline overlays
|
||||
if let Some(overlay_path) = self.shape_overlay_cache.get(&layer) {
|
||||
Self::remove_outline_overlays(overlay_path.clone(), responses)
|
||||
/// Delete all cached overlays
|
||||
pub fn clear_all_overlays(&mut self, responses: &mut VecDeque<Message>) {
|
||||
for (_, overlay_path) in self.shape_overlay_cache.drain() {
|
||||
Self::remove_outline_overlays(overlay_path, responses)
|
||||
}
|
||||
self.shape_overlay_cache.remove(&layer);
|
||||
|
||||
// Remove the ManipulatorGroup overlays
|
||||
let Some(layer_cache) = self.manipulator_group_overlay_cache.remove(&layer) else { return };
|
||||
|
||||
for manipulator_group_overlays in layer_cache.values() {
|
||||
Self::remove_manipulator_group_overlays(manipulator_group_overlays, responses);
|
||||
for (_, layer_cache) in self.manipulator_group_overlay_cache.drain() {
|
||||
for manipulator_group_overlays in layer_cache.values() {
|
||||
Self::remove_manipulator_group_overlays(manipulator_group_overlays, responses);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ impl ShapeState {
|
||||
pub fn set_selected_layers(&mut self, target_layers: Vec<LayerNodeIdentifier>) {
|
||||
self.selected_shape_state.retain(|layer_path, _| target_layers.contains(layer_path));
|
||||
for layer in target_layers {
|
||||
self.selected_shape_state.entry(layer).or_insert_with(SelectedLayerState::default);
|
||||
self.selected_shape_state.entry(layer).or_default();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,11 +142,6 @@ impl ShapeState {
|
||||
self.selected_shape_state.keys()
|
||||
}
|
||||
|
||||
/// Clear all of the shapes we can modify.
|
||||
pub fn clear_selected_layers(&mut self) {
|
||||
self.selected_shape_state.clear();
|
||||
}
|
||||
|
||||
pub fn has_selected_layers(&self) -> bool {
|
||||
!self.selected_shape_state.is_empty()
|
||||
}
|
||||
|
||||
@@ -164,6 +164,23 @@ pub fn add_bounding_box(responses: &mut VecDeque<Message>) -> Vec<LayerId> {
|
||||
path
|
||||
}
|
||||
|
||||
/// Update the location of a bounding box with no handles
|
||||
pub fn update_bounding_box(pos1: DVec2, pos2: DVec2, layer: &Option<Vec<LayerId>>, responses: &mut VecDeque<Message>) {
|
||||
if let Some(path) = layer.as_ref().cloned() {
|
||||
let transform = transform_from_box(pos1, pos2, DAffine2::IDENTITY).to_cols_array();
|
||||
let operation = Operation::SetLayerTransformInViewport { path, transform };
|
||||
responses.add_front(DocumentMessage::Overlays(operation.into()));
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes the bounding box overlay with no transform handles
|
||||
pub fn remove_bounding_box(layer_path: Option<Vec<LayerId>>, responses: &mut VecDeque<Message>) {
|
||||
if let Some(path) = layer_path {
|
||||
let operation = Operation::DeleteLayer { path };
|
||||
responses.add(DocumentMessage::Overlays(operation.into()));
|
||||
}
|
||||
}
|
||||
|
||||
/// Add the transform handle overlay
|
||||
fn add_transform_handles(responses: &mut VecDeque<Message>) -> [Vec<LayerId>; 8] {
|
||||
const EMPTY_VEC: Vec<LayerId> = Vec::new();
|
||||
|
||||
Reference in New Issue
Block a user