mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 18:18:12 +08:00
Rename handle mirroring to colinear
This commit is contained in:
@@ -132,8 +132,8 @@ pub enum VectorDataModification {
|
||||
RemoveManipulatorGroup { id: ManipulatorGroupId },
|
||||
RemoveManipulatorPoint { point: ManipulatorPointId },
|
||||
SetClosed { index: usize, closed: bool },
|
||||
SetManipulatorHandleMirroring { id: ManipulatorGroupId, mirror_angle: bool },
|
||||
SetManipulatorColinearHandlesState { id: ManipulatorGroupId, colinear: bool },
|
||||
SetManipulatorPosition { point: ManipulatorPointId, position: DVec2 },
|
||||
ToggleManipulatorHandleMirroring { id: ManipulatorGroupId },
|
||||
ToggleManipulatorColinearHandlesState { id: ManipulatorGroupId },
|
||||
UpdateSubpaths { subpaths: Vec<Subpath<ManipulatorGroupId>> },
|
||||
}
|
||||
|
||||
+5
-5
@@ -462,8 +462,8 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
let mut empty = false;
|
||||
|
||||
self.modify_inputs("Shape", false, |inputs, _node_id, _metadata| {
|
||||
let [subpaths, mirror_angle_groups] = inputs.as_mut_slice() else {
|
||||
panic!("Shape does not have subpath and mirror angle inputs");
|
||||
let [subpaths, colinear_manipulators] = inputs.as_mut_slice() else {
|
||||
panic!("Shape does not have both `subpath` and `colinear_manipulators` inputs");
|
||||
};
|
||||
|
||||
let NodeInput::Value {
|
||||
@@ -474,16 +474,16 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
return;
|
||||
};
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::ManipulatorGroupIds(mirror_angle_groups),
|
||||
tagged_value: TaggedValue::ManipulatorGroupIds(colinear_manipulators),
|
||||
..
|
||||
} = mirror_angle_groups
|
||||
} = colinear_manipulators
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
||||
[old_bounds_min, old_bounds_max] = transform_utils::nonzero_subpath_bounds(subpaths);
|
||||
|
||||
transform_utils::VectorModificationState { subpaths, mirror_angle_groups }.modify(modification);
|
||||
transform_utils::VectorModificationState { subpaths, colinear_manipulators }.modify(modification);
|
||||
empty = !subpaths.iter().any(|subpath| !subpath.is_empty());
|
||||
|
||||
[new_bounds_min, new_bounds_max] = transform_utils::nonzero_subpath_bounds(subpaths);
|
||||
|
||||
+13
-13
@@ -199,7 +199,7 @@ pub fn nonzero_subpath_bounds(subpaths: &[Subpath<ManipulatorGroupId>]) -> [DVec
|
||||
|
||||
pub struct VectorModificationState<'a> {
|
||||
pub subpaths: &'a mut Vec<Subpath<ManipulatorGroupId>>,
|
||||
pub mirror_angle_groups: &'a mut Vec<ManipulatorGroupId>,
|
||||
pub colinear_manipulators: &'a mut Vec<ManipulatorGroupId>,
|
||||
}
|
||||
impl<'a> VectorModificationState<'a> {
|
||||
fn insert_start(&mut self, subpath_index: usize, manipulator_group: ManipulatorGroup<ManipulatorGroupId>) {
|
||||
@@ -246,19 +246,19 @@ impl<'a> VectorModificationState<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn set_mirror(&mut self, id: ManipulatorGroupId, mirror_angle: bool) {
|
||||
if !mirror_angle {
|
||||
self.mirror_angle_groups.retain(|&mirrored_id| mirrored_id != id);
|
||||
} else if !self.mirror_angle_groups.contains(&id) {
|
||||
self.mirror_angle_groups.push(id);
|
||||
fn set_manipulator_colinear_handles_state(&mut self, id: ManipulatorGroupId, colinear: bool) {
|
||||
if !colinear {
|
||||
self.colinear_manipulators.retain(|&manipulator_group_id| manipulator_group_id != id);
|
||||
} else if !self.colinear_manipulators.contains(&id) {
|
||||
self.colinear_manipulators.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_mirror(&mut self, id: ManipulatorGroupId) {
|
||||
if self.mirror_angle_groups.contains(&id) {
|
||||
self.mirror_angle_groups.retain(|&mirrored_id| mirrored_id != id);
|
||||
fn toggle_manipulator_colinear_handles_state(&mut self, id: ManipulatorGroupId) {
|
||||
if self.colinear_manipulators.contains(&id) {
|
||||
self.colinear_manipulators.retain(|&manipulator_group_id| manipulator_group_id != id);
|
||||
} else {
|
||||
self.mirror_angle_groups.push(id);
|
||||
self.colinear_manipulators.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ impl<'a> VectorModificationState<'a> {
|
||||
SelectedType::InHandle => manipulator.in_handle = Some(position),
|
||||
SelectedType::OutHandle => manipulator.out_handle = Some(position),
|
||||
}
|
||||
if point.manipulator_type != SelectedType::Anchor && self.mirror_angle_groups.contains(&point.group) {
|
||||
if point.manipulator_type != SelectedType::Anchor && self.colinear_manipulators.contains(&point.group) {
|
||||
let reflect = |opposite: DVec2| {
|
||||
(manipulator.anchor - position)
|
||||
.try_normalize()
|
||||
@@ -298,9 +298,9 @@ impl<'a> VectorModificationState<'a> {
|
||||
VectorDataModification::RemoveManipulatorGroup { id } => self.remove_group(id),
|
||||
VectorDataModification::RemoveManipulatorPoint { point } => self.remove_point(point),
|
||||
VectorDataModification::SetClosed { index, closed } => self.subpaths[index].set_closed(closed),
|
||||
VectorDataModification::SetManipulatorHandleMirroring { id, mirror_angle } => self.set_mirror(id, mirror_angle),
|
||||
VectorDataModification::SetManipulatorColinearHandlesState { id, colinear } => self.set_manipulator_colinear_handles_state(id, colinear),
|
||||
VectorDataModification::SetManipulatorPosition { point, position } => self.set_position(point, position),
|
||||
VectorDataModification::ToggleManipulatorHandleMirroring { id } => self.toggle_mirror(id),
|
||||
VectorDataModification::ToggleManipulatorColinearHandlesState { id } => self.toggle_manipulator_colinear_handles_state(id),
|
||||
VectorDataModification::UpdateSubpaths { subpaths } => *self.subpaths = subpaths,
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -2442,7 +2442,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
||||
}),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Path Data", TaggedValue::Subpaths(vec![]), false),
|
||||
DocumentInputType::value("Mirror", TaggedValue::ManipulatorGroupIds(vec![]), false),
|
||||
DocumentInputType::value("Colinear Manipulators", TaggedValue::ManipulatorGroupIds(vec![]), false),
|
||||
],
|
||||
outputs: vec![DocumentOutputType::new("Vector", FrontendGraphDataType::Subpath)],
|
||||
..Default::default()
|
||||
|
||||
@@ -61,7 +61,7 @@ pub struct SnappingState {
|
||||
pub geometry_snapping: bool,
|
||||
pub grid_snapping: bool,
|
||||
pub bounds: BoundsSnapping,
|
||||
pub nodes: NodeSnapping,
|
||||
pub nodes: PointSnapping,
|
||||
pub grid: GridSnapping,
|
||||
pub tolerance: f64,
|
||||
pub artboards: bool,
|
||||
@@ -79,11 +79,11 @@ impl Default for SnappingState {
|
||||
edge_midpoints: false,
|
||||
centers: true,
|
||||
},
|
||||
nodes: NodeSnapping {
|
||||
nodes: PointSnapping {
|
||||
paths: true,
|
||||
path_intersections: true,
|
||||
sharp_nodes: true,
|
||||
smooth_nodes: true,
|
||||
point_handles_free: true,
|
||||
point_handles_colinear: true,
|
||||
line_midpoints: true,
|
||||
normals: true,
|
||||
tangents: true,
|
||||
@@ -110,8 +110,8 @@ impl SnappingState {
|
||||
BoundingBoxSnapTarget::Center => self.bounds.centers,
|
||||
},
|
||||
SnapTarget::Geometry(nodes) if self.geometry_snapping => match nodes {
|
||||
GeometrySnapTarget::Smooth => self.nodes.smooth_nodes,
|
||||
GeometrySnapTarget::Sharp => self.nodes.sharp_nodes,
|
||||
GeometrySnapTarget::HandlesColinear => self.nodes.point_handles_colinear,
|
||||
GeometrySnapTarget::HandlesFree => self.nodes.point_handles_free,
|
||||
GeometrySnapTarget::LineMidpoint => self.nodes.line_midpoints,
|
||||
GeometrySnapTarget::Path => self.nodes.paths,
|
||||
GeometrySnapTarget::Normal => self.nodes.normals,
|
||||
@@ -132,11 +132,11 @@ pub struct BoundsSnapping {
|
||||
pub centers: bool,
|
||||
}
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct NodeSnapping {
|
||||
pub struct PointSnapping {
|
||||
pub paths: bool,
|
||||
pub path_intersections: bool,
|
||||
pub sharp_nodes: bool,
|
||||
pub smooth_nodes: bool,
|
||||
pub point_handles_free: bool,
|
||||
pub point_handles_colinear: bool,
|
||||
pub line_midpoints: bool,
|
||||
pub normals: bool,
|
||||
pub tangents: bool,
|
||||
@@ -227,8 +227,8 @@ pub enum BoardSnapSource {
|
||||
}
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GeometrySnapSource {
|
||||
Smooth,
|
||||
Sharp,
|
||||
HandlesColinear,
|
||||
HandlesFree,
|
||||
LineMidpoint,
|
||||
PathIntersection,
|
||||
Handle,
|
||||
@@ -258,8 +258,8 @@ pub enum BoundingBoxSnapTarget {
|
||||
}
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GeometrySnapTarget {
|
||||
Smooth,
|
||||
Sharp,
|
||||
HandlesColinear,
|
||||
HandlesFree,
|
||||
LineMidpoint,
|
||||
Path,
|
||||
Normal,
|
||||
|
||||
Reference in New Issue
Block a user