Skip to content

Commit 153c5e2

Browse files
4adexKeavon
authored andcommitted
Fix add path node button enable
1 parent 523132d commit 153c5e2

2 files changed

Lines changed: 21 additions & 7 deletions

File tree

editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use graph_craft::document::value::TaggedValue;
2525
use graph_craft::document::{DocumentNodeImplementation, NodeId, NodeInput};
2626
use graph_craft::proto::GraphErrors;
2727
use graphene_std::math::math_ext::QuadExt;
28+
use graphene_std::vector::VectorModification;
2829
use graphene_std::vector::misc::subpath_to_kurbo_bezpath;
2930
use graphene_std::*;
3031
use kurbo::{Line, Point};
@@ -145,9 +146,17 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
145146
if first_layer.is_some() && has_single_selection && is_compatible {
146147
if let Some(layer) = first_layer {
147148
let node_type = "Path".to_string();
148-
let graph_layer = graph_modification_utils::NodeGraphLayer::new(layer, &network_interface);
149-
let is_modifiable = matches!(graph_layer.find_input("Path", 1), Some(TaggedValue::VectorModification(_)));
150-
if !is_modifiable {
149+
let path_node_with_no_diffs_exist = first_layer.is_some_and(|layer| {
150+
let graph_layer = graph_modification_utils::NodeGraphLayer::new(layer, &network_interface);
151+
if let Some(TaggedValue::VectorModification(vector)) = graph_layer.find_input("Path", 1) {
152+
let modification = *vector.clone();
153+
modification == VectorModification::default()
154+
} else {
155+
false
156+
}
157+
});
158+
159+
if !path_node_with_no_diffs_exist {
151160
responses.add(NodeGraphMessage::CreateNodeInLayerWithTransaction {
152161
node_type: node_type.clone(),
153162
layer: LayerNodeIdentifier::new_unchecked(layer.to_node()),

editor/src/messages/tool/tool_messages/path_tool.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use graph_craft::document::value::TaggedValue;
2323
use graphene_std::renderer::Quad;
2424
use graphene_std::transform::ReferencePoint;
2525
use graphene_std::vector::click_target::ClickTargetType;
26-
use graphene_std::vector::{HandleExt, HandleId, NoHashBuilder, SegmentId, VectorData};
26+
use graphene_std::vector::{HandleExt, HandleId, NoHashBuilder, SegmentId, VectorData, VectorModification};
2727
use graphene_std::vector::{ManipulatorPointId, PointId, VectorModificationType};
2828
use std::vec;
2929

@@ -2423,12 +2423,17 @@ impl Fsm for PathToolFsmState {
24232423

24242424
let is_compatible = compatible_type.as_deref() == Some("type:Instances<VectorData>");
24252425

2426-
let is_modifiable = first_layer.is_some_and(|layer| {
2426+
let path_node_with_no_diffs_exist = first_layer.is_some_and(|layer| {
24272427
let graph_layer = graph_modification_utils::NodeGraphLayer::new(layer, &document.network_interface);
2428-
matches!(graph_layer.find_input("Path", 1), Some(TaggedValue::VectorModification(_)))
2428+
if let Some(TaggedValue::VectorModification(vector)) = graph_layer.find_input("Path", 1) {
2429+
let modification = *vector.clone();
2430+
modification == VectorModification::default()
2431+
} else {
2432+
false
2433+
}
24292434
});
24302435

2431-
first_layer.is_some() && has_single_selection && is_compatible && !is_modifiable
2436+
first_layer.is_some() && has_single_selection && is_compatible && !path_node_with_no_diffs_exist
24322437
};
24332438
tool_data.update_selection_status(shape_editor, document);
24342439
self

0 commit comments

Comments
 (0)