mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 06:08:12 +08:00
Fix new nodes being added in the wrong place near graph edges (#4211)
This commit is contained in:
@@ -876,6 +876,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
|||||||
|
|
||||||
self.context_menu = Some(ContextMenuInformation {
|
self.context_menu = Some(ContextMenuInformation {
|
||||||
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2().into(),
|
context_menu_coordinates: (node_graph_point + node_graph_shift).as_ivec2().into(),
|
||||||
|
node_creation_coordinates: node_graph_point.as_ivec2().into(),
|
||||||
context_menu_data,
|
context_menu_data,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1315,6 +1316,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
|
|||||||
|
|
||||||
self.context_menu = Some(ContextMenuInformation {
|
self.context_menu = Some(ContextMenuInformation {
|
||||||
context_menu_coordinates: (point + node_graph_shift).as_ivec2().into(),
|
context_menu_coordinates: (point + node_graph_shift).as_ivec2().into(),
|
||||||
|
node_creation_coordinates: point.as_ivec2().into(),
|
||||||
context_menu_data: ContextMenuData::CreateNode { compatible_type },
|
context_menu_data: ContextMenuData::CreateNode { compatible_type },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -162,9 +162,12 @@ pub enum ContextMenuData {
|
|||||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
#[cfg_attr(feature = "wasm", derive(tsify::Tsify))]
|
||||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||||
pub struct ContextMenuInformation {
|
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")]
|
#[serde(rename = "contextMenuCoordinates")]
|
||||||
pub context_menu_coordinates: (i32, i32),
|
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")]
|
#[serde(rename = "contextMenuData")]
|
||||||
pub context_menu_data: ContextMenuData,
|
pub context_menu_data: ContextMenuData,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@
|
|||||||
function createNode(identifier: string) {
|
function createNode(identifier: string) {
|
||||||
if ($nodeGraph.contextMenuInformation === undefined) return;
|
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 {
|
function nodeBorderMask(nodeWidth: number, primaryInputExists: boolean, exposedSecondaryInputs: number, primaryOutputExists: boolean, exposedSecondaryOutputs: number): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user