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 to support different mouse cursors
if (_lastCursorType != cursorType) {
_lastCursorType = cursorType;
if (cursorType in _cursorMap) {
Log.d("changing cursor to ", cursorType);
SDL_SetCursor(_cursorMap[cursorType]);
if (cursorType == CursorType.None) {
SDL_ShowCursor(SDL_DISABLE);
return;
}
if (_lastCursorType == CursorType.None)
SDL_ShowCursor(SDL_ENABLE);
_lastCursorType = cursorType;
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) {
case CursorType.Arrow:
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
break;
case CursorType.IBeam:
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
break;
case CursorType.Wait:
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_WAIT);
@ -199,9 +209,9 @@ version(USE_SDL) {
cursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
break;
}
_cursorMap[cursorType] = cursor;
if (cursor) {
Log.d("changing cursor to ", cursorType);
_cursorMap[cursorType] = cursor;
SDL_SetCursor(cursor);
}
}