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
This commit is contained in:
@@ -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':
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user