[Bf-blender-cvs] [574c0fe38f3] blender2.8: Manipulators/Tools: always draw a cursor while interacting

Ines Almeida noreply at git.blender.org
Mon Apr 23 01:02:25 CEST 2018


Commit: 574c0fe38f332bd97c588029c0075ecba1fe19cd
Author: Ines Almeida
Date:   Mon Apr 23 00:42:17 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB574c0fe38f332bd97c588029c0075ecba1fe19cd

Manipulators/Tools: always draw a cursor while interacting

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.

===================================================================

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

===================================================================

diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 1df6ee9c8c9..8d4d1dfa53c 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -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   	*/
diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c
index 5f2e5a99090..df77b6129a7 100644
--- a/source/blender/editors/transform/transform_input.c
+++ b/source/blender/editors/transform/transform_input.c
@@ -30,10 +30,13 @@
 
 #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)) {
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index fc62ff7ce31..fe07e5a2510 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -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! */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 95ead3befdc..69537aa41c9 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -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);



More information about the Bf-blender-cvs mailing list