Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG

self.context_menu = Some(ContextMenuInformation {
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2().into(),
node_creation_coordinates: node_graph_point.as_ivec2().into(),
context_menu_data,
});

Expand Down Expand Up @@ -1315,6 +1316,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG

self.context_menu = Some(ContextMenuInformation {
context_menu_coordinates: (point + node_graph_shift).as_ivec2().into(),
node_creation_coordinates: point.as_ivec2().into(),
context_menu_data: ContextMenuData::CreateNode { compatible_type },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,12 @@ pub enum ContextMenuData {
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct ContextMenuInformation {
// Stores whether the context menu is open and its position in graph coordinates
// The menu's display position in graph coordinates, which may be shifted from the click point to keep the menu on-screen
#[serde(rename = "contextMenuCoordinates")]
pub context_menu_coordinates: (i32, i32),
// The click point in graph coordinates, where a node created from the menu is placed (unshifted, unlike the display position)
#[serde(rename = "nodeCreationCoordinates")]
pub node_creation_coordinates: (i32, i32),
#[serde(rename = "contextMenuData")]
pub context_menu_data: ContextMenuData,
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/views/Graph.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
function createNode(identifier: string) {
if ($nodeGraph.contextMenuInformation === undefined) return;

editor.createNode(identifier, $nodeGraph.contextMenuInformation.contextMenuCoordinates[0], $nodeGraph.contextMenuInformation.contextMenuCoordinates[1]);
editor.createNode(identifier, $nodeGraph.contextMenuInformation.nodeCreationCoordinates[0], $nodeGraph.contextMenuInformation.nodeCreationCoordinates[1]);
}

function nodeBorderMask(nodeWidth: number, primaryInputExists: boolean, exposedSecondaryInputs: number, primaryOutputExists: boolean, exposedSecondaryOutputs: number): string {
Expand Down
Loading