[Bf-blender-cvs] [17852b079c9] blender2.8: Tool System: support for tool cursors

Campbell Barton noreply at git.blender.org
Fri May 18 12:01:53 CEST 2018


Commit: 17852b079c9d2d67e474112aa79a3e8a674b05d2
Author: Campbell Barton
Date:   Fri May 18 11:44:28 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB17852b079c9d2d67e474112aa79a3e8a674b05d2

Tool System: support for tool cursors

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

M	source/blender/editors/screen/area.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_cursors.c

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

diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 4c5ba38984b..b2245886991 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1491,6 +1491,9 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar)
 		ar->type->cursor(win, sa, ar);
 	}
 	else {
+		if (WM_cursor_set_from_tool(win, sa, ar)) {
+			return;
+		}
 		WM_cursor_set(win, CURSOR_STD);
 	}
 }
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index de2ef45247b..df9d8dad6ee 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1104,8 +1104,12 @@ static void view3d_main_region_message_subscribe(
 }
 
 /* concept is to retrieve cursor type context-less */
-static void view3d_main_region_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *UNUSED(ar))
+static void view3d_main_region_cursor(wmWindow *win, ScrArea *sa, ARegion *ar)
 {
+	if (WM_cursor_set_from_tool(win, sa, ar)) {
+		return;
+	}
+
 	ViewLayer *view_layer = WM_window_get_active_view_layer(win);
 	Object *obedit = OBEDIT_FROM_VIEW_LAYER(view_layer);
 	if (obedit) {
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index afa6e71e610..0d48cd9ef20 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -157,6 +157,7 @@ void        WM_lib_reload(struct Library *lib, struct bContext *C, struct Report
 
 			/* mouse cursors */
 void		WM_cursor_set(struct wmWindow *win, int curs);
+bool		WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *sa, const ARegion *ar);
 void		WM_cursor_modal_set(struct wmWindow *win, int curs);
 void		WM_cursor_modal_restore(struct wmWindow *win);
 void		WM_cursor_wait		(bool val);
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index ad5e83ceda7..d5f67d81f18 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -42,6 +42,7 @@
 
 #include "DNA_listBase.h"
 #include "DNA_userdef_types.h" 
+#include "DNA_workspace_types.h"
 
 #include "BKE_context.h"
 #include "BKE_global.h"
@@ -156,6 +157,23 @@ void WM_cursor_set(wmWindow *win, int curs)
 	}
 }
 
+bool WM_cursor_set_from_tool(struct wmWindow *win, const ScrArea *sa, const ARegion *ar)
+{
+	if (ar && (ar->regiontype != RGN_TYPE_WINDOW)) {
+		return false;
+	}
+
+	bToolRef_Runtime *tref_rt = (sa && sa->runtime.tool) ? sa->runtime.tool->runtime : NULL;
+	if (tref_rt && tref_rt->cursor != CURSOR_STD) {
+		if (win->modalcursor == 0) {
+			WM_cursor_set(win, tref_rt->cursor);
+			win->cursor = tref_rt->cursor;
+			return true;
+		}
+	}
+	return false;
+}
+
 void WM_cursor_modal_set(wmWindow *win, int val)
 {
 	if (win->lastcursor == 0)



More information about the Bf-blender-cvs mailing list