Skip to content

Commit

Permalink
check raster image using input type instead
Browse files Browse the repository at this point in the history
  • Loading branch information
EllenGYY committed Mar 9, 2025
1 parent d37af6c commit bad4bed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ perf.data*
profile.json
flamegraph.svg

.cursor/
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
use crate::messages::portfolio::document::node_graph::document_node_definitions;
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_document_node_type;
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
use crate::messages::portfolio::document::utility_types::network_interface::{FlowType, InputConnector, NodeNetworkInterface, NodeTemplate};
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;
Expand Down Expand Up @@ -419,21 +419,12 @@ impl<'a> NodeGraphLayer<'a> {
self.find_node_inputs(node_name)?.get(index)?.as_value()
}

pub fn is_raster_layer(layer: LayerNodeIdentifier, network_interface: &NodeNetworkInterface) -> bool {
let layer = NodeGraphLayer::new(layer, network_interface);

// Iterate through all nodes in the horizontal layer flow
for node_id in layer.horizontal_layer_flow() {
// Get the node reference name
if let Some(Some(node_name)) = layer.network_interface.reference(&node_id, &[]) {
if let Some(node_type) = resolve_document_node_type(node_name) {
if node_type.category.contains("Raster") {
return true;
}
}
}
/// 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<graphene_core::Color>) {
return true;
}

false
}
}
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/fill_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl Fsm for FillToolFsmState {
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, &document.network_interface) {
if NodeGraphLayer::is_raster_layer(layer_identifier, &mut document.network_interface) {
return self;
}
let fill = match color_event {
Expand Down

0 comments on commit bad4bed

Please sign in to comment.