Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / transform / transform_input.c
index b60c8bf47f65b0d1cd61ecda32a7dd912aac440d..2004bba4f091385bb13e442fc3b588c01c28ff91 100644 (file)
 
 #include "DNA_screen_types.h"
 
+#include "BKE_context.h"
+
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
 #include "WM_types.h"
+#include "WM_api.h"
 
 #include "transform.h"
 
@@ -341,6 +344,29 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
                        break;
        }
 
+       /* setup for the mouse cursor: either set a custom one,
+        * or hide it if it will be drawn with the helpline */
+       wmWindow *win = CTX_wm_window(t->context);
+       switch (t->helpline) {
+               case HLP_NONE:
+                       /* INPUT_VECTOR, INPUT_CUSTOM_RATIO, INPUT_CUSTOM_RATIO_FLIP */
+                       if (t->flag & T_MODAL) {
+                               WM_cursor_set(win, BC_NSEW_SCROLLCURSOR);
+                       }
+                       break;
+               case HLP_SPRING:
+               case HLP_ANGLE:
+               case HLP_TRACKBALL:
+               case HLP_HARROW:
+               case HLP_VARROW:
+                       if (t->flag & T_MODAL) {
+                               WM_cursor_set(win, CURSOR_NONE);
+                       }
+                       break;
+               default:
+                       break;
+       }
+
        /* if we've allocated new data, free the old data
         * less hassle then checking before every alloc above */
        if (mi_data_prev && (mi_data_prev != mi->data)) {
@@ -391,6 +417,17 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp
                mi->apply(t, mi, mval_db, output);
        }
 
+       if (!is_zero_v3(t->values_modal_offset)) {
+               float values_ofs[3];
+               if (t->con.mode & CON_APPLY) {
+                       mul_v3_m3v3(values_ofs, t->spacemtx, t->values_modal_offset);
+               }
+               else {
+                       copy_v3_v3(values_ofs, t->values_modal_offset);
+               }
+               add_v3_v3(t->values, values_ofs);
+       }
+
        if (mi->post) {
                mi->post(t, output);
        }