2.5
authorTon Roosendaal <ton@blender.org>
Thu, 1 Jan 2009 18:05:12 +0000 (18:05 +0000)
committerTon Roosendaal <ton@blender.org>
Thu, 1 Jan 2009 18:05:12 +0000 (18:05 +0000)
- 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 :)

13 files changed:
source/blender/blenlib/BLI_editVert.h
source/blender/editors/animation/anim_markers.c
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_object.h
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/object/object_edit.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/wm_event_types.h

index 55be4cf..a4a4d5f 100644 (file)
@@ -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
index 141ed5a..a08f391 100644 (file)
@@ -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;
 }
 
index 5a09348..17ef2c1 100644 (file)
@@ -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);
index ee79a25..569cce1 100644 (file)
@@ -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);
index 02b1394..a23e3e4 100644 (file)
@@ -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);
 
index 8eb5119..5e3daa8 100644 (file)
 
 #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"
 #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;
index 27881ee..1bb452c 100644 (file)
@@ -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) {
index df33d2c..b3bc866 100644 (file)
@@ -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);
+
 }
 
index 32eb3da..7a5442b 100644 (file)
@@ -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)
index d1917d4..b7322e3 100644 (file)
@@ -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:
index e3eaca7..3125a21 100644 (file)
@@ -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);
 
index be97753..96a97e9 100644 (file)
@@ -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) 
index 87dbd33..93b5bf0 100644 (file)
 /* **************** 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