mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-28 18:08:11 +08:00
Refactor naming to deprecate "node graph frame" terminology (#1187)
This commit is contained in:
@@ -87,6 +87,27 @@ pub enum DocumentMessage {
|
||||
},
|
||||
FrameClear,
|
||||
GroupSelectedLayers,
|
||||
ImaginateClear {
|
||||
layer_path: Vec<LayerId>,
|
||||
node_id: NodeId,
|
||||
cached_index: usize,
|
||||
},
|
||||
ImaginateGenerate {
|
||||
layer_path: Vec<LayerId>,
|
||||
imaginate_node: Vec<NodeId>,
|
||||
},
|
||||
ImaginateRandom {
|
||||
layer_path: Vec<LayerId>,
|
||||
imaginate_node: Vec<NodeId>,
|
||||
then_generate: bool,
|
||||
},
|
||||
ImaginateTerminate {
|
||||
layer_path: Vec<LayerId>,
|
||||
node_path: Vec<NodeId>,
|
||||
},
|
||||
InputFrameRasterizeRegionBelowLayer {
|
||||
layer_path: Vec<LayerId>,
|
||||
},
|
||||
LayerChanged {
|
||||
affected_layer_path: Vec<LayerId>,
|
||||
},
|
||||
@@ -95,27 +116,6 @@ pub enum DocumentMessage {
|
||||
insert_index: isize,
|
||||
reverse_index: bool,
|
||||
},
|
||||
NodeGraphFrameClear {
|
||||
layer_path: Vec<LayerId>,
|
||||
node_id: NodeId,
|
||||
cached_index: usize,
|
||||
},
|
||||
NodeGraphFrameGenerate {
|
||||
layer_path: Vec<LayerId>,
|
||||
},
|
||||
NodeGraphFrameImaginate {
|
||||
layer_path: Vec<LayerId>,
|
||||
imaginate_node: Vec<NodeId>,
|
||||
},
|
||||
NodeGraphFrameImaginateRandom {
|
||||
layer_path: Vec<LayerId>,
|
||||
imaginate_node: Vec<NodeId>,
|
||||
then_generate: bool,
|
||||
},
|
||||
NodeGraphFrameImaginateTerminate {
|
||||
layer_path: Vec<LayerId>,
|
||||
node_path: Vec<NodeId>,
|
||||
},
|
||||
NudgeSelectedLayers {
|
||||
delta_x: f64,
|
||||
delta_y: f64,
|
||||
|
||||
@@ -28,7 +28,7 @@ use document_legacy::document::Document as DocumentLegacy;
|
||||
use document_legacy::layers::blend_mode::BlendMode;
|
||||
use document_legacy::layers::folder_layer::FolderLayer;
|
||||
use document_legacy::layers::layer_info::{LayerDataType, LayerDataTypeDiscriminant};
|
||||
use document_legacy::layers::nodegraph_layer::CachedOutputData;
|
||||
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;
|
||||
@@ -394,18 +394,18 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
responses.extend([LayerChanged { affected_layer_path }.into(), DocumentStructureChanged.into()]);
|
||||
}
|
||||
FrameClear => {
|
||||
let mut selected_frame_layers = self.selected_layers_with_type(LayerDataTypeDiscriminant::NodeGraphFrame);
|
||||
// Get what is hopefully the only selected NodeGraphFrame layer
|
||||
let mut selected_frame_layers = self.selected_layers_with_type(LayerDataTypeDiscriminant::Layer);
|
||||
// Get what is hopefully the only selected Layer layer
|
||||
let layer_path = selected_frame_layers.next();
|
||||
// Abort if we didn't have any NodeGraphFrame layer, or if there are additional ones also selected
|
||||
// Abort if we didn't have any Layer layer, or if there are additional ones also selected
|
||||
if layer_path.is_none() || selected_frame_layers.next().is_some() {
|
||||
return;
|
||||
}
|
||||
let layer_path = layer_path.unwrap();
|
||||
|
||||
let layer = self.document_legacy.layer(layer_path).expect("Clearing NodeGraphFrame image for invalid layer");
|
||||
let layer = self.document_legacy.layer(layer_path).expect("Clearing Layer image for invalid layer");
|
||||
let previous_blob_url = match &layer.data {
|
||||
LayerDataType::NodeGraphFrame(node_graph_frame) => node_graph_frame.as_blob_url(),
|
||||
LayerDataType::Layer(layer) => layer.as_blob_url(),
|
||||
x => panic!("Cannot find blob url for layer type {}", LayerDataTypeDiscriminant::from(x)),
|
||||
};
|
||||
|
||||
@@ -437,6 +437,51 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
replacement_selected_layers: vec![new_folder_path],
|
||||
});
|
||||
}
|
||||
ImaginateClear {
|
||||
layer_path,
|
||||
node_id,
|
||||
cached_index: input_index,
|
||||
} => {
|
||||
let value = graph_craft::document::value::TaggedValue::RcImage(None);
|
||||
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value });
|
||||
responses.add(InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
ImaginateGenerate { layer_path, imaginate_node } => {
|
||||
if let Some(message) = self.rasterize_region_below_layer(document_id, layer_path, preferences, persistent_data, Some(imaginate_node)) {
|
||||
responses.add(message);
|
||||
}
|
||||
}
|
||||
ImaginateRandom {
|
||||
layer_path,
|
||||
imaginate_node,
|
||||
then_generate,
|
||||
} => {
|
||||
// Set a random seed input
|
||||
responses.add(NodeGraphMessage::SetInputValue {
|
||||
node_id: *imaginate_node.last().unwrap(),
|
||||
// Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeType` in `document_node_type.rs`
|
||||
input_index: 1,
|
||||
value: graph_craft::document::value::TaggedValue::F64((generate_uuid() >> 1) as f64),
|
||||
});
|
||||
|
||||
// Generate the image
|
||||
if then_generate {
|
||||
responses.add(DocumentMessage::ImaginateGenerate { layer_path, imaginate_node });
|
||||
}
|
||||
}
|
||||
ImaginateTerminate { layer_path, node_path } => {
|
||||
responses.add(FrontendMessage::TriggerImaginateTerminate {
|
||||
document_id,
|
||||
layer_path,
|
||||
node_path,
|
||||
hostname: preferences.imaginate_server_hostname.clone(),
|
||||
});
|
||||
}
|
||||
InputFrameRasterizeRegionBelowLayer { layer_path } => {
|
||||
if let Some(message) = self.rasterize_region_below_layer(document_id, layer_path, preferences, persistent_data, None) {
|
||||
responses.add(message);
|
||||
}
|
||||
}
|
||||
LayerChanged { affected_layer_path } => {
|
||||
if let Ok(layer_entry) = self.layer_panel_entry(affected_layer_path.clone(), &render_data) {
|
||||
responses.add(FrontendMessage::UpdateDocumentLayerDetails { data: layer_entry });
|
||||
@@ -466,51 +511,6 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
insert_index,
|
||||
});
|
||||
}
|
||||
NodeGraphFrameClear {
|
||||
layer_path,
|
||||
node_id,
|
||||
cached_index: input_index,
|
||||
} => {
|
||||
let value = graph_craft::document::value::TaggedValue::RcImage(None);
|
||||
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value });
|
||||
responses.add(NodeGraphFrameGenerate { layer_path });
|
||||
}
|
||||
NodeGraphFrameGenerate { layer_path } => {
|
||||
if let Some(message) = self.call_node_graph_frame(document_id, layer_path, preferences, persistent_data, None) {
|
||||
responses.add(message);
|
||||
}
|
||||
}
|
||||
NodeGraphFrameImaginate { layer_path, imaginate_node } => {
|
||||
if let Some(message) = self.call_node_graph_frame(document_id, layer_path, preferences, persistent_data, Some(imaginate_node)) {
|
||||
responses.add(message);
|
||||
}
|
||||
}
|
||||
NodeGraphFrameImaginateRandom {
|
||||
layer_path,
|
||||
imaginate_node,
|
||||
then_generate,
|
||||
} => {
|
||||
// Set a random seed input
|
||||
responses.add(NodeGraphMessage::SetInputValue {
|
||||
node_id: *imaginate_node.last().unwrap(),
|
||||
// Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeType` in `document_node_type.rs`
|
||||
input_index: 1,
|
||||
value: graph_craft::document::value::TaggedValue::F64((generate_uuid() >> 1) as f64),
|
||||
});
|
||||
|
||||
// Generate the image
|
||||
if then_generate {
|
||||
responses.add(DocumentMessage::NodeGraphFrameImaginate { layer_path, imaginate_node });
|
||||
}
|
||||
}
|
||||
NodeGraphFrameImaginateTerminate { layer_path, node_path } => {
|
||||
responses.add(FrontendMessage::TriggerImaginateTerminate {
|
||||
document_id,
|
||||
layer_path,
|
||||
node_path,
|
||||
hostname: preferences.imaginate_server_hostname.clone(),
|
||||
});
|
||||
}
|
||||
NudgeSelectedLayers {
|
||||
delta_x,
|
||||
delta_y,
|
||||
@@ -622,7 +622,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
downres_node_type.to_document_node_default_inputs([Some(graph_craft::document::NodeInput::node(transform_node_id, 0))], next_pos()),
|
||||
);
|
||||
|
||||
responses.add(DocumentOperation::AddNodeGraphFrame {
|
||||
responses.add(DocumentOperation::AddFrame {
|
||||
path: path.clone(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
@@ -639,7 +639,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
skip_rerender: false,
|
||||
});
|
||||
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: path });
|
||||
|
||||
// Force chosen tool to be Select Tool after importing image.
|
||||
responses.add(ToolMessage::ActivateTool { tool_type: ToolType::Select });
|
||||
@@ -785,16 +785,13 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
|
||||
// Revoke the old blob URL
|
||||
match &layer.data {
|
||||
LayerDataType::NodeGraphFrame(node_graph_frame) => {
|
||||
if let Some(url) = node_graph_frame.as_blob_url() {
|
||||
LayerDataType::Layer(layer) => {
|
||||
if let Some(url) = layer.as_blob_url() {
|
||||
responses.add(FrontendMessage::TriggerRevokeBlobUrl { url: url.clone() });
|
||||
}
|
||||
}
|
||||
other => {
|
||||
warn!(
|
||||
"Setting blob URL for invalid layer type, which must be an `Imaginate`, `NodeGraphFrame` or `Image`. Found: `{:?}`",
|
||||
other
|
||||
);
|
||||
warn!("Setting blob URL for invalid layer type, which must be a `Layer` layer type. Found: `{:?}`", other);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -961,53 +958,54 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
}
|
||||
|
||||
impl DocumentMessageHandler {
|
||||
pub fn call_node_graph_frame(
|
||||
pub fn rasterize_region_below_layer(
|
||||
&mut self,
|
||||
document_id: u64,
|
||||
layer_path: Vec<LayerId>,
|
||||
_preferences: &PreferencesMessageHandler,
|
||||
persistent_data: &PersistentData,
|
||||
imaginate_node: Option<Vec<NodeId>>,
|
||||
imaginate_node_path: Option<Vec<NodeId>>,
|
||||
) -> Option<Message> {
|
||||
// Prepare the node graph input image
|
||||
|
||||
let Some(node_network) = self.document_legacy.layer(&layer_path).ok().and_then(|layer|layer.as_node_graph().ok()) else {
|
||||
let Some(node_network) = self.document_legacy.layer(&layer_path).ok().and_then(|layer| layer.as_node_graph().ok()) else {
|
||||
return None;
|
||||
};
|
||||
|
||||
// Check if we use the "Input Frame" node.
|
||||
// TODO: Remove once rasterization is moved into a node.
|
||||
let input_frame = node_network.nodes.iter().find(|(_, node)| node.name == "Input Frame");
|
||||
let input_node_id = input_frame.map(|(&id, _)| id);
|
||||
let primary_input_type = input_node_id.filter(|&target_node_id| node_network.connected_to_output(target_node_id, true));
|
||||
let input_frame_node_id = node_network.nodes.iter().find(|(_, node)| node.name == "Input Frame").map(|(&id, _)| id);
|
||||
let input_frame_connected_to_graph_output = input_frame_node_id.map_or(false, |target_node_id| node_network.connected_to_output(target_node_id, true));
|
||||
|
||||
// Only calculate the frame if the primary input is an image
|
||||
let response = if primary_input_type.is_some() {
|
||||
// Calculate the size of the region to be exported
|
||||
// If the Input Frame node is connected upstream, rasterize the artwork below this layer by calling into JS
|
||||
let response = if input_frame_connected_to_graph_output {
|
||||
let old_transforms = self.remove_document_transform();
|
||||
|
||||
// Calculate the size of the region to be exported and generate an SVG of the artwork below this layer within that region
|
||||
let transform = self.document_legacy.multiply_transforms(&layer_path).unwrap();
|
||||
let size = DVec2::new(transform.transform_vector2(DVec2::new(1., 0.)).length(), transform.transform_vector2(DVec2::new(0., 1.)).length());
|
||||
|
||||
let svg = self.render_document(size, transform.inverse(), persistent_data, DocumentRenderMode::OnlyBelowLayerInFolder(&layer_path));
|
||||
|
||||
self.restore_document_transform(old_transforms);
|
||||
|
||||
FrontendMessage::TriggerNodeGraphFrameGenerate {
|
||||
// Once JS asynchronously rasterizes the SVG, it will call the `PortfolioMessage::RenderGraphUsingRasterizedRegionBelowLayer` message with the rasterized image data
|
||||
FrontendMessage::TriggerRasterizeRegionBelowLayer {
|
||||
document_id,
|
||||
layer_path,
|
||||
svg,
|
||||
size,
|
||||
imaginate_node,
|
||||
imaginate_node_path,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
// Skip processing under node graph frame input if not connected
|
||||
// Skip taking a round trip through JS since there's nothing to rasterize, and instead directly call the message which would otherwise be called asynchronously from JS
|
||||
else {
|
||||
PortfolioMessage::ProcessNodeGraphFrame {
|
||||
PortfolioMessage::RenderGraphUsingRasterizedRegionBelowLayer {
|
||||
document_id,
|
||||
layer_path,
|
||||
image_data: Default::default(),
|
||||
input_image_data: vec![],
|
||||
size: (0, 0),
|
||||
imaginate_node,
|
||||
imaginate_node_path,
|
||||
}
|
||||
.into()
|
||||
};
|
||||
@@ -1170,16 +1168,6 @@ impl DocumentMessageHandler {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn selected_visible_text_layers(&self) -> impl Iterator<Item = &[LayerId]> {
|
||||
self.selected_layers().filter(|path| match self.document_legacy.layer(path) {
|
||||
Ok(layer) => {
|
||||
let discriminant: LayerDataTypeDiscriminant = (&layer.data).into();
|
||||
layer.visible && discriminant == LayerDataTypeDiscriminant::Text
|
||||
}
|
||||
Err(_) => false,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn visible_layers(&self) -> impl Iterator<Item = &[LayerId]> {
|
||||
self.all_layers().filter(|path| match self.document_legacy.layer(path) {
|
||||
Ok(layer) => layer.visible,
|
||||
@@ -1543,11 +1531,11 @@ impl DocumentMessageHandler {
|
||||
path.pop();
|
||||
}
|
||||
}
|
||||
LayerDataType::NodeGraphFrame(node_graph_frame) => {
|
||||
if node_graph_frame.cached_output_data == CachedOutputData::None {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path: path.clone() });
|
||||
LayerDataType::Layer(layer) => {
|
||||
if layer.cached_output_data == CachedOutputData::None {
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: path.clone() });
|
||||
}
|
||||
for node in node_graph_frame.network.nodes.values() {
|
||||
for node in layer.network.nodes.values() {
|
||||
for input in &node.inputs {
|
||||
if let NodeInput::Value {
|
||||
tagged_value: TaggedValue::Font(font),
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ impl<'a> ModifyInputsContext<'a> {
|
||||
let layer_path = self.layer.to_vec();
|
||||
|
||||
if !skip_rerender {
|
||||
self.responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
self.responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
} else {
|
||||
self.responses.add(DocumentMessage::FrameClear);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::messages::layout::utility_types::widgets::button_widgets::TextButton;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use document_legacy::document::Document;
|
||||
use document_legacy::layers::nodegraph_layer::NodeGraphFrameLayer;
|
||||
use document_legacy::layers::layer_layer::LayerLayer;
|
||||
use document_legacy::LayerId;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNode, DocumentNodeImplementation, NodeId, NodeInput, NodeNetwork, NodeOutput};
|
||||
@@ -223,8 +223,8 @@ impl NodeGraphMessageHandler {
|
||||
}
|
||||
|
||||
/// Collate the properties panel sections for a node graph
|
||||
pub fn collate_properties(&self, node_graph_frame: &NodeGraphFrameLayer, context: &mut NodePropertiesContext, sections: &mut Vec<LayoutGroup>) {
|
||||
let mut network = &node_graph_frame.network;
|
||||
pub fn collate_properties(&self, graph: &LayerLayer, context: &mut NodePropertiesContext, sections: &mut Vec<LayoutGroup>) {
|
||||
let mut network = &graph.network;
|
||||
for segment in &self.nested_path {
|
||||
network = network.nodes.get(segment).and_then(|node| node.implementation.get_network()).unwrap();
|
||||
}
|
||||
@@ -493,7 +493,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
// Only generate node graph if one of the selected nodes is connected to the output
|
||||
if self.selected_nodes.iter().any(|&node_id| network.connected_to_output(node_id, true)) {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -683,7 +683,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
Self::send_graph(network, responses);
|
||||
if should_rerender {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,7 +699,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
responses.add(PropertiesPanelMessage::ResendActiveProperties);
|
||||
if (node.name != "Imaginate" || input_index == 0) && network.connected_to_output(node_id, true) {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -737,7 +737,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
}
|
||||
node.inputs[input_index] = NodeInput::Value { tagged_value: value, exposed: false };
|
||||
if network.connected_to_output(*node_id, true) {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -811,7 +811,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
// Only generate node graph if one of the selected nodes is connected to the output
|
||||
if self.selected_nodes.iter().any(|&node_id| network.connected_to_output(node_id, true)) {
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -836,7 +836,7 @@ impl MessageHandler<NodeGraphMessage, (&mut Document, &mut dyn Iterator<Item = &
|
||||
}
|
||||
self.update_selection_action_buttons(document, responses);
|
||||
if let Some(layer_path) = self.layer_path.clone() {
|
||||
responses.add(DocumentMessage::NodeGraphFrameGenerate { layer_path });
|
||||
responses.add(DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -934,7 +934,7 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeType> = Lazy::new(|| DocumentNodeTyp
|
||||
identifier: NodeImplementation::proto("graphene_std::raster::ImaginateNode<_>"),
|
||||
inputs: vec![
|
||||
DocumentInputType::value("Input Image", TaggedValue::ImageFrame(ImageFrame::empty()), true),
|
||||
DocumentInputType::value("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `NodeGraphFrameImaginateRandom` updated with this entry's index
|
||||
DocumentInputType::value("Seed", TaggedValue::F64(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
|
||||
DocumentInputType::value("Resolution", TaggedValue::OptionalDVec2(None), false),
|
||||
DocumentInputType::value("Samples", TaggedValue::F64(30.), false),
|
||||
DocumentInputType::value("Sampling Method", TaggedValue::ImaginateSamplingMethod(ImaginateSamplingMethod::EulerA), false),
|
||||
|
||||
+10
-10
@@ -8,7 +8,7 @@ use glam::DVec2;
|
||||
use graph_craft::document::value::TaggedValue;
|
||||
use graph_craft::document::{DocumentNode, NodeId, NodeInput};
|
||||
use graph_craft::imaginate_input::*;
|
||||
use graphene_core::raster::{BlendMode, Color, LuminanceCalculation, RedGreenBlue, RelativeAbsolute, SelectiveColorChoice};
|
||||
use graphene_core::raster::{BlendMode, Color, ImageFrame, LuminanceCalculation, RedGreenBlue, RelativeAbsolute, SelectiveColorChoice};
|
||||
use graphene_core::text::Font;
|
||||
use graphene_core::vector::style::{FillType, GradientType, LineCap, LineJoin};
|
||||
use graphene_core::EditorApi;
|
||||
@@ -460,7 +460,7 @@ pub fn input_properties(_document_node: &DocumentNode, _node_id: NodeId, context
|
||||
let layer_path = context.layer_path.to_vec();
|
||||
let refresh_button = TextButton::new("Refresh Input")
|
||||
.tooltip("Refresh the artwork under the layer")
|
||||
.on_update(move |_| DocumentMessage::NodeGraphFrameGenerate { layer_path: layer_path.clone() }.into())
|
||||
.on_update(move |_| DocumentMessage::InputFrameRasterizeRegionBelowLayer { layer_path: layer_path.clone() }.into())
|
||||
.widget_holder();
|
||||
vec![LayoutGroup::Row { widgets: vec![information] }, LayoutGroup::Row { widgets: vec![refresh_button] }]
|
||||
}
|
||||
@@ -1035,7 +1035,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
.on_update({
|
||||
let imaginate_node = imaginate_node.clone();
|
||||
move |_| {
|
||||
DocumentMessage::NodeGraphFrameImaginateTerminate {
|
||||
DocumentMessage::ImaginateTerminate {
|
||||
layer_path: layer_path.clone(),
|
||||
node_path: imaginate_node.clone(),
|
||||
}
|
||||
@@ -1061,7 +1061,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
let imaginate_node = imaginate_node.clone();
|
||||
let layer_path = context.layer_path.to_vec();
|
||||
move |_| {
|
||||
DocumentMessage::NodeGraphFrameImaginateRandom {
|
||||
DocumentMessage::ImaginateRandom {
|
||||
layer_path: layer_path.clone(),
|
||||
imaginate_node: imaginate_node.clone(),
|
||||
then_generate: true,
|
||||
@@ -1077,7 +1077,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
let imaginate_node = imaginate_node.clone();
|
||||
let layer_path = context.layer_path.to_vec();
|
||||
move |_| {
|
||||
DocumentMessage::NodeGraphFrameImaginate {
|
||||
DocumentMessage::ImaginateGenerate {
|
||||
layer_path: layer_path.clone(),
|
||||
imaginate_node: imaginate_node.clone(),
|
||||
}
|
||||
@@ -1092,7 +1092,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
.on_update({
|
||||
let layer_path = context.layer_path.to_vec();
|
||||
move |_| {
|
||||
DocumentMessage::NodeGraphFrameClear {
|
||||
DocumentMessage::ImaginateClear {
|
||||
node_id,
|
||||
layer_path: layer_path.clone(),
|
||||
cached_index,
|
||||
@@ -1123,7 +1123,7 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
let imaginate_node = imaginate_node.clone();
|
||||
let layer_path = context.layer_path.to_vec();
|
||||
move |_| {
|
||||
DocumentMessage::NodeGraphFrameImaginateRandom {
|
||||
DocumentMessage::ImaginateRandom {
|
||||
layer_path: layer_path.clone(),
|
||||
imaginate_node: imaginate_node.clone(),
|
||||
then_generate: false,
|
||||
@@ -1145,12 +1145,12 @@ pub fn imaginate_properties(document_node: &DocumentNode, node_id: NodeId, conte
|
||||
};
|
||||
|
||||
// Create the input to the graph using an empty image
|
||||
let image_frame = std::borrow::Cow::Owned(EditorApi {
|
||||
let editor_api = std::borrow::Cow::Owned(EditorApi {
|
||||
image_frame: None,
|
||||
font_cache: Some(&context.persistent_data.font_cache),
|
||||
});
|
||||
// Compute the transform input to the node graph frame
|
||||
let image_frame: graphene_core::raster::ImageFrame<Color> = context.executor.compute_input(context.network, &imaginate_node, 0, image_frame).unwrap_or_default();
|
||||
// Compute the transform input to the image frame
|
||||
let image_frame: ImageFrame<Color> = context.executor.compute_input(context.network, &imaginate_node, 0, editor_api).unwrap_or_default();
|
||||
let transform = image_frame.transform;
|
||||
|
||||
let resolution = {
|
||||
|
||||
+2
-2
@@ -45,11 +45,11 @@ impl<'a> MessageHandler<PropertiesPanelMessage, (&PersistentData, PropertiesPane
|
||||
} else {
|
||||
let path = paths.into_iter().next().unwrap();
|
||||
if Some((path.clone(), document)) != self.active_selection {
|
||||
// Update the node graph frame visibility
|
||||
// Update the layer visibility
|
||||
if get_document(document)
|
||||
.layer(&path)
|
||||
.ok()
|
||||
.filter(|layer| LayerDataTypeDiscriminant::from(&layer.data) == LayerDataTypeDiscriminant::NodeGraphFrame)
|
||||
.filter(|layer| LayerDataTypeDiscriminant::from(&layer.data) == LayerDataTypeDiscriminant::Layer)
|
||||
.is_some()
|
||||
{
|
||||
responses.add(NodeGraphMessage::OpenNodeGraph { layer_path: path.clone() });
|
||||
|
||||
@@ -257,7 +257,7 @@ pub fn register_artwork_layer_properties(
|
||||
tooltip: "Shape".into(),
|
||||
..Default::default()
|
||||
})),
|
||||
LayerDataType::NodeGraphFrame(_) => WidgetHolder::new(Widget::IconLabel(IconLabel {
|
||||
LayerDataType::Layer(_) => WidgetHolder::new(Widget::IconLabel(IconLabel {
|
||||
icon: "Layer".into(),
|
||||
tooltip: "Layer".into(),
|
||||
..Default::default()
|
||||
@@ -266,7 +266,7 @@ pub fn register_artwork_layer_properties(
|
||||
WidgetHolder::unrelated_separator(),
|
||||
WidgetHolder::new(Widget::TextLabel(TextLabel {
|
||||
value: match &layer.data {
|
||||
LayerDataType::NodeGraphFrame(_) => "Layer".into(),
|
||||
LayerDataType::Layer(_) => "Layer".into(),
|
||||
other => LayerDataTypeDiscriminant::from(other).to_string(),
|
||||
},
|
||||
..TextLabel::default()
|
||||
@@ -298,7 +298,7 @@ pub fn register_artwork_layer_properties(
|
||||
vec![node_section_transform(layer, persistent_data), node_section_stroke(&shape.style.stroke().unwrap_or_default())]
|
||||
}
|
||||
}
|
||||
LayerDataType::NodeGraphFrame(node_graph_frame) => {
|
||||
LayerDataType::Layer(layer) => {
|
||||
let mut properties_sections = Vec::new();
|
||||
|
||||
let mut context = crate::messages::portfolio::document::node_graph::NodePropertiesContext {
|
||||
@@ -308,9 +308,9 @@ pub fn register_artwork_layer_properties(
|
||||
nested_path: &node_graph_message_handler.nested_path,
|
||||
layer_path: &layer_path,
|
||||
executor,
|
||||
network: &node_graph_frame.network,
|
||||
network: &layer.network,
|
||||
};
|
||||
node_graph_message_handler.collate_properties(node_graph_frame, &mut context, &mut properties_sections);
|
||||
node_graph_message_handler.collate_properties(layer, &mut context, &mut properties_sections);
|
||||
|
||||
properties_sections
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user