diff options
author | Ton Roosendaal <ton@blender.org> | 2009-01-01 21:05:12 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-01-01 21:05:12 +0300 |
commit | e2e282989e08506f199e58fe64bac41c5c594ab0 (patch) | |
tree | a3cb21c98ba7c42d7f893595b7248f8bdacc24ac /source | |
parent | 029b0c3ecf89323b7ee943e5c09fbde4ca2fbc60 (diff) |
2.5
- Put back vertex/edge/face select
- Mode menu allows going in/out editmode
- Tested some tweak event stuff in WM, made tweak event follow
user preset for 'action' or 'select' mouse.
(Wanted to try this for transform, but better get advise from
Martin first :)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_editVert.h | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/anim_markers.c | 22 | ||||
-rw-r--r-- | source/blender/editors/include/ED_mesh.h | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_object.h | 6 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_edit.c | 38 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_header.c | 86 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_ops.c | 3 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_select.c | 3 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 93 | ||||
-rw-r--r-- | source/blender/windowmanager/wm_event_types.h | 9 |
13 files changed, 157 insertions, 111 deletions
diff --git a/source/blender/blenlib/BLI_editVert.h b/source/blender/blenlib/BLI_editVert.h index 55be4cfae42..a4a4d5ffd84 100644 --- a/source/blender/blenlib/BLI_editVert.h +++ b/source/blender/blenlib/BLI_editVert.h @@ -173,7 +173,7 @@ typedef struct EditMesh EditFace *act_face; /* copy from scene */ - int selectmode; + short selectmode; struct DerivedMesh *derivedCage, *derivedFinal; /* the custom data layer mask that was last used to calculate diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 141ed5a9e70..a08f3911c36 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -340,25 +340,6 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op) } -/* for tweak handlers, check configuration for how to interpret events */ -int WM_modal_tweak_check(wmEvent *evt, int tweak_event) -{ - /* user preset?? dunno... */ - int tweak_modal= 1; - - switch(tweak_event) { - case EVT_TWEAK_L: - case EVT_TWEAK_M: - case EVT_TWEAK_R: - if(evt->val==tweak_modal) - return 1; - default: - /* this case is when modal callcback didnt get started with a tweak */ - if(evt->val) - return 1; - } - return 0; -} static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) { @@ -377,7 +358,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) case LEFTMOUSE: case MIDDLEMOUSE: case RIGHTMOUSE: - if(WM_modal_tweak_check(evt, mm->event_type)) { + if(WM_modal_tweak_exit(evt, mm->event_type)) { ed_marker_move_exit(C, op); WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); return OPERATOR_FINISHED; @@ -625,6 +606,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend) WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); + /* allowing tweaks */ return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 5a093484461..17ef2c1d1cd 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -109,6 +109,8 @@ void EM_select_edge(struct EditEdge *eed, int sel); void EM_select_face_fgon(struct EditMesh *em, struct EditFace *efa, int val); void EM_selectmode_flush(struct EditMesh *em); void EM_deselect_flush(struct EditMesh *em); +void EM_selectmode_set(struct EditMesh *em); +void EM_convertsel(struct EditMesh *em, short oldmode, short selectmode); /* exported to transform */ int EM_get_actSelection(struct EditMesh *em, struct EditSelection *ese); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index ee79a259d5a..569cce13b4e 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -44,6 +44,12 @@ void ED_base_object_activate(struct bContext *C, struct Base *base); void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base); +/* bitflags for enter/exit editmode */ +#define EM_FREEDATA 1 +#define EM_FREEUNDO 2 +#define EM_WAITCURSOR 4 +void ED_object_exit_editmode(struct bContext *C, int flag); +void ED_object_enter_editmode(struct bContext *C, int flag); /* cleanup */ int object_data_is_libdata(struct Object *ob); diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 02b139476b0..a23e3e42012 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -109,11 +109,9 @@ extern int faceselectedAND(EditFace *efa, int flag); void EM_remove_selection(EditMesh *em, void *data, int type); void EM_set_actFace(EditMesh *em, EditFace *efa); void EM_select_face(EditFace *efa, int sel); -void EM_selectmode_set(EditMesh *em); void EM_clear_flag_all(EditMesh *em, int flag); void EM_select_flush(EditMesh *em); void EM_set_flag_all(EditMesh *em, int flag); -void EM_convertsel(EditMesh *em, short oldmode, short selectmode); void EM_add_data_layer(EditMesh *em, CustomData *data, int type); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 8eb51192d8a..5e3daa843b6 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -113,6 +113,7 @@ #include "ED_anim_api.h" #include "ED_mesh.h" +#include "ED_object.h" #include "ED_screen.h" #include "ED_types.h" #include "ED_util.h" @@ -131,7 +132,6 @@ #include "object_intern.h" // own include /* ************* XXX **************** */ -#define EM_WAITCURSOR 0 static void allqueue() {} static void BIF_undo_push() {} static void error() {} @@ -250,7 +250,7 @@ void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menu exit_paint_modes(); -// XXX if (G.obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ +// XXX if (G.obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ ob= add_object(type); // ED_base_object_activate(C, BASACT); base_init_from_view3d(BASACT, v3d); @@ -1992,21 +1992,20 @@ void OBJECT_OT_make_track(wmOperatorType *ot) /* ******************* toggle editmode operator ***************** */ -static void exit_editmode(bContext *C, wmOperator *op, int flag) /* freedata==0 at render, 1= freedata, 2= do undo buffer too */ +void ED_object_exit_editmode(bContext *C, int flag) { Scene *scene= CTX_data_scene(C); Object *ob; // Object *obedit= CTX_data_edit_object(C); - int freedata = flag; // XXX & EM_FREEDATA; + int freedata = flag & EM_FREEDATA; if(G.obedit==NULL) return; -// if(flag & EM_WAITCURSOR) waitcursor(1); + if(flag & EM_WAITCURSOR) waitcursor(1); if(G.obedit->type==OB_MESH) { Mesh *me= G.obedit->data; // if(EM_texFaceCheck()) -// allqueue(REDRAWIMAGE, 0); // if(retopo_mesh_paint_check()) // retopo_end_okee(); @@ -2059,14 +2058,14 @@ static void exit_editmode(bContext *C, wmOperator *op, int flag) /* freedata==0 if(G.obedit==NULL) // XXX && (flag & EM_FREEUNDO)) ED_undo_push(C, "Editmode"); - // if(flag & EM_WAITCURSOR) waitcursor(0); + if(flag & EM_WAITCURSOR) waitcursor(0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, ob); } -static void enter_editmode(bContext *C, wmOperator *op) +void ED_object_enter_editmode(bContext *C, int flag) { Scene *scene= CTX_data_scene(C); Base *base= CTX_data_active_base(C); @@ -2085,7 +2084,7 @@ static void enter_editmode(bContext *C, wmOperator *op) return; } - //if(wc) waitcursor(1); + if(flag & EM_WAITCURSOR) waitcursor(1); if(ob->type==OB_MESH) { Mesh *me= ob->data; @@ -2144,24 +2143,23 @@ static void enter_editmode(bContext *C, wmOperator *op) } if(ok) { - DAG_object_flush_update(scene, G.obedit, OB_RECALC_DATA); - } else { G.obedit= NULL; WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, ob); } + if(flag & EM_WAITCURSOR) waitcursor(0); } static int toggle_editmode_exec(bContext *C, wmOperator *op) { if(!CTX_data_edit_object(C)) - enter_editmode(C, op); + ED_object_enter_editmode(C, EM_WAITCURSOR); else - exit_editmode(C, op, 1); + ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); return OPERATOR_FINISHED; } @@ -2188,7 +2186,7 @@ void check_editmode(int type) if (G.obedit==0 || G.obedit->type==type) return; -// XXX exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ +// XXX ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* freedata, and undo */ } /* 0 == do center, 1 == center new, 2 == center cursor */ @@ -3339,8 +3337,8 @@ void convertmenu(Scene *scene, View3D *v3d) /* texspace and normals */ if(!basen) BASACT= base; -// XXX enter_editmode(scene, v3d, EM_WAITCURSOR); -// XXX exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ +// XXX ED_object_enter_editmode(C, 0); +// XXX exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ BASACT= basact; allqueue(REDRAWVIEW3D, 0); @@ -4337,9 +4335,9 @@ static void apply_objects_internal(Scene *scene, View3D *v3d, int apply_scale, i /* texspace and normals */ BASACT= base; -// XXX enter_editmode(scene, v3d, EM_WAITCURSOR); +// XXX ED_object_enter_editmode(C, 0); BIF_undo_push("Applied object"); /* editmode undo itself */ -// XXX exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ +// XXX ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ BASACT= basact; change = 1; @@ -4413,9 +4411,9 @@ static void apply_objects_internal(Scene *scene, View3D *v3d, int apply_scale, i /* texspace and normals */ BASACT= base; -// XXX enter_editmode(scene, v3d, EM_WAITCURSOR); +// XXX ED_object_enter_editmode(C, 0); BIF_undo_push("Applied object"); /* editmode undo itself */ -// XXX exit_editmode(EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ +// XXX ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ BASACT= basact; change = 1; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 27881ee627f..1bb452cffb6 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -64,6 +64,7 @@ #include "ED_screen.h" #include "ED_object.h" +#include "ED_mesh.h" #include "ED_util.h" #include "ED_types.h" @@ -5306,8 +5307,12 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) View3D *v3d= sa->spacedata.first; Object *ob= OBACT; Object *obedit = CTX_data_edit_object(C); - int bit, shift=0; // XXX shift arg? - + EditMesh *em= NULL; + int bit, ctrl=0, shift=0; // XXX shift arg? + + if(obedit && obedit->type==OB_MESH) { + em= ((Mesh *)obedit->data)->edit_mesh; + } /* watch it: if sa->win does not exist, check that when calling direct drawing routines */ switch(event) { @@ -5362,13 +5367,13 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); // XXX if(ob) exit_posemode(); /* exit posemode for active object */ -// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ } else if (v3d->modeselect == V3D_EDITMODE_SEL) { if(!obedit) { v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); -// XXX enter_editmode(EM_WAITCURSOR); + ED_object_enter_editmode(C, EM_WAITCURSOR); ED_undo_push(C, "Original"); /* here, because all over code enter_editmode is abused */ } } @@ -5376,7 +5381,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) if (!(G.f & G_SCULPTMODE)) { v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); -// XXX if(obedit) exit_editmode(2); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEUNDO); /* exit editmode and undo */ // XXX set_sculptmode(); } @@ -5385,7 +5390,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) if (!(G.f & G_VERTEXPAINT)) { v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); -// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ // XXX set_vpaint(); } @@ -5394,7 +5399,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) if (!(G.f & G_TEXTUREPAINT)) { v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); -// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ // XXX set_texturepaint(); } @@ -5403,7 +5408,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) if (!(G.f & G_WEIGHTPAINT) && (ob && ob->type == OB_MESH) ) { v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); -// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ // XXX set_wpaint(); } @@ -5412,7 +5417,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) if (ob) { v3d->flag &= ~V3D_MODE; -// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ // XXX enter_posemode(); } @@ -5421,7 +5426,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) if (!(G.f & G_PARTICLEEDIT)) { v3d->flag &= ~V3D_MODE; // XXX exit_paint_modes(); -// XXX if(obedit) exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ + if(obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */ // XXX PE_set_particle_edit(); } @@ -5435,39 +5440,42 @@ static void do_view3d_buttons(bContext *C, void *arg, int event) break; case B_SEL_VERT: - if(shift==0 || scene->selectmode==0) - scene->selectmode= SCE_SELECT_VERTEX; -// XXX EM_selectmode_set(); - countall(); - ED_undo_push(C, "Selectmode Set: Vertex"); - allqueue(REDRAWVIEW3D, 1); - allqueue(REDRAWIMAGE, 0); /* only needed in cases where mesh and UV selection are in sync */ + if(em) { + if(shift==0 || em->selectmode==0) + em->selectmode= SCE_SELECT_VERTEX; + scene->selectmode= em->selectmode; + EM_selectmode_set(em); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit); + ED_undo_push(C, "Selectmode Set: Vertex"); + } break; case B_SEL_EDGE: - if(shift==0 || scene->selectmode==0){ - if( (scene->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){ -// XXX if(ctrl) EM_convertsel(SCE_SELECT_VERTEX,SCE_SELECT_EDGE); + if(em) { + if(shift==0 || em->selectmode==0){ + if( (em->selectmode ^ SCE_SELECT_EDGE) == SCE_SELECT_VERTEX){ + if(ctrl) EM_convertsel(em, SCE_SELECT_VERTEX,SCE_SELECT_EDGE); + } + em->selectmode = SCE_SELECT_EDGE; } - scene->selectmode = SCE_SELECT_EDGE; + scene->selectmode= em->selectmode; + EM_selectmode_set(em); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit); + ED_undo_push(C, "Selectmode Set: Edge"); } -// XXX EM_selectmode_set(); - countall(); - ED_undo_push(C, "Selectmode Set: Edge"); - allqueue(REDRAWVIEW3D, 1); - allqueue(REDRAWIMAGE, 0); /* only needed in cases where mesh and UV selection are in sync */ break; case B_SEL_FACE: - if( shift==0 || scene->selectmode==0){ - if( ((scene->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((scene->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){ -// XXX if(ctrl) EM_convertsel((scene->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE); + if(em) { + if( shift==0 || em->selectmode==0){ + if( ((scene->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_VERTEX) || ((scene->selectmode ^ SCE_SELECT_FACE) == SCE_SELECT_EDGE)){ + if(ctrl) EM_convertsel(em, (scene->selectmode ^ SCE_SELECT_FACE),SCE_SELECT_FACE); + } + em->selectmode = SCE_SELECT_FACE; } - scene->selectmode = SCE_SELECT_FACE; + scene->selectmode= em->selectmode; + EM_selectmode_set(em); + WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, G.obedit); + ED_undo_push(C, "Selectmode Set: Face"); } -// XXX EM_selectmode_set(); - countall(); - ED_undo_push(C, "Selectmode Set: Face"); - allqueue(REDRAWVIEW3D, 1); - allqueue(REDRAWIMAGE, 0); /* only needed in cases where mesh and UV selection are in sync */ break; case B_SEL_PATH: @@ -5915,12 +5923,14 @@ void view3d_header_buttons(const bContext *C, ARegion *ar) /* selection modus */ if(obedit && (obedit->type == OB_MESH)) { + EditMesh *em= ((Mesh *)obedit->data)->edit_mesh; + uiBlockBeginAlign(block); - uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode (Ctrl Tab 1)"); + uiDefIconButBitS(block, TOG, SCE_SELECT_VERTEX, B_SEL_VERT, ICON_VERTEXSEL, xco,yco,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Vertex select mode (Ctrl Tab 1)"); xco+= XIC; - uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Edge select mode (Ctrl Tab 2)"); + uiDefIconButBitS(block, TOG, SCE_SELECT_EDGE, B_SEL_EDGE, ICON_EDGESEL, xco,yco,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Edge select mode (Ctrl Tab 2)"); xco+= XIC; - uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, xco,yco,XIC,YIC, &scene->selectmode, 1.0, 0.0, 0, 0, "Face select mode (Ctrl Tab 3)"); + uiDefIconButBitS(block, TOG, SCE_SELECT_FACE, B_SEL_FACE, ICON_FACESEL, xco,yco,XIC,YIC, &em->selectmode, 1.0, 0.0, 0, 0, "Face select mode (Ctrl Tab 3)"); xco+= XIC; uiBlockEndAlign(block); if(v3d->drawtype > OB_WIRE) { diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index df33d2c660e..b3bc866987c 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -133,5 +133,8 @@ void view3d_keymap(wmWindowManager *wm) transform_keymap_for_space(wm, keymap, SPACE_VIEW3D); + /* generates event, in end to make select work */ + WM_keymap_verify_item(keymap, "WM_OT_tweak_gesture", SELECTMOUSE, 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 32eb3dabfa5..7a5442be2a8 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1473,7 +1473,8 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event) else mouse_select(C, mval, extend, 0); - return OPERATOR_FINISHED; + /* allowing tweaks */ + return OPERATOR_PASS_THROUGH; } void VIEW3D_OT_select(wmOperatorType *ot) diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index d1917d460d1..b7322e3142e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -625,6 +625,7 @@ void transformEvent(TransInfo *t, wmEvent *event) break; case ESCKEY: case RIGHTMOUSE: + printf("cancelled\n"); t->state = TRANS_CANCEL; break; case LEFTMOUSE: diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index e3eaca7accd..3125a21bbd2 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -94,6 +94,7 @@ struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, ListBase * void WM_event_remove_handlers(struct bContext *C, ListBase *handlers); void WM_event_add_mousemove(struct bContext *C); +int WM_modal_tweak_exit(struct wmEvent *evt, int tweak_event); void WM_event_add_notifier(struct bContext *C, unsigned int type, void *data); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index be977530fad..96a97e95bd7 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -530,36 +530,54 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) } } -static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) +/* do userdef mappings */ +static int wm_userdef_event_map(int kmitype) { - int kmitype= kmi->type; - - /* first do userdef mappings */ - if(kmitype==SELECTMOUSE) { - if(U.flag & USER_LMOUSESELECT) - kmitype= LEFTMOUSE; - else - kmitype= RIGHTMOUSE; - } - else if(kmitype==ACTIONMOUSE) { - if(U.flag & USER_LMOUSESELECT) - kmitype= RIGHTMOUSE; - else - kmitype= LEFTMOUSE; - } - else if(kmitype==WHEELOUTMOUSE) { - if(U.uiflag & USER_WHEELZOOMDIR) - kmitype= WHEELUPMOUSE; - else - kmitype= WHEELDOWNMOUSE; - } - else if(kmitype==WHEELINMOUSE) { - if(U.uiflag & USER_WHEELZOOMDIR) - kmitype= WHEELDOWNMOUSE; - else - kmitype= WHEELUPMOUSE; + switch(kmitype) { + case SELECTMOUSE: + if(U.flag & USER_LMOUSESELECT) + return LEFTMOUSE; + else + return RIGHTMOUSE; + + case ACTIONMOUSE: + if(U.flag & USER_LMOUSESELECT) + return RIGHTMOUSE; + else + return LEFTMOUSE; + + case WHEELOUTMOUSE: + if(U.uiflag & USER_WHEELZOOMDIR) + return WHEELUPMOUSE; + else + return WHEELDOWNMOUSE; + + case WHEELINMOUSE: + if(U.uiflag & USER_WHEELZOOMDIR) + return WHEELDOWNMOUSE; + else + return WHEELUPMOUSE; + + case EVT_TWEAK_A: + if(U.flag & USER_LMOUSESELECT) + return EVT_TWEAK_R; + else + return EVT_TWEAK_L; + + case EVT_TWEAK_S: + if(U.flag & USER_LMOUSESELECT) + return EVT_TWEAK_L; + else + return EVT_TWEAK_R; } + return kmitype; +} + +static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi) +{ + int kmitype= wm_userdef_event_map(kmi->type); + /* the matching rules */ if(winevent->type!=kmitype) return 0; @@ -961,6 +979,27 @@ void WM_event_add_mousemove(bContext *C) wm_event_add(window, &event); } +/* for modal callbacks, check configuration for how to interpret exit with tweaks */ +int WM_modal_tweak_exit(wmEvent *evt, int tweak_event) +{ + /* user preset?? dunno... */ + int tweak_modal= 1; + + switch(tweak_event) { + case EVT_TWEAK_L: + case EVT_TWEAK_M: + case EVT_TWEAK_R: + if(evt->val==tweak_modal) + return 1; + default: + /* this case is when modal callcback didnt get started with a tweak */ + if(evt->val) + return 1; + } + return 0; +} + + /* ********************* ghost stuff *************** */ static int convert_key(GHOST_TKey key) diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h index 87dbd337d32..93b5bf02e71 100644 --- a/source/blender/windowmanager/wm_event_types.h +++ b/source/blender/windowmanager/wm_event_types.h @@ -260,12 +260,17 @@ /* **************** BLENDER GESTURE EVENTS ********************* */ #define EVT_ACTIONZONE 0x5001 -/* tweak events, for L M R mousebuttons */ + /* tweak events, for L M R mousebuttons */ #define EVT_TWEAK_L 0x5002 #define EVT_TWEAK_M 0x5003 #define EVT_TWEAK_R 0x5004 + /* tweak events for action or select mousebutton */ +#define EVT_TWEAK_A 0x5005 +#define EVT_TWEAK_S 0x5006 -#define EVT_GESTURE 0x5005 + + +#define EVT_GESTURE 0x5010 /* value of tweaks and line gestures, note, KM_ANY (-1) works for this case too */ #define EVT_GESTURE_N 1 |