X-Git-Url: https://git.blender.org/gitweb/gitweb.cgi/blender.git/blobdiff_plain/a1c8543f2acd7086d412cb794b32f96794b00659..a16df53619a2ab3b41c0cbcf6f9e01a9bf370c9c:/source/blender/windowmanager/intern/wm_cursors.c diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 8c86070ca61..8b4ddd786e0 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -28,6 +28,7 @@ */ #include +#include #include "GHOST_C-api.h" @@ -85,47 +86,107 @@ static void window_set_custom_cursor_ex(wmWindow *win, BCursor *cursor, int useB /* Cursor Globals */ static BCursor *BlenderCursor[BC_NUMCURSORS]; /*Points to static BCursor Structs */ -static short CurrentCursor=-1, LastCursor=-1; -void WM_set_cursor(bContext *C, int curs) +void WM_cursor_set(wmWindow *win, int curs) { - wmWindow *win= C->window; if (win==NULL) return; /* Can't set custom cursor before Window init */ - win->cursor= curs; - + if (curs==CURSOR_NONE) { GHOST_SetCursorVisibility(win->ghostwin, 0); return; } GHOST_SetCursorVisibility(win->ghostwin, 1); - + + win->cursor= curs; + /* detect if we use system cursor or Blender cursor */ if(curs>=BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); - return; } + else { + if ((curs=BC_NUMCURSORS)) return; + + if (curs==SYSCURSOR) { /* System default Cursor */ + GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); + } + else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) { + window_set_custom_cursor_ex(win, BlenderCursor[curs], 0); + } + else { + window_set_custom_cursor_ex(win, BlenderCursor[curs], 1); + } + } +} - if ((curs=BC_NUMCURSORS)) return; +static int LastCursor=-1; /* global, assumed we only have one */ +void WM_cursor_modal(wmWindow *win, int val) +{ + if(LastCursor == -1) + LastCursor = win->cursor; + WM_cursor_set(win, val); +} - LastCursor=CurrentCursor; - CurrentCursor=curs; +void WM_cursor_restore(wmWindow *win) +{ + if(LastCursor != -1) + WM_cursor_set(win, LastCursor); + LastCursor = -1; +} - if (curs==LASTCURSOR) curs=LastCursor; - if (curs==SYSCURSOR) { /* System default Cursor */ - GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); - } - else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) { - window_set_custom_cursor_ex(win, BlenderCursor[curs], 0); +void WM_cursor_wait(wmWindow *win, int val) +{ + if(val) { + WM_cursor_modal(win, CURSOR_WAIT); + } else { + WM_cursor_restore(win); } - else { - window_set_custom_cursor_ex(win, BlenderCursor[curs], 1); +} + +/* afer this you can call restore too */ +void WM_timecursor(wmWindow *win, int nr) +{ + /* 10 8x8 digits */ + static char number_bitmaps[10][8]= { + {0, 56, 68, 68, 68, 68, 68, 56}, + {0, 24, 16, 16, 16, 16, 16, 56}, + {0, 60, 66, 32, 16, 8, 4, 126}, + {0, 124, 32, 16, 56, 64, 66, 60}, + {0, 32, 48, 40, 36, 126, 32, 32}, + {0, 124, 4, 60, 64, 64, 68, 56}, + {0, 56, 4, 4, 60, 68, 68, 56}, + {0, 124, 64, 32, 16, 8, 8, 8}, + {0, 60, 66, 66, 60, 66, 66, 60}, + {0, 56, 68, 68, 120, 64, 68, 56} + }; + unsigned char mask[16][2]; + unsigned char bitmap[16][2]; + int i, idx; + + if(LastCursor != -1) + LastCursor= win->cursor; + + memset(&bitmap, 0x00, sizeof(bitmap)); + memset(&mask, 0xFF, sizeof(mask)); + + /* print number bottom right justified */ + for (idx= 3; nr && idx>=0; idx--) { + char *digit= number_bitmaps[nr%10]; + int x = idx%2; + int y = idx/2; + + for (i=0; i<8; i++) + bitmap[i + y*8][x]= digit[i]; + nr/= 10; } + + window_set_custom_cursor(win, mask, bitmap, 7, 7); } + /* ****************************************************************** Custom Cursor Description: @@ -168,7 +229,7 @@ are for */ #define BEGIN_CURSOR_BLOCK { #define END_CURSOR_BLOCK } -void WM_init_cursor_data(void){ +void wm_init_cursor_data(void){ /********************** NW_ARROW Cursor **************************/ BEGIN_CURSOR_BLOCK