From: andy Date: Tue, 6 Apr 2004 04:06:11 +0000 (+0000) Subject: Added mouse cursor definitions stolen from the X11 cursor font (via a X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=86d4fcf5b6611a7eed5ef3f0b3aad86f8e2485ff;p=flightgear.git Added mouse cursor definitions stolen from the X11 cursor font (via a pointer from Melchior to a font editor that could read .pcf and generate image files) --- diff --git a/src/Main/fg_os_sdl.cxx b/src/Main/fg_os_sdl.cxx index fd3b7242e..8813cad78 100644 --- a/src/Main/fg_os_sdl.cxx +++ b/src/Main/fg_os_sdl.cxx @@ -18,6 +18,7 @@ static fgMouseMotionHandler MouseMotionHandler = 0; static int CurrentModifiers = 0; static int CurrentMouseX = 0; static int CurrentMouseY = 0; +static int CurrentMouseCursor = MOUSE_CURSOR_POINTER; static bool NeedRedraw = false; void fgRegisterIdleHandler(fgIdleHandler func) @@ -54,6 +55,7 @@ void fgRegisterMouseMotionHandler(fgMouseMotionHandler func) // // fg_os implementation // +static void initCursors(); void fgOSOpenWindow(int w, int h, int bpp, bool alpha, bool fullscreen) { @@ -82,6 +84,9 @@ void fgOSOpenWindow(int w, int h, int bpp, bool alpha, bool fullscreen) // explicitly, and will turn this off. SDL_EnableUNICODE(1); + initCursors(); + fgSetMouseCursor(MOUSE_CURSOR_POINTER); + // FIXME: we may not get what we asked for (especially in full // screen modes), so these need to be propagated back to the // property tree for the rest of the code to inspect... @@ -205,6 +210,129 @@ void fgOSFullScreen() // change modes. } -// Figure out what to do with these -void fgSetMouseCursor(int cursor) {} -int fgGetMouseCursor() { return MOUSE_CURSOR_POINTER; } +static struct cursor_rec { + int name; + SDL_Cursor* sdlCursor; + int w; + int h; + int hotx; + int hoty; + char *img[32]; // '.' == white, '#' == black, ' ' == transparent +} cursors[] = { + { MOUSE_CURSOR_POINTER, 0, // must be first! + 10, 16, 1, 1, + { ".. ", + ".#. ", + ".##. ", + ".###. ", + ".####. ", + ".#####. ", + ".######. ", + ".#######. ", + ".########.", + ".#####....", + ".##.##. ", + ".#. .##. ", + ".. .##. ", + " .##. ", + " .##. ", + " .. " } }, + { MOUSE_CURSOR_CROSSHAIR, 0, + 17, 17, 8, 8, + { " ... ", + " .#. ", + " .#. ", + " .#. ", + " .#. ", + " .#. ", + " .#. ", + "........#........", + ".#######.#######.", + "........#........", + " .#. ", + " .#. ", + " .#. ", + " .#. ", + " .#. ", + " .#. ", + " ... " } }, + { MOUSE_CURSOR_WAIT, 0, + 16, 16, 7, 7, + { " .########. ", + " .########. ", + " .########. ", + " .##########. ", + ".##....#...##. ", + "##.....#....##..", + "#......#.....###", + "#.....###....###", + "#.....###....###", + "#....#.......###", + "##..#.......##..", + ".##........##. ", + " .##########. ", + " .########. ", + " .########. ", + " .########. " } }, + { MOUSE_CURSOR_LEFTRIGHT, 0, + 17, 9, 8, 4, + { " .. .. ", + " .#. .#. ", + " .##.......##. ", + " .#############. ", + ".####.......####.", + " .#############. ", + " .##.......##. ", + " .#. .#. ", + " .. .. " } }, + { MOUSE_CURSOR_NONE, 0, // must come last! + 1, 1, 0, 0, { " " } }, +}; + +#define NCURSORS (sizeof(cursors)/sizeof(struct cursor_rec)) + +void fgSetMouseCursor(int cursor) +{ + if(cursor == MOUSE_CURSOR_NONE) { + SDL_ShowCursor(SDL_DISABLE); + return; + } + SDL_ShowCursor(SDL_ENABLE); + for(int i=0; i> 3); + int bit = 1 << (7 - (x & 7)); + int pix = cursors[i].img[y][x]; + if(pix != ' ') { mask[byte] |= bit; } + if(pix == '#') { img[byte] |= bit; } + } + } + cursors[i].sdlCursor = SDL_CreateCursor(img, mask, 32, 32, + cursors[i].hotx, + cursors[i].hoty); + } +}