mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-22 08:48:11 +08:00
Fix Rust code lints (#1448)
* Fix Rust lints to satisfy Clippy * Remove some unused commented out code
This commit is contained in:
@@ -112,11 +112,11 @@ pub fn get_gradient(layer: LayerNodeIdentifier, document: &Document) -> Option<G
|
||||
return None;
|
||||
};
|
||||
Some(Gradient {
|
||||
start: start.clone(),
|
||||
end: end.clone(),
|
||||
transform: transform.clone(),
|
||||
start: *start,
|
||||
end: *end,
|
||||
transform: *transform,
|
||||
positions: positions.clone(),
|
||||
gradient_type: gradient_type.clone(),
|
||||
gradient_type: *gradient_type,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ pub fn get_manipulator_from_id(subpaths: &[Subpath<ManipulatorGroupId>], id: Man
|
||||
/// An immutable reference to a layer within the document node graph for easy access.
|
||||
pub struct NodeGraphLayer<'a> {
|
||||
node_graph: &'a NodeNetwork,
|
||||
outwards_links: HashMap<NodeId, Vec<NodeId>>,
|
||||
_outwards_links: HashMap<NodeId, Vec<NodeId>>,
|
||||
layer_node: NodeId,
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ impl<'a> NodeGraphLayer<'a> {
|
||||
|
||||
Some(Self {
|
||||
node_graph,
|
||||
outwards_links,
|
||||
_outwards_links: outwards_links,
|
||||
layer_node: layer.to_node(),
|
||||
})
|
||||
}
|
||||
@@ -225,7 +225,7 @@ impl<'a> NodeGraphLayer<'a> {
|
||||
}
|
||||
Some(Self {
|
||||
node_graph,
|
||||
outwards_links,
|
||||
_outwards_links: outwards_links,
|
||||
layer_node,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::consts::{COLOR_ACCENT, PATH_OUTLINE_WEIGHT};
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use document_legacy::document_metadata::LayerNodeIdentifier;
|
||||
use document_legacy::layers::style::{self, Fill, RenderData, Stroke};
|
||||
use document_legacy::layers::style::{self, Fill, Stroke};
|
||||
use document_legacy::{LayerId, Operation};
|
||||
|
||||
use glam::DAffine2;
|
||||
@@ -18,13 +18,7 @@ pub struct PathOutline {
|
||||
|
||||
impl PathOutline {
|
||||
/// Creates an outline of a layer either with a pre-existing overlay or by generating a new one
|
||||
fn try_create_outline(
|
||||
layer: LayerNodeIdentifier,
|
||||
overlay_path: Option<Vec<LayerId>>,
|
||||
document: &DocumentMessageHandler,
|
||||
responses: &mut VecDeque<Message>,
|
||||
render_data: &RenderData,
|
||||
) -> Option<Vec<LayerId>> {
|
||||
fn try_create_outline(layer: LayerNodeIdentifier, overlay_path: Option<Vec<LayerId>>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) -> Option<Vec<LayerId>> {
|
||||
let subpath = document.metadata().layer_outline(layer);
|
||||
let transform = document.metadata().transform_to_viewport(layer);
|
||||
|
||||
@@ -64,15 +58,9 @@ impl PathOutline {
|
||||
/// Creates an outline of a layer either with a pre-existing overlay or by generating a new one.
|
||||
///
|
||||
/// Creates an outline, discarding the overlay on failure.
|
||||
fn create_outline(
|
||||
layer: LayerNodeIdentifier,
|
||||
overlay_path: Option<Vec<LayerId>>,
|
||||
document: &DocumentMessageHandler,
|
||||
responses: &mut VecDeque<Message>,
|
||||
render_data: &RenderData,
|
||||
) -> Option<Vec<LayerId>> {
|
||||
fn create_outline(layer: LayerNodeIdentifier, overlay_path: Option<Vec<LayerId>>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) -> Option<Vec<LayerId>> {
|
||||
let copied_overlay_path = overlay_path.clone();
|
||||
let result = Self::try_create_outline(layer, overlay_path, document, responses, render_data);
|
||||
let result = Self::try_create_outline(layer, overlay_path, document, responses);
|
||||
if result.is_none() {
|
||||
// Discard the overlay layer if it exists
|
||||
if let Some(overlay_path) = copied_overlay_path {
|
||||
@@ -93,7 +81,7 @@ impl PathOutline {
|
||||
}
|
||||
|
||||
/// Performs an intersect test and generates a hovered overlay if necessary
|
||||
pub fn intersect_test_hovered(&mut self, input: &InputPreprocessorMessageHandler, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>, render_data: &RenderData) {
|
||||
pub fn intersect_test_hovered(&mut self, input: &InputPreprocessorMessageHandler, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
|
||||
// Get the layer the user is hovering over
|
||||
let intersection = document.metadata().click(input.mouse.position, &document.document_legacy.document_network);
|
||||
|
||||
@@ -108,7 +96,7 @@ impl PathOutline {
|
||||
}
|
||||
|
||||
// Updates the overlay, generating a new one if necessary
|
||||
self.hovered_overlay_path = Self::create_outline(hovered_layer, self.hovered_overlay_path.take(), document, responses, render_data);
|
||||
self.hovered_overlay_path = Self::create_outline(hovered_layer, self.hovered_overlay_path.take(), document, responses);
|
||||
if self.hovered_overlay_path.is_none() {
|
||||
self.clear_hovered(responses);
|
||||
}
|
||||
@@ -125,11 +113,11 @@ impl PathOutline {
|
||||
}
|
||||
|
||||
/// Updates the selected overlays, generating or removing overlays if necessary
|
||||
pub fn update_selected<'a>(&mut self, selected: impl Iterator<Item = LayerNodeIdentifier>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>, render_data: &RenderData) {
|
||||
pub fn update_selected(&mut self, selected: impl Iterator<Item = LayerNodeIdentifier>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
|
||||
let mut old_overlay_paths = std::mem::take(&mut self.selected_overlay_paths);
|
||||
|
||||
for layer_identifier in selected {
|
||||
if let Some(overlay_path) = Self::create_outline(layer_identifier, old_overlay_paths.pop(), document, responses, render_data) {
|
||||
if let Some(overlay_path) = Self::create_outline(layer_identifier, old_overlay_paths.pop(), document, responses) {
|
||||
self.selected_overlay_paths.push(overlay_path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use document_legacy::document_metadata::LayerNodeIdentifier;
|
||||
use document_legacy::layers::style::{self, RenderData};
|
||||
use document_legacy::layers::style;
|
||||
use document_legacy::{LayerId, Operation};
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
@@ -51,7 +51,7 @@ impl Pivot {
|
||||
}
|
||||
|
||||
/// Recomputes the pivot position and transform.
|
||||
fn recalculate_pivot(&mut self, document: &DocumentMessageHandler, render_data: &RenderData) {
|
||||
fn recalculate_pivot(&mut self, document: &DocumentMessageHandler) {
|
||||
let mut layers = document.metadata().selected_visible_layers();
|
||||
let Some(first) = layers.next() else {
|
||||
// If no layers are selected then we revert things back to default
|
||||
@@ -138,8 +138,8 @@ impl Pivot {
|
||||
responses.add(DocumentMessage::Overlays(Operation::TransformLayerInViewport { path: inner, transform }.into()));
|
||||
}
|
||||
|
||||
pub fn update_pivot(&mut self, document: &DocumentMessageHandler, render_data: &RenderData, responses: &mut VecDeque<Message>) {
|
||||
self.recalculate_pivot(document, render_data);
|
||||
pub fn update_pivot(&mut self, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
|
||||
self.recalculate_pivot(document);
|
||||
self.redraw_pivot(responses);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user