diff options
author | Ton Roosendaal <ton@blender.org> | 2008-12-31 20:50:00 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-12-31 20:50:00 +0300 |
commit | 0371e6cb21bcd16e80803a0c6f1b71edc81c04d2 (patch) | |
tree | 16765331da89952513511de95330e08dd338c48a /source | |
parent | b54d8f3c57c9fe4ea018401b1cb24806630066db (diff) |
2.5
Added extend-select for edit mesh.
Note for operator design; you cannot give operators hardcoded
properties like "SHIFT" or "ALT", that conflicts with the idea
of keymaps. Instead the properties have to be functional, like
setting 'extend' on or off.
I also think mouse select could get these operators:
- activate/select, option 'extend'
- activate/select on object center, option 'extend'
- activate/select, with menu, option 'extend'
and of course loop-select, group-select, and so on.
BTW: border-select could also get 'extend' option :)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_mods.c | 12 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 69 |
4 files changed, 29 insertions, 61 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 23acfff6e1a..0f9a6c383da 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -104,7 +104,7 @@ void EM_editselection_plane(float *plane, EditSelection *ese); /* editmesh_mods.c */ extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs; -void mouse_mesh(struct bContext *C, short mval[2]); +void mouse_mesh(struct bContext *C, short mval[2], short extend); int EM_check_backbuf(unsigned int index); int EM_mask_init_backbuf_border(struct View3D *v3d, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); void EM_free_backbuf(void); diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index b9b939014b2..5dae6a686c0 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -2174,13 +2174,13 @@ static void mouse_mesh_loop(ViewContext *vc) /* here actual select happens */ -void mouse_mesh(bContext *C, short mval[2]) +void mouse_mesh(bContext *C, short mval[2], short extend) { ViewContext vc; EditVert *eve; EditEdge *eed; EditFace *efa; - int shift= 0, alt= 0; // XXX + int alt= 0; // XXX /* setup view context for argument to callbacks */ em_setup_viewcontext(C, &vc); @@ -2190,7 +2190,7 @@ void mouse_mesh(bContext *C, short mval[2]) if(alt) mouse_mesh_loop(&vc); else if(unified_findnearest(&vc, &eve, &eed, &efa)) { - if((shift)==0) EM_clear_flag_all(vc.em, SELECT); + if(extend==0) EM_clear_flag_all(vc.em, SELECT); if(efa) { /* set the last selected face */ @@ -2200,7 +2200,7 @@ void mouse_mesh(bContext *C, short mval[2]) EM_store_selection(vc.em, efa, EDITFACE); EM_select_face_fgon(vc.em, efa, 1); } - else if(shift) { + else if(extend) { EM_remove_selection(vc.em, efa, EDITFACE); EM_select_face_fgon(vc.em, efa, 0); } @@ -2210,7 +2210,7 @@ void mouse_mesh(bContext *C, short mval[2]) EM_store_selection(vc.em, eed, EDITEDGE); EM_select_edge(eed, 1); } - else if(shift) { + else if(extend) { EM_remove_selection(vc.em, eed, EDITEDGE); EM_select_edge(eed, 0); } @@ -2220,7 +2220,7 @@ void mouse_mesh(bContext *C, short mval[2]) eve->f |= SELECT; EM_store_selection(vc.em, eve, EDITVERT); } - else if(shift){ + else if(extend){ EM_remove_selection(vc.em, eve, EDITVERT); eve->f &= ~SELECT; } diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index debbf9c9a7d..9901fc11c43 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -70,7 +70,6 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_viewnumpad); WM_operatortype_append(VIEW3D_OT_viewcenter); WM_operatortype_append(VIEW3D_OT_select); - WM_operatortype_append(VIEW3D_OT_select_extend); WM_operatortype_append(VIEW3D_OT_borderselect); WM_operatortype_append(VIEW3D_OT_clipping); WM_operatortype_append(VIEW3D_OT_circle_select); @@ -122,14 +121,10 @@ void view3d_keymap(wmWindowManager *wm) /* selection*/ 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, KM_SHIFT, 0)->ptr, "type", 1); WM_keymap_add_item(keymap, "VIEW3D_OT_borderselect", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_circle_select", CKEY, KM_PRESS, 0, 0); - /* select extend*/ - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_extend", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", KM_SHIFT); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_extend", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "modifier", KM_CTRL); - RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_select_extend", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "modifier", KM_ALT); - WM_keymap_add_item(keymap, "VIEW3D_OT_clipping", BKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_render_border", BKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 3dcf531ad38..1396ad2929b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -835,8 +835,9 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff return 0; } + /* mval is region coords */ -static void mouse_select(bContext *C, short *mval, short modifier) +static void mouse_select(bContext *C, short *mval, short extend, short obcenter) { ViewContext vc; ARegion *ar= CTX_wm_region(C); @@ -859,10 +860,12 @@ static void mouse_select(bContext *C, short *mval, short modifier) if(BASACT && BASACT->next) startbase= BASACT->next; /* This block uses the control key to make the object selected by its center point rather then its contents */ - if(G.obedit==0 && modifier == KM_CTRL) { + /* XXX later on, in editmode do not activate */ + if(G.obedit==NULL && obcenter) { /* note; shift+alt goes to group-flush-selecting */ - if(modifier == KM_ALT && modifier == KM_CTRL) + /* XXX solve */ + if(0) basact= mouse_select_menu(&vc, NULL, 0, mval); else { base= startbase; @@ -896,7 +899,7 @@ static void mouse_select(bContext *C, short *mval, short modifier) for(a=0; a<hits; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones= 1; /* note; shift+alt goes to group-flush-selecting */ - if(has_bones==0 && (modifier == KM_ALT)) + if(has_bones==0 && 0) basact= mouse_select_menu(&vc, buffer, hits, mval); else { static short lastmval[2]={-100, -100}; @@ -1023,11 +1026,11 @@ static void mouse_select(bContext *C, short *mval, short modifier) oldbasact= BASACT; BASACT= basact; - if(modifier != KM_SHIFT) { + if(!extend) { deselectall_except(scene, basact); ED_base_object_select(basact, BA_SELECT); } - else if(modifier == KM_CTRL && modifier == KM_ALT) { + else if(0) { // XXX select_all_from_groups(basact); } else { @@ -1442,10 +1445,17 @@ void VIEW3D_OT_borderselect(wmOperatorType *ot) /* ****** Mouse Select ****** */ +static EnumPropertyItem prop_select_types[] = { + {0, "EXCLUSIVE", "Exclusive", ""}, + {1, "EXTEND", "Extend", ""}, + {0, NULL, NULL, NULL} +}; + static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); Object *obedit= CTX_data_edit_object(C); + short extend= RNA_enum_is_equal(op->ptr, "type", "EXTEND"); short mval[2]; mval[0]= event->x - ar->winrct.xmin; @@ -1455,16 +1465,17 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) if(obedit) { if(obedit->type==OB_MESH) - mouse_mesh(C, mval); + mouse_mesh(C, mval, extend); } else - mouse_select(C, mval, 0); + mouse_select(C, mval, extend, 0); return OPERATOR_FINISHED; } void VIEW3D_OT_select(wmOperatorType *ot) { + PropertyRNA *prop; /* identifiers */ ot->name= "Activate/Select"; @@ -1474,46 +1485,8 @@ void VIEW3D_OT_select(wmOperatorType *ot) ot->invoke= view3d_select_invoke; ot->poll= ED_operator_view3d_active; -} -static EnumPropertyItem prop_select_extend_types[] = { - {KM_SHIFT, "SHIFT", "Shift", ""}, - {KM_CTRL, "CTRL", "Ctrl", ""}, - {KM_ALT, "ALT", "Alt", ""}, - {0, NULL, NULL, NULL} -}; - -static int view3d_select_extend_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - ARegion *ar= CTX_wm_region(C); - short mval[2], modifier; - - mval[0]= event->x - ar->winrct.xmin; - mval[1]= event->y - ar->winrct.ymin; - - modifier = RNA_enum_get(op->ptr, "modifier"); - - view3d_operator_needs_opengl(C); - - mouse_select(C, mval, modifier); - - return OPERATOR_FINISHED; -} - -void VIEW3D_OT_select_extend(wmOperatorType *ot) -{ - PropertyRNA *prop; - - /* identifiers */ - ot->name= "Activate/Select Extend"; - ot->idname= "VIEW3D_OT_select_extend"; - - /* api callbacks */ - ot->invoke= view3d_select_extend_invoke; - ot->poll= ED_operator_view3d_active; - - prop = RNA_def_property(ot->srna, "modifier", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, prop_select_extend_types); - + prop = RNA_def_property(ot->srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_select_types); } |