UI: Use bool rather then int/short's where possible
[blender.git] / source / blender / editors / transform / transform.c
index 82c117a7486cc3081a330fbfbeef2329fab9ef3b..825a8c973a253aac0656e5346ddcf2b1f397127c 100644 (file)
@@ -82,6 +82,7 @@
 #include "ED_mesh.h"
 #include "ED_clip.h"
 #include "ED_mask.h"
+#include "ED_node.h"
 
 #include "WM_types.h"
 #include "WM_api.h"
@@ -105,13 +106,105 @@ static int doVertSlide(TransInfo *t, float perc);
 
 static void drawEdgeSlide(const struct bContext *C, TransInfo *t);
 static void drawVertSlide(const struct bContext *C, TransInfo *t);
+static void len_v3_ensure(float v[3], const float length);
+static void postInputRotation(TransInfo *t, float values[3]);
 
-static bool transdata_check_local_center(TransInfo *t)
+
+/* Transform Callbacks */
+static void initBend(TransInfo *t);
+static eRedrawFlag handleEventBend(TransInfo *t, const struct wmEvent *event);
+static void Bend(TransInfo *t, const int mval[2]);
+
+static void initShear(TransInfo *t);
+static eRedrawFlag handleEventShear(TransInfo *t, const struct wmEvent *event);
+static void applyShear(TransInfo *t, const int mval[2]);
+
+static void initResize(TransInfo *t);
+static void applyResize(TransInfo *t, const int mval[2]);
+
+static void initSkinResize(TransInfo *t);
+static void applySkinResize(TransInfo *t, const int mval[2]);
+
+static void initTranslation(TransInfo *t);
+static void applyTranslation(TransInfo *t, const int mval[2]);
+
+static void initToSphere(TransInfo *t);
+static void applyToSphere(TransInfo *t, const int mval[2]);
+
+static void initRotation(TransInfo *t);
+static void applyRotation(TransInfo *t, const int mval[2]);
+
+static void initShrinkFatten(TransInfo *t);
+static void applyShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initTilt(TransInfo *t);
+static void applyTilt(TransInfo *t, const int mval[2]);
+
+static void initCurveShrinkFatten(TransInfo *t);
+static void applyCurveShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initMaskShrinkFatten(TransInfo *t);
+static void applyMaskShrinkFatten(TransInfo *t, const int mval[2]);
+
+static void initTrackball(TransInfo *t);
+static void applyTrackball(TransInfo *t, const int mval[2]);
+
+static void initPushPull(TransInfo *t);
+static void applyPushPull(TransInfo *t, const int mval[2]);
+
+static void initBevelWeight(TransInfo *t);
+static void applyBevelWeight(TransInfo *t, const int mval[2]);
+
+static void initCrease(TransInfo *t);
+static void applyCrease(TransInfo *t, const int mval[2]);
+
+static void initBoneSize(TransInfo *t);
+static void applyBoneSize(TransInfo *t, const int mval[2]);
+
+static void initBoneEnvelope(TransInfo *t);
+static void applyBoneEnvelope(TransInfo *t, const int mval[2]);
+
+static void initBoneRoll(TransInfo *t);
+static void applyBoneRoll(TransInfo *t, const int mval[2]);
+
+static void initEdgeSlide(TransInfo *t);
+static eRedrawFlag handleEventEdgeSlide(TransInfo *t, const struct wmEvent *event);
+static void applyEdgeSlide(TransInfo *t, const int mval[2]);
+
+static void initVertSlide(TransInfo *t);
+static eRedrawFlag handleEventVertSlide(TransInfo *t, const struct wmEvent *event);
+static void applyVertSlide(TransInfo *t, const int mval[2]);
+
+static void initTimeTranslate(TransInfo *t);
+static void applyTimeTranslate(TransInfo *t, const int mval[2]);
+
+static void initTimeSlide(TransInfo *t);
+static void applyTimeSlide(TransInfo *t, const int mval[2]);
+
+static void initTimeScale(TransInfo *t);
+static void applyTimeScale(TransInfo *t, const int mval[2]);
+
+static void initBakeTime(TransInfo *t);
+static void applyBakeTime(TransInfo *t, const int mval[2]);
+
+static void initMirror(TransInfo *t);
+static void applyMirror(TransInfo *t, const int mval[2]);
+
+static void initAlign(TransInfo *t);
+static void applyAlign(TransInfo *t, const int mval[2]);
+
+static void initSeqSlide(TransInfo *t);
+static void applySeqSlide(TransInfo *t, const int mval[2]);
+/* end transform callbacks */
+
+
+static bool transdata_check_local_center(TransInfo *t, short around)
 {
-       return ((t->around == V3D_LOCAL) && (
+       return ((around == V3D_LOCAL) && (
                    (t->flag & (T_OBJECT | T_POSE)) ||
                    (t->obedit && ELEM4(t->obedit->type, OB_MESH, OB_CURVE, OB_MBALL, OB_ARMATURE)) ||
-                   (t->spacetype == SPACE_IPO))
+                   (t->spacetype == SPACE_IPO) ||
+                   (t->options & (CTX_MOVIECLIP | CTX_MASK)))
                );
 }
 
@@ -382,20 +475,15 @@ void projectFloatViewEx(TransInfo *t, const float vec[3], float adr[2], const eV
                        }
                        break;
                }
-               case SPACE_IMAGE:
-               case SPACE_CLIP:
-               case SPACE_IPO:
-               case SPACE_NLA:
+               default:
                {
-                       int a[2];
+                       int a[2] = {0, 0};
                        projectIntView(t, vec, a);
                        adr[0] = a[0];
                        adr[1] = a[1];
-                       return;
+                       break;
                }
        }
-
-       zero_v2(adr);
 }
 void projectFloatView(TransInfo *t, const float vec[3], float adr[2])
 {
@@ -851,11 +939,18 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 {
        float mati[3][3] = MAT3_UNITY;
        char cmode = constraintModeToChar(t);
-       int handled = 1;
-       
+       bool handled = false;
+
        t->redraw |= handleMouseInput(t, &t->mouse, event);
 
-       if (event->type == MOUSEMOVE) {
+       /* Handle modal numinput events first, if already activated. */
+       if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) &&
+           hasNumInput(&t->num) && handleNumInput(t->context, &(t->num), event))
+       {
+               t->redraw |= TREDRAW_HARD;
+               handled = true;
+       }
+       else if (event->type == MOUSEMOVE) {
                if (t->modifiers & MOD_CONSTRAINT_SELECT)
                        t->con.mode |= CON_SELECT;
 
@@ -864,7 +959,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                // t->redraw |= TREDRAW_SOFT; /* Use this for soft redraw. Might cause flicker in object mode */
                t->redraw |= TREDRAW_HARD;
 
-
                if (t->state == TRANS_STARTING) {
                        t->state = TRANS_RUNNING;
                }
@@ -873,16 +967,18 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 
                // Snapping mouse move events
                t->redraw |= handleSnapping(t, event);
+               handled = true;
        }
-
        /* handle modal keymap first */
-       if (event->type == EVT_MODAL_MAP) {
+       else if (event->type == EVT_MODAL_MAP) {
                switch (event->val) {
                        case TFM_MODAL_CANCEL:
                                t->state = TRANS_CANCEL;
+                               handled = true;
                                break;
                        case TFM_MODAL_CONFIRM:
                                t->state = TRANS_CONFIRM;
+                               handled = true;
                                break;
                        case TFM_MODAL_TRANSLATE:
                                /* only switch when... */
@@ -894,10 +990,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        initSnapping(t, NULL); // need to reinit after mode change
                                        t->redraw |= TREDRAW_HARD;
                                        WM_event_add_mousemove(t->context);
+                                       handled = true;
                                }
                                else if (t->mode == TFM_SEQ_SLIDE) {
                                        t->flag ^= T_ALT_TRANSFORM;
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                else {
                                        if (t->obedit && t->obedit->type == OB_MESH) {
@@ -922,6 +1020,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                        }
                                                        initSnapping(t, NULL); // need to reinit after mode change
                                                        t->redraw |= TREDRAW_HARD;
+                                                       handled = true;
                                                        WM_event_add_mousemove(t->context);
                                                }
                                        }
@@ -931,6 +1030,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 
                                                        t->flag ^= T_ALT_TRANSFORM;
                                                        t->redraw |= TREDRAW_HARD;
+                                                       handled = true;
                                                }
                                        }
                                }
@@ -952,6 +1052,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                }
                                                initSnapping(t, NULL); // need to reinit after mode change
                                                t->redraw |= TREDRAW_HARD;
+                                               handled = true;
                                        }
                                }
                                break;
@@ -964,10 +1065,12 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        initResize(t);
                                        initSnapping(t, NULL); // need to reinit after mode change
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                else if (t->mode == TFM_SHRINKFATTEN) {
                                        t->flag ^= T_ALT_TRANSFORM;
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                else if (t->mode == TFM_RESIZE) {
                                        if (t->options & CTX_MOVIECLIP) {
@@ -975,6 +1078,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
 
                                                t->flag ^= T_ALT_TRANSFORM;
                                                t->redraw |= TREDRAW_HARD;
+                                               handled = true;
                                        }
                                }
                                break;
@@ -982,14 +1086,17 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                        case TFM_MODAL_SNAP_INV_ON:
                                t->modifiers |= MOD_SNAP_INVERT;
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
                        case TFM_MODAL_SNAP_INV_OFF:
                                t->modifiers &= ~MOD_SNAP_INVERT;
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
                        case TFM_MODAL_SNAP_TOGGLE:
                                t->modifiers ^= MOD_SNAP;
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
                        case TFM_MODAL_AXIS_X:
                                if ((t->flag & T_NO_CONSTRAINT) == 0) {
@@ -1005,6 +1112,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                }
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_AXIS_Y:
@@ -1021,6 +1129,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                }
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_AXIS_Z:
@@ -1032,6 +1141,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                setUserConstraint(t, t->current_orientation, (CON_AXIS2), IFACE_("along %s Z"));
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_PLANE_X:
@@ -1043,6 +1153,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), IFACE_("locking %s X"));
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_PLANE_Y:
@@ -1054,6 +1165,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS2), IFACE_("locking %s Y"));
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_PLANE_Z:
@@ -1065,23 +1177,26 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS1), IFACE_("locking %s Z"));
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_CONS_OFF:
                                if ((t->flag & T_NO_CONSTRAINT) == 0) {
                                        stopConstraint(t);
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case TFM_MODAL_ADD_SNAP:
                                addSnapPoint(t);
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
                        case TFM_MODAL_REMOVE_SNAP:
                                removeSnapPoint(t);
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
-                               
                        case TFM_MODAL_PROPSIZE:
                                /* MOUSEPAN usage... */
                                if (t->flag & T_PROP_EDIT) {
@@ -1090,63 +1205,69 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
                                                t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far);
                                        calculatePropRatio(t);
+                                       t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
-                               t->redraw |= TREDRAW_HARD;
                                break;
-                               
                        case TFM_MODAL_PROPSIZE_UP:
                                if (t->flag & T_PROP_EDIT) {
                                        t->prop_size *= 1.1f;
                                        if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
                                                t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far);
                                        calculatePropRatio(t);
+                                       t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
-                               t->redraw |= TREDRAW_HARD;
                                break;
                        case TFM_MODAL_PROPSIZE_DOWN:
                                if (t->flag & T_PROP_EDIT) {
                                        t->prop_size *= 0.90909090f;
                                        calculatePropRatio(t);
+                                       t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
-                               t->redraw |= TREDRAW_HARD;
                                break;
                        case TFM_MODAL_EDGESLIDE_UP:
                        case TFM_MODAL_EDGESLIDE_DOWN:
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
                        case TFM_MODAL_AUTOIK_LEN_INC:
-                               if (t->flag & T_AUTOIK)
+                               if (t->flag & T_AUTOIK) {
                                        transform_autoik_update(t, 1);
-                               t->redraw |= TREDRAW_HARD;
+                                       t->redraw |= TREDRAW_HARD;
+                                       handled = true;
+                               }
                                break;
                        case TFM_MODAL_AUTOIK_LEN_DEC:
-                               if (t->flag & T_AUTOIK) 
+                               if (t->flag & T_AUTOIK) {
                                        transform_autoik_update(t, -1);
-                               t->redraw |= TREDRAW_HARD;
+                                       t->redraw |= TREDRAW_HARD;
+                                       handled = true;
+                               }
                                break;
                        default:
-                               handled = 0;
                                break;
                }
-
-               // Modal numinput events
-               t->redraw |= handleNumInput(&(t->num), event);
        }
        /* else do non-mapped events */
        else if (event->val == KM_PRESS) {
                switch (event->type) {
                        case RIGHTMOUSE:
                                t->state = TRANS_CANCEL;
+                               handled = true;
                                break;
                        /* enforce redraw of transform when modifiers are used */
                        case LEFTSHIFTKEY:
                        case RIGHTSHIFTKEY:
                                t->modifiers |= MOD_CONSTRAINT_PLANE;
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
 
                        case SPACEKEY:
                                t->state = TRANS_CONFIRM;
+                               handled = true;
                                break;
 
                        case MIDDLEMOUSE:
@@ -1178,14 +1299,17 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                }
                                        }
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case ESCKEY:
                                t->state = TRANS_CANCEL;
+                               handled = true;
                                break;
                        case PADENTER:
                        case RETKEY:
                                t->state = TRANS_CONFIRM;
+                               handled = true;
                                break;
                        case GKEY:
                                /* only switch when... */
@@ -1196,6 +1320,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        initTranslation(t);
                                        initSnapping(t, NULL); // need to reinit after mode change
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case SKEY:
@@ -1207,6 +1332,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        initResize(t);
                                        initSnapping(t, NULL); // need to reinit after mode change
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case RKEY:
@@ -1226,6 +1352,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                                }
                                                initSnapping(t, NULL); // need to reinit after mode change
                                                t->redraw |= TREDRAW_HARD;
+                                               handled = true;
                                        }
                                }
                                break;
@@ -1234,23 +1361,27 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        t->flag ^= T_PROP_CONNECTED;
                                        sort_trans_data_dist(t);
                                        calculatePropRatio(t);
-                                       t->redraw = 1;
+                                       t->redraw = TREDRAW_HARD;
+                                       handled = true;
                                }
                                else {
                                        stopConstraint(t);
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case XKEY:
                        case YKEY:
                        case ZKEY:
                                transform_event_xyz_constraint(t, event->type, cmode);
+                               handled = true;
                                break;
                        case OKEY:
                                if (t->flag & T_PROP_EDIT && event->shift) {
                                        t->prop_mode = (t->prop_mode + 1) % PROP_MODE_MAX;
                                        calculatePropRatio(t);
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case PADPLUSKEY:
@@ -1259,8 +1390,9 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO)
                                                t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far);
                                        calculatePropRatio(t);
+                                       t->redraw = TREDRAW_HARD;
+                                       handled = true;
                                }
-                               t->redraw = 1;
                                break;
                        case PAGEUPKEY:
                        case WHEELDOWNMOUSE:
@@ -1270,14 +1402,16 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                else {
                                        view_editmove(event->type);
                                }
-                               t->redraw = 1;
+                               t->redraw = TREDRAW_HARD;
+                               handled = true;
                                break;
                        case PADMINUS:
                                if (event->alt && t->flag & T_PROP_EDIT) {
                                        t->prop_size *= 0.90909090f;
                                        calculatePropRatio(t);
+                                       t->redraw = TREDRAW_HARD;
+                                       handled = true;
                                }
-                               t->redraw = 1;
                                break;
                        case PAGEDOWNKEY:
                        case WHEELUPMOUSE:
@@ -1287,27 +1421,23 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                else {
                                        view_editmove(event->type);
                                }
-                               t->redraw = 1;
+                               t->redraw = TREDRAW_HARD;
+                               handled = true;
                                break;
                        case LEFTALTKEY:
                        case RIGHTALTKEY:
                                if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
                                        t->flag |= T_ALT_TRANSFORM;
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
-
                                break;
                        default:
-                               handled = 0;
                                break;
                }
 
-               // Numerical input events
-               t->redraw |= handleNumInput(&(t->num), event);
-
-               // Snapping key events
+               /* Snapping key events */
                t->redraw |= handleSnapping(t, event);
-
        }
        else if (event->val == KM_RELEASE) {
                switch (event->type) {
@@ -1315,6 +1445,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                        case RIGHTSHIFTKEY:
                                t->modifiers &= ~MOD_CONSTRAINT_PLANE;
                                t->redraw |= TREDRAW_HARD;
+                               handled = true;
                                break;
 
                        case MIDDLEMOUSE:
@@ -1322,6 +1453,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                        t->modifiers &= ~MOD_CONSTRAINT_SELECT;
                                        postSelectConstraint(t);
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
                                break;
                        case LEFTALTKEY:
@@ -1329,11 +1461,10 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                if (ELEM(t->spacetype, SPACE_SEQ, SPACE_VIEW3D)) {
                                        t->flag &= ~T_ALT_TRANSFORM;
                                        t->redraw |= TREDRAW_HARD;
+                                       handled = true;
                                }
-
                                break;
                        default:
-                               handled = 0;
                                break;
                }
 
@@ -1345,13 +1476,19 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                        }
                }
        }
-       else
-               handled = 0;
 
        // Per transform event, if present
-       if (t->handleEvent)
+       if (t->handleEvent && !handled)
                t->redraw |= t->handleEvent(t, event);
 
+       /* Try to init modal numinput now, if possible. */
+       if (!(handled || t->redraw) && ((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) &&
+           handleNumInput(t->context, &(t->num), event))
+       {
+               t->redraw |= TREDRAW_HARD;
+               handled = true;
+       }
+
        if (handled || t->redraw) {
                return 0;
        }
@@ -1360,7 +1497,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
        }
 }
 
-int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int cent2d[2])
+int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2])
 {
        TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
        int success;
@@ -1372,7 +1509,7 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int c
 
        t->mode = TFM_DUMMY;
 
-       initTransInfo(C, t, NULL, NULL);    // internal data, mouse, vectors
+       initTransInfo(C, t, NULL, NULL);
 
        /* avoid doing connectivity lookups (when V3D_LOCAL is set) */
        t->around = V3D_CENTER;
@@ -1390,7 +1527,7 @@ int calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], int c
                calculateCenter(t);
 
                if (cent2d) {
-                       copy_v2_v2_int(cent2d, t->center2d);
+                       copy_v2_v2(cent2d, t->center2d);
                }
 
                if (cent3d) {
@@ -1662,7 +1799,7 @@ static void drawAutoKeyWarning(TransInfo *UNUSED(t), ARegion *ar)
 
        ED_region_visible_rect(ar, &rect);
        
-       BLF_width_and_height_default(printable, &printable_size[0], &printable_size[1]);
+       BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]);
        
        xco = rect.xmax - (int)printable_size[0] - 10;
        yco = rect.ymax - (int)printable_size[1] - 10;
@@ -1854,7 +1991,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
                        options |= CTX_TEXTURE;
                }
        }
-       
+
        t->options = options;
 
        t->mode = mode;
@@ -1874,9 +2011,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
                t->launch_event = LEFTMOUSE;
        }
 
-       if (!initTransInfo(C, t, op, event)) {  /* internal data, mouse, vectors */
-               return 0;
-       }
+       initTransInfo(C, t, op, event);
 
        if (t->spacetype == SPACE_VIEW3D) {
                //calc_manipulator_stats(curarea);
@@ -1896,12 +2031,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
        else if (t->spacetype == SPACE_CLIP) {
                unit_m3(t->spacemtx);
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
+               t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else if (t->spacetype == SPACE_NODE) {
                unit_m3(t->spacemtx);
                /*t->draw_handle_apply = ED_region_draw_cb_activate(t->ar->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW);*/
                t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
-               /*t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);*/
+               t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t);
        }
        else
                unit_m3(t->spacemtx);
@@ -1972,8 +2108,8 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
                case TFM_SHEAR:
                        initShear(t);
                        break;
-               case TFM_WARP:
-                       initWarp(t);
+               case TFM_BEND:
+                       initBend(t);
                        break;
                case TFM_SHRINKFATTEN:
                        initShrinkFatten(t);
@@ -2194,7 +2330,7 @@ int transformEnd(bContext *C, TransInfo *t)
 
 /* ************************** TRANSFORM LOCKS **************************** */
 
-static void protectedTransBits(short protectflag, float *vec)
+static void protectedTransBits(short protectflag, float vec[3])
 {
        if (protectflag & OB_LOCK_LOCX)
                vec[0] = 0.0f;
@@ -2204,7 +2340,7 @@ static void protectedTransBits(short protectflag, float *vec)
                vec[2] = 0.0f;
 }
 
-static void protectedSizeBits(short protectflag, float *size)
+static void protectedSizeBits(short protectflag, float size[3])
 {
        if (protectflag & OB_LOCK_SCALEX)
                size[0] = 1.0f;
@@ -2214,7 +2350,7 @@ static void protectedSizeBits(short protectflag, float *size)
                size[2] = 1.0f;
 }
 
-static void protectedRotateBits(short protectflag, float *eul, float *oldeul)
+static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3])
 {
        if (protectflag & OB_LOCK_ROTX)
                eul[0] = oldeul[0];
@@ -2269,7 +2405,7 @@ static void protectedAxisAngleBits(short protectflag, float axis[3], float *angl
 }
 
 /* this function only does the delta rotation */
-static void protectedQuaternionBits(short protectflag, float *quat, float *oldquat)
+static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4])
 {
        /* check that protection flags are set */
        if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0)
@@ -2573,187 +2709,226 @@ static void constraintSizeLim(TransInfo *t, TransData *td)
        }
 }
 
-/* ************************** WARP *************************** */
 
-static void postInputWarp(TransInfo *t, float values[3])
-{
-       mul_v3_fl(values, (float)(M_PI * 2));
+/* -------------------------------------------------------------------- */
+/* Transform (Bend) */
 
-       if (t->customData) { /* non-null value indicates reversed input */
-               negate_v3(values);
-       }
-}
+/** \name Transform Bend
+ * \{ */
+
+struct BendCustomData {
+       float warp_sta[3];
+       float warp_end[3];
+
+       float warp_nor[3];
+       float warp_tan[3];
 
-void initWarp(TransInfo *t)
+       /* for applying the mouse distance */
+       float warp_init_dist;
+};
+
+static void initBend(TransInfo *t)
 {
-       float max[3], min[3];
-       int i;
+       const float mval_fl[2] = {UNPACK2(t->mval)};
+       const float *curs;
+       float tvec[3];
+       struct BendCustomData *data;
        
-       t->mode = TFM_WARP;
-       t->transform = Warp;
-       t->handleEvent = handleEventWarp;
+       t->mode = TFM_BEND;
+       t->transform = Bend;
+       t->handleEvent = handleEventBend;
        
-       setInputPostFct(&t->mouse, postInputWarp);
-       initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
+       setInputPostFct(&t->mouse, postInputRotation);
+       initMouseInputMode(t, &t->mouse, INPUT_ANGLE_SPRING);
        
-       t->idx_max = 0;
-       t->num.idx_max = 0;
+       t->idx_max = 1;
+       t->num.idx_max = 1;
        t->snap[0] = 0.0f;
-       t->snap[1] = 5.0f / 180.0f * (float)M_PI;
-       t->snap[2] = 1.0f / 180.0f * (float)M_PI;
-       
-       t->num.increment = 1.0f;
+       t->snap[1] = DEG2RAD(5.0);
+       t->snap[2] = DEG2RAD(1.0);
+
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
+       t->num.unit_type[0] = B_UNIT_ROTATION;
+       t->num.unit_type[1] = B_UNIT_LENGTH;
 
        t->flag |= T_NO_CONSTRAINT;
-       
-       /* we need min/max in view space */
-       for (i = 0; i < t->total; i++) {
-               float center[3];
-               copy_v3_v3(center, t->data[i].center);
-               mul_m3_v3(t->data[i].mtx, center);
-               mul_m4_v3(t->viewmat, center);
-               sub_v3_v3(center, t->viewmat[3]);
-               if (i) {
-                       minmax_v3v3_v3(min, max, center);
-               }
-               else {
-                       copy_v3_v3(max, center);
-                       copy_v3_v3(min, center);
-               }
+
+       //copy_v3_v3(t->center, ED_view3d_cursor3d_get(t->scene, t->view));
+       calculateCenterCursor(t);
+
+       t->val = 0.0f;
+
+       data = MEM_callocN(sizeof(*data), __func__);
+
+       curs = ED_view3d_cursor3d_get(t->scene, t->view);
+       copy_v3_v3(data->warp_sta, curs);
+       ED_view3d_win_to_3d(t->ar, curs, mval_fl, data->warp_end);
+
+       copy_v3_v3(data->warp_nor, t->viewinv[2]);
+       if (t->flag & T_EDIT) {
+               sub_v3_v3(data->warp_sta, t->obedit->obmat[3]);
+               sub_v3_v3(data->warp_end, t->obedit->obmat[3]);
        }
+       normalize_v3(data->warp_nor);
 
-       mid_v3_v3v3(t->center, min, max);
+       /* tangent */
+       sub_v3_v3v3(tvec, data->warp_end, data->warp_sta);
+       cross_v3_v3v3(data->warp_tan, tvec, data->warp_nor);
+       normalize_v3(data->warp_tan);
 
-       if (max[0] == min[0])
-               max[0] += 0.1f;  /* not optimal, but flipping is better than invalid garbage (i.e. division by zero!) */
-       t->val = (max[0] - min[0]) / 2.0f; /* t->val is X dimension projected boundbox */
+       data->warp_init_dist = len_v3v3(data->warp_end, data->warp_sta);
+
+       t->customData = data;
 }
 
-int handleEventWarp(TransInfo *t, const wmEvent *event)
+static eRedrawFlag handleEventBend(TransInfo *UNUSED(t), const wmEvent *event)
 {
-       int status = 0;
+       eRedrawFlag status = TREDRAW_NOTHING;
        
        if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
-               // Use customData pointer to signal warp direction
-               if (t->customData == NULL)
-                       t->customData = (void *)1;
-               else
-                       t->customData = NULL;
-               
-               status = 1;
+               status = TREDRAW_HARD;
        }
        
        return status;
 }
 
-int Warp(TransInfo *t, const int UNUSED(mval[2]))
+static void Bend(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
-       float vec[3], circumfac, dist, phi0, co, si, cursor[3], gcursor[3];
-       const float *curs;
+       float vec[3];
+       float pivot[3];
+       float warp_end_radius[3];
        int i;
        char str[MAX_INFO_LEN];
-       
-       curs = give_cursor(t->scene, t->view);
-       /*
-        * gcursor is the one used for helpline.
-        * It has to be in the same space as the drawing loop
-        * (that means it needs to be in the object's space when in edit mode and
-        *  in global space in object mode)
-        *
-        * cursor is used for calculations.
-        * It needs to be in view space, but we need to take object's offset
-        * into account if in Edit mode.
-        */
-       copy_v3_v3(cursor, curs);
-       copy_v3_v3(gcursor, cursor);
-       if (t->flag & T_EDIT) {
-               sub_v3_v3(cursor, t->obedit->obmat[3]);
-               sub_v3_v3(gcursor, t->obedit->obmat[3]);
-               mul_m3_v3(t->data->smtx, gcursor);
+       const struct BendCustomData *data = t->customData;
+       const bool is_clamp = (t->flag & T_ALT_TRANSFORM) == 0;
+
+       union {
+               struct { float angle, scale; };
+               float vector[2];
+       } values;
+
+       /* amount of radians for bend */
+       copy_v2_v2(values.vector, t->values);
+
+#if 0
+       snapGrid(t, angle_rad);
+#else
+       /* hrmf, snapping radius is using 'angle' steps, need to convert to something else
+        * this isnt essential but nicer to give reasonable snapping values for radius */
+       if (t->tsnap.mode == SCE_SNAP_MODE_INCREMENT) {
+               const float radius_snap = 0.1f;
+               const float snap_hack = (t->snap[1] * data->warp_init_dist) / radius_snap;
+               values.scale *= snap_hack;
+               snapGridIncrement(t, values.vector);
+               values.scale /= snap_hack;
        }
-       mul_m4_v3(t->viewmat, cursor);
-       sub_v3_v3(cursor, t->viewmat[3]);
-       
-       /* amount of radians for warp */
-       circumfac = t->values[0];
-       
-       snapGrid(t, &circumfac);
-       applyNumInput(&t->num, &circumfac);
+#endif
        
        /* header print for NumInput */
        if (hasNumInput(&t->num)) {
-               char c[NUM_STR_REP_LEN];
+               char c[NUM_STR_REP_LEN * 2];
                
+               applyNumInput(&t->num, values.vector);
+
                outputNumInput(&(t->num), c);
                
-               BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp: %s"), c);
+               BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %s Radius: %s Alt, Clamp %s"),
+                            &c[0], &c[NUM_STR_REP_LEN],
+                            WM_bool_as_string(is_clamp));
 
-               circumfac = DEG2RADF(circumfac);
+               values.scale = values.scale / data->warp_init_dist;
        }
        else {
                /* default header print */
-               BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Warp: %.3f"), RAD2DEGF(circumfac));
+               BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Bend Angle: %.3f Radius: %.4f, Alt, Clamp %s"),
+                            RAD2DEGF(values.angle), values.scale * data->warp_init_dist,
+                            WM_bool_as_string(is_clamp));
        }
        
-       t->values[0] = circumfac;
+       copy_v2_v2(t->values, values.vector);
 
-       circumfac /= 2; /* only need 180 on each side to make 360 */
+       values.angle *= -1.0f;
+       values.scale *= data->warp_init_dist;
        
+       /* calc 'data->warp_end' from 'data->warp_end_init' */
+       copy_v3_v3(warp_end_radius, data->warp_end);
+       dist_ensure_v3_v3fl(warp_end_radius, data->warp_sta, values.scale);
+       /* done */
+
+       /* calculate pivot */
+       copy_v3_v3(pivot, data->warp_sta);
+       if (values.angle > 0.0f) {
+               madd_v3_v3fl(pivot, data->warp_tan, -values.scale * shell_angle_to_dist((float)M_PI_2 - values.angle));
+       }
+       else {
+               madd_v3_v3fl(pivot, data->warp_tan, +values.scale * shell_angle_to_dist((float)M_PI_2 + values.angle));
+       }
+
        for (i = 0; i < t->total; i++, td++) {
-               float loc[3];
+               float mat[3][3];
+               float delta[3];
+               float fac, fac_scaled;
+
                if (td->flag & TD_NOACTION)
                        break;
                
                if (td->flag & TD_SKIP)
                        continue;
-               
-               /* translate point to center, rotate in such a way that outline==distance */
+
+               if (UNLIKELY(values.angle == 0.0f)) {
+                       copy_v3_v3(td->loc, td->iloc);
+                       continue;
+               }
+
                copy_v3_v3(vec, td->iloc);
                mul_m3_v3(td->mtx, vec);
-               mul_m4_v3(t->viewmat, vec);
-               sub_v3_v3(vec, t->viewmat[3]);
-               
-               dist = vec[0] - cursor[0];
-               
-               /* t->val is X dimension projected boundbox */
-               phi0 = (circumfac * dist / t->val);
-               
-               vec[1] = (vec[1] - cursor[1]);
-               
-               co = cosf(phi0);
-               si = sinf(phi0);
-               loc[0] = -si * vec[1] + cursor[0];
-               loc[1] = co * vec[1] + cursor[1];
-               loc[2] = vec[2];
-               
-               mul_m4_v3(t->viewinv, loc);
-               sub_v3_v3(loc, t->viewinv[3]);
-               mul_m3_v3(td->smtx, loc);
-               
-               sub_v3_v3(loc, td->iloc);
-               mul_v3_fl(loc, td->factor);
-               add_v3_v3v3(td->loc, td->iloc, loc);
+
+               fac = line_point_factor_v3(vec, data->warp_sta, warp_end_radius);
+               if (is_clamp) {
+                       CLAMP(fac, 0.0f, 1.0f);
+               }
+
+               fac_scaled = fac * td->factor;
+               axis_angle_normalized_to_mat3(mat, data->warp_nor, values.angle * fac_scaled);
+               interp_v3_v3v3(delta, data->warp_sta, warp_end_radius, fac_scaled);
+               sub_v3_v3(delta, data->warp_sta);
+
+               /* delta is subtracted, rotation adds back this offset */
+               sub_v3_v3(vec, delta);
+
+               sub_v3_v3(vec, pivot);
+               mul_m3_v3(mat, vec);
+               add_v3_v3(vec, pivot);
+
+               mul_m3_v3(td->smtx, vec);
+               copy_v3_v3(td->loc, vec);
        }
        
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
 
-/* ************************** SHEAR *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Shear) */
+
+/** \name Transform Shear
+ * \{ */
 
 static void postInputShear(TransInfo *UNUSED(t), float values[3])
 {
        mul_v3_fl(values, 0.05f);
 }
 
-void initShear(TransInfo *t)
+static void initShear(TransInfo *t)
 {
        t->mode = TFM_SHEAR;
-       t->transform = Shear;
+       t->transform = applyShear;
        t->handleEvent = handleEventShear;
        
        setInputPostFct(&t->mouse, postInputShear);
@@ -2764,15 +2939,17 @@ void initShear(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
-       
-       t->num.increment = 0.1f;
+
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;  /* Don't think we have any unit here? */
 
        t->flag |= T_NO_CONSTRAINT;
 }
 
-int handleEventShear(TransInfo *t, const wmEvent *event)
+static eRedrawFlag handleEventShear(TransInfo *t, const wmEvent *event)
 {
-       int status = 0;
+       eRedrawFlag status = TREDRAW_NOTHING;
        
        if (event->type == MIDDLEMOUSE && event->val == KM_PRESS) {
                // Use customData pointer to signal Shear direction
@@ -2785,26 +2962,26 @@ int handleEventShear(TransInfo *t, const wmEvent *event)
                        t->customData = NULL;
                }
 
-               status = 1;
+               status = TREDRAW_HARD;
        }
        else if (event->type == XKEY && event->val == KM_PRESS) {
                initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_ABSOLUTE);
                t->customData = NULL;
                
-               status = 1;
+               status = TREDRAW_HARD;
        }
        else if (event->type == YKEY && event->val == KM_PRESS) {
                initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
                t->customData = (void *)1;
                
-               status = 1;
+               status = TREDRAW_HARD;
        }
        
        return status;
 }
 
 
-int Shear(TransInfo *t, const int UNUSED(mval[2]))
+static void applyShear(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        float vec[3];
@@ -2818,7 +2995,7 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
        
        value = t->values[0];
        
-       snapGrid(t, &value);
+       snapGridIncrement(t, &value);
        
        applyNumInput(&t->num, &value);
        
@@ -2878,25 +3055,33 @@ int Shear(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Resize) */
 
-/* ************************** RESIZE *************************** */
+/** \name Transform Resize
+ * \{ */
 
-void initResize(TransInfo *t)
+static void initResize(TransInfo *t)
 {
        t->mode = TFM_RESIZE;
-       t->transform = Resize;
+       t->transform = applyResize;
        
        initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
        
        t->flag |= T_NULL_ONE;
-       t->num.flag |= NUM_NULL_ONE;
+       t->num.val_flag[0] |= NUM_NULL_ONE;
+       t->num.val_flag[1] |= NUM_NULL_ONE;
+       t->num.val_flag[2] |= NUM_NULL_ONE;
        t->num.flag |= NUM_AFFECT_ALL;
        if (!t->obedit) {
                t->flag |= T_NO_ZERO;
-               t->num.flag |= NUM_NO_ZERO;
+               t->num.val_flag[0] |= NUM_NO_ZERO;
+               t->num.val_flag[1] |= NUM_NO_ZERO;
+               t->num.val_flag[2] |= NUM_NO_ZERO;
        }
        
        t->idx_max = 2;
@@ -2905,11 +3090,14 @@ void initResize(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
+       t->num.unit_type[1] = B_UNIT_NONE;
+       t->num.unit_type[2] = B_UNIT_NONE;
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerResize(TransInfo *t, float vec[3], char *str)
+static void headerResize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
        size_t ofs = 0;
@@ -3004,7 +3192,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
        }
        
        /* local constraint shouldn't alter center */
-       if (transdata_check_local_center(t)) {
+       if (transdata_check_local_center(t, t->around)) {
                copy_v3_v3(center, td->center);
        }
        else if (t->options & CTX_MOVIECLIP) {
@@ -3085,7 +3273,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3])
        constraintTransLim(t, td);
 }
 
-int Resize(TransInfo *t, const int mval[2])
+static void applyResize(TransInfo *t, const int mval[2])
 {
        TransData *td;
        float size[3], mat[3][3];
@@ -3103,7 +3291,7 @@ int Resize(TransInfo *t, const int mval[2])
        
        size[0] = size[1] = size[2] = ratio;
        
-       snapGrid(t, size);
+       snapGridIncrement(t, size);
        
        if (hasNumInput(&t->num)) {
                applyNumInput(&t->num, size);
@@ -3160,25 +3348,33 @@ int Resize(TransInfo *t, const int mval[2])
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Skin) */
 
-/* ************************** SKIN *************************** */
+/** \name Transform Skin
+ * \{ */
 
-void initSkinResize(TransInfo *t)
+static void initSkinResize(TransInfo *t)
 {
        t->mode = TFM_SKIN_RESIZE;
-       t->transform = SkinResize;
+       t->transform = applySkinResize;
        
        initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
        
        t->flag |= T_NULL_ONE;
-       t->num.flag |= NUM_NULL_ONE;
+       t->num.val_flag[0] |= NUM_NULL_ONE;
+       t->num.val_flag[1] |= NUM_NULL_ONE;
+       t->num.val_flag[2] |= NUM_NULL_ONE;
        t->num.flag |= NUM_AFFECT_ALL;
        if (!t->obedit) {
                t->flag |= T_NO_ZERO;
-               t->num.flag |= NUM_NO_ZERO;
+               t->num.val_flag[0] |= NUM_NO_ZERO;
+               t->num.val_flag[1] |= NUM_NO_ZERO;
+               t->num.val_flag[2] |= NUM_NO_ZERO;
        }
        
        t->idx_max = 2;
@@ -3187,10 +3383,14 @@ void initSkinResize(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
+       t->num.unit_type[1] = B_UNIT_NONE;
+       t->num.unit_type[2] = B_UNIT_NONE;
 }
 
-int SkinResize(TransInfo *t, const int UNUSED(mval[2]))
+static void applySkinResize(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td;
        float size[3], mat[3][3];
@@ -3201,7 +3401,7 @@ int SkinResize(TransInfo *t, const int UNUSED(mval[2]))
        ratio = t->values[0];
        size[0] = size[1] = size[2] = ratio;
        
-       snapGrid(t, size);
+       snapGridIncrement(t, size);
        
        if (hasNumInput(&t->num)) {
                applyNumInput(&t->num, size);
@@ -3250,19 +3450,23 @@ int SkinResize(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
 
-/* ************************** TOSPHERE *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (ToSphere) */
 
-void initToSphere(TransInfo *t)
+/** \name Transform ToSphere
+ * \{ */
+
+static void initToSphere(TransInfo *t)
 {
        TransData *td = t->data;
        int i;
        
        t->mode = TFM_TOSPHERE;
-       t->transform = ToSphere;
+       t->transform = applyToSphere;
        
        initMouseInputMode(t, &t->mouse, INPUT_HORIZONTAL_RATIO);
        
@@ -3272,9 +3476,11 @@ void initToSphere(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
        
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
-       t->num.flag |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
+       t->num.val_flag[0] |= NUM_NULL_ONE | NUM_NO_NEGATIVE;
        t->flag |= T_NO_CONSTRAINT;
        
        // Calculate average radius
@@ -3285,7 +3491,7 @@ void initToSphere(TransInfo *t)
        t->val /= (float)t->total;
 }
 
-int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
+static void applyToSphere(TransInfo *t, const int UNUSED(mval[2]))
 {
        float vec[3];
        float ratio, radius;
@@ -3295,7 +3501,7 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
        
        ratio = t->values[0];
        
-       snapGrid(t, &ratio);
+       snapGridIncrement(t, &ratio);
        
        applyNumInput(&t->num, &ratio);
        
@@ -3343,12 +3549,15 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
 
-/* ************************** ROTATION *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Rotation) */
 
+/** \name Transform Rotation
+ * \{ */
 
 static void postInputRotation(TransInfo *t, float values[3])
 {
@@ -3357,10 +3566,10 @@ static void postInputRotation(TransInfo *t, float values[3])
        }
 }
 
-void initRotation(TransInfo *t)
+static void initRotation(TransInfo *t)
 {
        t->mode = TFM_ROTATION;
-       t->transform = Rotation;
+       t->transform = applyRotation;
        
        setInputPostFct(&t->mouse, postInputRotation);
        initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
@@ -3368,10 +3577,13 @@ void initRotation(TransInfo *t)
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
-       t->snap[1] = (float)((5.0 / 180) * M_PI);
-       t->snap[2] = t->snap[1] * 0.2f;
+       t->snap[1] = DEG2RAD(5.0);
+       t->snap[2] = DEG2RAD(1.0);
        
-       t->num.increment = 1.0f;
+       copy_v3_fl(t->num.val_inc, t->snap[2]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
+       t->num.unit_type[0] = B_UNIT_ROTATION;
 
        if (t->flag & T_2D_EDIT)
                t->flag |= T_NO_CONSTRAINT;
@@ -3389,9 +3601,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
        const float *center;
 
        /* local constraint shouldn't alter center */
-       if (transdata_check_local_center(t) ||
-           ((around == V3D_LOCAL) && (t->options & CTX_MOVIECLIP)))
-       {
+       if (transdata_check_local_center(t, around)) {
                center = td->center;
        }
        else {
@@ -3606,7 +3816,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
        }
 }
 
-static void applyRotation(TransInfo *t, float angle, float axis[3])
+static void applyRotationValue(TransInfo *t, float angle, float axis[3])
 {
        TransData *td = t->data;
        float mat[3][3];
@@ -3634,7 +3844,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3])
        }
 }
 
-int Rotation(TransInfo *t, const int UNUSED(mval[2]))
+static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
        size_t ofs = 0;
@@ -3643,7 +3853,7 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
 
        final = t->values[0];
 
-       snapGrid(t, &final);
+       snapGridIncrement(t, &final);
 
        if ((t->con.mode & CON_APPLY) && t->con.applyRot) {
                t->con.applyRot(t, NULL, t->axis, NULL);
@@ -3664,8 +3874,8 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
                
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Rot: %s %s %s"), &c[0], t->con.text, t->proptext);
 
-               /* Clamp between -180 and 180 */
-               final = angle_wrap_rad(DEG2RADF(final));
+               /* Clamp between -PI and PI */
+               final = angle_wrap_rad(final);
        }
        else {
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Rot: %.2f%s %s"),
@@ -3678,37 +3888,44 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
 
        t->values[0] = final;
        
-       applyRotation(t, final, t->axis);
+       applyRotationValue(t, final, t->axis);
        
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
 
+/* -------------------------------------------------------------------- */
+/* Transform (Rotation - Trackball) */
 
-/* ************************** TRACKBALL *************************** */
+/** \name Transform Rotation - Trackball
+ * \{ */
 
-void initTrackball(TransInfo *t)
+static void initTrackball(TransInfo *t)
 {
        t->mode = TFM_TRACKBALL;
-       t->transform = Trackball;
+       t->transform = applyTrackball;
 
        initMouseInputMode(t, &t->mouse, INPUT_TRACKBALL);
 
        t->idx_max = 1;
        t->num.idx_max = 1;
        t->snap[0] = 0.0f;
-       t->snap[1] = (float)((5.0 / 180) * M_PI);
-       t->snap[2] = t->snap[1] * 0.2f;
+       t->snap[1] = DEG2RAD(5.0);
+       t->snap[2] = DEG2RAD(1.0);
 
-       t->num.increment = 1.0f;
+       copy_v3_fl(t->num.val_inc, t->snap[2]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
+       t->num.unit_type[0] = B_UNIT_ROTATION;
+       t->num.unit_type[1] = B_UNIT_ROTATION;
 
        t->flag |= T_NO_CONSTRAINT;
 }
 
-static void applyTrackball(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2])
+static void applyTrackballValue(TransInfo *t, const float axis1[3], const float axis2[3], float angles[2])
 {
        TransData *td = t->data;
        float mat[3][3], smat[3][3], totmat[3][3];
@@ -3737,7 +3954,7 @@ static void applyTrackball(TransInfo *t, const float axis1[3], const float axis2
        }
 }
 
-int Trackball(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTrackball(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
        size_t ofs = 0;
@@ -3753,7 +3970,7 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
        phi[0] = t->values[0];
        phi[1] = t->values[1];
 
-       snapGrid(t, phi);
+       snapGridIncrement(t, phi);
 
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN * 2];
@@ -3764,9 +3981,6 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
 
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Trackball: %s %s %s"),
                                    &c[0], &c[NUM_STR_REP_LEN], t->proptext);
-
-               phi[0] = DEG2RADF(phi[0]);
-               phi[1] = DEG2RADF(phi[1]);
        }
        else {
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Trackball: %.2f %.2f %s"),
@@ -3785,18 +3999,22 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
        // TRANSFORM_FIX_ME
        //copy_m3_m3(t->mat, mat);      // used in manipulator
 
-       applyTrackball(t, axis1, axis2, phi);
+       applyTrackballValue(t, axis1, axis2, phi);
 
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
-/* ************************** TRANSLATION *************************** */
 
-void initTranslation(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Translation) */
+
+/** \name Transform Translation
+ * \{ */
+
+static void initTranslation(TransInfo *t)
 {
        if (t->spacetype == SPACE_ACTION) {
                /* this space uses time translate */
@@ -3804,7 +4022,7 @@ void initTranslation(TransInfo *t)
        }
 
        t->mode = TFM_TRANSLATION;
-       t->transform = Translation;
+       t->transform = applyTranslation;
 
        initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
 
@@ -3828,19 +4046,23 @@ void initTranslation(TransInfo *t)
        }
        else if (t->spacetype == SPACE_NODE) {
                t->snap[0] = 0.0f;
-               t->snap[1] = 125.0f;
-               t->snap[2] = 25.0f;
+               t->snap[1] = ED_node_grid_size() * NODE_GRID_STEPS;
+               t->snap[2] = ED_node_grid_size();
        }
        else {
                t->snap[0] = 0.0f;
                t->snap[1] = t->snap[2] = 1.0f;
        }
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_LENGTH;
+       t->num.unit_type[1] = B_UNIT_LENGTH;
+       t->num.unit_type[2] = B_UNIT_LENGTH;
+
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTranslation(TransInfo *t, float vec[3], char *str)
+static void headerTranslation(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
 {
        size_t ofs = 0;
        char tvec[NUM_STR_REP_LEN * 3];
@@ -3864,7 +4086,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
 
                        for (i = 0; i < 3; i++) {
                                bUnit_AsString(&tvec[NUM_STR_REP_LEN * i], NUM_STR_REP_LEN, dvec[i] * t->scene->unit.scale_length,
-                                              4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1);
+                                              4, t->scene->unit.system, B_UNIT_LENGTH, do_split, true);
                        }
                }
                else {
@@ -3876,7 +4098,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
 
        if (!(t->flag & T_2D_EDIT) && t->scene->unit.system)
                bUnit_AsString(distvec, sizeof(distvec), dist * t->scene->unit.scale_length, 4, t->scene->unit.system,
-                              B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0);
+                              B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, false);
        else if (dist > 1e10f || dist < -1e10f)     /* prevent string buffer overflow */
                BLI_snprintf(distvec, NUM_STR_REP_LEN, "%.4e", dist);
        else
@@ -3927,7 +4149,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
        }
 }
 
-static void applyTranslation(TransInfo *t, float vec[3])
+static void applyTranslationValue(TransInfo *t, float vec[3])
 {
        TransData *td = t->data;
        float tvec[3];
@@ -3994,7 +4216,7 @@ static void applyTranslation(TransInfo *t, float vec[3])
 }
 
 /* uses t->vec to store actual translation in */
-int Translation(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
 
@@ -4010,7 +4232,7 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
                headerTranslation(t, pvec, str);
        }
        else {
-               snapGrid(t, t->values);
+               snapGridIncrement(t, t->values);
                applyNumInput(&t->num, t->values);
                if (hasNumInput(&t->num)) {
                        removeAspectRatio(t, t->values);
@@ -4019,11 +4241,11 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
                headerTranslation(t, t->values, str);
        }
 
-       applyTranslation(t, t->values);
+       applyTranslationValue(t, t->values);
 
        /* evil hack - redo translation if clipping needed */
        if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 0)) {
-               applyTranslation(t, t->values);
+               applyTranslationValue(t, t->values);
 
                /* In proportional edit it can happen that */
                /* vertices in the radius of the brush end */
@@ -4037,13 +4259,17 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Shrink-Fatten) */
 
-/* ************************** SHRINK/FATTEN *************************** */
+/** \name Transform Shrink-Fatten
+ * \{ */
 
-void initShrinkFatten(TransInfo *t)
+static void initShrinkFatten(TransInfo *t)
 {
        // If not in mesh edit mode, fallback to Resize
        if (t->obedit == NULL || t->obedit->type != OB_MESH) {
@@ -4051,7 +4277,7 @@ void initShrinkFatten(TransInfo *t)
        }
        else {
                t->mode = TFM_SHRINKFATTEN;
-               t->transform = ShrinkFatten;
+               t->transform = applyShrinkFatten;
 
                initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
 
@@ -4061,14 +4287,16 @@ void initShrinkFatten(TransInfo *t)
                t->snap[1] = 1.0f;
                t->snap[2] = t->snap[1] * 0.1f;
 
-               t->num.increment = t->snap[1];
+               copy_v3_fl(t->num.val_inc, t->snap[1]);
+               t->num.unit_sys = t->scene->unit.system;
+               t->num.unit_type[0] = B_UNIT_LENGTH;
 
                t->flag |= T_NO_CONSTRAINT;
        }
 }
 
 
-int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
+static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 {
        float distance;
        int i;
@@ -4078,7 +4306,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 
        distance = -t->values[0];
 
-       snapGrid(t, &distance);
+       snapGridIncrement(t, &distance);
 
        applyNumInput(&t->num, &distance);
 
@@ -4106,7 +4334,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
                }
        }
        BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Even Thickness %s"),
-                    (t->flag & T_ALT_TRANSFORM) ? IFACE_("ON") : IFACE_("OFF"));
+                    WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
        /* done with header string */
 
 
@@ -4132,33 +4360,39 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
-/* ************************** TILT *************************** */
 
-void initTilt(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Tilt) */
+
+/** \name Transform Tilt
+ * \{ */
+
+static void initTilt(TransInfo *t)
 {
        t->mode = TFM_TILT;
-       t->transform = Tilt;
+       t->transform = applyTilt;
 
        initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
 
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
-       t->snap[1] = (float)((5.0 / 180) * M_PI);
-       t->snap[2] = t->snap[1] * 0.2f;
+       t->snap[1] = DEG2RAD(5.0);
+       t->snap[2] = DEG2RAD(1.0);
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[2]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
+       t->num.unit_type[0] = B_UNIT_ROTATION;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
 
-
-int Tilt(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTilt(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        int i;
@@ -4168,7 +4402,7 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
 
        final = t->values[0];
 
-       snapGrid(t, &final);
+       snapGridIncrement(t, &final);
 
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
@@ -4179,8 +4413,6 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
 
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Tilt: %s° %s"), &c[0], t->proptext);
 
-               final = DEG2RADF(final);
-
                /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */
                t->values[0] = final;
        }
@@ -4203,17 +4435,20 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
+/* -------------------------------------------------------------------- */
+/* Transform (Curve Shrink/Fatten) */
 
-/* ******************** Curve Shrink/Fatten *************** */
+/** \name Transform Curve Shrink/Fatten
+ * \{ */
 
-void initCurveShrinkFatten(TransInfo *t)
+static void initCurveShrinkFatten(TransInfo *t)
 {
        t->mode = TFM_CURVE_SHRINKFATTEN;
-       t->transform = CurveShrinkFatten;
+       t->transform = applyCurveShrinkFatten;
 
        initMouseInputMode(t, &t->mouse, INPUT_SPRING);
 
@@ -4223,15 +4458,17 @@ void initCurveShrinkFatten(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_ZERO;
-       t->num.flag |= NUM_NO_ZERO;
+       t->num.val_flag[0] |= NUM_NO_ZERO;
 
        t->flag |= T_NO_CONSTRAINT;
 }
 
-int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
+static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        float ratio;
@@ -4240,7 +4477,7 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 
        ratio = t->values[0];
 
-       snapGrid(t, &ratio);
+       snapGridIncrement(t, &ratio);
 
        applyNumInput(&t->num, &ratio);
 
@@ -4273,15 +4510,20 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
 
-void initMaskShrinkFatten(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Mask Shrink/Fatten) */
+
+/** \name Transform Mask Shrink/Fatten
+ * \{ */
+
+static void initMaskShrinkFatten(TransInfo *t)
 {
        t->mode = TFM_MASK_SHRINKFATTEN;
-       t->transform = MaskShrinkFatten;
+       t->transform = applyMaskShrinkFatten;
 
        initMouseInputMode(t, &t->mouse, INPUT_SPRING);
 
@@ -4291,15 +4533,17 @@ void initMaskShrinkFatten(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_ZERO;
-       t->num.flag |= NUM_NO_ZERO;
+       t->num.val_flag[0] |= NUM_NO_ZERO;
 
        t->flag |= T_NO_CONSTRAINT;
 }
 
-int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
+static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td;
        float ratio;
@@ -4308,7 +4552,7 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
 
        ratio = t->values[0];
 
-       snapGrid(t, &ratio);
+       snapGridIncrement(t, &ratio);
 
        applyNumInput(&t->num, &ratio);
 
@@ -4362,16 +4606,20 @@ int MaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
-/* ************************** PUSH/PULL *************************** */
 
-void initPushPull(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Push/Pull) */
+
+/** \name Transform Push/Pull
+ * \{ */
+
+static void initPushPull(TransInfo *t)
 {
        t->mode = TFM_PUSHPULL;
-       t->transform = PushPull;
+       t->transform = applyPushPull;
 
        initMouseInputMode(t, &t->mouse, INPUT_VERTICAL_ABSOLUTE);
 
@@ -4381,11 +4629,13 @@ void initPushPull(TransInfo *t)
        t->snap[1] = 1.0f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_LENGTH;
 }
 
 
-int PushPull(TransInfo *t, const int UNUSED(mval[2]))
+static void applyPushPull(TransInfo *t, const int UNUSED(mval[2]))
 {
        float vec[3], axis[3];
        float distance;
@@ -4395,7 +4645,7 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
 
        distance = t->values[0];
 
-       snapGrid(t, &distance);
+       snapGridIncrement(t, &distance);
 
        applyNumInput(&t->num, &distance);
 
@@ -4447,16 +4697,20 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
-/* ************************** BEVEL WEIGHT *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Bevel Weight) */
 
-void initBevelWeight(TransInfo *t)
+/** \name Transform Bevel Weight
+ * \{ */
+
+static void initBevelWeight(TransInfo *t)
 {
        t->mode = TFM_BWEIGHT;
-       t->transform = BevelWeight;
+       t->transform = applyBevelWeight;
 
        initMouseInputMode(t, &t->mouse, INPUT_SPRING);
 
@@ -4466,12 +4720,14 @@ void initBevelWeight(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
-int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
+static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        float weight;
@@ -4483,7 +4739,7 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
        weight -= 1.0f;
        if (weight > 1.0f) weight = 1.0f;
 
-       snapGrid(t, &weight);
+       snapGridIncrement(t, &weight);
 
        applyNumInput(&t->num, &weight);
 
@@ -4520,16 +4776,20 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
-/* ************************** CREASE *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Crease) */
 
-void initCrease(TransInfo *t)
+/** \name Transform Crease
+ * \{ */
+
+static void initCrease(TransInfo *t)
 {
        t->mode = TFM_CREASE;
-       t->transform = Crease;
+       t->transform = applyCrease;
 
        initMouseInputMode(t, &t->mouse, INPUT_SPRING);
 
@@ -4539,12 +4799,14 @@ void initCrease(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
-int Crease(TransInfo *t, const int UNUSED(mval[2]))
+static void applyCrease(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        float crease;
@@ -4556,7 +4818,7 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
        crease -= 1.0f;
        if (crease > 1.0f) crease = 1.0f;
 
-       snapGrid(t, &crease);
+       snapGridIncrement(t, &crease);
 
        applyNumInput(&t->num, &crease);
 
@@ -4596,32 +4858,41 @@ int Crease(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
-/* ******************** EditBone (B-bone) width scaling *************** */
+/* -------------------------------------------------------------------- */
+/* Transform (EditBone (B-bone) width scaling) */
 
-void initBoneSize(TransInfo *t)
+/** \name Transform B-bone width scaling
+ * \{ */
+
+static void initBoneSize(TransInfo *t)
 {
        t->mode = TFM_BONESIZE;
-       t->transform = BoneSize;
+       t->transform = applyBoneSize;
 
        initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
 
        t->idx_max = 2;
        t->num.idx_max = 2;
-       t->num.flag |= NUM_NULL_ONE;
+       t->num.val_flag[0] |= NUM_NULL_ONE;
+       t->num.val_flag[1] |= NUM_NULL_ONE;
+       t->num.val_flag[2] |= NUM_NULL_ONE;
        t->num.flag |= NUM_AFFECT_ALL;
        t->snap[0] = 0.0f;
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
+       t->num.unit_type[1] = B_UNIT_NONE;
+       t->num.unit_type[2] = B_UNIT_NONE;
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerBoneSize(TransInfo *t, float vec[3], char *str)
+static void headerBoneSize(TransInfo *t, float vec[3], char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
        if (hasNumInput(&t->num)) {
@@ -4667,7 +4938,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3])
        td->loc[1] = oldy;
 }
 
-int BoneSize(TransInfo *t, const int mval[2])
+static void applyBoneSize(TransInfo *t, const int mval[2])
 {
        TransData *td = t->data;
        float size[3], mat[3][3];
@@ -4686,7 +4957,7 @@ int BoneSize(TransInfo *t, const int mval[2])
        
        size[0] = size[1] = size[2] = ratio;
        
-       snapGrid(t, size);
+       snapGridIncrement(t, size);
        
        if (hasNumInput(&t->num)) {
                applyNumInput(&t->num, size);
@@ -4716,17 +4987,20 @@ int BoneSize(TransInfo *t, const int mval[2])
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
 
+/* -------------------------------------------------------------------- */
+/* Transform (Bone Envelope) */
 
-/* ******************** EditBone envelope *************** */
+/** \name Transform Bone Envelope
+ * \{ */
 
-void initBoneEnvelope(TransInfo *t)
+static void initBoneEnvelope(TransInfo *t)
 {
        t->mode = TFM_BONE_ENVELOPE;
-       t->transform = BoneEnvelope;
+       t->transform = applyBoneEnvelope;
        
        initMouseInputMode(t, &t->mouse, INPUT_SPRING);
        
@@ -4736,12 +5010,14 @@ void initBoneEnvelope(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
        
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
-int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
+static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        float ratio;
@@ -4750,7 +5026,7 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
        
        ratio = t->values[0];
        
-       snapGrid(t, &ratio);
+       snapGridIncrement(t, &ratio);
        
        applyNumInput(&t->num, &ratio);
        
@@ -4784,11 +5060,16 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
        
        ED_area_headerprint(t->sa, str);
-       
-       return 1;
 }
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Edge Slide) */
+
+/** \name Transform Edge Slide
+ * \{ */
 
-/* ********************  Edge Slide   *************** */
 static BMEdge *get_other_edge(BMVert *v, BMEdge *e)
 {
        BMIter iter;
@@ -4803,6 +5084,26 @@ static BMEdge *get_other_edge(BMVert *v, BMEdge *e)
        return NULL;
 }
 
+/* interpoaltes along a line made up of 2 segments (used for edge slide) */
+static void interp_line_v3_v3v3v3(float p[3], const float v1[3], const float v2[3], const float v3[3], const float t)
+{
+       float t_mid, t_delta;
+
+       /* could be pre-calculated */
+       t_mid = line_point_factor_v3(v2, v1, v3);
+
+       t_delta = t - t_mid;
+       if (fabsf(t_delta) < FLT_EPSILON) {
+               copy_v3_v3(p, v2);
+       }
+       else if (t_delta < 0.0f) {
+               interp_v3_v3v3(p, v1, v2, t / t_mid);
+       }
+       else {
+               interp_v3_v3v3(p, v2, v3, (t - t_mid) / (1.0f - t_mid));
+       }
+}
+
 static void len_v3_ensure(float v[3], const float length)
 {
        normalize_v3(v);
@@ -5291,7 +5592,7 @@ static bool createEdgeSlideVerts(TransInfo *t)
        use_btree_disp = (v3d && t->obedit->dt > OB_WIRE && v3d->drawtype > OB_WIRE);
 
        if (use_btree_disp) {
-               btree = BKE_bmbvh_new(em, BMBVH_RESPECT_HIDDEN, NULL, false);
+               btree = BKE_bmbvh_new_from_editmesh(em, BMBVH_RESPECT_HIDDEN, NULL, false);
        }
        else {
                btree = NULL;
@@ -5626,12 +5927,12 @@ void freeEdgeSlideVerts(TransInfo *t)
        recalcData(t);
 }
 
-void initEdgeSlide(TransInfo *t)
+static void initEdgeSlide(TransInfo *t)
 {
        EdgeSlideData *sld;
 
        t->mode = TFM_EDGE_SLIDE;
-       t->transform = EdgeSlide;
+       t->transform = applyEdgeSlide;
        t->handleEvent = handleEventEdgeSlide;
 
        if (!createEdgeSlideVerts(t)) {
@@ -5656,12 +5957,14 @@ void initEdgeSlide(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
-int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
+static eRedrawFlag handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
 {
        if (t->mode == TFM_EDGE_SLIDE) {
                EdgeSlideData *sld = t->customData;
@@ -5671,7 +5974,7 @@ int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
                                case EKEY:
                                        if (event->val == KM_PRESS) {
                                                sld->is_proportional = !sld->is_proportional;
-                                               return 1;
+                                               return TREDRAW_HARD;
                                        }
                                        break;
                                case FKEY:
@@ -5680,7 +5983,7 @@ int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
                                                if (sld->is_proportional == FALSE) {
                                                        sld->flipped_vtx = !sld->flipped_vtx;
                                                }
-                                               return 1;
+                                               return TREDRAW_HARD;
                                        }
                                        break;
                                }
@@ -5705,7 +6008,7 @@ int handleEventEdgeSlide(struct TransInfo *t, const struct wmEvent *event)
                        }
                }
        }
-       return 0;
+       return TREDRAW_NOTHING;
 }
 
 static void drawEdgeSlide(const struct bContext *C, TransInfo *t)
@@ -5715,20 +6018,16 @@ static void drawEdgeSlide(const struct bContext *C, TransInfo *t)
                /* Non-Prop mode */
                if (sld && sld->is_proportional == FALSE) {
                        View3D *v3d = CTX_wm_view3d(C);
-                       float marker[3];
-                       float v1[3], v2[3];
-                       float interp_v;
+                       float co_a[3], co_b[3], co_mark[3];
                        TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index];
+                       const float fac = (sld->perc + 1.0f) / 2.0f;
                        const float ctrl_size = UI_GetThemeValuef(TH_FACEDOT_SIZE) + 1.5f;
                        const float guide_size = ctrl_size - 0.5f;
                        const float line_size = UI_GetThemeValuef(TH_OUTLINE_WIDTH) + 0.5f;
                        const int alpha_shade = -30;
 
-                       add_v3_v3v3(v1, curr_sv->v_co_orig, curr_sv->dir_a);
-                       add_v3_v3v3(v2, curr_sv->v_co_orig, curr_sv->dir_b);
-
-                       interp_v = (sld->perc + 1.0f) / 2.0f;
-                       interp_v3_v3v3(marker, v2, v1, interp_v);
+                       add_v3_v3v3(co_a, curr_sv->v_co_orig, curr_sv->dir_a);
+                       add_v3_v3v3(co_b, curr_sv->v_co_orig, curr_sv->dir_b);
 
                        if (v3d && v3d->zbuf)
                                glDisable(GL_DEPTH_TEST);
@@ -5769,7 +6068,12 @@ static void drawEdgeSlide(const struct bContext *C, TransInfo *t)
                        UI_ThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade);
                        glPointSize(guide_size);
                        bglBegin(GL_POINTS);
-                       bglVertex3fv(marker);
+#if 0
+                       interp_v3_v3v3(co_mark, co_b, co_a, fac);
+                       bglVertex3fv(co_mark);
+#endif
+                       interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac);
+                       bglVertex3fv(co_mark);
                        bglEnd();
 
 
@@ -5831,10 +6135,10 @@ static int doEdgeSlide(TransInfo *t, float perc)
                                add_v3_v3v3(co_b, sv->v_co_orig, sv->dir_b);
 
                                if (sld->flipped_vtx) {
-                                       interp_v3_v3v3(sv->v->co, co_b, co_a, fac);
+                                       interp_line_v3_v3v3v3(sv->v->co, co_b, sv->v_co_orig, co_a, fac);
                                }
                                else {
-                                       interp_v3_v3v3(sv->v->co, co_a, co_b, fac);
+                                       interp_line_v3_v3v3v3(sv->v->co, co_a, sv->v_co_orig, co_b, fac);
                                }
                        }
                }
@@ -5845,7 +6149,7 @@ static int doEdgeSlide(TransInfo *t, float perc)
        return 1;
 }
 
-int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
+static void applyEdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
        float final;
@@ -5853,12 +6157,9 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
        bool flipped = sld->flipped_vtx;
        bool is_proportional = sld->is_proportional;
 
-       const char *on_str = IFACE_("ON");
-       const char *off_str = IFACE_("OFF");
-
        final = t->values[0];
 
-       snapGrid(t, &final);
+       snapGridIncrement(t, &final);
 
        /* only do this so out of range values are not displayed */
        CLAMP(final, -1.0f, 1.0f);
@@ -5870,12 +6171,22 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
 
                outputNumInput(&(t->num), c);
 
-               BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %s (E)ven: %s, (F)lipped: %s"),
-                            &c[0], !is_proportional ? on_str : off_str, flipped ? on_str : off_str);
+               if (is_proportional) {
+                       BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %s (E)ven: %s"),
+                                    &c[0], WM_bool_as_string(!is_proportional));
+               }
+               else {
+                       BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %s (E)ven: %s, (F)lipped: %s"),
+                                    &c[0], WM_bool_as_string(!is_proportional), WM_bool_as_string(flipped));
+               }
+       }
+       else if (is_proportional) {
+               BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %.4f (E)ven: %s"),
+                            final, WM_bool_as_string(!is_proportional));
        }
        else {
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Edge Slide: %.4f (E)ven: %s, (F)lipped: %s"),
-                            final, !is_proportional ? on_str : off_str, flipped ? on_str : off_str);
+                            final, WM_bool_as_string(!is_proportional), WM_bool_as_string(flipped));
        }
 
        CLAMP(final, -1.0f, 1.0f);
@@ -5888,12 +6199,16 @@ int EdgeSlide(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Vert Slide) */
 
+/** \name Transform Vert Slide
+ * \{ */
 
-/* ******************** Vert Slide *************** */
 static void calcVertSlideCustomPoints(struct TransInfo *t)
 {
        VertSlideData *sld = t->customData;
@@ -6130,12 +6445,12 @@ void freeVertSlideVerts(TransInfo *t)
        recalcData(t);
 }
 
-void initVertSlide(TransInfo *t)
+static void initVertSlide(TransInfo *t)
 {
        VertSlideData *sld;
 
        t->mode = TFM_VERT_SLIDE;
-       t->transform = VertSlide;
+       t->transform = applyVertSlide;
        t->handleEvent = handleEventVertSlide;
 
        if (!createVertSlideVerts(t)) {
@@ -6160,12 +6475,14 @@ void initVertSlide(TransInfo *t)
        t->snap[1] = 0.1f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
-int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
+static eRedrawFlag handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
 {
        if (t->mode == TFM_VERT_SLIDE) {
                VertSlideData *sld = t->customData;
@@ -6178,7 +6495,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
                                                if (sld->flipped_vtx) {
                                                        calcVertSlideCustomPoints(t);
                                                }
-                                               return 1;
+                                               return TREDRAW_HARD;
                                        }
                                        break;
                                case FKEY:
@@ -6186,7 +6503,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
                                        if (event->val == KM_PRESS) {
                                                sld->flipped_vtx = !sld->flipped_vtx;
                                                calcVertSlideCustomPoints(t);
-                                               return 1;
+                                               return TREDRAW_HARD;
                                        }
                                        break;
                                }
@@ -6196,7 +6513,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
                                        if (event->val == KM_PRESS) {
                                                t->flag ^= T_ALT_TRANSFORM;
                                                calcVertSlideCustomPoints(t);
-                                               return 1;
+                                               return TREDRAW_HARD;
                                        }
                                        break;
                                }
@@ -6232,7 +6549,7 @@ int handleEventVertSlide(struct TransInfo *t, const struct wmEvent *event)
                        }
                }
        }
-       return 0;
+       return TREDRAW_NOTHING;
 }
 
 static void drawVertSlide(const struct bContext *C, TransInfo *t)
@@ -6349,7 +6666,7 @@ static int doVertSlide(TransInfo *t, float perc)
        return 1;
 }
 
-int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
+static void applyVertSlide(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
        size_t ofs = 0;
@@ -6360,12 +6677,9 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
        const bool is_clamp = !(t->flag & T_ALT_TRANSFORM);
        const bool is_constrained = !(is_clamp == false || hasNumInput(&t->num));
 
-       const char *on_str = IFACE_("ON");
-       const char *off_str = IFACE_("OFF");
-
        final = t->values[0];
 
-       snapGrid(t, &final);
+       snapGridIncrement(t, &final);
 
        /* only do this so out of range values are not displayed */
        if (is_constrained) {
@@ -6383,11 +6697,11 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
        else {
                ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, "%.4f ", final);
        }
-       ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(E)ven: %s, "), !is_proportional ? on_str : off_str);
+       ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(E)ven: %s, "), WM_bool_as_string(!is_proportional));
        if (!is_proportional) {
-               ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(F)lipped: %s, "), flipped ? on_str : off_str);
+               ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("(F)lipped: %s, "), WM_bool_as_string(flipped));
        }
-       ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), is_clamp ? on_str : off_str);
+       ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_("Alt or (C)lamp: %s"), WM_bool_as_string(is_clamp));
        /* done with header string */
 
        /* do stuff here */
@@ -6396,32 +6710,38 @@ int VertSlide(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
 
-/* ******************** EditBone roll *************** */
+/* -------------------------------------------------------------------- */
+/* Transform (EditBone Roll) */
 
-void initBoneRoll(TransInfo *t)
+/** \name Transform EditBone Roll
+ * \{ */
+
+static void initBoneRoll(TransInfo *t)
 {
        t->mode = TFM_BONE_ROLL;
-       t->transform = BoneRoll;
+       t->transform = applyBoneRoll;
 
        initMouseInputMode(t, &t->mouse, INPUT_ANGLE);
 
        t->idx_max = 0;
        t->num.idx_max = 0;
        t->snap[0] = 0.0f;
-       t->snap[1] = (float)((5.0 / 180) * M_PI);
-       t->snap[2] = t->snap[1] * 0.2f;
+       t->snap[1] = DEG2RAD(5.0);
+       t->snap[2] = DEG2RAD(1.0);
 
-       t->num.increment = 1.0f;
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS);
+       t->num.unit_type[0] = B_UNIT_ROTATION;
 
        t->flag |= T_NO_CONSTRAINT | T_NO_PROJECT;
 }
 
-int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
+static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        int i;
@@ -6431,7 +6751,7 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
 
        final = t->values[0];
 
-       snapGrid(t, &final);
+       snapGridIncrement(t, &final);
 
        if (hasNumInput(&t->num)) {
                char c[NUM_STR_REP_LEN];
@@ -6441,8 +6761,6 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
                outputNumInput(&(t->num), c);
 
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Roll: %s"), &c[0]);
-
-               final = DEG2RADF(final);
        }
        else {
                BLI_snprintf(str, MAX_INFO_LEN, IFACE_("Roll: %.2f"), RAD2DEGF(final));
@@ -6462,15 +6780,19 @@ int BoneRoll(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
-/* ************************** BAKE TIME ******************* */
 
-void initBakeTime(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Bake-Time) */
+
+/** \name Transform Bake-Time
+ * \{ */
+
+static void initBakeTime(TransInfo *t)
 {
-       t->transform = BakeTime;
+       t->transform = applyBakeTime;
        initMouseInputMode(t, &t->mouse, INPUT_NONE);
 
        t->idx_max = 0;
@@ -6479,10 +6801,12 @@ void initBakeTime(TransInfo *t)
        t->snap[1] = 1.0f;
        t->snap[2] = t->snap[1] * 0.1f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;  /* Don't think this uses units? */
 }
 
-int BakeTime(TransInfo *t, const int mval[2])
+static void applyBakeTime(TransInfo *t, const int mval[2])
 {
        TransData *td = t->data;
        float time;
@@ -6500,7 +6824,7 @@ int BakeTime(TransInfo *t, const int mval[2])
                time = (float)(t->center2d[0] - mval[0]) * fac;
        }
 
-       snapGrid(t, &time);
+       snapGridIncrement(t, &time);
 
        applyNumInput(&t->num, &time);
 
@@ -6540,15 +6864,19 @@ int BakeTime(TransInfo *t, const int mval[2])
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
-/* ************************** MIRROR *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Mirror) */
 
-void initMirror(TransInfo *t)
+/** \name Transform Mirror
+ * \{ */
+
+static void initMirror(TransInfo *t)
 {
-       t->transform = Mirror;
+       t->transform = applyMirror;
        initMouseInputMode(t, &t->mouse, INPUT_NONE);
 
        t->flag |= T_NULL_ONE;
@@ -6557,7 +6885,7 @@ void initMirror(TransInfo *t)
        }
 }
 
-int Mirror(TransInfo *t, const int UNUSED(mval[2]))
+static void applyMirror(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td;
        float size[3], mat[3][3];
@@ -6618,22 +6946,26 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2]))
                else
                        ED_area_headerprint(t->sa, IFACE_("Select a mirror axis (X, Y, Z)"));
        }
-
-       return 1;
 }
+/** \} */
+
 
-/* ************************** ALIGN *************************** */
+/* -------------------------------------------------------------------- */
+/* Transform (Align) */
 
-void initAlign(TransInfo *t)
+/** \name Transform Align
+ * \{ */
+
+static void initAlign(TransInfo *t)
 {
        t->flag |= T_NO_CONSTRAINT;
 
-       t->transform = Align;
+       t->transform = applyAlign;
 
        initMouseInputMode(t, &t->mouse, INPUT_NONE);
 }
 
-int Align(TransInfo *t, const int UNUSED(mval[2]))
+static void applyAlign(TransInfo *t, const int UNUSED(mval[2]))
 {
        TransData *td = t->data;
        float center[3];
@@ -6674,15 +7006,19 @@ int Align(TransInfo *t, const int UNUSED(mval[2]))
        recalcData(t);
 
        ED_area_headerprint(t->sa, IFACE_("Align"));
-
-       return 1;
 }
+/** \} */
+
+
+/* -------------------------------------------------------------------- */
+/* Transform (Sequencer Slide) */
 
-/* ************************** SEQ SLIDE *************************** */
+/** \name Transform Sequencer Slide
+ * \{ */
 
-void initSeqSlide(TransInfo *t)
+static void initSeqSlide(TransInfo *t)
 {
-       t->transform = SeqSlide;
+       t->transform = applySeqSlide;
 
        initMouseInputMode(t, &t->mouse, INPUT_VECTOR);
 
@@ -6694,11 +7030,14 @@ void initSeqSlide(TransInfo *t)
        t->snap[1] = floor(t->scene->r.frs_sec / t->scene->r.frs_sec_base);
        t->snap[2] = 10.0f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       /* Would be nice to have a time handling in units as well (supporting frames in addition to "natural" time...). */
+       t->num.unit_type[0] = B_UNIT_NONE;
+       t->num.unit_type[1] = B_UNIT_NONE;
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerSeqSlide(TransInfo *t, float val[2], char *str)
+static void headerSeqSlide(TransInfo *t, float val[2], char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
        size_t ofs = 0;
@@ -6719,10 +7058,10 @@ static void headerSeqSlide(TransInfo *t, float val[2], char *str)
                }
        }
        ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" or Alt) Expand to fit %s"),
-                           (t->flag & T_ALT_TRANSFORM) ? IFACE_("ON") : IFACE_("OFF"));
+                           WM_bool_as_string((t->flag & T_ALT_TRANSFORM) != 0));
 }
 
-static void applySeqSlide(TransInfo *t, const float val[2])
+static void applySeqSlideValue(TransInfo *t, const float val[2])
 {
        TransData *td = t->data;
        int i;
@@ -6745,7 +7084,7 @@ static void applySeqSlide(TransInfo *t, const float val[2])
        }
 }
 
-int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
+static void applySeqSlide(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
 
@@ -6756,7 +7095,7 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
                copy_v3_v3(t->values, tvec);
        }
        else {
-               snapGrid(t, t->values);
+               snapGridIncrement(t, t->values);
                applyNumInput(&t->num, t->values);
        }
 
@@ -6764,19 +7103,23 @@ int SeqSlide(TransInfo *t, const int UNUSED(mval[2]))
        t->values[1] = floor(t->values[1] + 0.5f);
 
        headerSeqSlide(t, t->values, str);
-       applySeqSlide(t, t->values);
+       applySeqSlideValue(t, t->values);
 
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
 
-/* ************************** ANIM EDITORS - TRANSFORM TOOLS *************************** */
 
-/* ---------------- Special Helpers for Various Settings ------------- */
+/* -------------------------------------------------------------------- */
+/* Animation Editors - Transform Utils
+ *
+ * Special Helpers for Various Settings
+ */
 
+/** \name Animation Editor Utils
+ * \{ */
 
 /* This function returns the snapping 'mode' for Animation Editors only
  * We cannot use the standard snapping due to NLA-strip scaling complexities.
@@ -6928,10 +7271,16 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d,
                td2d->h2[0] = td2d->ih2[0] + *td->val - td->ival;
        }
 }
+/** \} */
 
-/* ----------------- Translation ----------------------- */
 
-void initTimeTranslate(TransInfo *t)
+/* -------------------------------------------------------------------- */
+/* Transform (Animation Translation) */
+
+/** \name Transform Animation Translation
+ * \{ */
+
+static void initTimeTranslate(TransInfo *t)
 {
        /* this tool is only really available in the Action Editor... */
        if (!ELEM(t->spacetype, SPACE_ACTION, SPACE_SEQ)) {
@@ -6939,7 +7288,7 @@ void initTimeTranslate(TransInfo *t)
        }
 
        t->mode = TFM_TIME_TRANSLATE;
-       t->transform = TimeTranslate;
+       t->transform = applyTimeTranslate;
 
        initMouseInputMode(t, &t->mouse, INPUT_NONE);
 
@@ -6952,11 +7301,13 @@ void initTimeTranslate(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = t->snap[2] = 1.0f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       /* No time unit supporting frames currently... */
+       t->num.unit_type[0] = B_UNIT_NONE;
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTimeTranslate(TransInfo *t, char *str)
+static void headerTimeTranslate(TransInfo *t, char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
 
@@ -6992,7 +7343,7 @@ static void headerTimeTranslate(TransInfo *t, char *str)
        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("DeltaX: %s"), &tvec[0]);
 }
 
-static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
+static void applyTimeTranslateValue(TransInfo *t, float UNUSED(sval))
 {
        TransData *td = t->data;
        TransData2D *td2d = t->data2d;
@@ -7049,7 +7400,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval))
        }
 }
 
-int TimeTranslate(TransInfo *t, const int mval[2])
+static void applyTimeTranslate(TransInfo *t, const int mval[2])
 {
        View2D *v2d = (View2D *)t->view;
        float cval[2], sval[2];
@@ -7068,18 +7419,22 @@ int TimeTranslate(TransInfo *t, const int mval[2])
        t->values[0] = t->vec[0];
        headerTimeTranslate(t, str);
 
-       applyTimeTranslate(t, sval[0]);
+       applyTimeTranslateValue(t, sval[0]);
 
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
-/* ----------------- Time Slide ----------------------- */
+/* -------------------------------------------------------------------- */
+/* Transform (Animation Time Slide) */
 
-void initTimeSlide(TransInfo *t)
+/** \name Transform Animation Time Slide
+ * \{ */
+
+static void initTimeSlide(TransInfo *t)
 {
        /* this tool is only really available in the Action Editor... */
        if (t->spacetype == SPACE_ACTION) {
@@ -7094,7 +7449,7 @@ void initTimeSlide(TransInfo *t)
 
 
        t->mode = TFM_TIME_SLIDE;
-       t->transform = TimeSlide;
+       t->transform = applyTimeSlide;
        t->flag |= T_FREE_CUSTOMDATA;
 
        initMouseInputMode(t, &t->mouse, INPUT_NONE);
@@ -7108,11 +7463,13 @@ void initTimeSlide(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = t->snap[2] = 1.0f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       /* No time unit supporting frames currently... */
+       t->num.unit_type[0] = B_UNIT_NONE;
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTimeSlide(TransInfo *t, float sval, char *str)
+static void headerTimeSlide(TransInfo *t, float sval, char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
 
@@ -7134,7 +7491,7 @@ static void headerTimeSlide(TransInfo *t, float sval, char *str)
        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("TimeSlide: %s"), &tvec[0]);
 }
 
-static void applyTimeSlide(TransInfo *t, float sval)
+static void applyTimeSlideValue(TransInfo *t, float sval)
 {
        TransData *td = t->data;
        int i;
@@ -7181,7 +7538,7 @@ static void applyTimeSlide(TransInfo *t, float sval)
        }
 }
 
-int TimeSlide(TransInfo *t, const int mval[2])
+static void applyTimeSlide(TransInfo *t, const int mval[2])
 {
        View2D *v2d = (View2D *)t->view;
        float cval[2], sval[2];
@@ -7203,20 +7560,24 @@ int TimeSlide(TransInfo *t, const int mval[2])
        t->values[0] = (maxx - minx) * t->vec[0] / 2.0f + sval[0];
 
        headerTimeSlide(t, sval[0], str);
-       applyTimeSlide(t, sval[0]);
+       applyTimeSlideValue(t, sval[0]);
 
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
 }
+/** \} */
+
 
-/* ----------------- Scaling ----------------------- */
+/* -------------------------------------------------------------------- */
+/* Transform (Animation Time Scale) */
 
-void initTimeScale(TransInfo *t)
+/** \name Transform Animation Time Scale
+ * \{ */
+
+static void initTimeScale(TransInfo *t)
 {
-       int center[2];
+       float center[2];
 
        /* this tool is only really available in the Action Editor
         * AND NLA Editor (for strip scaling)
@@ -7226,12 +7587,12 @@ void initTimeScale(TransInfo *t)
        }
 
        t->mode = TFM_TIME_SCALE;
-       t->transform = TimeScale;
+       t->transform = applyTimeScale;
 
        /* 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);
+       projectFloatView(t, t->center, center);
        center[1] = t->imval[1];
 
        /* force a reinit with the center2d used here */
@@ -7240,7 +7601,7 @@ void initTimeScale(TransInfo *t)
        initMouseInputMode(t, &t->mouse, INPUT_SPRING_FLIP);
 
        t->flag |= T_NULL_ONE;
-       t->num.flag |= NUM_NULL_ONE;
+       t->num.val_flag[0] |= NUM_NULL_ONE;
 
        /* num-input has max of (n-1) */
        t->idx_max = 0;
@@ -7251,11 +7612,12 @@ void initTimeScale(TransInfo *t)
        t->snap[0] = 0.0f;
        t->snap[1] = t->snap[2] = 1.0f;
 
-       t->num.increment = t->snap[1];
+       copy_v3_fl(t->num.val_inc, t->snap[1]);
+       t->num.unit_sys = t->scene->unit.system;
+       t->num.unit_type[0] = B_UNIT_NONE;
 }
 
-/* We assume str is MAX_INFO_LEN long. */
-static void headerTimeScale(TransInfo *t, char *str)
+static void headerTimeScale(TransInfo *t, char str[MAX_INFO_LEN])
 {
        char tvec[NUM_STR_REP_LEN * 3];
 
@@ -7267,7 +7629,7 @@ static void headerTimeScale(TransInfo *t, char *str)
        BLI_snprintf(str, MAX_INFO_LEN, IFACE_("ScaleX: %s"), &tvec[0]);
 }
 
-static void applyTimeScale(TransInfo *t)
+static void applyTimeScaleValue(TransInfo *t)
 {
        Scene *scene = t->scene;
        TransData *td = t->data;
@@ -7307,7 +7669,7 @@ static void applyTimeScale(TransInfo *t)
        }
 }
 
-int TimeScale(TransInfo *t, const int UNUSED(mval[2]))
+static void applyTimeScale(TransInfo *t, const int UNUSED(mval[2]))
 {
        char str[MAX_INFO_LEN];
        
@@ -7317,22 +7679,13 @@ int TimeScale(TransInfo *t, const int UNUSED(mval[2]))
        t->values[0] = t->vec[0];
        headerTimeScale(t, str);
 
-       applyTimeScale(t);
+       applyTimeScaleValue(t);
 
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
-
-       return 1;
-}
-
-/* ************************************ */
-
-void BIF_TransformSetUndo(const char *UNUSED(str))
-{
-       // TRANSFORM_FIX_ME
-       //Trans.undostr = str;
 }
+/** \} */
 
 
 /* TODO, move to: transform_queries.c */