diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-20 21:13:56 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-03-20 21:18:51 +0300 |
commit | 6500b31728d870506207d9d70837b171cbef32ea (patch) | |
tree | efea5ab405c7498e4e5d5624d739b23bfd5600fa /source/blender/editors/space_node | |
parent | e0d95b7f79a31c6dcee15132f9de2861204f2a5b (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')
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 6 |
2 files changed, 11 insertions, 8 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 diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 1a18e886808..eb20f4e7175 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -943,10 +943,12 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event) int dir; if (node) { + float cursor[2]; + /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], - &snode->cursor[0], &snode->cursor[1]); - dir = node->typeinfo->resize_area_func(node, snode->cursor[0], snode->cursor[1]); + &cursor[0], &cursor[1]); + dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]); if (dir != 0) { node_resize_init(C, op, event, node, dir); return OPERATOR_RUNNING_MODAL; |