diff --git a/.gitignore b/.gitignore index 9f898935..815f5c39 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ target/ perf.data* profile.json flamegraph.svg + diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index dffca237..b7f68eb3 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -1655,7 +1655,7 @@ impl DocumentMessageHandler { path.pop(); } } - structure_section.push(space | 1 << 63); + structure_section.push(space | (1 << 63)); } /// Serializes the layer structure into a condensed 1D structure. diff --git a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs index 2cac6d8b..59e183a6 100644 --- a/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs +++ b/editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs @@ -1095,7 +1095,7 @@ fn static_nodes() -> Vec { }, DocumentNodeDefinition { identifier: "Image", - category: "", + category: "Raster", node_template: NodeTemplate { document_node: DocumentNode { implementation: DocumentNodeImplementation::Network(NodeNetwork { diff --git a/editor/src/messages/portfolio/document/utility_types/network_interface.rs b/editor/src/messages/portfolio/document/utility_types/network_interface.rs index 3920eb7f..1c828472 100644 --- a/editor/src/messages/portfolio/document/utility_types/network_interface.rs +++ b/editor/src/messages/portfolio/document/utility_types/network_interface.rs @@ -366,7 +366,7 @@ impl NodeNetworkInterface { // If a chain node does not have a selected downstream layer, then set the position to absolute let downstream_layer = self.downstream_layer(node_id, network_path); - if downstream_layer.map_or(true, |downstream_layer| new_ids.keys().all(|key| *key != downstream_layer.to_node())) { + if downstream_layer.is_none_or(|downstream_layer| new_ids.keys().all(|key| *key != downstream_layer.to_node())) { let Some(position) = self.position(node_id, network_path) else { log::error!("Could not get position in create_node_template"); return None; diff --git a/editor/src/messages/tool/common_functionality/graph_modification_utils.rs b/editor/src/messages/tool/common_functionality/graph_modification_utils.rs index b9e75aed..87d30c12 100644 --- a/editor/src/messages/tool/common_functionality/graph_modification_utils.rs +++ b/editor/src/messages/tool/common_functionality/graph_modification_utils.rs @@ -5,6 +5,7 @@ use crate::messages::portfolio::document::utility_types::network_interface::{Flo use crate::messages::prelude::*; use bezier_rs::Subpath; +use graph_craft::concrete; use graph_craft::document::{value::TaggedValue, NodeId, NodeInput}; use graphene_core::raster::image::ImageFrameTable; use graphene_core::raster::BlendMode; @@ -417,4 +418,16 @@ impl<'a> NodeGraphLayer<'a> { // TODO: Find a better way to accept a node input rather than using its index (which is quite unclear and fragile) self.find_node_inputs(node_name)?.get(index)?.as_value() } + + /// Check if a layer is a raster layer + pub fn is_raster_layer(layer: LayerNodeIdentifier, network_interface: &mut NodeNetworkInterface) -> bool { + let layer_input_type = network_interface.input_type(&InputConnector::node(layer.to_node(), 1), &[]).0.nested_type(); + if layer_input_type == concrete!(graphene_core::raster::image::ImageFrameTable) + || layer_input_type == concrete!(graphene_core::application_io::TextureFrameTable) + || layer_input_type == concrete!(graphene_std::RasterFrame) + { + return true; + } + false + } } diff --git a/editor/src/messages/tool/common_functionality/snapping/alignment_snapper.rs b/editor/src/messages/tool/common_functionality/snapping/alignment_snapper.rs index b99b1ecc..32d56318 100644 --- a/editor/src/messages/tool/common_functionality/snapping/alignment_snapper.rs +++ b/editor/src/messages/tool/common_functionality/snapping/alignment_snapper.rs @@ -89,7 +89,7 @@ impl AlignmentSnapper { if let Some(point_on_x) = point_on_x { let distance_to_snapped = point.document_point.distance(point_on_x); let distance_to_align_target = point_on_x.distance(target_position); - if distance_to_snapped < tolerance && snap_x.as_ref().map_or(true, |point| distance_to_align_target < point.distance_to_align_target) { + if distance_to_snapped < tolerance && snap_x.as_ref().is_none_or(|point| distance_to_align_target < point.distance_to_align_target) { snap_x = Some(SnappedPoint { snapped_point_document: point_on_x, source: point.source, // TODO(0Hypercube): map source @@ -108,7 +108,7 @@ impl AlignmentSnapper { if let Some(point_on_y) = point_on_y { let distance_to_snapped = point.document_point.distance(point_on_y); let distance_to_align_target = point_on_y.distance(target_position); - if distance_to_snapped < tolerance && snap_y.as_ref().map_or(true, |point| distance_to_align_target < point.distance_to_align_target) { + if distance_to_snapped < tolerance && snap_y.as_ref().is_none_or(|point| distance_to_align_target < point.distance_to_align_target) { snap_y = Some(SnappedPoint { snapped_point_document: point_on_y, source: point.source, // TODO(0Hypercube): map source diff --git a/editor/src/messages/tool/tool_messages/fill_tool.rs b/editor/src/messages/tool/tool_messages/fill_tool.rs index ce87e181..f3103540 100644 --- a/editor/src/messages/tool/tool_messages/fill_tool.rs +++ b/editor/src/messages/tool/tool_messages/fill_tool.rs @@ -1,7 +1,6 @@ use super::tool_prelude::*; - +use crate::messages::tool::common_functionality::graph_modification_utils::NodeGraphLayer; use graphene_core::vector::style::Fill; - #[derive(Default)] pub struct FillTool { fsm_state: FillToolFsmState, @@ -87,6 +86,10 @@ impl Fsm for FillToolFsmState { let Some(layer_identifier) = document.click(input) else { return self; }; + // If the layer is a raster layer, don't fill it, wait till the flood fill tool is implemented + if NodeGraphLayer::is_raster_layer(layer_identifier, &mut document.network_interface) { + return self; + } let fill = match color_event { FillToolMessage::FillPrimaryColor => Fill::Solid(global_tool_data.primary_color), FillToolMessage::FillSecondaryColor => Fill::Solid(global_tool_data.secondary_color), @@ -147,8 +150,6 @@ mod test_fill { } #[tokio::test] - // TODO: fix https://github.com/GraphiteEditor/Graphite/issues/2270 - #[should_panic] async fn ignore_raster() { let mut editor = EditorTestUtils::create(); editor.new_document().await; diff --git a/editor/src/messages/tool/tool_messages/freehand_tool.rs b/editor/src/messages/tool/tool_messages/freehand_tool.rs index 3686b144..5413210d 100644 --- a/editor/src/messages/tool/tool_messages/freehand_tool.rs +++ b/editor/src/messages/tool/tool_messages/freehand_tool.rs @@ -311,7 +311,7 @@ impl Fsm for FreehandToolFsmState { } fn extend_path_with_next_segment(tool_data: &mut FreehandToolData, position: DVec2, extend: bool, responses: &mut VecDeque) { - if !tool_data.end_point.map_or(true, |(last_pos, _)| position != last_pos) || !position.is_finite() { + if !tool_data.end_point.is_none_or(|(last_pos, _)| position != last_pos) || !position.is_finite() { return; } diff --git a/editor/src/messages/tool/tool_messages/spline_tool.rs b/editor/src/messages/tool/tool_messages/spline_tool.rs index 6f76f839..a86cfccb 100644 --- a/editor/src/messages/tool/tool_messages/spline_tool.rs +++ b/editor/src/messages/tool/tool_messages/spline_tool.rs @@ -364,7 +364,7 @@ impl Fsm for SplineToolFsmState { return SplineToolFsmState::Ready; }; tool_data.next_point = tool_data.snapped_point(document, input).snapped_point_document; - if tool_data.points.last().map_or(true, |last_pos| last_pos.1.distance(tool_data.next_point) > DRAG_THRESHOLD) { + if tool_data.points.last().is_none_or(|last_pos| last_pos.1.distance(tool_data.next_point) > DRAG_THRESHOLD) { let preview_point = tool_data.preview_point; extend_spline(tool_data, false, responses); tool_data.preview_point = preview_point; diff --git a/node-graph/gcore/src/application_io.rs b/node-graph/gcore/src/application_io.rs index a8c889ca..e7787a8c 100644 --- a/node-graph/gcore/src/application_io.rs +++ b/node-graph/gcore/src/application_io.rs @@ -87,7 +87,14 @@ impl Hash for ImageTexture { impl PartialEq for ImageTexture { fn eq(&self, other: &Self) -> bool { - self.texture == other.texture + #[cfg(feature = "wgpu")] + { + self.texture == other.texture + } + #[cfg(not(feature = "wgpu"))] + { + true // Unit values are always equal + } } } diff --git a/node-graph/gcore/src/vector/vector_data/modification.rs b/node-graph/gcore/src/vector/vector_data/modification.rs index e5060d19..9251f6db 100644 --- a/node-graph/gcore/src/vector/vector_data/modification.rs +++ b/node-graph/gcore/src/vector/vector_data/modification.rs @@ -132,7 +132,7 @@ impl SegmentModification { let start = self.handle_primary.get(&id).copied().map(|handle| handle.map(|handle| handle + start)); let end = self.handle_end.get(&id).copied().map(|handle| handle.map(|handle| handle + end)); - if !start.unwrap_or_default().map_or(true, |start| start.is_finite()) || !end.unwrap_or_default().map_or(true, |end| end.is_finite()) { + if !start.unwrap_or_default().is_none_or(|start| start.is_finite()) || !end.unwrap_or_default().is_none_or(|end| end.is_finite()) { warn!("Invalid handles when applying a segment modification"); continue; }