2.5 / Nodes / Border select

* bring border select (BKey), works in editor, but draws
  badly only in header when initiated from menu, so that's
  commented out for now.
This commit is contained in:
Nathan Letwory
2009-01-05 23:53:04 +00:00
parent 9986642d27
commit 8a8585cda9
4 changed files with 78 additions and 1 deletions

View File

@@ -75,7 +75,8 @@ static void do_node_selectmenu(bContext *C, void *arg, int event)
switch(event) {
case 1: /* border select */
// XXX node_border_select(snode);
// NODE_FIX_ME border select draws in menu area only :S
// WM_operator_name_call(C, "NODE_OT_border_select", WM_OP_INVOKE_REGION_WIN, NULL, NULL);
break;
case 2: /* select/deselect all */
// XXX node_deselectall(snode, 1);

View File

@@ -39,6 +39,10 @@ struct wmWindowManager;
#define NODE_SELECT_MOUSE 1
/* border select defines XXX these seem to be hardcode values still in border select invoke, check */
#define NODE_EXTEND 1
#define NODE_EXCLUSIVE 3
/* node_header.c */
void node_header_buttons(const bContext *C, ARegion *ar);
@@ -54,6 +58,7 @@ void NODE_OT_select(struct wmOperatorType *ot);
void NODE_OT_extend_select(struct wmOperatorType *ot);
void NODE_OT_toggle_visibility(struct wmOperatorType *ot);
void NODE_OT_fit_all(struct wmOperatorType *ot);
void NODE_OT_border_select(struct wmOperatorType *ot);
/* drawnode.c */
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link);

View File

@@ -52,6 +52,7 @@ void node_operatortypes(void)
WM_operatortype_append(NODE_OT_extend_select);
WM_operatortype_append(NODE_OT_toggle_visibility);
WM_operatortype_append(NODE_OT_fit_all);
WM_operatortype_append(NODE_OT_border_select);
}
void node_keymap(struct wmWindowManager *wm)
@@ -62,6 +63,7 @@ void node_keymap(struct wmWindowManager *wm)
RNA_enum_set(WM_keymap_add_item(keymap, "NODE_OT_extend_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select_type", NODE_SELECT_MOUSE);
WM_keymap_add_item(keymap, "NODE_OT_toggle_visibility", ACTIONMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_fit_all", HOMEKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "NODE_OT_border_select", BKEY, KM_PRESS, 0, 0);
transform_keymap_for_space(wm, keymap, SPACE_NODE);
}

View File

@@ -190,3 +190,72 @@ void NODE_OT_select(wmOperatorType *ot)
prop = RNA_def_property(ot->srna, "my", 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);
printf("%d - %f %f %f %f\n", val, rectf.xmin, rectf.ymin, rectf.xmax, rectf.ymax);
for(node= snode->edittree->nodes.first; node; node= node->next) {
printf("\t%f %f %f %f\n", node->totr.xmin, node->totr.ymin, node->totr.xmax, node->totr.ymax);
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);
}