diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-24 00:16:45 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-09-24 00:16:45 +0400 |
commit | 1199551239ed0832e2784718a49ecda1c2614303 (patch) | |
tree | 28973dafaab9910a783d77ed548effd4be830485 /source/blender/editors | |
parent | 960cdb8f5d6fa5617f5003190cc4926f7b031df6 (diff) |
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_node/node_header.c | 13 |
1 files changed, 13 insertions, 0 deletions
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); |