Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-20 21:13:56 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-03-20 21:18:51 +0300
commit6500b31728d870506207d9d70837b171cbef32ea (patch)
treeefea5ab405c7498e4e5d5624d739b23bfd5600fa /source/blender/editors/space_node/node_add.c
parente0d95b7f79a31c6dcee15132f9de2861204f2a5b (diff)
Fix T62788: drop image into node editor puts node at wrong location.
It should be under the mouse cursor but was wrong for high DPI. Also put the cursor in the header now so it's easy to reposition.
Diffstat (limited to 'source/blender/editors/space_node/node_add.c')
-rw-r--r--source/blender/editors/space_node/node_add.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index fd433b48a66..6cb45f8d318 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -71,13 +71,11 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx
node = nodeAddStaticNode(C, snode->edittree, type);
BLI_assert(node && node->typeinfo);
- /* generics */
- node->locx = locx;
- node->locy = locy + 60.0f; /* arbitrary... so its visible, (0,0) is top of node */
- nodeSetSelected(node, true);
+ /* Position mouse in node header. */
+ node->locx = locx - NODE_DY * 1.5f / UI_DPI_FAC;
+ node->locy = locy + NODE_DY * 0.5f / UI_DPI_FAC;
- node->locx = locx;
- node->locy = locy + 60.0f;
+ nodeSetSelected(node, true);
ntreeUpdateTree(bmain, snode->edittree);
ED_node_set_active(bmain, snode->edittree, node);
@@ -355,6 +353,9 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even
UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1],
&snode->cursor[0], &snode->cursor[1]);
+ snode->cursor[0] /= UI_DPI_FAC;
+ snode->cursor[1] /= UI_DPI_FAC;
+
if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name"))
return node_add_file_exec(C, op);
else