From 0bac707241fee6fb9692047fdc2e679ec472b066 Mon Sep 17 00:00:00 2001 From: Chase <60807752+Chase-Percy@users.noreply.github.com> Date: Thu, 27 Apr 2023 19:21:20 +0800 Subject: [PATCH] Fix #1174: Spline does not have mirror handles enabled (#1182) * Set spline mirror handles to enabled by default * refactor mirror setting into common function --------- Co-authored-by: Keavon Chambers --- .../graph_modification_utils.rs | 15 ++++++++++++++- .../messages/tool/tool_messages/ellipse_tool.rs | 13 +------------ .../messages/tool/tool_messages/spline_tool.rs | 2 ++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/editor/src/messages/tool/common_functionality/graph_modification_utils.rs b/editor/src/messages/tool/common_functionality/graph_modification_utils.rs index 11a8e8b8..21f94fd2 100644 --- a/editor/src/messages/tool/common_functionality/graph_modification_utils.rs +++ b/editor/src/messages/tool/common_functionality/graph_modification_utils.rs @@ -1,7 +1,8 @@ use crate::messages::portfolio::document::node_graph; +use crate::messages::portfolio::document::node_graph::VectorDataModification; use crate::messages::prelude::*; -use bezier_rs::Subpath; +use bezier_rs::{ManipulatorGroup, Subpath}; use document_legacy::{LayerId, Operation}; use graph_craft::document::NodeNetwork; use graphene_core::uuid::ManipulatorGroupId; @@ -28,3 +29,15 @@ pub fn new_custom_layer(network: NodeNetwork, layer_path: Vec, response ); responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path }); } + +pub fn set_manipulator_mirror_angle(manipulator_groups: &Vec>, layer_path: &Vec, mirror_angle: bool, responses: &mut VecDeque) { + for manipulator_group in manipulator_groups { + responses.add(GraphOperationMessage::Vector { + layer: layer_path.clone(), + modification: VectorDataModification::SetManipulatorHandleMirroring { + id: manipulator_group.id, + mirror_angle, + }, + }); + } +} diff --git a/editor/src/messages/tool/tool_messages/ellipse_tool.rs b/editor/src/messages/tool/tool_messages/ellipse_tool.rs index 5d290862..36743527 100644 --- a/editor/src/messages/tool/tool_messages/ellipse_tool.rs +++ b/editor/src/messages/tool/tool_messages/ellipse_tool.rs @@ -1,7 +1,6 @@ use crate::messages::frontend::utility_types::MouseCursorIcon; use crate::messages::input_mapper::utility_types::input_keyboard::{Key, MouseMotion}; use crate::messages::layout::utility_types::layout_widget::PropertyHolder; -use crate::messages::portfolio::document::node_graph::VectorDataModification; use crate::messages::prelude::*; use crate::messages::tool::common_functionality::graph_modification_utils; use crate::messages::tool::common_functionality::resize::Resize; @@ -130,17 +129,7 @@ impl Fsm for EllipseToolFsmState { let subpath = bezier_rs::Subpath::new_ellipse(DVec2::ZERO, DVec2::ONE); let manipulator_groups = subpath.manipulator_groups().to_vec(); graph_modification_utils::new_vector_layer(vec![subpath], layer_path.clone(), responses); - - // Set the four manipulator groups to have their handle angles mirrored by default - for manipulator_group in manipulator_groups { - responses.add(GraphOperationMessage::Vector { - layer: layer_path.clone(), - modification: VectorDataModification::SetManipulatorHandleMirroring { - id: manipulator_group.id, - mirror_angle: true, - }, - }); - } + graph_modification_utils::set_manipulator_mirror_angle(&manipulator_groups, &layer_path, true, responses); // Set the fill color to the primary working color responses.add(GraphOperationMessage::FillSet { diff --git a/editor/src/messages/tool/tool_messages/spline_tool.rs b/editor/src/messages/tool/tool_messages/spline_tool.rs index be0fc052..e33a7835 100644 --- a/editor/src/messages/tool/tool_messages/spline_tool.rs +++ b/editor/src/messages/tool/tool_messages/spline_tool.rs @@ -264,7 +264,9 @@ fn add_spline(tool_data: &SplineToolData, global_tool_data: &DocumentToolData, s let subpath = bezier_rs::Subpath::new_cubic_spline(points); let layer_path = tool_data.path.clone().unwrap(); + let manipulator_groups = subpath.manipulator_groups().to_vec(); graph_modification_utils::new_vector_layer(vec![subpath], layer_path.clone(), responses); + graph_modification_utils::set_manipulator_mirror_angle(&manipulator_groups, &layer_path, true, responses); responses.add(GraphOperationMessage::StrokeSet { layer: layer_path.clone(),