diff options
Diffstat (limited to 'source/blender/editors/space_node/node_select.c')
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 1abcaccc939..3d8b1676ea5 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -37,10 +37,12 @@ #include "DNA_scene_types.h" #include "BKE_context.h" +#include "BKE_main.h" #include "BLI_rect.h" #include "BLI_utildefines.h" +#include "ED_node.h" #include "ED_screen.h" #include "ED_types.h" @@ -60,7 +62,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) { bNode *node; - for(next_node(ntree); (node=next_node(NULL));) { + for(node=ntree->nodes.last; node; node=node->prev) { /* node body (header and scale are in other operators) */ if (BLI_in_rctf(&node->totr, mx, my)) return node; @@ -70,7 +72,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) /* ****** Click Select ****** */ -static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2], short extend) +static bNode *node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend) { bNode *node; float mx, my; @@ -91,8 +93,10 @@ static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2] } else node->flag ^= SELECT; - - node_set_active(snode, node); + + ED_node_set_active(bmain, snode->edittree, node); + + node_sort(snode->edittree); } return node; @@ -100,6 +104,7 @@ static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const int mval[2] static int node_select_exec(bContext *C, wmOperator *op) { + Main *bmain= CTX_data_main(C); SpaceNode *snode= CTX_wm_space_node(C); ARegion *ar= CTX_wm_region(C); int mval[2]; @@ -113,7 +118,7 @@ static int node_select_exec(bContext *C, wmOperator *op) extend = RNA_boolean_get(op->ptr, "extend"); /* perform the select */ - node= node_mouse_select(snode, ar, mval, extend); + node= node_mouse_select(bmain, snode, ar, mval, extend); /* send notifiers */ WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); @@ -179,6 +184,8 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) } } + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -249,6 +256,8 @@ static int node_select_all_exec(bContext *C, wmOperator *UNUSED(op)) node->flag |= NODE_SELECT; } + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -289,6 +298,8 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op)) node->flag |= NODE_SELECT; } + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -329,6 +340,8 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op)) node->flag |= NODE_SELECT; } + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -355,6 +368,9 @@ static int node_select_same_type_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); node_select_same_type(snode); + + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -381,7 +397,11 @@ static int node_select_same_type_next_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); node_select_same_type_np(snode, 0); + + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); + return OPERATOR_FINISHED; } @@ -405,6 +425,9 @@ static int node_select_same_type_prev_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); node_select_same_type_np(snode, 1); + + node_sort(snode->edittree); + WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL); return OPERATOR_FINISHED; } |