Merged changes in the trunk up to revision 26260.
[blender-staging.git] / source / blender / editors / transform / transform.c
index 926f1f00afe74702b697db496e44da8ac140af50..99ed4e04f0fd0ae262f8cfc97b0b5c562e22a2db 100644 (file)
@@ -217,7 +217,7 @@ void projectIntView(TransInfo *t, float *vec, int *adr)
 
                UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
        }
-       else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
+       else if(ELEM3(t->spacetype, SPACE_IPO, SPACE_NLA, SPACE_ACTION)) {
                int out[2] = {0, 0};
 
                UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1], out, out+1);
@@ -470,6 +470,8 @@ static void view_editmove(unsigned short event)
 #define TFM_MODAL_CONS_OFF             15
 #define TFM_MODAL_ADD_SNAP             16
 #define TFM_MODAL_REMOVE_SNAP  17
+/*     18 and 19 used by numinput, defined in transform.h
+ * */
 
 /* called in transform_ops.c, on each regeneration of keymaps */
 wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
@@ -492,6 +494,8 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
        {TFM_MODAL_CONS_OFF, "CONS_OFF", 0, "Remove Constraints", ""},
        {TFM_MODAL_ADD_SNAP, "ADD_SNAP", 0, "Add Snap Point", ""},
        {TFM_MODAL_REMOVE_SNAP, "REMOVE_SNAP", 0, "Remove Last Snap Point", ""},
+       {TFM_MODAL_INCREMENT_UP, "INCREMENT_UP", 0, "Numinput Increment Up", ""},
+       {TFM_MODAL_INCREMENT_DOWN, "INCREMENT_DOWN", 0, "Numinput Increment Down", ""},
        {0, NULL, 0, NULL, NULL}};
        
        wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map");
@@ -519,6 +523,9 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf)
        WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, 0, 0, TFM_MODAL_ADD_SNAP);
        WM_modalkeymap_add_item(keymap, AKEY, KM_PRESS, KM_ALT, 0, TFM_MODAL_REMOVE_SNAP);
 
+       WM_modalkeymap_add_item(keymap, UPARROWKEY, KM_PRESS, 0, 0, TFM_MODAL_INCREMENT_UP);
+       WM_modalkeymap_add_item(keymap, DOWNARROWKEY, KM_PRESS, 0, 0, TFM_MODAL_INCREMENT_DOWN);
+
        return keymap;
 }
 
@@ -699,6 +706,9 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                handled = 0;
                                break;
                }
+
+               // Modal numinput events
+               t->redraw |= handleNumInput(&(t->num), event, t->snap[1]);
        }
        /* else do non-mapped events */
        else if (event->val==KM_PRESS) {
@@ -951,7 +961,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                }
 
                // Numerical input events
-               t->redraw |= handleNumInput(&(t->num), event);
+               t->redraw |= handleNumInput(&(t->num), event, t->snap[1]);
 
                // NDof input events
                switch(handleNDofInput(&(t->ndof), event))
@@ -5449,10 +5459,20 @@ int TimeSlide(TransInfo *t, short mval[2])
 
 void initTimeScale(TransInfo *t)
 {
+       int center[2];
+
        t->mode = TFM_TIME_SCALE;
        t->transform = TimeScale;
-       
-       // TODO: the scaling ratios obtained here aren't rapid enough 
+
+       /* recalculate center2d to use CFRA and mouse Y, since that's
+        * what is used in time scale */
+       t->center[0] = t->scene->r.cfra;
+       projectIntView(t, t->center, center);
+       center[1] = t->imval[1];
+
+       /* force a reinit with the center2d used here */
+       initMouseInput(t, &t->mouse, center, t->imval);
+
        initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
 
        t->flag |= T_NULL_ONE;