doxygen: blender/editors tagged.
[blender.git] / source / blender / editors / space_node / node_select.c
index 055290fbb6674a963de0482433f4f784f71af260..4aa56ef370d4fbcd3b44e4f6fa2dc4523bdd3170 100644 (file)
@@ -1,5 +1,5 @@
-/**
- * $Id:
+/*
+ * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * ***** END GPL LICENSE BLOCK *****
  */
 
+/** \file blender/editors/space_node/node_select.c
+ *  \ingroup spnode
+ */
+
+
 #include <stdio.h>
 
 #include "DNA_node_types.h"
-#include "DNA_material_types.h"
-#include "DNA_texture_types.h"
 #include "DNA_scene_types.h"
-#include "DNA_screen_types.h"
-#include "DNA_space_types.h"
 
 #include "BKE_context.h"
-#include "BKE_node.h"
-#include "BKE_global.h"
-#include "BKE_utildefines.h"
 
 #include "BLI_rect.h"
+#include "BLI_utildefines.h"
 
-#include "ED_space_api.h"
 #include "ED_screen.h"
 #include "ED_types.h"
 
@@ -116,19 +114,9 @@ static int node_select_exec(bContext *C, wmOperator *op)
        
        /* perform the select */
        node= node_mouse_select(snode, ar, mval, extend);
-
-       /* need refresh/a notifier vs compo notifier */
-       WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); /* Do we need to pass the scene? */
-
-       /* WATCH THIS, there are a few other ways to change the active material */
-       if(node) {
-               if (node->id && ELEM(GS(node->id->name), ID_MA, ID_TE)) {
-                       WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING_DRAW, node->id);
-               }
-       }
        
-    /* send notifiers */
-       WM_event_add_notifier(C, NC_NODE|ND_NODE_SELECT, NULL);
+       /* send notifiers */
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
        
        /* allow tweak event to work too */
        return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
@@ -154,6 +142,7 @@ void NODE_OT_select(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Select";
        ot->idname= "NODE_OT_select";
+       ot->description= "Select node under cursor";
        
        /* api callbacks */
        ot->invoke= node_select_invoke;
@@ -196,7 +185,7 @@ static int node_borderselect_exec(bContext *C, wmOperator *op)
                }
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); /* Do we need to pass the scene? */
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
 
        return OPERATOR_FINISHED;
 }
@@ -234,6 +223,7 @@ void NODE_OT_select_border(wmOperatorType *ot)
        /* identifiers */
        ot->name= "Border Select";
        ot->idname= "NODE_OT_select_border";
+       ot->description= "Use box selection to select nodes";
        
        /* api callbacks */
        ot->invoke= node_border_select_invoke;
@@ -252,7 +242,7 @@ void NODE_OT_select_border(wmOperatorType *ot)
 
 /* ****** Select/Deselect All ****** */
 
-static int node_select_all_exec(bContext *C, wmOperator *op)
+static int node_select_all_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        bNode *first = snode->edittree->nodes.first;
@@ -272,14 +262,14 @@ static int node_select_all_exec(bContext *C, wmOperator *op)
                        node->flag |= NODE_SELECT;
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
        return OPERATOR_FINISHED;
 }
 
 void NODE_OT_select_all(wmOperatorType *ot)
 {
        /* identifiers */
-       ot->name = "Select/Deselect All";
+       ot->name = "Select or Deselect All";
        ot->description = "(De)select all nodes";
        ot->idname = "NODE_OT_select_all";
        
@@ -293,7 +283,7 @@ void NODE_OT_select_all(wmOperatorType *ot)
 
 /* ****** Select Linked To ****** */
 
-static int node_select_linked_to_exec(bContext *C, wmOperator *op)
+static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        bNodeLink *link;
@@ -303,7 +293,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *op)
                node->flag &= ~NODE_TEST;
 
        for (link=snode->edittree->links.first; link; link=link->next) {
-               if (link->fromnode->flag & NODE_SELECT)
+               if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT))
                        link->tonode->flag |= NODE_TEST;
        }
        
@@ -312,7 +302,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *op)
                        node->flag |= NODE_SELECT;
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
        return OPERATOR_FINISHED;
 }
 
@@ -333,7 +323,7 @@ void NODE_OT_select_linked_to(wmOperatorType *ot)
 
 /* ****** Select Linked From ****** */
 
-static int node_select_linked_from_exec(bContext *C, wmOperator *op)
+static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op))
 {
        SpaceNode *snode = CTX_wm_space_node(C);
        bNodeLink *link;
@@ -343,7 +333,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *op)
                node->flag &= ~NODE_TEST;
 
        for(link=snode->edittree->links.first; link; link=link->next) {
-               if(link->tonode->flag & NODE_SELECT)
+               if(link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT))
                        link->fromnode->flag |= NODE_TEST;
        }
        
@@ -352,7 +342,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *op)
                        node->flag |= NODE_SELECT;
        }
        
-       WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL);
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
        return OPERATOR_FINISHED;
 }
 
@@ -371,3 +361,78 @@ void NODE_OT_select_linked_from(wmOperatorType *ot)
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/* ****** Select Same Type ****** */
+
+static int node_select_same_type_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       SpaceNode *snode = CTX_wm_space_node(C);
+
+       node_select_same_type(snode);
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, NULL);
+       return OPERATOR_FINISHED;
+}
+
+void NODE_OT_select_same_type(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name = "Select Same Type";
+       ot->description = "Select all the same type";
+       ot->idname = "NODE_OT_select_same_type";
+       
+       /* api callbacks */
+       ot->exec = node_select_same_type_exec;
+       ot->poll = ED_operator_node_active;
+       
+       /* 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 *UNUSED(op))
+{
+       SpaceNode *snode = CTX_wm_space_node(C);
+
+       node_select_same_type_np(snode, 0);
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, 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 *UNUSED(op))
+{
+       SpaceNode *snode = CTX_wm_space_node(C);
+
+       node_select_same_type_np(snode, 1);
+       WM_event_add_notifier(C, NC_NODE|NA_SELECTED, 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;
+}