From 1199551239ed0832e2784718a49ecda1c2614303 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 23 Sep 2010 20:16:45 +0000 Subject: Fix #22922: adding new nodes didn't add them at the mouse location. This also caused auto connect to not work in some cases, because that now orders nodes and only connects if the new node is to the right of the old node. I doubted between always connecting to the new node as output or keeping this ordering trick also when adding nodes. Decided on the latter because then you can also add a node between two others and have it auto connect to both. --- source/blender/editors/space_node/node_header.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/blender/editors/space_node/node_header.c') diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 17c50b32e98..0711ef66497 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -49,6 +49,7 @@ #include "UI_interface.h" +#include "UI_view2d.h" #include "node_intern.h" @@ -153,6 +154,18 @@ static void node_menu_add(const bContext *C, Menu *menu) { uiLayout *layout= menu->layout; SpaceNode *snode= CTX_wm_space_node(C); + ScrArea *sa= CTX_wm_area(C); + ARegion *ar; + + /* get location to add node at mouse */ + for(ar=sa->regionbase.first; ar; ar=ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + wmWindow *win= CTX_wm_window(C); + UI_view2d_region_to_view(&ar->v2d, + win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, + &snode->mx, &snode->my); + } + } if(!snode->nodetree) uiLayoutSetActive(layout, 0); -- cgit v1.2.3