mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 21:18:12 +08:00
Fix assorted Clippy lints (#3390)
This commit is contained in:
+2
-2
@@ -272,7 +272,7 @@ fn calculate_isometric_top_line_points(columns: u32, rows: u32, spacing: DVec2,
|
||||
let offset = if columns == 1 || rows == 1 { DVec2::ZERO } else { DVec2::new(spacing.x * 0.5, 0.) };
|
||||
let isometric_spacing = calculate_isometric_offset(spacing, angles);
|
||||
let isometric_offset = DVec2::new(0., isometric_spacing.y);
|
||||
let end_isometric_offset = if columns % 2 == 0 { DVec2::ZERO } else { DVec2::new(0., isometric_spacing.y) };
|
||||
let end_isometric_offset = if columns.is_multiple_of(2) { DVec2::ZERO } else { DVec2::new(0., isometric_spacing.y) };
|
||||
|
||||
(top_left + offset - isometric_offset, top_right - offset - end_isometric_offset)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ fn calculate_isometric_bottom_line_points(columns: u32, rows: u32, spacing: DVec
|
||||
let bottom_right = calculate_isometric_point(columns - 1, rows - 1, angles, spacing);
|
||||
|
||||
let offset = if columns == 1 || rows == 1 { DVec2::ZERO } else { DVec2::new(spacing.x * 0.5, 0.) };
|
||||
let isometric_offset = if columns % 2 == 0 {
|
||||
let isometric_offset = if columns.is_multiple_of(2) {
|
||||
let offset = calculate_isometric_offset(spacing, angles);
|
||||
DVec2::new(0., offset.y)
|
||||
} else {
|
||||
|
||||
+8
-8
@@ -108,10 +108,10 @@ impl NumberOfPointsDial {
|
||||
let viewport = document.metadata().transform_to_viewport(layer);
|
||||
let center = viewport.transform_point2(DVec2::ZERO);
|
||||
|
||||
if let Some(closest_segment) = shape_editor.upper_closest_segment(&document.network_interface, mouse_position, POINT_RADIUS_HANDLE_SEGMENT_THRESHOLD) {
|
||||
if closest_segment.layer() == layer {
|
||||
return;
|
||||
}
|
||||
if let Some(closest_segment) = shape_editor.upper_closest_segment(&document.network_interface, mouse_position, POINT_RADIUS_HANDLE_SEGMENT_THRESHOLD)
|
||||
&& closest_segment.layer() == layer
|
||||
{
|
||||
return;
|
||||
}
|
||||
let point_on_max_radius = star_vertex_position(viewport, 0, sides, radius1, radius2);
|
||||
|
||||
@@ -126,10 +126,10 @@ impl NumberOfPointsDial {
|
||||
let viewport = document.metadata().transform_to_viewport(layer);
|
||||
let center = viewport.transform_point2(DVec2::ZERO);
|
||||
|
||||
if let Some(closest_segment) = shape_editor.upper_closest_segment(&document.network_interface, mouse_position, POINT_RADIUS_HANDLE_SEGMENT_THRESHOLD) {
|
||||
if closest_segment.layer() == layer {
|
||||
return;
|
||||
}
|
||||
if let Some(closest_segment) = shape_editor.upper_closest_segment(&document.network_interface, mouse_position, POINT_RADIUS_HANDLE_SEGMENT_THRESHOLD)
|
||||
&& closest_segment.layer() == layer
|
||||
{
|
||||
return;
|
||||
}
|
||||
let point_on_max_radius = polygon_vertex_position(viewport, 0, sides, radius);
|
||||
|
||||
|
||||
@@ -691,10 +691,10 @@ impl ShapeState {
|
||||
let mut selected_stack = Vec::new();
|
||||
// Find all subpaths that have been clicked
|
||||
for stroke in vector.stroke_bezier_paths() {
|
||||
if stroke.contains_point(layer_mouse) {
|
||||
if let Some(first) = stroke.manipulator_groups().first() {
|
||||
selected_stack.push(first.id);
|
||||
}
|
||||
if stroke.contains_point(layer_mouse)
|
||||
&& let Some(first) = stroke.manipulator_groups().first()
|
||||
{
|
||||
selected_stack.push(first.id);
|
||||
}
|
||||
}
|
||||
state.clear_points();
|
||||
@@ -929,20 +929,20 @@ impl ShapeState {
|
||||
ManipulatorPointId::Anchor(point) => self.move_anchor(point, &vector, delta, layer, None, responses),
|
||||
ManipulatorPointId::PrimaryHandle(segment) => {
|
||||
self.move_primary(segment, delta, layer, responses);
|
||||
if let Some(handle) = point.as_handle() {
|
||||
if let Some(handles) = vector.colinear_manipulators.iter().find(|handles| handles[0] == handle || handles[1] == handle) {
|
||||
let modification_type = VectorModificationType::SetG1Continuous { handles: *handles, enabled: false };
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
if let Some(handle) = point.as_handle()
|
||||
&& let Some(handles) = vector.colinear_manipulators.iter().find(|handles| handles[0] == handle || handles[1] == handle)
|
||||
{
|
||||
let modification_type = VectorModificationType::SetG1Continuous { handles: *handles, enabled: false };
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
}
|
||||
ManipulatorPointId::EndHandle(segment) => {
|
||||
self.move_end(segment, delta, layer, responses);
|
||||
if let Some(handle) = point.as_handle() {
|
||||
if let Some(handles) = vector.colinear_manipulators.iter().find(|handles| handles[0] == handle || handles[1] == handle) {
|
||||
let modification_type = VectorModificationType::SetG1Continuous { handles: *handles, enabled: false };
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
if let Some(handle) = point.as_handle()
|
||||
&& let Some(handles) = vector.colinear_manipulators.iter().find(|handles| handles[0] == handle || handles[1] == handle)
|
||||
{
|
||||
let modification_type = VectorModificationType::SetG1Continuous { handles: *handles, enabled: false };
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1078,10 +1078,10 @@ impl ShapeState {
|
||||
|
||||
for &point in layer_state.selected_points.iter() {
|
||||
// Skip a point which has more than 2 segments connected (vector meshes)
|
||||
if let ManipulatorPointId::Anchor(anchor) = point {
|
||||
if vector.all_connected(anchor).count() > 2 {
|
||||
continue;
|
||||
}
|
||||
if let ManipulatorPointId::Anchor(anchor) = point
|
||||
&& vector.all_connected(anchor).count() > 2
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Here we take handles as the current handle and the most opposite non-colinear-handle
|
||||
@@ -1409,10 +1409,11 @@ impl ShapeState {
|
||||
|
||||
match point {
|
||||
ManipulatorPointId::Anchor(anchor) => {
|
||||
if let Some(handles) = Self::dissolve_anchor(anchor, responses, layer, &vector) {
|
||||
if !vector.all_connected(anchor).any(|a| selected_segments.contains(&a.segment)) && vector.all_connected(anchor).count() <= 2 {
|
||||
missing_anchors.insert(anchor, handles);
|
||||
}
|
||||
if let Some(handles) = Self::dissolve_anchor(anchor, responses, layer, &vector)
|
||||
&& !vector.all_connected(anchor).any(|a| selected_segments.contains(&a.segment))
|
||||
&& vector.all_connected(anchor).count() <= 2
|
||||
{
|
||||
missing_anchors.insert(anchor, handles);
|
||||
}
|
||||
deleted_anchors.insert(anchor);
|
||||
}
|
||||
@@ -1643,11 +1644,11 @@ impl ShapeState {
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
}
|
||||
} else if let Some(handle) = point.as_handle() {
|
||||
if let Some(handles) = vector.colinear_manipulators.iter().find(|handles| handles[0] == handle || handles[1] == handle) {
|
||||
let modification_type = VectorModificationType::SetG1Continuous { handles: *handles, enabled: false };
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
} else if let Some(handle) = point.as_handle()
|
||||
&& let Some(handles) = vector.colinear_manipulators.iter().find(|handles| handles[0] == handle || handles[1] == handle)
|
||||
{
|
||||
let modification_type = VectorModificationType::SetG1Continuous { handles: *handles, enabled: false };
|
||||
responses.add(GraphOperationMessage::Vector { layer, modification_type });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1728,17 +1729,20 @@ impl ShapeState {
|
||||
let bezier = bezier.apply_transformation(|point| viewspace.transform_point2(point));
|
||||
let valid = |handle: DVec2, control: DVec2| handle.distance_squared(control) > crate::consts::HIDE_HANDLE_DISTANCE.powi(2);
|
||||
|
||||
if let Some(primary_handle) = bezier.handle_start() {
|
||||
if valid(primary_handle, bezier.start) && (bezier.handle_end().is_some() || valid(primary_handle, bezier.end)) && primary_handle.distance_squared(pos) <= closest_distance_squared {
|
||||
closest_distance_squared = primary_handle.distance_squared(pos);
|
||||
manipulator_point = Some(ManipulatorPointId::PrimaryHandle(segment_id));
|
||||
}
|
||||
if let Some(primary_handle) = bezier.handle_start()
|
||||
&& valid(primary_handle, bezier.start)
|
||||
&& (bezier.handle_end().is_some() || valid(primary_handle, bezier.end))
|
||||
&& primary_handle.distance_squared(pos) <= closest_distance_squared
|
||||
{
|
||||
closest_distance_squared = primary_handle.distance_squared(pos);
|
||||
manipulator_point = Some(ManipulatorPointId::PrimaryHandle(segment_id));
|
||||
}
|
||||
if let Some(end_handle) = bezier.handle_end() {
|
||||
if valid(end_handle, bezier.end) && end_handle.distance_squared(pos) <= closest_distance_squared {
|
||||
closest_distance_squared = end_handle.distance_squared(pos);
|
||||
manipulator_point = Some(ManipulatorPointId::EndHandle(segment_id));
|
||||
}
|
||||
if let Some(end_handle) = bezier.handle_end()
|
||||
&& valid(end_handle, bezier.end)
|
||||
&& end_handle.distance_squared(pos) <= closest_distance_squared
|
||||
{
|
||||
closest_distance_squared = end_handle.distance_squared(pos);
|
||||
manipulator_point = Some(ManipulatorPointId::EndHandle(segment_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -276,22 +276,22 @@ impl SnapManager {
|
||||
snapped_points.push(closest_curve.clone());
|
||||
}
|
||||
|
||||
if document.snapping_state.target_enabled(SnapTarget::Grid(GridSnapTarget::Line)) {
|
||||
if let Some(closest_line) = get_closest_line(&snap_results.grid_lines) {
|
||||
snapped_points.push(closest_line.clone());
|
||||
}
|
||||
if document.snapping_state.target_enabled(SnapTarget::Grid(GridSnapTarget::Line))
|
||||
&& let Some(closest_line) = get_closest_line(&snap_results.grid_lines)
|
||||
{
|
||||
snapped_points.push(closest_line.clone());
|
||||
}
|
||||
|
||||
if !constrained {
|
||||
if document.snapping_state.target_enabled(SnapTarget::Path(PathSnapTarget::IntersectionPoint)) {
|
||||
if let Some(closest_curves_intersection) = get_closest_intersection(point.document_point, &snap_results.curves) {
|
||||
snapped_points.push(closest_curves_intersection);
|
||||
}
|
||||
if document.snapping_state.target_enabled(SnapTarget::Path(PathSnapTarget::IntersectionPoint))
|
||||
&& let Some(closest_curves_intersection) = get_closest_intersection(point.document_point, &snap_results.curves)
|
||||
{
|
||||
snapped_points.push(closest_curves_intersection);
|
||||
}
|
||||
if document.snapping_state.target_enabled(SnapTarget::Grid(GridSnapTarget::Intersection)) {
|
||||
if let Some(closest_grid_intersection) = get_grid_intersection(point.document_point, &snap_results.grid_lines) {
|
||||
snapped_points.push(closest_grid_intersection);
|
||||
}
|
||||
if document.snapping_state.target_enabled(SnapTarget::Grid(GridSnapTarget::Intersection))
|
||||
&& let Some(closest_grid_intersection) = get_grid_intersection(point.document_point, &snap_results.grid_lines)
|
||||
{
|
||||
snapped_points.push(closest_grid_intersection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,34 +67,36 @@ impl AlignmentSnapper {
|
||||
let target_position = target_point.document_point;
|
||||
|
||||
// Perpendicular snap for line's endpoints
|
||||
if let Some(quad) = target_point.quad.map(|q| q.0) {
|
||||
if quad[0] == quad[3] && quad[1] == quad[2] && quad[0] == target_point.document_point {
|
||||
let [p1, p2, ..] = quad;
|
||||
let Some(direction) = (p2 - p1).try_normalize() else { return };
|
||||
let normal = DVec2::new(-direction.y, direction.x);
|
||||
if let Some(quad) = target_point.quad.map(|q| q.0)
|
||||
&& quad[0] == quad[3]
|
||||
&& quad[1] == quad[2]
|
||||
&& quad[0] == target_point.document_point
|
||||
{
|
||||
let [p1, p2, ..] = quad;
|
||||
let Some(direction) = (p2 - p1).try_normalize() else { return };
|
||||
let normal = DVec2::new(-direction.y, direction.x);
|
||||
|
||||
for endpoint in [p1, p2] {
|
||||
if let Some(perpendicular_snap) = Quad::intersect_rays(point.document_point, direction, endpoint, normal) {
|
||||
let distance_squared = point.document_point.distance_squared(perpendicular_snap);
|
||||
if distance_squared < tolerance_squared {
|
||||
let distance = distance_squared.sqrt();
|
||||
let distance_to_align_target = perpendicular_snap.distance_squared(endpoint).sqrt();
|
||||
for endpoint in [p1, p2] {
|
||||
if let Some(perpendicular_snap) = Quad::intersect_rays(point.document_point, direction, endpoint, normal) {
|
||||
let distance_squared = point.document_point.distance_squared(perpendicular_snap);
|
||||
if distance_squared < tolerance_squared {
|
||||
let distance = distance_squared.sqrt();
|
||||
let distance_to_align_target = perpendicular_snap.distance_squared(endpoint).sqrt();
|
||||
|
||||
let snap_point = SnappedPoint {
|
||||
snapped_point_document: perpendicular_snap,
|
||||
source: point.source,
|
||||
target: SnapTarget::Alignment(AlignmentSnapTarget::PerpendicularToEndpoint),
|
||||
target_bounds: Some(Quad(quad)),
|
||||
distance,
|
||||
tolerance,
|
||||
distance_to_align_target,
|
||||
fully_constrained: false,
|
||||
at_intersection: true,
|
||||
alignment_target_horizontal: Some(endpoint),
|
||||
..Default::default()
|
||||
};
|
||||
snap_results.points.push(snap_point);
|
||||
}
|
||||
let snap_point = SnappedPoint {
|
||||
snapped_point_document: perpendicular_snap,
|
||||
source: point.source,
|
||||
target: SnapTarget::Alignment(AlignmentSnapTarget::PerpendicularToEndpoint),
|
||||
target_bounds: Some(Quad(quad)),
|
||||
distance,
|
||||
tolerance,
|
||||
distance_to_align_target,
|
||||
fully_constrained: false,
|
||||
at_intersection: true,
|
||||
alignment_target_horizontal: Some(endpoint),
|
||||
..Default::default()
|
||||
};
|
||||
snap_results.points.push(snap_point);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -769,17 +769,17 @@ impl BoundingBoxManager {
|
||||
let edges = self.check_selected_edges(input.mouse.position);
|
||||
|
||||
let is_near_square = edges.is_some_and(|hover_edge| self.over_extended_edge_midpoint(input.mouse.position, hover_edge));
|
||||
if dragging_bounds && is_near_square {
|
||||
if let Some(skew_edge) = skew_edge {
|
||||
if self.check_skew_handle(input.mouse.position, skew_edge) {
|
||||
if skew_edge.0 || skew_edge.1 {
|
||||
return MouseCursorIcon::EWResize;
|
||||
} else if skew_edge.2 || skew_edge.3 {
|
||||
return MouseCursorIcon::NSResize;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if dragging_bounds
|
||||
&& is_near_square
|
||||
&& let Some(skew_edge) = skew_edge
|
||||
&& self.check_skew_handle(input.mouse.position, skew_edge)
|
||||
{
|
||||
if skew_edge.0 || skew_edge.1 {
|
||||
return MouseCursorIcon::EWResize;
|
||||
} else if skew_edge.2 || skew_edge.3 {
|
||||
return MouseCursorIcon::NSResize;
|
||||
}
|
||||
};
|
||||
|
||||
match edges {
|
||||
Some((top, bottom, left, right)) => match (top, bottom, left, right) {
|
||||
|
||||
@@ -588,10 +588,10 @@ pub fn make_path_editable_is_allowed(network_interface: &mut NodeNetworkInterfac
|
||||
|
||||
// Must not already have an existing Path node, in the right-most part of the layer chain, which has an empty set of modifications
|
||||
// (otherwise users could repeatedly keep running this command and stacking up empty Path nodes)
|
||||
if let Some(TaggedValue::VectorModification(modifications)) = NodeGraphLayer::new(first_layer, network_interface).find_input("Path", 1) {
|
||||
if modifications.as_ref() == &VectorModification::default() {
|
||||
return None;
|
||||
}
|
||||
if let Some(TaggedValue::VectorModification(modifications)) = NodeGraphLayer::new(first_layer, network_interface).find_input("Path", 1)
|
||||
&& modifications.as_ref() == &VectorModification::default()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(first_layer)
|
||||
|
||||
Reference in New Issue
Block a user