#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;
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
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 */
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");
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;
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);
}
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)
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