Manipulators/Tools: always draw a cursor while interacting
authorInes Almeida <britalmeida@gmail.com>
Sun, 22 Apr 2018 22:42:17 +0000 (00:42 +0200)
committerInes Almeida <britalmeida@gmail.com>
Sun, 22 Apr 2018 22:59:01 +0000 (00:59 +0200)
Cursor can be a system one or drawn with OpenGL.
Before, dragging the transform manipulator would hide the cursor and reset it to the initial positon.

source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_input.c
source/blender/editors/transform/transform_manipulator.c
source/blender/windowmanager/intern/wm_event_system.c

index 1df6ee9c8c9c94ac526be2287a8544e27f24eb67..8d4d1dfa53ce8f83592e910f9cd787d0f02039ae 100644 (file)
@@ -483,7 +483,7 @@ typedef struct TransInfo {
        short           persp;
        short           around;
        char            spacetype;              /* spacetype where transforming is      */
-       char            helpline;               /* helpline modes (not to be confused with hotline) */
+       char            helpline;               /* choice of custom cursor with or without a help line from the gizmo to the mouse pos */
        short           obedit_type;    /* Avoid looking inside TransDataContainer obedit. */
 
        float           vec[3];                 /* translation, to show for widget      */
index 5f2e5a990907e6e108d22144d2d49b3acbb5e26f..df77b6129a7f6b12fdf5853d6384a3dd4e537803 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,25 @@ 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 */
+                WM_cursor_set(win, BC_HANDCURSOR);
+                break;
+        case HLP_SPRING:
+        case HLP_ANGLE:
+        case HLP_TRACKBALL:
+        case HLP_HARROW:
+        case HLP_VARROW:
+                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)) {
index fc62ff7ce31ba347f343d36168c82df111898887..fe07e5a2510df7717f19e50934866d9da56409f3 100644 (file)
@@ -1191,17 +1191,14 @@ static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup)
 #define MANIPULATOR_NEW_ARROW(v, draw_style) { \
        man->manipulators[v] = WM_manipulator_new_ptr(wt_arrow, mgroup, NULL); \
        RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \
-       WM_manipulator_set_flag(man->manipulators[v], WM_MANIPULATOR_GRAB_CURSOR, true); \
 } ((void)0)
 #define MANIPULATOR_NEW_DIAL(v, draw_options) { \
        man->manipulators[v] = WM_manipulator_new_ptr(wt_dial, mgroup, NULL); \
        RNA_enum_set(man->manipulators[v]->ptr, "draw_options", draw_options); \
-       WM_manipulator_set_flag(man->manipulators[v], WM_MANIPULATOR_GRAB_CURSOR, true); \
 } ((void)0)
 #define MANIPULATOR_NEW_PRIM(v, draw_style) { \
        man->manipulators[v] = WM_manipulator_new_ptr(wt_prim, mgroup, NULL); \
        RNA_enum_set(man->manipulators[v]->ptr, "draw_style", draw_style); \
-       WM_manipulator_set_flag(man->manipulators[v], WM_MANIPULATOR_GRAB_CURSOR, true); \
 } ((void)0)
 
        /* add/init widgets - order matters! */
index 95ead3befdcab703e3827bf8d46c8381f70aafba..69537aa41c9d59da5bcef8d67690e9acf6c22cc2 100644 (file)
@@ -1903,7 +1903,10 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand
 
                                /* remove modal handler, operator itself should have been canceled and freed */
                                if (retval & (OPERATOR_CANCELLED | OPERATOR_FINISHED)) {
-                                       WM_cursor_grab_disable(CTX_wm_window(C), NULL);
+                                       /* set cursor back to the default for the region */
+                                       wmWindow *win = CTX_wm_window(C);
+                                       WM_cursor_grab_disable(win, NULL);
+                                       ED_region_cursor_set(win, CTX_wm_area(C), CTX_wm_region(C));
 
                                        BLI_remlink(handlers, handler);
                                        wm_event_free_handler(handler);