2.5 MSVC9 projectfiles
[blender-staging.git] / source / blender / editors / space_node / node_select.c
index e5a631e2178c46253d3c54190b0abddb3ed6ce46..cc8e03e0b44b91744e6ddfea2a5cbbe75613443f 100644 (file)
@@ -53,7 +53,7 @@
  
 #include "node_intern.h"
  
-static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short modifier)
+static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short extend)
 {
        bNode *node;
        float mx, my;
@@ -80,10 +80,10 @@ static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short
                        break;
        }
        if(node) {
-               if((modifier & KM_SHIFT)==0)
+               if((extend & KM_SHIFT)==0)
                        node_deselectall(snode, 0);
                
-               if(modifier & KM_SHIFT) {
+               if(extend & KM_SHIFT) {
                        if(node->flag & SELECT)
                                node->flag &= ~SELECT;
                        else
@@ -95,7 +95,7 @@ static void node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short
                node_set_active(snode, node);
                
                /* viewer linking */
-               if(modifier & KM_CTRL)
+               if(extend & KM_CTRL)
                        ;//     node_link_viewer(snode, node);
                
                //std_rmouse_transform(node_transform_ext);     /* does undo push for select */
@@ -109,7 +109,7 @@ static int node_select_exec(bContext *C, wmOperator *op)
        ARegion *ar= CTX_wm_region(C);
        int select_type;
        short mval[2];
-       short modifier;
+       short extend;
 
        select_type = RNA_enum_get(op->ptr, "select_type");
        
@@ -117,8 +117,8 @@ static int node_select_exec(bContext *C, wmOperator *op)
                case NODE_SELECT_MOUSE:
                        mval[0] = RNA_int_get(op->ptr, "mx");
                        mval[1] = RNA_int_get(op->ptr, "my");
-                       modifier = RNA_int_get(op->ptr, "modifier");
-                       node_mouse_select(snode, ar, mval, modifier);
+                       extend = RNA_int_get(op->ptr, "extend");
+                       node_mouse_select(snode, ar, mval, extend);
                        break;
        }
        return OPERATOR_FINISHED;
@@ -140,7 +140,7 @@ static int node_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 
 static int node_extend_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       RNA_int_set(op->ptr, "modifier", KM_SHIFT);
+       RNA_int_set(op->ptr, "extend", KM_SHIFT);
 
        return node_select_invoke(C, op, event);
 }
@@ -168,7 +168,7 @@ void NODE_OT_extend_select(wmOperatorType *ot)
        
        prop = RNA_def_property(ot->srna, "mx", PROP_INT, PROP_NONE);
        prop = RNA_def_property(ot->srna, "my", PROP_INT, PROP_NONE);
-       prop = RNA_def_property(ot->srna, "modifier", PROP_INT, PROP_NONE);
+       prop = RNA_def_property(ot->srna, "extend", PROP_INT, PROP_NONE);
 }
 
 void NODE_OT_select(wmOperatorType *ot)
@@ -188,5 +188,70 @@ void NODE_OT_select(wmOperatorType *ot)
        
        prop = RNA_def_property(ot->srna, "mx", PROP_INT, PROP_NONE);
        prop = RNA_def_property(ot->srna, "my", PROP_INT, PROP_NONE);
-       prop = RNA_def_property(ot->srna, "modifier", PROP_INT, PROP_NONE);
+       prop = RNA_def_property(ot->srna, "extend", PROP_INT, PROP_NONE);
 }
+
+/* ****** Border Select ****** */
+
+static EnumPropertyItem prop_select_types[] = {
+       {NODE_EXCLUSIVE, "EXCLUSIVE", "Exclusive", ""}, /* right mouse */
+       {NODE_EXTEND, "EXTEND", "Extend", ""}, /* left mouse */
+       {0, NULL, NULL, NULL}
+};
+
+static int node_borderselect_exec(bContext *C, wmOperator *op)
+{
+       SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C);
+       ARegion *ar= CTX_wm_region(C);
+       bNode *node;
+       rcti rect;
+       rctf rectf;
+       short val;
+       
+       val= RNA_int_get(op->ptr, "event_type");
+       
+       rect.xmin= RNA_int_get(op->ptr, "xmin");
+       rect.ymin= RNA_int_get(op->ptr, "ymin");
+       UI_view2d_region_to_view(&ar->v2d, rect.xmin, rect.ymin, &rectf.xmin, &rectf.ymin);
+       
+       rect.xmax= RNA_int_get(op->ptr, "xmax");
+       rect.ymax= RNA_int_get(op->ptr, "ymax");
+       UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax);
+       
+       for(node= snode->edittree->nodes.first; node; node= node->next) {
+               if(BLI_isect_rctf(&rectf, &node->totr, NULL)) {
+                       if(val==NODE_EXTEND)
+                               node->flag |= SELECT;
+                       else
+                               node->flag &= ~SELECT;
+               }
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+void NODE_OT_border_select(wmOperatorType *ot)
+{
+       PropertyRNA *prop;
+       
+       /* identifiers */
+       ot->name= "Border Select";
+       ot->idname= "NODE_OT_border_select";
+       
+       /* api callbacks */
+       ot->invoke= WM_border_select_invoke;
+       ot->exec= node_borderselect_exec;
+       ot->modal= WM_border_select_modal;
+       
+       ot->poll= ED_operator_node_active;
+       
+       /* rna */
+       RNA_def_property(ot->srna, "event_type", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "xmin", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE);
+       RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE);
+
+       prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_select_types);
+}
\ No newline at end of file