mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-20 19:56:09 +08:00
Store Input for Monitor Nodes (#1454)
* Add input storage to monitor_node * Return input via serialize function
This commit is contained in:
+14
-12
@@ -125,6 +125,17 @@ impl Default for DocumentNodeBlueprint {
|
||||
// TODO: make document nodes not require a `'static` lifetime to avoid having to split the construction into const and non-const parts.
|
||||
static DOCUMENT_NODE_TYPES: once_cell::sync::Lazy<Vec<DocumentNodeBlueprint>> = once_cell::sync::Lazy::new(static_nodes);
|
||||
|
||||
fn monitor_node() -> DocumentNode {
|
||||
DocumentNode {
|
||||
name: "Monitor".to_string(),
|
||||
inputs: Vec::new(),
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_, _, _>"),
|
||||
manual_composition: Some(concrete!(Footprint)),
|
||||
skip_deduplication: true,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Dynamic node library
|
||||
/// Defines the "signature" or "header file"-like metadata for the document nodes, but not the implementation (which is defined in the node registry).
|
||||
/// The document node is the instance while these are the "class" (or "blueprint").
|
||||
@@ -203,11 +214,8 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
|
||||
(
|
||||
1,
|
||||
DocumentNode {
|
||||
name: "Monitor".to_string(),
|
||||
inputs: vec![NodeInput::node(0, 0)],
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_>"),
|
||||
skip_deduplication: true,
|
||||
..Default::default()
|
||||
..monitor_node()
|
||||
},
|
||||
),
|
||||
(
|
||||
@@ -2122,11 +2130,8 @@ fn static_nodes() -> Vec<DocumentNodeBlueprint> {
|
||||
outputs: vec![NodeOutput::new(1, 0)],
|
||||
nodes: [
|
||||
DocumentNode {
|
||||
name: "Monitor".to_string(),
|
||||
inputs: vec![NodeInput::Network(concrete!(VectorData))],
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_>"),
|
||||
skip_deduplication: true,
|
||||
..Default::default()
|
||||
..monitor_node()
|
||||
},
|
||||
DocumentNode {
|
||||
name: "Transform".to_string(),
|
||||
@@ -2329,11 +2334,8 @@ pub static IMAGINATE_NODE: Lazy<DocumentNodeBlueprint> = Lazy::new(|| DocumentNo
|
||||
(
|
||||
0,
|
||||
DocumentNode {
|
||||
name: "Frame Monitor".into(),
|
||||
inputs: vec![NodeInput::Network(concrete!(ImageFrame<Color>))],
|
||||
implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_>"),
|
||||
skip_deduplication: true,
|
||||
..Default::default()
|
||||
..monitor_node()
|
||||
},
|
||||
),
|
||||
(
|
||||
|
||||
@@ -203,7 +203,7 @@ impl NodeRuntime {
|
||||
|
||||
let monitor_nodes = scoped_network
|
||||
.recursive_nodes()
|
||||
.filter(|(_, node)| node.implementation == DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_>"))
|
||||
.filter(|(_, node)| node.implementation == DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode<_, _, _>"))
|
||||
.map(|(_, node)| node.path.clone().unwrap_or_default())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
@@ -259,10 +259,12 @@ impl NodeRuntime {
|
||||
warn!("Failed to introspect monitor node for thumbnail");
|
||||
continue;
|
||||
};
|
||||
let Some(graphic_element_data) = value.downcast_ref::<graphene_core::GraphicElementData>() else {
|
||||
|
||||
let Some(io_data) = value.downcast_ref::<graphene_core::memo::IORecord<Footprint, graphene_core::GraphicElementData>>() else {
|
||||
warn!("Failed to downcast thumbnail to graphic element data");
|
||||
continue;
|
||||
};
|
||||
let graphic_element_data = &io_data.output;
|
||||
use graphene_core::renderer::*;
|
||||
let bounds = graphic_element_data.bounding_box(DAffine2::IDENTITY);
|
||||
let render_params = RenderParams::new(ViewMode::Normal, ImageRenderMode::BlobUrl, bounds, true);
|
||||
|
||||
Reference in New Issue
Block a user