Add a basic API and rudimentary frontend for node graph layers (#846)

* Node graph API stub

* Rename and fix SetInputValue

* Get list of links from network

* Test populating node graph UI

* Node properties

* Fix viewport bounds

* Slightly change promise usage

* A tiny bit of cleanup I did while reading code

* Cleanup and work towards hooking up node links in Vue template

* Add the brighten colour node

* Run cargo fmt

* Add to and from hsla

* GrayscaleImage node with small perf improvement

* Fix gutter panel resizing

* Display node links from backend

* Add support for connecting node links

* Use existing message

* Fix formatting error

* Add a (currently crashing) brighten node

* Replace brighten node with proto node implementation

* Add support for connecting node links

* Update watch dirs

* Add hue shift node

* Add create_node function to editor api

* Basic insert node UI

* Fix broken names

* Add log

* Fix positioning

* Set connector index to 0

* Add properties for Heu shift / brighten

* Allow deselecting nodes

* Redesign Properties panel collapsible sections

Co-authored-by: Keavon Chambers <keavon@keavon.com>
Co-authored-by: Dennis Kobert <dennis@kobert.dev>
This commit is contained in:
0HyperCube
2022-11-12 21:23:28 +00:00
committed by Keavon Chambers
parent e8256dd350
commit 504136b61b
37 changed files with 1213 additions and 294 deletions

View File

@@ -118,25 +118,69 @@ impl Default for NodeGraphFrameLayer {
fn default() -> Self {
use graph_craft::document::*;
use graph_craft::proto::NodeIdentifier;
let brighten_network = NodeNetwork {
inputs: vec![0, 0],
output: 0,
nodes: [(
0,
DocumentNode {
name: "brighten".into(),
inputs: vec![NodeInput::Network, NodeInput::Network],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new(
"graphene_core::raster::BrightenColorNode",
&[graph_craft::proto::Type::Concrete(std::borrow::Cow::Borrowed("&TypeErasedNode"))],
)),
},
)]
.into_iter()
.collect(),
};
let hue_shift_network = NodeNetwork {
inputs: vec![0, 0],
output: 0,
nodes: [(
0,
DocumentNode {
name: "hue shift".into(),
inputs: vec![NodeInput::Network, NodeInput::Network],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new(
"graphene_core::raster::HueShiftNode",
&[graph_craft::proto::Type::Concrete(std::borrow::Cow::Borrowed("&TypeErasedNode"))],
)),
},
)]
.into_iter()
.collect(),
};
Self {
mime: String::new(),
network: NodeNetwork {
inputs: vec![1],
output: 1,
inputs: vec![2, 1],
output: 2,
nodes: [
(
0,
DocumentNode {
name: "grayscale".into(),
inputs: vec![NodeInput::Network],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::raster::GrayscaleNode", &[])),
name: "Hue Shift Color".into(),
inputs: vec![NodeInput::Network, NodeInput::Value(value::TaggedValue::F32(50.))],
implementation: DocumentNodeImplementation::Network(hue_shift_network),
},
),
(
1,
DocumentNode {
name: "map image".into(),
inputs: vec![NodeInput::Network, NodeInput::Node(0)],
name: "Brighten Color".into(),
inputs: vec![NodeInput::Node(0), NodeInput::Value(value::TaggedValue::F32(10.))],
implementation: DocumentNodeImplementation::Network(brighten_network),
},
),
(
2,
DocumentNode {
name: "Map Image".into(),
inputs: vec![NodeInput::Network, NodeInput::Node(1)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_std::raster::MapImageNode", &[])),
},
),