Merge branch 'master' into blender2.8
[blender.git] / source / blender / windowmanager / intern / wm_cursors.c
index 6aef38a320bf765604b8c7538d6aeed690c7d35f..f13dac9cb4c920fb121123c7d9867ad0e0f65a4a 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "DNA_listBase.h"
 #include "DNA_userdef_types.h"
 
 #include "DNA_listBase.h"
 #include "DNA_userdef_types.h"
+#include "DNA_workspace_types.h"
 
 #include "BKE_context.h"
 #include "BKE_global.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)
 void WM_cursor_modal_set(wmWindow *win, int val)
 {
        if (win->lastcursor == 0)