From 331e8007ed403ea30bc74f2eeaa40399212a5a18 Mon Sep 17 00:00:00 2001 From: Leon Schittek Date: Sat, 19 Nov 2022 19:03:38 +0100 Subject: [PATCH] Fix T102520: Positioning of nodes added via search Always position the nodes added with the node search at the point where the search operator was invoked by ensuring the operator context is the main node editor region. This was an unintended change of rBbdb57541475f, caused by the operator now getting the cursor position in region space. So when the operator was called from the menu, it would get the cursor position in the region space of the menu, which lead to an offset when adding the node since it expected the coordinates to be in the space of the node editor. Setting the correct operator context also fixes inconsistent transform sensitivity depending on zoom when adding nodes via the search in the menu which has been an issue since as far back as Blender 2.79. Also includes a small fix for the vertical offset of nodes added by the search which varied depending on the UI scale. Same fix as in rB998ffcbf096e. Reviewed By: Hans Goudey Differential Revision: http://developer.blender.org/D16555 --- release/scripts/startup/bl_ui/space_node.py | 2 +- source/blender/editors/space_node/add_node_search.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_node.py b/release/scripts/startup/bl_ui/space_node.py index 593c6400529..90744d9f359 100644 --- a/release/scripts/startup/bl_ui/space_node.py +++ b/release/scripts/startup/bl_ui/space_node.py @@ -219,7 +219,7 @@ class NODE_MT_add(bpy.types.Menu): import nodeitems_utils layout = self.layout - layout.operator_context = 'INVOKE_DEFAULT' + layout.operator_context = 'INVOKE_REGION_WIN' snode = context.space_data if snode.tree_type == 'GeometryNodeTree': diff --git a/source/blender/editors/space_node/add_node_search.cc b/source/blender/editors/space_node/add_node_search.cc index 28e18c20f46..eccc6848b8e 100644 --- a/source/blender/editors/space_node/add_node_search.cc +++ b/source/blender/editors/space_node/add_node_search.cc @@ -256,7 +256,7 @@ static void add_node_search_exec_fn(bContext *C, void *arg1, void *arg2) } new_node->locx = storage.cursor.x / UI_DPI_FAC; - new_node->locy = storage.cursor.y / UI_DPI_FAC + 20 * UI_DPI_FAC; + new_node->locy = storage.cursor.y / UI_DPI_FAC + 20; nodeSetSelected(new_node, true); nodeSetActive(&node_tree, new_node);