mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 16:18:12 +08:00
Fix clippy lints (#1327)
* Fix clippy lints * Update formatting * Remove unsafe send impls * New type for Rc<NodeContainer>
This commit is contained in:
committed by
Keavon Chambers
parent
743803ce04
commit
80cc5bee73
@@ -315,7 +315,11 @@ impl BrushToolData {
|
||||
for (node, _node_id) in network.primary_flow() {
|
||||
if node.name == "Brush" {
|
||||
let points_input = node.inputs.get(2)?;
|
||||
let NodeInput::Value { tagged_value: TaggedValue::BrushStrokes(strokes), .. } = points_input else {
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::BrushStrokes(strokes),
|
||||
..
|
||||
} = points_input
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
self.strokes = strokes.clone();
|
||||
|
||||
@@ -210,7 +210,7 @@ impl Fsm for EllipseToolFsmState {
|
||||
use EllipseToolFsmState::*;
|
||||
use EllipseToolMessage::*;
|
||||
|
||||
let mut shape_data = &mut tool_data.data;
|
||||
let shape_data = &mut tool_data.data;
|
||||
|
||||
if let ToolMessage::Ellipse(event) = event {
|
||||
match (self, event) {
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Fsm for NodeGraphToolFsmState {
|
||||
use FrameToolMessage::*;
|
||||
use NodeGraphToolFsmState::*;
|
||||
|
||||
let mut shape_data = &mut tool_data.data;
|
||||
let shape_data = &mut tool_data.data;
|
||||
|
||||
if let ToolMessage::Frame(event) = event {
|
||||
match (self, event) {
|
||||
|
||||
@@ -289,7 +289,7 @@ impl SelectedGradient {
|
||||
inner_gradient.transform = gradient_space_transform(&inner_gradient.path, layer, document, render_data);
|
||||
|
||||
// Clear if no longer a gradient
|
||||
let Some(gradient) = layer.style().ok().and_then(|style|style.fill().as_gradient()) else {
|
||||
let Some(gradient) = layer.style().ok().and_then(|style| style.fill().as_gradient()) else {
|
||||
responses.add(ToolMessage::RefreshToolOptions);
|
||||
*gradient = None;
|
||||
return;
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Fsm for ImaginateToolFsmState {
|
||||
use ImaginateToolFsmState::*;
|
||||
use ImaginateToolMessage::*;
|
||||
|
||||
let mut shape_data = &mut tool_data.data;
|
||||
let shape_data = &mut tool_data.data;
|
||||
|
||||
if let ToolMessage::Imaginate(event) = event {
|
||||
match (self, event) {
|
||||
|
||||
@@ -351,7 +351,7 @@ impl Fsm for PathToolFsmState {
|
||||
}
|
||||
.into(),
|
||||
));
|
||||
return PathToolFsmState::Ready;
|
||||
PathToolFsmState::Ready
|
||||
}
|
||||
(_, PathToolMessage::DragStop { shift_mirror_distance }) => {
|
||||
let shift_pressed = input.keyboard.get(shift_mirror_distance as usize);
|
||||
|
||||
@@ -232,7 +232,9 @@ impl PenToolData {
|
||||
// Stop the handles on the first point from mirroring
|
||||
let Some(subpaths) = get_subpaths(layer, document) else { return };
|
||||
let manipulator_groups = subpaths[subpath_index].manipulator_groups();
|
||||
let Some(last_handle) = (if from_start { manipulator_groups.first() } else { manipulator_groups.last() }) else { return };
|
||||
let Some(last_handle) = (if from_start { manipulator_groups.first() } else { manipulator_groups.last() }) else {
|
||||
return;
|
||||
};
|
||||
|
||||
responses.add(GraphOperationMessage::Vector {
|
||||
layer: layer.to_vec(),
|
||||
@@ -765,7 +767,9 @@ fn should_extend(document: &DocumentMessageHandler, pos: DVec2, tolerance: f64)
|
||||
let mut best_distance_squared = tolerance * tolerance;
|
||||
|
||||
for layer_path in document.selected_layers() {
|
||||
let Ok(viewspace) = document.document_legacy.generate_transform_relative_to_viewport(layer_path) else { continue };
|
||||
let Ok(viewspace) = document.document_legacy.generate_transform_relative_to_viewport(layer_path) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let subpaths = get_subpaths(layer_path, document)?;
|
||||
for (subpath_index, subpath) in subpaths.iter().enumerate() {
|
||||
@@ -795,7 +799,11 @@ fn get_subpaths<'a>(layer_path: &[LayerId], document: &'a DocumentMessageHandler
|
||||
for (node, _node_id) in network.primary_flow() {
|
||||
if node.name == "Path Generator" {
|
||||
let subpaths_input = node.inputs.get(0)?;
|
||||
let NodeInput::Value { tagged_value: TaggedValue::Subpaths(subpaths), .. } = subpaths_input else {
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::Subpaths(subpaths),
|
||||
..
|
||||
} = subpaths_input
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ impl Fsm for RectangleToolFsmState {
|
||||
use RectangleToolFsmState::*;
|
||||
use RectangleToolMessage::*;
|
||||
|
||||
let mut shape_data = &mut tool_data.data;
|
||||
let shape_data = &mut tool_data.data;
|
||||
|
||||
if let ToolMessage::Rectangle(event) = event {
|
||||
match (self, event) {
|
||||
|
||||
@@ -503,7 +503,7 @@ impl Fsm for SelectToolFsmState {
|
||||
tool_data.drag_start = input.mouse.position;
|
||||
tool_data.drag_current = input.mouse.position;
|
||||
|
||||
let dragging_bounds = tool_data.bounding_box_overlays.as_mut().and_then(|mut bounding_box| {
|
||||
let dragging_bounds = tool_data.bounding_box_overlays.as_mut().and_then(|bounding_box| {
|
||||
let edges = bounding_box.check_selected_edges(input.mouse.position);
|
||||
|
||||
bounding_box.selected_edges = edges.map(|(top, bottom, left, right)| {
|
||||
|
||||
@@ -250,7 +250,7 @@ impl Fsm for ShapeToolFsmState {
|
||||
use ShapeToolFsmState::*;
|
||||
use ShapeToolMessage::*;
|
||||
|
||||
let mut shape_data = &mut tool_data.data;
|
||||
let shape_data = &mut tool_data.data;
|
||||
|
||||
if let ToolMessage::Shape(event) = event {
|
||||
match (self, event) {
|
||||
|
||||
@@ -299,9 +299,27 @@ impl TextToolData {
|
||||
}
|
||||
|
||||
fn extract_text_node_inputs(node: &DocumentNode) -> Option<(&String, &Font, f64)> {
|
||||
let NodeInput::Value { tagged_value: TaggedValue::String(text), .. } = &node.inputs[1] else { return None; };
|
||||
let NodeInput::Value { tagged_value: TaggedValue::Font(font), .. } = &node.inputs[2] else { return None; };
|
||||
let NodeInput::Value { tagged_value: TaggedValue::F64(font_size), .. } = &node.inputs[3] else { return None; };
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::String(text),
|
||||
..
|
||||
} = &node.inputs[1]
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::Font(font),
|
||||
..
|
||||
} = &node.inputs[2]
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let NodeInput::Value {
|
||||
tagged_value: TaggedValue::F64(font_size),
|
||||
..
|
||||
} = &node.inputs[3]
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
Some((text, font, *font_size))
|
||||
}
|
||||
|
||||
@@ -456,7 +474,9 @@ fn get_text_node_id(network: &NodeNetwork) -> Option<NodeId> {
|
||||
}
|
||||
|
||||
fn is_text_layer(document: &DocumentMessageHandler, layer_path: &[LayerId]) -> bool {
|
||||
let Some(network) = get_network(layer_path, document) else { return false; };
|
||||
let Some(network) = get_network(layer_path, document) else {
|
||||
return false;
|
||||
};
|
||||
get_text_node_id(network).is_some()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user