cursor changing for editors - working ok on SDL

This commit is contained in:
Vadim Lopatin 2014-05-14 11:18:18 +04:00
parent e16d1cacbc
commit faeac55f4b
1 changed files with 16 additions and 6 deletions

View File

@ -150,19 +150,29 @@ version(USE_SDL) {
override protected void setCursorType(uint cursorType) { override protected void setCursorType(uint cursorType) {
// override to support different mouse cursors // override to support different mouse cursors
if (_lastCursorType != cursorType) { if (_lastCursorType != cursorType) {
_lastCursorType = cursorType; if (cursorType == CursorType.None) {
if (cursorType in _cursorMap) { SDL_ShowCursor(SDL_DISABLE);
Log.d("changing cursor to ", cursorType);
SDL_SetCursor(_cursorMap[cursorType]);
return; return;
} }
if (_lastCursorType == CursorType.None)
SDL_ShowCursor(SDL_ENABLE);
_lastCursorType = cursorType;
SDL_Cursor * cursor; SDL_Cursor * cursor;
// check for existing cursor in map
if (cursorType in _cursorMap) {
//Log.d("changing cursor to ", cursorType);
cursor = _cursorMap[cursorType];
if (cursor)
SDL_SetCursor(cursor);
return;
}
// create new cursor
switch (cursorType) { switch (cursorType) {
case CursorType.Arrow: case CursorType.Arrow:
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
break; break;
case CursorType.IBeam: case CursorType.IBeam:
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
break; break;
case CursorType.Wait: case CursorType.Wait:
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT); cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
@ -199,9 +209,9 @@ version(USE_SDL) {
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
break; break;
} }
_cursorMap[cursorType] = cursor;
if (cursor) { if (cursor) {
Log.d("changing cursor to ", cursorType); Log.d("changing cursor to ", cursorType);
_cursorMap[cursorType] = cursor;
SDL_SetCursor(cursor); SDL_SetCursor(cursor);
} }
} }