From 372ee054c0deb4ca07e1a70c7b905d24043723be Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 1 Jan 2008 18:29:19 +0000 Subject: Some notes for those who try to follow this :) - first work on getting area/screen handling back - added structure for where to put stuff, is still under review, wait a bit for docs? Campbell is working on removing every bad level include from sources, so we can safely rebuild the src/ directory. --- source/blender/windowmanager/WM_api.h | 2 + source/blender/windowmanager/intern/wm_cursors.c | 83 +++++++++++++++++++----- 2 files changed, 68 insertions(+), 17 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 044661fb521..2aad763336e 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -53,6 +53,8 @@ void WM_write_autosave (struct bContext *C); /* mouse cursors */ void WM_init_cursor_data (void); void WM_set_cursor (struct bContext *C, int curs); +void WM_waitcursor (struct bContext *C, int val); +void WM_timecursor (struct bContext *C, int nr); /* keymap and handlers */ void WM_keymap_set_item (ListBase *lb, char *idname, short type, diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 8c86070ca61..e4299b8949b 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" @@ -100,32 +101,80 @@ void WM_set_cursor(bContext *C, int curs) } GHOST_SetCursorVisibility(win->ghostwin, 1); - + + LastCursor=CurrentCursor; + CurrentCursor=curs; + + /* previous cursor? */ + if (curs==LASTCURSOR) curs=LastCursor; + /* detect if we use system cursor or Blender cursor */ if(curs>=BC_GHOST_CURSORS) { GHOST_SetCursorShape(win->ghostwin, convert_cursor(curs)); - return; } - - if ((curs=BC_NUMCURSORS)) return; - - - LastCursor=CurrentCursor; - CurrentCursor=curs; - - if (curs==LASTCURSOR) curs=LastCursor; - - if (curs==SYSCURSOR) { /* System default Cursor */ - GHOST_SetCursorShape(win->ghostwin, convert_cursor(CURSOR_STD)); + 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); + } } - else if ( (U.curssize==0) || (BlenderCursor[curs]->big_bm == NULL) ) { - window_set_custom_cursor_ex(win, BlenderCursor[curs], 0); +} + +void WM_waitcursor(bContext *C, int val) +{ + if(C->window) { + if(val) { + WM_set_cursor(C, CURSOR_WAIT); + } else { + WM_set_cursor(C, LASTCURSOR); + } } - else { - window_set_custom_cursor_ex(win, BlenderCursor[curs], 1); +} + +void WM_timecursor(bContext *C, 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; + + 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(C->window, mask, bitmap, 7, 7); } + /* ****************************************************************** Custom Cursor Description: -- cgit v1.2.3