diff options
author | Diego Borghetti <bdiego@gmail.com> | 2010-05-12 17:55:09 +0400 |
---|---|---|
committer | Diego Borghetti <bdiego@gmail.com> | 2010-05-12 17:55:09 +0400 |
commit | 3c3502fda40959f75453f4bc40d4c09e26f5b2ec (patch) | |
tree | b8b0bb6973588dddcf5c5986108937780336694d /source | |
parent | 9a4ba57ee9fc8005f734c961b73b99398880b37f (diff) |
Small change to Node Space and two new function.
"Select all of the same type" now is binding to Shift + GKEY
Two new function, select next and prev node of the same type.
Select a node and press Shift + [ or Shift + ] go to the
previous and next node of the same type (of the active node).
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 41 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 50 |
4 files changed, 100 insertions, 2 deletions
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index bb9bb338767..3988397eb85 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -954,6 +954,47 @@ int node_select_same_type(SpaceNode *snode) return(redraw); } +/* return 1 if we need redraw, otherwise zero. + * dir can be 0 == next or 0 != prev. + */ +int node_select_same_type_np(SpaceNode *snode, int dir) +{ + bNode *nac, *p; + + /* search the active one. */ + for (nac= snode->edittree->nodes.first; nac; nac= nac->next) { + if (nac->flag & SELECT) + break; + } + + /* no active node, return. */ + if (!nac) + return(0); + + if (dir == 0) + p= nac->next; + else + p= nac->prev; + + while (p) { + /* Now search the next with the same type. */ + if (p->type == nac->type) + break; + + if (dir == 0) + p= p->next; + else + p= p->prev; + } + + if (p) { + node_deselectall(snode); + p->flag |= SELECT; + return(1); + } + return(0); +} + int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index f76a462080f..9cbd3ab87d5 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -63,6 +63,8 @@ void NODE_OT_visibility_toggle(struct wmOperatorType *ot); void NODE_OT_view_all(struct wmOperatorType *ot); void NODE_OT_select_border(struct wmOperatorType *ot); void NODE_OT_select_same_type(struct wmOperatorType *ot); +void NODE_OT_select_same_type_next(wmOperatorType *ot); +void NODE_OT_select_same_type_prev(wmOperatorType *ot); /* drawnode.c */ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link); @@ -82,6 +84,7 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode); void node_set_active(SpaceNode *snode, bNode *node); void node_deselectall(SpaceNode *snode); int node_select_same_type(SpaceNode *snode); +int node_select_same_type_np(SpaceNode *snode, int dir); void snode_composite_job(const struct bContext *C, ScrArea *sa); bNode *node_tree_get_editgroup(bNodeTree *ntree); void node_tree_verify_groups(bNodeTree *nodetree); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 297771682fb..5b8e6fe852e 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -52,7 +52,9 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_select_linked_from); WM_operatortype_append(NODE_OT_select_border); WM_operatortype_append(NODE_OT_select_same_type); - + WM_operatortype_append(NODE_OT_select_same_type_next); + WM_operatortype_append(NODE_OT_select_same_type_prev); + WM_operatortype_append(NODE_OT_view_all); WM_operatortype_append(NODE_OT_visibility_toggle); WM_operatortype_append(NODE_OT_mute); @@ -155,7 +157,9 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_select_linked_to", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_select_linked_from", LKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "NODE_OT_select_same_type", FKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "NODE_OT_select_same_type", GKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "NODE_OT_select_same_type_next", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "NODE_OT_select_same_type_prev", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 07e259cd0bb..32e57e29ab0 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -388,3 +388,53 @@ void NODE_OT_select_same_type(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } + +/* ****** Select The Next/Prev Node Of The Same Type ****** */ + +static int node_select_same_type_next_exec(bContext *C, wmOperator *op) +{ + SpaceNode *snode = CTX_wm_space_node(C); + + node_select_same_type_np(snode, 0); + WM_event_add_notifier(C, NC_NODE|ND_NODE_SELECT, NULL); + return OPERATOR_FINISHED; +} + +void NODE_OT_select_same_type_next(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Same Type Next"; + ot->description = "Select the next node of the same type."; + ot->idname = "NODE_OT_select_same_type_next"; + + /* api callbacks */ + ot->exec = node_select_same_type_next_exec; + ot->poll = ED_operator_node_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int node_select_same_type_prev_exec(bContext *C, wmOperator *op) +{ + SpaceNode *snode = CTX_wm_space_node(C); + + node_select_same_type_np(snode, 1); + WM_event_add_notifier(C, NC_NODE|ND_NODE_SELECT, NULL); + return OPERATOR_FINISHED; +} + +void NODE_OT_select_same_type_prev(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Select Same Type Prev"; + ot->description = "Select the prev node of the same type."; + ot->idname = "NODE_OT_select_same_type_prev"; + + /* api callbacks */ + ot->exec = node_select_same_type_prev_exec; + ot->poll = ED_operator_node_active; + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} |