mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-08 00:05:00 +00:00
Fix Rust code lints (#1448)
* Fix Rust lints to satisfy Clippy * Remove some unused commented out code
This commit is contained in:
parent
f6d104265a
commit
605c0de392
24 changed files with 117 additions and 187 deletions
|
@ -374,8 +374,7 @@ impl PathGraph {
|
|||
|
||||
pub fn get_cycles(&self) -> Vec<Cycle> {
|
||||
let mut cycles = Vec::new();
|
||||
let mut markers = Vec::new();
|
||||
markers.resize(self.size(), 0);
|
||||
let mut markers = vec![0; self.size()];
|
||||
|
||||
self.vertices.iter().enumerate().for_each(|(vertex_index, _vertex)| {
|
||||
if (markers[vertex_index] & 1) == 0 {
|
||||
|
|
|
@ -122,7 +122,7 @@ impl DocumentMetadata {
|
|||
let Some(output_node) = graph.nodes.get(&id) else {
|
||||
return;
|
||||
};
|
||||
let Some((layer_node, node_id)) = first_child_layer(graph, output_node, id) else {
|
||||
let Some((layer_node, node_id)) = first_child_layer(graph, output_node) else {
|
||||
return;
|
||||
};
|
||||
let parent = LayerNodeIdentifier::ROOT;
|
||||
|
@ -134,21 +134,21 @@ impl DocumentMetadata {
|
|||
if !self.structure.contains_key(¤t_identifier) {
|
||||
parent.push_child(self, current_identifier);
|
||||
|
||||
if let Some((child_node, child_id)) = first_child_layer(graph, current_node, current_id) {
|
||||
if let Some((child_node, child_id)) = first_child_layer(graph, current_node) {
|
||||
stack.push((child_node, child_id, current_identifier));
|
||||
}
|
||||
}
|
||||
|
||||
current = sibling_below(graph, current_node, current_id);
|
||||
current = sibling_below(graph, current_node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn first_child_layer<'a>(graph: &'a NodeNetwork, node: &DocumentNode, id: NodeId) -> Option<(&'a DocumentNode, NodeId)> {
|
||||
fn first_child_layer<'a>(graph: &'a NodeNetwork, node: &DocumentNode) -> Option<(&'a DocumentNode, NodeId)> {
|
||||
graph.primary_flow_from_opt(Some(node.inputs[0].as_node()?)).find(|(node, _)| node.name == "Layer")
|
||||
}
|
||||
fn sibling_below<'a>(graph: &'a NodeNetwork, node: &DocumentNode, id: NodeId) -> Option<(&'a DocumentNode, NodeId)> {
|
||||
fn sibling_below<'a>(graph: &'a NodeNetwork, node: &DocumentNode) -> Option<(&'a DocumentNode, NodeId)> {
|
||||
node.inputs[7].as_node().and_then(|id| graph.nodes.get(&id).filter(|node| node.name == "Layer").map(|node| (node, id)))
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ impl DocumentMetadata {
|
|||
|
||||
/// Find the layer that has been clicked on from a viewport space location
|
||||
pub fn click(&self, viewport_location: DVec2, network: &NodeNetwork) -> Option<LayerNodeIdentifier> {
|
||||
self.click_xray(viewport_location).filter(|&layer| !is_artboard(layer, network)).next()
|
||||
self.click_xray(viewport_location).find(|&layer| !is_artboard(layer, network))
|
||||
}
|
||||
|
||||
/// Get the bounding box of the click target of the specified layer in the specified transform space
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
use graphite_proc_macros::WidgetBuilder;
|
||||
|
||||
use derivative::*;
|
||||
|
|
|
@ -22,13 +22,11 @@ use document_legacy::document_metadata::LayerNodeIdentifier;
|
|||
use document_legacy::layers::blend_mode::BlendMode;
|
||||
|
||||
use document_legacy::layers::layer_info::{LayerDataType, LayerDataTypeDiscriminant};
|
||||
use document_legacy::layers::layer_layer::CachedOutputData;
|
||||
use document_legacy::layers::style::{RenderData, ViewMode};
|
||||
use document_legacy::{DocumentError, DocumentResponse, LayerId, Operation as DocumentOperation};
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{NodeInput, NodeNetwork};
|
||||
use graphene_core::raster::ImageFrame;
|
||||
use graphene_core::text::Font;
|
||||
|
||||
use glam::{DAffine2, DVec2};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -891,7 +889,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
}
|
||||
UpdateDocumentTransform { transform } => {
|
||||
self.document_legacy.metadata.document_to_viewport = transform;
|
||||
let transform = graphene_core::renderer::format_transform_matrix(transform);
|
||||
responses.add(DocumentMessage::RenderRulers);
|
||||
responses.add(DocumentMessage::RenderScrollbars);
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
|
@ -993,13 +990,9 @@ impl DocumentMessageHandler {
|
|||
DocumentRenderMode::OnlyBelowLayerInFolder(below_layer_path) => (self.document_legacy.render_layers_below(below_layer_path, &render_data).unwrap(), None),
|
||||
DocumentRenderMode::LayerCutout(layer_path, background) => (self.document_legacy.render_layer(layer_path, &render_data).unwrap(), Some(background)),
|
||||
};
|
||||
let artboards = match transparent_background {
|
||||
false => "<!--artboards-->",
|
||||
true => "".into(),
|
||||
};
|
||||
let outside_artboards_color = outside.map_or_else(|| if false { "ffffff" } else { "222222" }.to_string(), |col| col.rgba_hex());
|
||||
let outside_artboards = match transparent_background {
|
||||
false => format!(r##"<rect x="0" y="0" width="100%" height="100%" fill="#{outside_artboards_color}" />"##),
|
||||
let canvas_background_color = outside.map_or_else(|| "222222".to_string(), |col| col.rgba_hex());
|
||||
let canvas_background = match transparent_background {
|
||||
false => format!(r##"<rect x="0" y="0" width="100%" height="100%" fill="#{canvas_background_color}" />"##),
|
||||
true => "".into(),
|
||||
};
|
||||
let matrix = transform
|
||||
|
@ -1008,7 +1001,7 @@ impl DocumentMessageHandler {
|
|||
.enumerate()
|
||||
.fold(String::new(), |acc, (i, entry)| acc + &(entry.to_string() + if i == 5 { "" } else { "," }));
|
||||
let svg = format!(
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1 1" width="{}" height="{}">{}{outside_artboards}<g transform="matrix({matrix})">{artboards}{artwork}</g></svg>"#,
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 1 1" width="{}" height="{}">{}{canvas_background}<g transform="matrix({matrix})">{artwork}</g></svg>"#,
|
||||
size.x, size.y, "\n",
|
||||
);
|
||||
|
||||
|
@ -1128,11 +1121,11 @@ impl DocumentMessageHandler {
|
|||
|
||||
fn serialize_structure(&self, folder: LayerNodeIdentifier, structure: &mut Vec<u64>, data: &mut Vec<LayerId>, path: &mut Vec<LayerId>) {
|
||||
let mut space = 0;
|
||||
for layer_node in folder.children(&self.metadata()) {
|
||||
for layer_node in folder.children(self.metadata()) {
|
||||
data.push(layer_node.to_node());
|
||||
info!("Pushed child");
|
||||
space += 1;
|
||||
if layer_node.has_children(&self.metadata()) {
|
||||
if layer_node.has_children(self.metadata()) {
|
||||
path.push(layer_node.to_node());
|
||||
|
||||
// TODO: Skip if folder is not expanded.
|
||||
|
@ -1197,7 +1190,7 @@ impl DocumentMessageHandler {
|
|||
// Compute the indices for each layer to be able to sort them
|
||||
let mut layers_with_indices: Vec<(&[LayerId], Vec<usize>)> = paths
|
||||
// 'path.len() > 0' filters out root layer since it has no indices
|
||||
.filter_map(|path| (!path.is_empty()).then_some(path))
|
||||
.filter(|path| !path.is_empty())
|
||||
.filter_map(|path| {
|
||||
// TODO: `indices_for_path` can return an error. We currently skip these layers and log a warning. Once this problem is solved this code can be simplified.
|
||||
match self.document_legacy.indices_for_path(path) {
|
||||
|
@ -1446,7 +1439,7 @@ impl DocumentMessageHandler {
|
|||
}
|
||||
|
||||
/// Loads layer resources such as creating the blob URLs for the images and loading all of the fonts in the document
|
||||
pub fn load_layer_resources(&self, responses: &mut VecDeque<Message>, root: &LayerDataType, mut path: Vec<LayerId>, _document_id: u64) {
|
||||
pub fn load_layer_resources(&self, responses: &mut VecDeque<Message>) {
|
||||
let mut fonts = HashSet::new();
|
||||
for (_node_id, node) in self.document_legacy.document_network.recursive_nodes() {
|
||||
for input in &node.inputs {
|
||||
|
|
|
@ -62,7 +62,7 @@ impl<'a> ModifyInputsContext<'a> {
|
|||
/// Updates the input of an existing node
|
||||
fn modify_existing_node_inputs(&mut self, node_id: NodeId, update_input: impl FnOnce(&mut Vec<NodeInput>, NodeId, &DocumentMetadata)) {
|
||||
let document_node = self.network.nodes.get_mut(&node_id).unwrap();
|
||||
update_input(&mut document_node.inputs, node_id, &self.document_metadata);
|
||||
update_input(&mut document_node.inputs, node_id, self.document_metadata);
|
||||
}
|
||||
|
||||
pub fn insert_between(&mut self, id: NodeId, pre: NodeOutput, post: NodeOutput, mut node: DocumentNode, input: usize, output: usize, shift_upstream: IVec2) -> Option<NodeId> {
|
||||
|
@ -106,7 +106,7 @@ impl<'a> ModifyInputsContext<'a> {
|
|||
NodeOutput::new(node_id, 0)
|
||||
} else {
|
||||
// The user has connected another node to the output. Insert a layer node between the output and the node.
|
||||
let mut node = resolve_document_node_type("Layer").expect("Layer node").default_document_node();
|
||||
let node = resolve_document_node_type("Layer").expect("Layer node").default_document_node();
|
||||
let node_id = self.insert_between(generate_uuid(), NodeOutput::new(node_id, output_index), output, node, 0, 0, IVec2::new(-8, 0))?;
|
||||
NodeOutput::new(node_id, 0)
|
||||
};
|
||||
|
@ -114,7 +114,7 @@ impl<'a> ModifyInputsContext<'a> {
|
|||
let node = resolve_document_node_type("Layer").expect("Layer node").default_document_node();
|
||||
self.insert_between(new_id, sibling_layer, output, node, 7, 0, IVec2::new(0, 3))
|
||||
} else {
|
||||
let mut layer_node = resolve_document_node_type("Layer").expect("Node").default_document_node();
|
||||
let layer_node = resolve_document_node_type("Layer").expect("Node").default_document_node();
|
||||
self.insert_node_before(new_id, output_node_id, input_index, layer_node, IVec2::new(-5, 3))
|
||||
};
|
||||
|
||||
|
@ -145,7 +145,6 @@ impl<'a> ModifyInputsContext<'a> {
|
|||
Default::default(),
|
||||
);
|
||||
self.responses.add(NodeGraphMessage::SendGraph { should_rerender: true });
|
||||
let cull_id = generate_uuid();
|
||||
self.insert_node_before(generate_uuid(), layer, 0, artboard_node, IVec2::new(-8, 0))
|
||||
}
|
||||
|
||||
|
@ -257,7 +256,7 @@ impl<'a> ModifyInputsContext<'a> {
|
|||
return;
|
||||
};
|
||||
let mut new_document_node = node_type.to_document_node_default_inputs([Some(new_input)], metadata);
|
||||
update_input(&mut new_document_node.inputs, node_id, &self.document_metadata);
|
||||
update_input(&mut new_document_node.inputs, node_id, self.document_metadata);
|
||||
self.network.nodes.insert(node_id, new_document_node);
|
||||
}
|
||||
|
||||
|
@ -361,7 +360,10 @@ impl<'a> ModifyInputsContext<'a> {
|
|||
};
|
||||
let pivot = DAffine2::from_translation(upstream_transform.transform_point2(bounds.layerspace_pivot(transform_utils::get_current_normalized_pivot(inputs))));
|
||||
|
||||
if let Some(current_transform) = current_transform.filter(|transform| transform.matrix2.determinant() != 0. && upstream_transform.matrix2.determinant() != 0.) {
|
||||
if current_transform
|
||||
.filter(|transform| transform.matrix2.determinant() != 0. && upstream_transform.matrix2.determinant() != 0.)
|
||||
.is_some()
|
||||
{
|
||||
transform = transform * upstream_transform.inverse();
|
||||
}
|
||||
let final_transform = pivot.inverse() * to.inverse() * transform * pivot;
|
||||
|
@ -546,7 +548,6 @@ impl MessageHandler<GraphOperationMessage, (&mut Document, &mut NodeGraphMessage
|
|||
if let Some(mut modify_inputs) = ModifyInputsContext::new_layer(&layer, document, node_graph, responses) {
|
||||
modify_inputs.transform_set(transform, transform_in, parent_transform, current_transform, bounds, skip_rerender);
|
||||
}
|
||||
let transform = transform.to_cols_array();
|
||||
}
|
||||
GraphOperationMessage::TransformSetPivot { layer, pivot } => {
|
||||
let bounds = LayerBounds::new(document, &layer);
|
||||
|
|
|
@ -743,10 +743,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
|
|||
|
||||
responses.add(NodeGraphMessage::SendGraph { should_rerender: false });
|
||||
}
|
||||
NodeGraphMessage::RunDocumentGraph => responses.add(PortfolioMessage::SubmitGraphRender {
|
||||
document_id: document_id,
|
||||
layer_path: Vec::new(),
|
||||
}),
|
||||
NodeGraphMessage::RunDocumentGraph => responses.add(PortfolioMessage::SubmitGraphRender { document_id, layer_path: Vec::new() }),
|
||||
NodeGraphMessage::SendGraph { should_rerender } => {
|
||||
if let Some(network) = document.document_network.nested_network(&self.network) {
|
||||
Self::send_graph(network, &self.layer_path, responses);
|
||||
|
|
|
@ -1171,7 +1171,7 @@ pub fn logic_operator_properties(document_node: &DocumentNode, node_id: NodeId,
|
|||
vec![LayoutGroup::Row { widgets }]
|
||||
}
|
||||
|
||||
pub fn transform_properties(document_node: &DocumentNode, node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
pub fn transform_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let translation_assist = |widgets: &mut Vec<WidgetHolder>| {
|
||||
let pivot_index = 5;
|
||||
if let NodeInput::Value {
|
||||
|
|
|
@ -6,7 +6,6 @@ use crate::messages::tool::common_functionality::shape_editor::ShapeState;
|
|||
use crate::messages::tool::utility_types::ToolType;
|
||||
use document_legacy::document::Document;
|
||||
use document_legacy::document_metadata::LayerNodeIdentifier;
|
||||
use document_legacy::layers::style::RenderData;
|
||||
use graphene_core::renderer::Quad;
|
||||
use graphene_core::vector::{ManipulatorPointId, SelectedType};
|
||||
|
||||
|
@ -31,13 +30,11 @@ impl OriginalTransforms {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update<'a>(&mut self, selected: &'a [LayerNodeIdentifier], responses: &'a mut VecDeque<Message>, document: &'a Document, shape_editor: Option<&'a ShapeState>, tool_type: &'a ToolType) {
|
||||
pub fn update<'a>(&mut self, selected: &'a [LayerNodeIdentifier], document: &'a Document, shape_editor: Option<&'a ShapeState>) {
|
||||
match self {
|
||||
OriginalTransforms::Layer(layer_map) => {
|
||||
for &layer in selected {
|
||||
if !layer_map.contains_key(&layer) {
|
||||
layer_map.insert(layer, document.metadata.transform_to_document(layer));
|
||||
}
|
||||
layer_map.entry(layer).or_insert_with(|| document.metadata.transform_to_document(layer));
|
||||
}
|
||||
}
|
||||
OriginalTransforms::Path(path_map) => {
|
||||
|
@ -335,7 +332,7 @@ impl<'a> Selected<'a> {
|
|||
*original_transforms = OriginalTransforms::Layer(HashMap::new());
|
||||
}
|
||||
|
||||
original_transforms.update(selected, responses, document, shape_editor, tool_type);
|
||||
original_transforms.update(selected, document, shape_editor);
|
||||
|
||||
Self {
|
||||
selected,
|
||||
|
@ -348,7 +345,7 @@ impl<'a> Selected<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mean_average_of_pivots(&mut self, render_data: &RenderData) -> DVec2 {
|
||||
pub fn mean_average_of_pivots(&mut self) -> DVec2 {
|
||||
let xy_summation = self
|
||||
.selected
|
||||
.iter()
|
||||
|
@ -359,7 +356,7 @@ impl<'a> Selected<'a> {
|
|||
xy_summation / self.selected.len() as f64
|
||||
}
|
||||
|
||||
pub fn center_of_aabb(&mut self, render_data: &RenderData) -> DVec2 {
|
||||
pub fn center_of_aabb(&mut self) -> DVec2 {
|
||||
let [min, max] = self
|
||||
.selected
|
||||
.iter()
|
||||
|
|
|
@ -11,11 +11,9 @@ use crate::messages::prelude::*;
|
|||
use crate::messages::tool::utility_types::{HintData, HintGroup};
|
||||
use crate::node_graph_executor::NodeGraphExecutor;
|
||||
|
||||
use document_legacy::layers::layer_info::LayerDataType;
|
||||
use document_legacy::layers::style::RenderData;
|
||||
use document_legacy::Operation as DocumentOperation;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{NodeId, NodeInput};
|
||||
use graph_craft::document::NodeId;
|
||||
use graphene_core::text::Font;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
@ -236,7 +234,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
self.persistent_data.font_cache.insert(font, preview_url, data, is_default);
|
||||
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
|
||||
|
||||
if let Some(document) = self.active_document_mut() {
|
||||
if self.active_document_mut().is_some() {
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
|
@ -298,7 +296,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
}
|
||||
PortfolioMessage::LoadDocumentResources { document_id } => {
|
||||
if let Some(document) = self.document_mut(document_id) {
|
||||
document.load_layer_resources(responses, &document.document_legacy.root.data, Vec::new(), document_id);
|
||||
document.load_layer_resources(responses);
|
||||
}
|
||||
}
|
||||
PortfolioMessage::LoadFont { font, is_default } => {
|
||||
|
@ -400,7 +398,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
layer_path: destination_path.clone(),
|
||||
layer_metadata: entry.layer_metadata,
|
||||
});
|
||||
document.load_layer_resources(responses, &entry.layer.data, destination_path.clone(), self.active_document_id.unwrap());
|
||||
document.load_layer_resources(responses);
|
||||
responses.add_front(DocumentOperation::InsertLayer {
|
||||
layer: Box::new(entry.layer.clone()),
|
||||
destination_path,
|
||||
|
@ -433,7 +431,7 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
for entry in data.iter().rev() {
|
||||
let destination_path = [shallowest_common_folder.to_vec(), vec![generate_uuid()]].concat();
|
||||
|
||||
document.load_layer_resources(responses, &entry.layer.data, destination_path.clone(), self.active_document_id.unwrap());
|
||||
document.load_layer_resources(responses);
|
||||
responses.add(DocumentOperation::InsertLayer {
|
||||
layer: Box::new(entry.layer.clone()),
|
||||
destination_path: destination_path.clone(),
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, u64, &InputPreprocess
|
|||
#[remain::unsorted]
|
||||
ToolMessage::TransformLayer(message) => self
|
||||
.transform_layer_handler
|
||||
.process_message(message, responses, (document, input, &render_data, &self.tool_state.tool_data, &mut self.shape_editor)),
|
||||
.process_message(message, responses, (document, input, &self.tool_state.tool_data, &mut self.shape_editor)),
|
||||
|
||||
#[remain::unsorted]
|
||||
ToolMessage::ActivateToolSelect => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Select }),
|
||||
|
|
|
@ -252,7 +252,7 @@ impl SelectedGradient {
|
|||
};
|
||||
|
||||
// Clear the gradient if layer deleted
|
||||
if !inner_gradient.layer.exists(&document.metadata()) {
|
||||
if !inner_gradient.layer.exists(document.metadata()) {
|
||||
responses.add(ToolMessage::RefreshToolOptions);
|
||||
*gradient = None;
|
||||
return;
|
||||
|
@ -497,7 +497,7 @@ impl Fsm for GradientToolFsmState {
|
|||
if pos.distance_squared(mouse) < tolerance {
|
||||
dragging = true;
|
||||
tool_data.selected_gradient = Some(SelectedGradient {
|
||||
layer: overlay.layer.clone(),
|
||||
layer: overlay.layer,
|
||||
transform: overlay.transform,
|
||||
gradient: overlay.gradient.clone(),
|
||||
dragging: GradientDragTarget::Step(index),
|
||||
|
@ -514,7 +514,7 @@ impl Fsm for GradientToolFsmState {
|
|||
dragging = true;
|
||||
start_snap(&mut tool_data.snap_manager, document, input, render_data);
|
||||
tool_data.selected_gradient = Some(SelectedGradient {
|
||||
layer: overlay.layer.clone(),
|
||||
layer: overlay.layer,
|
||||
transform: overlay.transform,
|
||||
gradient: overlay.gradient.clone(),
|
||||
dragging: dragging_target,
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::vec;
|
|||
|
||||
use super::tool_prelude::*;
|
||||
use crate::consts::{DRAG_THRESHOLD, SELECTION_THRESHOLD, SELECTION_TOLERANCE};
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils::{self, get_manipulator_from_id, get_mirror_handles, get_subpaths};
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils::{get_manipulator_from_id, get_mirror_handles, get_subpaths};
|
||||
use crate::messages::tool::common_functionality::overlay_renderer::OverlayRenderer;
|
||||
use crate::messages::tool::common_functionality::shape_editor::{ManipulatorAngle, ManipulatorPointInfo, OpposingHandleLengths, SelectedPointsInfo, ShapeState};
|
||||
use crate::messages::tool::common_functionality::snapping::SnapManager;
|
||||
|
|
|
@ -99,21 +99,21 @@ impl ToolMetadata for SelectTool {
|
|||
}
|
||||
|
||||
impl SelectTool {
|
||||
fn deep_selection_widget(&self) -> WidgetHolder {
|
||||
let layer_selection_behavior_entries = [NestedSelectionBehavior::Deepest, NestedSelectionBehavior::Shallowest]
|
||||
.iter()
|
||||
.map(|mode| {
|
||||
DropdownEntryData::new(mode.to_string())
|
||||
.value(mode.to_string())
|
||||
.on_update(move |_| SelectToolMessage::SelectOptions(SelectOptionsUpdate::NestedSelectionBehavior(*mode)).into())
|
||||
})
|
||||
.collect();
|
||||
// fn deep_selection_widget(&self) -> WidgetHolder {
|
||||
// let layer_selection_behavior_entries = [NestedSelectionBehavior::Deepest, NestedSelectionBehavior::Shallowest]
|
||||
// .iter()
|
||||
// .map(|mode| {
|
||||
// DropdownEntryData::new(mode.to_string())
|
||||
// .value(mode.to_string())
|
||||
// .on_update(move |_| SelectToolMessage::SelectOptions(SelectOptionsUpdate::NestedSelectionBehavior(*mode)).into())
|
||||
// })
|
||||
// .collect();
|
||||
|
||||
DropdownInput::new(vec![layer_selection_behavior_entries])
|
||||
.selected_index(Some((self.tool_data.nested_selection_behavior == NestedSelectionBehavior::Shallowest) as u32))
|
||||
.tooltip("Choose if clicking nested layers directly selects the deepest, or selects the shallowest and deepens by double clicking")
|
||||
.widget_holder()
|
||||
}
|
||||
// DropdownInput::new(vec![layer_selection_behavior_entries])
|
||||
// .selected_index(Some((self.tool_data.nested_selection_behavior == NestedSelectionBehavior::Shallowest) as u32))
|
||||
// .tooltip("Choose if clicking nested layers directly selects the deepest, or selects the shallowest and deepens by double clicking")
|
||||
// .widget_holder()
|
||||
// }
|
||||
|
||||
fn pivot_widget(&self, disabled: bool) -> WidgetHolder {
|
||||
PivotAssist::new(self.tool_data.pivot.to_pivot_position())
|
||||
|
@ -155,7 +155,7 @@ impl SelectTool {
|
|||
|
||||
fn boolean_widgets(&self) -> impl Iterator<Item = WidgetHolder> {
|
||||
["Union", "Subtract Front", "Subtract Back", "Intersect", "Difference"].into_iter().map(|name| {
|
||||
IconButton::new(format!("Boolean{}", name.replace(" ", "")), 24)
|
||||
IconButton::new(format!("Boolean{}", name.replace(' ', "")), 24)
|
||||
.tooltip(format!("Boolean {name} (coming soon)"))
|
||||
.on_update(|_| DialogMessage::RequestComingSoonDialog { issue: Some(1091) }.into())
|
||||
.widget_holder()
|
||||
|
@ -337,10 +337,10 @@ impl SelectToolData {
|
|||
// });
|
||||
}
|
||||
|
||||
// Since the selected layers have now moved back to their original transforms before the drag began, we rerender them to be displayed as if they weren't touched.
|
||||
for layer_path in self.not_duplicated_layers.iter().flatten() {
|
||||
//responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.clone() });
|
||||
}
|
||||
// // Since the selected layers have now moved back to their original transforms before the drag began, we rerender them to be displayed as if they weren't touched.
|
||||
// for layer_path in self.not_duplicated_layers.iter().flatten() {
|
||||
// responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.clone() });
|
||||
// }
|
||||
}
|
||||
|
||||
/// Removes the duplicated layers. Called when Alt is released and the layers have previously been duplicated.
|
||||
|
@ -393,8 +393,8 @@ impl Fsm for SelectToolFsmState {
|
|||
tool_data.selected_layers_changed = selected_layers_count != tool_data.selected_layers_count;
|
||||
tool_data.selected_layers_count = selected_layers_count;
|
||||
|
||||
tool_data.path_outlines.update_selected(document.metadata().selected_layers(), document, responses, render_data);
|
||||
tool_data.path_outlines.intersect_test_hovered(input, document, responses, render_data);
|
||||
tool_data.path_outlines.update_selected(document.metadata().selected_layers(), document, responses);
|
||||
tool_data.path_outlines.intersect_test_hovered(input, document, responses);
|
||||
|
||||
match (document.metadata().selected_visible_layers_bounding_box_viewport(), tool_data.bounding_box_overlays.take()) {
|
||||
(None, Some(bounding_box_overlays)) => bounding_box_overlays.delete(responses),
|
||||
|
@ -411,7 +411,7 @@ impl Fsm for SelectToolFsmState {
|
|||
(_, _) => {}
|
||||
};
|
||||
|
||||
tool_data.pivot.update_pivot(document, render_data, responses);
|
||||
tool_data.pivot.update_pivot(document, responses);
|
||||
|
||||
self
|
||||
}
|
||||
|
@ -419,14 +419,14 @@ impl Fsm for SelectToolFsmState {
|
|||
// Edit the clicked layer
|
||||
if let Some(intersect) = document.metadata().click(input.mouse.position, &document.document_legacy.document_network) {
|
||||
match tool_data.nested_selection_behavior {
|
||||
NestedSelectionBehavior::Shallowest => edit_layer_shallowest_manipulation(document, intersect, tool_data, responses),
|
||||
NestedSelectionBehavior::Shallowest => edit_layer_shallowest_manipulation(document, intersect, responses),
|
||||
NestedSelectionBehavior::Deepest => edit_layer_deepest_manipulation(intersect, &document.document_legacy, responses),
|
||||
}
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
(SelectToolFsmState::Ready, SelectToolMessage::DragStart { add_to_selection, select_deepest }) => {
|
||||
(SelectToolFsmState::Ready, SelectToolMessage::DragStart { add_to_selection, select_deepest: _ }) => {
|
||||
tool_data.path_outlines.clear_hovered(responses);
|
||||
|
||||
tool_data.drag_start = input.mouse.position;
|
||||
|
@ -451,7 +451,6 @@ impl Fsm for SelectToolFsmState {
|
|||
.unwrap_or_default();
|
||||
|
||||
let mut selected: Vec<_> = document.metadata().selected_visible_layers().collect();
|
||||
let quad = tool_data.selection_quad();
|
||||
let intersection = document.metadata().click(input.mouse.position, &document.document_legacy.document_network);
|
||||
|
||||
// If the user is dragging the bounding box bounds, go into ResizingBounds mode.
|
||||
|
@ -466,12 +465,12 @@ impl Fsm for SelectToolFsmState {
|
|||
tool_data.snap_manager.add_all_document_handles(document, input, &[], &[], &[]);
|
||||
|
||||
SelectToolFsmState::DraggingPivot
|
||||
} else if let Some(selected_edges) = dragging_bounds {
|
||||
} else if let Some(_selected_edges) = dragging_bounds {
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
||||
let snap_x = selected_edges.2 || selected_edges.3;
|
||||
let snap_y = selected_edges.0 || selected_edges.1;
|
||||
|
||||
// let snap_x = selected_edges.2 || selected_edges.3;
|
||||
// let snap_y = selected_edges.0 || selected_edges.1;
|
||||
//
|
||||
// tool_data
|
||||
// .snap_manager
|
||||
// .start_snap(document, input, document.bounding_boxes(Some(&selected), None, render_data), snap_x, snap_y);
|
||||
|
@ -493,7 +492,7 @@ impl Fsm for SelectToolFsmState {
|
|||
None,
|
||||
&ToolType::Select,
|
||||
);
|
||||
bounds.center_of_transformation = selected.mean_average_of_pivots(render_data);
|
||||
bounds.center_of_transformation = selected.mean_average_of_pivots();
|
||||
}
|
||||
|
||||
SelectToolFsmState::ResizingBounds
|
||||
|
@ -511,7 +510,7 @@ impl Fsm for SelectToolFsmState {
|
|||
&ToolType::Select,
|
||||
);
|
||||
|
||||
bounds.center_of_transformation = selected.mean_average_of_pivots(render_data);
|
||||
bounds.center_of_transformation = selected.mean_average_of_pivots();
|
||||
}
|
||||
|
||||
tool_data.layers_dragging = selected;
|
||||
|
@ -681,7 +680,7 @@ impl Fsm for SelectToolFsmState {
|
|||
|
||||
// Generate the select outline (but not if the user is going to use the bound overlays)
|
||||
if cursor == MouseCursorIcon::Default {
|
||||
tool_data.path_outlines.intersect_test_hovered(input, document, responses, render_data);
|
||||
tool_data.path_outlines.intersect_test_hovered(input, document, responses);
|
||||
} else {
|
||||
tool_data.path_outlines.clear_hovered(responses);
|
||||
}
|
||||
|
@ -694,8 +693,6 @@ impl Fsm for SelectToolFsmState {
|
|||
SelectToolFsmState::Ready
|
||||
}
|
||||
(SelectToolFsmState::Dragging, SelectToolMessage::Enter) => {
|
||||
rerender_selected_layers(tool_data, responses);
|
||||
|
||||
let response = match input.mouse.position.distance(tool_data.drag_start) < 10. * f64::EPSILON {
|
||||
true => DocumentMessage::Undo,
|
||||
false => DocumentMessage::CommitTransaction,
|
||||
|
@ -706,8 +703,6 @@ impl Fsm for SelectToolFsmState {
|
|||
SelectToolFsmState::Ready
|
||||
}
|
||||
(SelectToolFsmState::Dragging, SelectToolMessage::DragStop { remove_from_selection }) => {
|
||||
rerender_selected_layers(tool_data, responses);
|
||||
|
||||
// Deselect layer if not snap dragging
|
||||
if !tool_data.has_dragged && input.keyboard.key(remove_from_selection) && tool_data.layer_selected_on_start.is_none() {
|
||||
let quad = tool_data.selection_quad();
|
||||
|
@ -741,8 +736,6 @@ impl Fsm for SelectToolFsmState {
|
|||
SelectToolFsmState::Ready
|
||||
}
|
||||
(SelectToolFsmState::ResizingBounds, SelectToolMessage::DragStop { .. } | SelectToolMessage::Enter) => {
|
||||
rerender_selected_layers(tool_data, responses);
|
||||
|
||||
let response = match input.mouse.position.distance(tool_data.drag_start) < 10. * f64::EPSILON {
|
||||
true => DocumentMessage::Undo,
|
||||
false => DocumentMessage::CommitTransaction,
|
||||
|
@ -758,8 +751,6 @@ impl Fsm for SelectToolFsmState {
|
|||
SelectToolFsmState::Ready
|
||||
}
|
||||
(SelectToolFsmState::RotatingBounds, SelectToolMessage::DragStop { .. } | SelectToolMessage::Enter) => {
|
||||
rerender_selected_layers(tool_data, responses);
|
||||
|
||||
let response = match input.mouse.position.distance(tool_data.drag_start) < 10. * f64::EPSILON {
|
||||
true => DocumentMessage::Undo,
|
||||
false => DocumentMessage::CommitTransaction,
|
||||
|
@ -803,19 +794,15 @@ impl Fsm for SelectToolFsmState {
|
|||
|
||||
if let Some(layer) = selected_layers.next() {
|
||||
// Check that only one layer is selected
|
||||
if selected_layers.next().is_none() {
|
||||
if is_text_layer(layer, &document.document_legacy) {
|
||||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Text });
|
||||
responses.add(TextToolMessage::EditSelected);
|
||||
}
|
||||
if selected_layers.next().is_none() && is_text_layer(layer, &document.document_legacy) {
|
||||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Text });
|
||||
responses.add(TextToolMessage::EditSelected);
|
||||
}
|
||||
}
|
||||
|
||||
SelectToolFsmState::Ready
|
||||
}
|
||||
(SelectToolFsmState::Dragging, SelectToolMessage::Abort) => {
|
||||
rerender_selected_layers(tool_data, responses);
|
||||
|
||||
tool_data.snap_manager.cleanup(responses);
|
||||
responses.add(DocumentMessage::Undo);
|
||||
|
||||
|
@ -912,12 +899,7 @@ impl Fsm for SelectToolFsmState {
|
|||
}
|
||||
}
|
||||
|
||||
fn rerender_selected_layers(tool_data: &mut SelectToolData, responses: &mut VecDeque<Message>) {
|
||||
// for layer in &tool_data.layers_dragging {
|
||||
// responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer.to_path() });
|
||||
// }
|
||||
}
|
||||
fn drag_shallowest_manipulation(responses: &mut VecDeque<Message>, mut selected: Vec<LayerNodeIdentifier>, tool_data: &mut SelectToolData, document: &DocumentMessageHandler) {
|
||||
fn drag_shallowest_manipulation(responses: &mut VecDeque<Message>, selected: Vec<LayerNodeIdentifier>, tool_data: &mut SelectToolData, document: &DocumentMessageHandler) {
|
||||
let layer = selected[0];
|
||||
let ancestor = layer.ancestors(document.metadata()).find(|&ancestor| document.metadata().selected_layers_contains(ancestor));
|
||||
|
||||
|
@ -942,14 +924,12 @@ fn drag_deepest_manipulation(responses: &mut VecDeque<Message>, mut selected: Ve
|
|||
// .start_snap(document, input, document.bounding_boxes(Some(&tool_data.layers_dragging), None, render_data), true, true);
|
||||
}
|
||||
|
||||
fn edit_layer_shallowest_manipulation(document: &DocumentMessageHandler, layer: LayerNodeIdentifier, tool_data: &mut SelectToolData, responses: &mut VecDeque<Message>) {
|
||||
fn edit_layer_shallowest_manipulation(document: &DocumentMessageHandler, layer: LayerNodeIdentifier, responses: &mut VecDeque<Message>) {
|
||||
if document.metadata().selected_layers_contains(layer) {
|
||||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Path });
|
||||
return;
|
||||
}
|
||||
|
||||
let selected_layers_collected: Vec<_> = document.selected_layers().collect();
|
||||
|
||||
let Some(new_selected) = layer
|
||||
.ancestors(document.metadata())
|
||||
.find(|ancestor| ancestor.parent(document.metadata()).is_some_and(|parent| document.metadata().selected_layers_contains(parent)))
|
||||
|
@ -968,14 +948,3 @@ fn edit_layer_deepest_manipulation(layer: LayerNodeIdentifier, document: &Docume
|
|||
responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Path });
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::if_same_then_else)]
|
||||
fn recursive_search(document: &DocumentMessageHandler, layer_path: &[u64], incoming_layer_path_vector: &Vec<u64>) -> bool {
|
||||
let layer_paths = document.document_legacy.folder_children_paths(layer_path);
|
||||
for path in layer_paths {
|
||||
if path == *incoming_layer_path_vector || (document.document_legacy.is_folder(&path) && recursive_search(document, &path, incoming_layer_path_vector)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
use super::tool_prelude::*;
|
||||
use crate::application::generate_uuid;
|
||||
use crate::consts::{COLOR_ACCENT, SELECTION_TOLERANCE};
|
||||
use crate::messages::portfolio::document::node_graph::new_text_network;
|
||||
use crate::consts::COLOR_ACCENT;
|
||||
use crate::messages::tool::common_functionality::color_selector::{ToolColorOptions, ToolColorType};
|
||||
use crate::messages::tool::common_functionality::graph_modification_utils::{self, is_text_layer};
|
||||
|
||||
use document_legacy::document_metadata::LayerNodeIdentifier;
|
||||
use document_legacy::intersection::Quad;
|
||||
use document_legacy::layers::layer_info::Layer;
|
||||
use document_legacy::layers::style::{self, Fill, RenderData, Stroke};
|
||||
use document_legacy::LayerId;
|
||||
use document_legacy::Operation;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNode, NodeId, NodeInput, NodeNetwork};
|
||||
use graphene_core::text::{load_face, Font};
|
||||
use graphene_core::Color;
|
||||
|
||||
|
@ -277,7 +274,7 @@ impl TextToolData {
|
|||
|
||||
fn interact(&mut self, state: TextToolFsmState, mouse: DVec2, document: &DocumentMessageHandler, render_data: &RenderData, responses: &mut VecDeque<Message>) -> TextToolFsmState {
|
||||
// Check if the user has selected an existing text layer
|
||||
if let Some(clicked_text_layer_path) = document.metadata().click(mouse, &document.network()).filter(|&layer| is_text_layer(layer, &document.document_legacy)) {
|
||||
if let Some(clicked_text_layer_path) = document.metadata().click(mouse, document.network()).filter(|&layer| is_text_layer(layer, &document.document_legacy)) {
|
||||
self.start_editing_layer(clicked_text_layer_path, state, document, render_data, responses);
|
||||
|
||||
TextToolFsmState::Editing
|
||||
|
|
|
@ -5,7 +5,6 @@ use crate::messages::prelude::*;
|
|||
use crate::messages::tool::common_functionality::shape_editor::ShapeState;
|
||||
use crate::messages::tool::utility_types::{ToolData, ToolType};
|
||||
|
||||
use document_legacy::layers::style::RenderData;
|
||||
use graphene_core::vector::ManipulatorPointId;
|
||||
|
||||
use glam::DVec2;
|
||||
|
@ -38,10 +37,10 @@ impl TransformLayerMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
type TransformData<'a> = (&'a DocumentMessageHandler, &'a InputPreprocessorMessageHandler, &'a RenderData<'a>, &'a ToolData, &'a mut ShapeState);
|
||||
type TransformData<'a> = (&'a DocumentMessageHandler, &'a InputPreprocessorMessageHandler, &'a ToolData, &'a mut ShapeState);
|
||||
impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformLayerMessageHandler {
|
||||
#[remain::check]
|
||||
fn process_message(&mut self, message: TransformLayerMessage, responses: &mut VecDeque<Message>, (document, ipp, render_data, tool_data, shape_editor): TransformData) {
|
||||
fn process_message(&mut self, message: TransformLayerMessage, responses: &mut VecDeque<Message>, (document, ipp, tool_data, shape_editor): TransformData) {
|
||||
use TransformLayerMessage::*;
|
||||
|
||||
let using_path_tool = tool_data.active_tool_type == ToolType::Path;
|
||||
|
@ -88,7 +87,7 @@ impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformL
|
|||
}
|
||||
}
|
||||
} else {
|
||||
*selected.pivot = selected.mean_average_of_pivots(render_data);
|
||||
*selected.pivot = selected.mean_average_of_pivots();
|
||||
}
|
||||
|
||||
*mouse_position = ipp.mouse.position;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::messages::frontend::utility_types::FrontendImageData;
|
||||
use crate::messages::portfolio::document::node_graph::{transform_utils, wrap_network_in_scope};
|
||||
use crate::messages::portfolio::document::node_graph::wrap_network_in_scope;
|
||||
use crate::messages::portfolio::document::utility_types::misc::{LayerMetadata, LayerPanelEntry};
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
|
@ -9,12 +9,12 @@ use document_legacy::layers::layer_info::{LayerDataType, LayerDataTypeDiscrimina
|
|||
use document_legacy::{LayerId, Operation};
|
||||
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{generate_uuid, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, NodeOutput};
|
||||
use graph_craft::document::{generate_uuid, DocumentNodeImplementation, NodeId, NodeNetwork};
|
||||
use graph_craft::graphene_compiler::Compiler;
|
||||
use graph_craft::imaginate_input::ImaginatePreferences;
|
||||
use graph_craft::{concrete, Type};
|
||||
use graphene_core::application_io::{ApplicationIo, NodeGraphUpdateMessage, NodeGraphUpdateSender, RenderConfig};
|
||||
use graphene_core::raster::{Image, ImageFrame};
|
||||
use graphene_core::raster::Image;
|
||||
use graphene_core::renderer::{ClickTarget, GraphicElementRendered, SvgSegment, SvgSegmentList};
|
||||
use graphene_core::text::FontCache;
|
||||
use graphene_core::transform::{Footprint, Transform};
|
||||
|
@ -152,7 +152,7 @@ impl NodeRuntime {
|
|||
let (result, monitor_nodes) = self.execute_network(&path, graph, transform, viewport_resolution).await;
|
||||
let mut responses = VecDeque::new();
|
||||
self.update_thumbnails(&path, &monitor_nodes, &mut responses);
|
||||
self.update_upstream_transforms(&path, &monitor_nodes, &mut responses);
|
||||
self.update_upstream_transforms(&monitor_nodes);
|
||||
let response = GenerationResponse {
|
||||
generation_id,
|
||||
result,
|
||||
|
@ -169,7 +169,7 @@ impl NodeRuntime {
|
|||
}
|
||||
}
|
||||
|
||||
async fn execute_network<'a>(&'a mut self, path: &[LayerId], mut graph: NodeNetwork, transform: DAffine2, viewport_resolution: UVec2) -> (Result<TaggedValue, String>, MonitorNodes) {
|
||||
async fn execute_network<'a>(&'a mut self, path: &[LayerId], graph: NodeNetwork, transform: DAffine2, viewport_resolution: UVec2) -> (Result<TaggedValue, String>, MonitorNodes) {
|
||||
if self.wasm_io.is_none() {
|
||||
self.wasm_io = Some(WasmApplicationIo::new().await);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ impl NodeRuntime {
|
|||
}
|
||||
}
|
||||
}
|
||||
(Ok((result)), monitor_nodes)
|
||||
(Ok(result), monitor_nodes)
|
||||
}
|
||||
|
||||
/// Recomputes the thumbnails for the layers in the graph, modifying the state and updating the UI.
|
||||
|
@ -306,7 +306,7 @@ impl NodeRuntime {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_upstream_transforms(&mut self, layer_path: &[LayerId], monitor_nodes: &[Vec<u64>], responses: &mut VecDeque<Message>) {
|
||||
pub fn update_upstream_transforms(&mut self, monitor_nodes: &[Vec<u64>]) {
|
||||
for node_path in monitor_nodes {
|
||||
let Some(node_id) = node_path.get(node_path.len() - 2).copied() else {
|
||||
warn!("Monitor node has invalid node id");
|
||||
|
@ -522,7 +522,7 @@ impl NodeGraphExecutor {
|
|||
let node_graph_output = result.map_err(|e| format!("Node graph evaluation failed: {e:?}"))?;
|
||||
let execution_context = self.futures.remove(&generation_id).ok_or_else(|| "Invalid generation ID".to_string())?;
|
||||
responses.extend(updates);
|
||||
self.process_node_graph_output(node_graph_output, execution_context.layer_path.clone(), transform, responses, execution_context.document_id)?;
|
||||
self.process_node_graph_output(node_graph_output, execution_context.layer_path.clone(), transform, responses)?;
|
||||
responses.add(DocumentMessage::LayerChanged {
|
||||
affected_layer_path: execution_context.layer_path,
|
||||
});
|
||||
|
@ -558,7 +558,7 @@ impl NodeGraphExecutor {
|
|||
responses.add(FrontendMessage::UpdateDocumentNodeRender { svg });
|
||||
}
|
||||
|
||||
fn process_node_graph_output(&mut self, node_graph_output: TaggedValue, layer_path: Vec<LayerId>, transform: DAffine2, responses: &mut VecDeque<Message>, document_id: u64) -> Result<(), String> {
|
||||
fn process_node_graph_output(&mut self, node_graph_output: TaggedValue, layer_path: Vec<LayerId>, transform: DAffine2, responses: &mut VecDeque<Message>) -> Result<(), String> {
|
||||
self.last_output_type.insert(layer_path.clone(), Some(node_graph_output.ty()));
|
||||
match node_graph_output {
|
||||
TaggedValue::SurfaceFrame(SurfaceFrame { surface_id, transform }) => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::raster::{BlendMode, ImageFrame};
|
||||
use crate::vector::{subpath, VectorData};
|
||||
use crate::vector::VectorData;
|
||||
use crate::{Color, Node};
|
||||
|
||||
use bezier_rs::BezierHandles;
|
||||
|
@ -231,7 +231,6 @@ impl GraphicElement {
|
|||
let mut builder = PathBuilder::new();
|
||||
|
||||
let transform = to_transform(vector_data.transform);
|
||||
let style = &vector_data.style;
|
||||
for subpath in vector_data.subpaths.iter() {
|
||||
let start = vector_data.transform.transform_point2(subpath[0].anchor);
|
||||
builder.move_to(start.x as f32, start.y as f32);
|
||||
|
@ -300,7 +299,7 @@ impl GraphicElement {
|
|||
group_element
|
||||
}
|
||||
// TODO
|
||||
GraphicElementData::Artboard(board) => usvg::Node::new(usvg::NodeKind::Group(usvg::Group::default())),
|
||||
GraphicElementData::Artboard(_board) => usvg::Node::new(usvg::NodeKind::Group(usvg::Group::default())),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -861,7 +861,6 @@ pub struct PosterizeNode<P> {
|
|||
fn posterize(color: Color, posterize_value: f32) -> Color {
|
||||
let color = color.to_gamma_srgb();
|
||||
|
||||
let posterize_value = posterize_value;
|
||||
let number_of_areas = posterize_value.recip();
|
||||
let size_of_areas = (posterize_value - 1.).recip();
|
||||
let channel = |channel: f32| (channel / number_of_areas).floor() * size_of_areas;
|
||||
|
|
|
@ -70,12 +70,10 @@ impl Gradient {
|
|||
let transformed_bound_transform = DAffine2::from_scale_angle_translation(transformed_bounds[1] - transformed_bounds[0], 0., transformed_bounds[0]);
|
||||
let updated_transform = multiplied_transform * bound_transform;
|
||||
|
||||
let positions = self
|
||||
.positions
|
||||
.iter()
|
||||
.filter_map(|(pos, color)| color.map(|color| (pos, color)))
|
||||
.map(|(position, color)| format!(r##"<stop offset="{}" stop-color="#{}" />"##, position, color.rgba_hex()))
|
||||
.collect::<String>();
|
||||
let mut positions = String::new();
|
||||
for (position, color) in self.positions.iter().filter_map(|(pos, color)| color.map(|color| (pos, color))) {
|
||||
let _ = write!(positions, r##"<stop offset="{}" stop-color="#{}" />"##, position, color.rgba_hex());
|
||||
}
|
||||
|
||||
let mod_gradient = transformed_bound_transform.inverse();
|
||||
let mod_points = mod_gradient.inverse() * transformed_bound_transform.inverse() * updated_transform;
|
||||
|
|
|
@ -228,7 +228,7 @@ impl DocumentNode {
|
|||
identifier: fqn,
|
||||
input,
|
||||
construction_args: args,
|
||||
document_node_path: self.path.unwrap_or(Vec::new()),
|
||||
document_node_path: self.path.unwrap_or_default(),
|
||||
skip_deduplication: self.skip_deduplication,
|
||||
hash: self.hash,
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ use graphene_core::raster::Image;
|
|||
use graphene_core::renderer::{GraphicElementRendered, RenderParams, SvgRender};
|
||||
use graphene_core::transform::Footprint;
|
||||
use graphene_core::vector::style::ViewMode;
|
||||
use graphene_core::Color;
|
||||
use graphene_core::{
|
||||
raster::{color::SRGBA8, ImageFrame},
|
||||
Node,
|
||||
};
|
||||
use graphene_core::{Color, GraphicGroup};
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use js_sys::{Object, Reflect};
|
||||
use std::collections::HashMap;
|
||||
|
@ -29,9 +29,6 @@ use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
|
|||
#[cfg(feature = "wgpu")]
|
||||
use wgpu_executor::WgpuExecutor;
|
||||
|
||||
use base64::Engine;
|
||||
use glam::DAffine2;
|
||||
|
||||
pub struct Canvas(CanvasRenderingContext2d);
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue