diff options
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 50 |
3 files changed, 47 insertions, 7 deletions
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 4a66cb525bb..929e1f7751d 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -61,6 +61,8 @@ typedef struct ViewDepths { #define V3D_XRAY 1 #define V3D_TRANSP 2 +#define V3D_SELECT_MOUSE 1 + /* project short */ #define IS_CLIPPED 12000 diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 2589ce7bdb4..6ac110ea0cf 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -115,7 +115,7 @@ void view3d_keymap(wmWindowManager *wm) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD6, KM_PRESS, KM_CTRL, 0)->ptr, "viewnum", V3D_VIEW_PANRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD8, KM_PRESS, KM_CTRL, 0)->ptr, "viewnum", V3D_VIEW_PANUP); - WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "select_type", V3D_SELECT_MOUSE); WM_keymap_add_item(keymap, "VIEW3D_OT_borderselect", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_clipping", BKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_circle_select", CKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index dd6899ea12f..2be8df678f0 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1234,25 +1234,57 @@ static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval) } -static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) +/* *****************Selection Operations Operator******************* */ + +static EnumPropertyItem prop_select_items[] = { + {V3D_SELECT_MOUSE, "NORMAL", "Normal Select", "Select using the mouse"}, + {0, NULL, NULL, NULL}}; + +static int view3d_select_exec(bContext *C, wmOperator *op) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); View3D *v3d= sa->spacedata.first; + Scene *scene= CTX_data_scene(C); + int select_type; short mval[2]; - - /* note; otherwise opengl select won't work. do this for every glSelectBuffer() */ - wmSubWindowSet(CTX_wm_window(C), ar->swinid); + + select_type = RNA_enum_get(op->ptr, "select_type"); + + view3d_operator_needs_opengl(C); + printf("about to look at enum"); + switch (select_type) { + case V3D_SELECT_MOUSE : + printf("caught event"); + mval[0] = RNA_int_get(op->ptr, "mx"); + mval[1] = RNA_int_get(op->ptr, "my"); + mouse_select(scene, ar, v3d, mval); + printf("selected object"); + break; + } + return OPERATOR_FINISHED; +} + +static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= CTX_wm_region(C); + View3D *v3d= sa->spacedata.first; + short mval[2]; mval[0]= event->x - ar->winrct.xmin; mval[1]= event->y - ar->winrct.ymin; - mouse_select(CTX_data_scene(C), ar, v3d, mval); + + RNA_int_set(op->ptr, "mx", mval[0]); + RNA_int_set(op->ptr, "my", mval[1]); + + return view3d_select_exec(C,op); - return OPERATOR_FINISHED; } void VIEW3D_OT_select(wmOperatorType *ot) { + PropertyRNA *prop; /* identifiers */ ot->name= "Activate/Select"; @@ -1261,6 +1293,12 @@ void VIEW3D_OT_select(wmOperatorType *ot) /* api callbacks */ ot->invoke= view3d_select_invoke; ot->poll= ED_operator_view3d_active; + + prop = RNA_def_property(ot->srna, "select_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_select_items); + + prop = RNA_def_property(ot->srna, "mx", PROP_INT, PROP_NONE); + prop = RNA_def_property(ot->srna, "my", PROP_INT, PROP_NONE); } /* ******************** border and circle ************************************** */ |