Skip to content

Commit 6d74abb

Browse files
adamgerhantKeavon
andauthored
Node network subgraph editing (#1750)
* Breadcrumb visualization, nested network consistency, create definitions for Merge internal nodes * Add index to network inputs, remove imports usage from flatten network * Replace NodeOutput with NodeInput::Node * Fully remove imports field, remove unnecessary identity nodes, move Output node to encapsulating network * Replace previous_outputs with root_node, fix adding artboard/layer to empty network * Import/Export UI nodes * Display input/output types dynamically from compiled network * Add LayerNodeIdentifer::ROOT_PARENT * Prevent .to_node() on ROOT_PARENT * Separate NodeGraphMessage and GraphOperationMessage * General bug fixes with nested networks * Change layer color, various bug fixes and improvements * Fix disconnect and set node input for proto nodes and UI export node * Dashed line to export for previewed node * Fix deleting proto nodes and nodes that feed into export * Allow modifications to nodes outside of nested network * Get network from Node Id parameter * Change root_node to previous_root_node * Get TaggedValue from proto node implementation type when disconnecting * Improve preview functionality and state * Artboard position and delete children fix * Name inputs/outputs based on DocumentNodeDefinition or type, fix new artboard/layer insertion * replace "Link" with "Wire", adjust previewing * Various bug fixes and improvements * Modify Sample and Poisson-Disk points, fix incorrect input index and deleting currently viewed node * Open demo artwork * Fix opening already upgraded documents and refactor FrontendGraphDataType usages * Fix deleting within network and other bugs * Get default node input from compiled network when copying, fix previews, tests, demo artwork * Code cleanup * Hide EditorApi and add a comment describing unresolved Import node input types * Code review * Replace placeholder ROOT_PARENT NodeId with std::u64::MAX * Breadcrumb padding --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent e4d3faa commit 6d74abb

File tree

77 files changed

+3894
-2297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3894
-2297
lines changed

Cargo.lock

Lines changed: 154 additions & 163 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/isometric-fountain.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/just-a-potted-cactus.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/procedural-string-lights.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/red-dress.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/valley-of-spires.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/src/application.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,8 @@ mod test {
8888
block_on(crate::node_graph_executor::run_node_graph());
8989
let mut res = VecDeque::new();
9090
editor.poll_node_graph_evaluation(&mut res);
91-
//println!("node_graph_poll: {res:#?}");
9291

93-
//println!("in: {message:#?}");
9492
let res = editor.handle_message(message);
95-
//println!("out: {res:#?}");
9693
responses.push(res);
9794
}
9895
let responses = responses.pop().unwrap();

editor/src/consts.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ pub const COLOR_OVERLAY_YELLOW: &str = "#ffc848";
7171
pub const COLOR_OVERLAY_WHITE: &str = "#ffffff";
7272
pub const COLOR_OVERLAY_GRAY: &str = "#cccccc";
7373

74-
// Fonts
75-
pub const DEFAULT_FONT_FAMILY: &str = "Cabin";
76-
pub const DEFAULT_FONT_STYLE: &str = "Normal (400)";
77-
7874
// Document
7975
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
8076
pub const FILE_SAVE_SUFFIX: &str = ".graphite";

editor/src/dispatcher.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::consts::{DEFAULT_FONT_FAMILY, DEFAULT_FONT_STYLE};
21
use crate::messages::debug::utility_types::MessageLoggingVerbosity;
32
use crate::messages::dialog::DialogMessageData;
43
use crate::messages::prelude::*;
@@ -99,7 +98,7 @@ impl Dispatcher {
9998
queue.add(MenuBarMessage::SendLayout);
10099

101100
// Load the default font
102-
let font = Font::new(DEFAULT_FONT_FAMILY.into(), DEFAULT_FONT_STYLE.into());
101+
let font = Font::new(graphene_core::consts::DEFAULT_FONT_FAMILY.into(), graphene_core::consts::DEFAULT_FONT_STYLE.into());
103102
queue.add(FrontendMessage::TriggerFontLoad { font, is_default: true });
104103
}
105104
Message::Batched(messages) => {
@@ -307,7 +306,7 @@ mod test {
307306
editor.handle_message(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
308307
editor.handle_message(PortfolioMessage::PasteIntoFolder {
309308
clipboard: Clipboard::Internal,
310-
parent: LayerNodeIdentifier::ROOT,
309+
parent: LayerNodeIdentifier::ROOT_PARENT,
311310
insert_index: -1,
312311
});
313312
let document_after_copy = editor.dispatcher.message_handlers.portfolio_message_handler.active_document().unwrap().clone();
@@ -341,7 +340,7 @@ mod test {
341340
editor.handle_message(PortfolioMessage::Copy { clipboard: Clipboard::Internal });
342341
editor.handle_message(PortfolioMessage::PasteIntoFolder {
343342
clipboard: Clipboard::Internal,
344-
parent: LayerNodeIdentifier::ROOT,
343+
parent: LayerNodeIdentifier::ROOT_PARENT,
345344
insert_index: -1,
346345
});
347346

@@ -385,12 +384,12 @@ mod test {
385384
editor.draw_rect(0., 800., 12., 200.);
386385
editor.handle_message(PortfolioMessage::PasteIntoFolder {
387386
clipboard: Clipboard::Internal,
388-
parent: LayerNodeIdentifier::ROOT,
387+
parent: LayerNodeIdentifier::ROOT_PARENT,
389388
insert_index: -1,
390389
});
391390
editor.handle_message(PortfolioMessage::PasteIntoFolder {
392391
clipboard: Clipboard::Internal,
393-
parent: LayerNodeIdentifier::ROOT,
392+
parent: LayerNodeIdentifier::ROOT_PARENT,
394393
insert_index: -1,
395394
});
396395

editor/src/messages/dialog/dialog_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum DialogMessage {
2626
localized_commit_year: String,
2727
},
2828
RequestComingSoonDialog {
29-
issue: Option<i32>,
29+
issue: Option<u32>,
3030
},
3131
RequestDemoArtworkDialog,
3232
RequestExportDialog,

editor/src/messages/dialog/simple_dialogs/coming_soon_dialog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::messages::prelude::*;
33

44
/// A dialog to notify users of an unfinished issue, optionally with an issue number.
55
pub struct ComingSoonDialog {
6-
pub issue: Option<i32>,
6+
pub issue: Option<u32>,
77
}
88

99
impl DialogLayoutHolder for ComingSoonDialog {

editor/src/messages/frontend/frontend_message.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::utility_types::{FrontendDocumentDetails, MouseCursorIcon};
22
use crate::messages::layout::utility_types::widget_prelude::*;
3-
use crate::messages::portfolio::document::node_graph::utility_types::{FrontendNode, FrontendNodeLink, FrontendNodeType};
3+
use crate::messages::portfolio::document::node_graph::utility_types::{FrontendNode, FrontendNodeType, FrontendNodeWire};
44
use crate::messages::portfolio::document::utility_types::nodes::{JsRawBuffer, LayerPanelEntry, RawBuffer};
55
use crate::messages::prelude::*;
66
use crate::messages::tool::utility_types::HintData;
@@ -188,7 +188,7 @@ pub enum FrontendMessage {
188188
},
189189
UpdateNodeGraph {
190190
nodes: Vec<FrontendNode>,
191-
links: Vec<FrontendNodeLink>,
191+
wires: Vec<FrontendNodeWire>,
192192
},
193193
UpdateNodeGraphBarLayout {
194194
#[serde(rename = "layoutTarget")]
@@ -220,6 +220,10 @@ pub enum FrontendMessage {
220220
layout_target: LayoutTarget,
221221
diff: Vec<WidgetDiff>,
222222
},
223+
UpdateSubgraphPath {
224+
#[serde(rename = "subgraphPath")]
225+
subgraph_path: Vec<String>,
226+
},
223227
UpdateToolOptionsLayout {
224228
#[serde(rename = "layoutTarget")]
225229
layout_target: LayoutTarget,

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ pub fn input_mappings() -> Mapping {
6262
entry!(KeyDown(KeyH); modifiers=[Accel], action_dispatch=NodeGraphMessage::ToggleSelectedVisibility),
6363
entry!(KeyDown(KeyL); modifiers=[Accel], action_dispatch=NodeGraphMessage::ToggleSelectedLocked),
6464
entry!(KeyDown(KeyL); modifiers=[Alt], action_dispatch=NodeGraphMessage::ToggleSelectedAsLayersOrNodes),
65+
entry!(KeyDown(KeyC); modifiers=[Shift], action_dispatch=NodeGraphMessage::PrintSelectedNodeCoordinates),
6566
//
6667
// TransformLayerMessage
6768
entry!(KeyDown(Enter); action_dispatch=TransformLayerMessage::ApplyTransformOperation),

editor/src/messages/layout/layout_message_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ impl LayoutMessageHandler {
186186
let callback_message = (number_input.on_update.callback)(number_input);
187187
responses.add(callback_message);
188188
}
189+
// TODO: This crashes when the cursor is in a text box, such as in the Text node, and the transform node is clicked (https://github.com/GraphiteEditor/Graphite/issues/1761)
189190
Value::String(str) => match str.as_str() {
190191
"Increment" => responses.add((number_input.increment_callback_increase.callback)(number_input)),
191192
"Decrement" => responses.add((number_input.increment_callback_decrease.callback)(number_input)),

editor/src/messages/portfolio/document/document_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum DocumentMessage {
4545
CreateEmptyFolder,
4646
DebugPrintDocument,
4747
DeleteLayer {
48-
id: NodeId,
48+
layer: LayerNodeIdentifier,
4949
},
5050
DeleteSelectedLayers,
5151
DeselectAllLayers,

0 commit comments

Comments
 (0)