2.5
authorTon Roosendaal <ton@blender.org>
Wed, 28 Jan 2009 15:39:39 +0000 (15:39 +0000)
committerTon Roosendaal <ton@blender.org>
Wed, 28 Jan 2009 15:39:39 +0000 (15:39 +0000)
Made 'select-tweak-grab' work in 3d window, fcurve and nodes.
For nodes it works with both left/right, the others follow
user preset for select.

Tweak is a WM event, which also follows user preset for
tablet-style tweaks (release = apply).

You enable tweak events with an operator WM_OT_tweak_gesture.
Keymap entries can assign to left/middle/right button or to
action/select button tweaks.

source/blender/editors/animation/anim_markers.c
source/blender/editors/space_ipo/ipo_ops.c
source/blender/editors/space_ipo/ipo_select.c
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_node/node_select.c
source/blender/editors/space_node/node_state.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_ops.c
source/blender/windowmanager/intern/wm_event_system.c

index 947b3bad9e74685eebeaba63b71a2adbfab6f0b1..723a59e38f25ccdc5264ac43b717e570af1c0364 100644 (file)
@@ -867,7 +867,7 @@ void ED_marker_keymap(wmWindowManager *wm)
        
        WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0);
        
-       /* generates event, in end to make select work */
+       /* generates event, needs to be after select to work */
        WM_keymap_verify_item(keymap, "WM_OT_tweak_gesture", RIGHTMOUSE, KM_PRESS, 0, 0);
        
 }
index f0792658248e0ec09c610830ab34abaa38d10f50..68ce0997906a53a713d5e8ba8ed229c4909656c3 100644 (file)
@@ -186,7 +186,9 @@ static void graphedit_keymap_keyframes (wmWindowManager *wm, ListBase *keymap)
        //WM_keymap_add_item(keymap, "GRAPHEDIT_OT_set_previewrange", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
        //WM_keymap_add_item(keymap, "GRAPHEDIT_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
        
-               
+       /* generates event, needs to be after select to work */
+       WM_keymap_add_item(keymap, "WM_OT_tweak_gesture", SELECTMOUSE, KM_PRESS, 0, 0);
+
        /* transform system */
        transform_keymap_for_space(wm, keymap, SPACE_IPO);
 }
index 07d34bdfa6cc1c87e026fe5bfead5b532fe93da5..1f4fbe135e5411c2bce538408ea5de65750148c9 100644 (file)
@@ -870,7 +870,8 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev
        /* set notifier tha things have changed */
        ANIM_animdata_send_notifiers(C, &ac, ANIM_CHANGED_BOTH);
        
-       return OPERATOR_FINISHED;
+       /* for tweak grab to work */
+       return OPERATOR_PASS_THROUGH;
 }
  
 void GRAPHEDIT_OT_keyframes_clickselect (wmOperatorType *ot)
index 09a5d12bd3485ffc5f251bf567fe7dea7e33f38c..55aa53e9821dc3f764cdfbd25f8b5579a447d78a 100644 (file)
@@ -73,5 +73,9 @@ void node_keymap(struct wmWindowManager *wm)
        WM_keymap_add_item(keymap, "NODE_OT_border_select", BKEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "NODE_OT_delete_selection", XKEY, KM_PRESS, 0, 0);
        
+       /* generates event, needs to be after select to work */
+       WM_keymap_add_item(keymap, "WM_OT_tweak_gesture", ACTIONMOUSE, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "WM_OT_tweak_gesture", SELECTMOUSE, KM_PRESS, 0, 0);
+       
        transform_keymap_for_space(wm, keymap, SPACE_NODE);
 }
index dad10d34eac56031c31be72d97791761a6253805..25d9d45a93438ea2f426d6f3a874fbea269a0531 100644 (file)
@@ -125,10 +125,9 @@ static int node_select_exec(bContext *C, wmOperator *op)
        }
 
        WM_event_add_notifier(C, NC_SCENE|ND_NODES, NULL); /* Do we need to pass the scene? */
-       
-       //WM_event_add_modal_handler(C, &window->handlers, op);
 
-       return /*OPERATOR_RUNNING_MODAL;*/ OPERATOR_FINISHED;
+       /* allow tweak event to work too */
+       return OPERATOR_PASS_THROUGH;
 }
 
 static int node_select_modal(bContext *C, wmOperator *op, wmEvent *event)
index 0fe1acd8a1a7e49843775439bbaa17c5fb7ac2a0..908e990fadb0717c336ce1200770352af103887e 100644 (file)
@@ -126,7 +126,7 @@ static int do_header_hidden_node(SpaceNode *snode, bNode *node, float mx, float
        return 0;
 }
 
-static void node_toggle_visibility(SpaceNode *snode, ARegion *ar, short *mval)
+static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, short *mval)
 {
        bNode *node;
        float mx, my;
@@ -140,16 +140,17 @@ static void node_toggle_visibility(SpaceNode *snode, ARegion *ar, short *mval)
                if(node->flag & NODE_HIDDEN) {
                        if(do_header_hidden_node(snode, node, mx, my)) {
                                ED_region_tag_redraw(ar);
-                               break;
+                               return 1;
                        }
                }
                else {
                        if(do_header_node(snode, node, mx, my)) {
                                ED_region_tag_redraw(ar);
-                               break;
+                               return 1;
                        }
                }
        }
+       return 0;
 }
 
 static int node_toggle_visibility_exec(bContext *C, wmOperator *op)
@@ -160,9 +161,10 @@ static int node_toggle_visibility_exec(bContext *C, wmOperator *op)
 
        mval[0] = RNA_int_get(op->ptr, "mouse_x");
        mval[1] = RNA_int_get(op->ptr, "mouse_y");
-       node_toggle_visibility(snode, ar, mval);
-
-       return OPERATOR_FINISHED;
+       if(node_toggle_visibility(snode, ar, mval))
+               return OPERATOR_FINISHED;
+       else
+               return OPERATOR_PASS_THROUGH;
 }
 
 static int node_toggle_visibility_invoke(bContext *C, wmOperator *op, wmEvent *event)
index bac5febbee3fda10a27ca3324e7b2077d76d61e6..1c5e6396be44b748d9f84baa8c7d4a8c782f71ec 100644 (file)
@@ -882,7 +882,8 @@ void transformEvent(TransInfo *t, wmEvent *event)
                        break;
                case LEFTMOUSE:
                case RIGHTMOUSE:
-                       if (t->options & CTX_TWEAK)
+                       if(WM_modal_tweak_exit(event, t->event_type))
+//                     if (t->options & CTX_TWEAK)
                                t->state = TRANS_CONFIRM;
                        break;
                }
index c3696da757c22815f740d77e7a753fb878d7237b..89f31c18338dabd345f85e5188e0a89dd9a534ec 100644 (file)
@@ -218,6 +218,7 @@ typedef struct TransInfo {
     float       center[3];      /* center of transformation             */
     int         center2d[2];    /* center in screen coordinates         */
     short       imval[2];       /* initial mouse position               */
+       short           event_type;             /* event->type used to invoke transform */
        short       idx_max;            /* maximum index on the input vector    */
        float           snap[3];                /* Snapping Gears                                               */
        char            frame_side;             /* Mouse side of the cfra, 'L', 'R' or 'B' */
index 6484239b0ed047dabfd421938beea65be37a12b6..490a2a83da311fa07a8788e15fd0da496434f093 100644 (file)
@@ -684,6 +684,8 @@ void initTransInfo (bContext *C, TransInfo *t, wmEvent *event)
        {
                t->imval[0] = event->x - t->ar->winrct.xmin;
                t->imval[1] = event->y - t->ar->winrct.ymin;
+               
+               t->event_type = event->type;
        }
        else
        {
index 260f7fdf03ece85bf4a101e20df6b490199a0915..9fcddf3965f17d86dd6c7af3933352e3295911d0 100644 (file)
@@ -242,7 +242,10 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
                case SPACE_VIEW3D:
                        km = WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
-
+                       
+                       km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
+                       RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
+                       
                        km = WM_keymap_add_item(keymap, "TFM_OT_transform", RKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_ROTATION);
 
@@ -265,6 +268,9 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
                        km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE);
                        
+                       km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
+                       RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE);
+                       
                        km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
                        
@@ -276,6 +282,9 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
                        break;
                case SPACE_IPO:
                        km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
+                       RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
+                       
+                       km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
                        
                                // XXX the 'mode' identifier here is not quite right
@@ -292,6 +301,11 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
                        km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
                        
+                       km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_A, KM_ANY, 0, 0);
+                       RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
+                       km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
+                       RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
+                       
                        km = WM_keymap_add_item(keymap, "TFM_OT_transform", RKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_ROTATION);
                        
@@ -301,7 +315,10 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
                case SPACE_SEQ:
                        km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
-
+                       
+                       km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
+                       RNA_int_set(km->ptr, "mode", TFM_TRANSLATION);
+                       
                        km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
                        RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
                        break;
index 435c2790c05f21ecf6e77b245511c6df322fc1ca..8e3c87c654dd1d4c9e298968d1357218830c1d04 100644 (file)
@@ -970,8 +970,8 @@ void WM_event_add_mousemove(bContext *C)
 /* 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;
+       /* user preset or keymap? dunno... */
+       int tweak_modal= (U.flag & USER_DRAGIMMEDIATE)==0;
        
        switch(tweak_event) {
                case EVT_TWEAK_L: