Tool System: support for tool cursors
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user