diff options
author | Nathan Letwory <nathan@letworyinteractive.com> | 2009-01-06 02:53:04 +0300 |
---|---|---|
committer | Nathan Letwory <nathan@letworyinteractive.com> | 2009-01-06 02:53:04 +0300 |
commit | 8a8585cda9be38520304acecdaca50dd8511bbfa (patch) | |
tree | de847eeea96b403c85382a9a6b7a9842e3db7b1c | |
parent | 9986642d276786dbea3913dea52f6f5d193d8847 (diff) |
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.
-rw-r--r-- | source/blender/editors/space_node/node_header.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_intern.h | 5 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_select.c | 69 |
4 files changed, 78 insertions, 1 deletions
diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 7191bb2214c..8858805c0ac 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -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); diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index a8857671f4b..40fc72f97de 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -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); diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index dc6f3c77cdf..5be6f6a9777 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -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); } diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 6623d1fb4f4..bd3a3e405d0 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -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); +}
\ No newline at end of file |