Update class Cursor. Fix compile bug in class Window

This commit is contained in:
Kirigaya Kazuto 2017-05-22 19:17:02 +08:00
parent 52cb15482e
commit 1b2ba7b2d8
2 changed files with 15 additions and 14 deletions

View File

@ -983,33 +983,30 @@ namespace MiniEngine
return _cur.get(); return _cur.get();
} }
//private
void Cursor::_clear() void Cursor::_clear()
{ {
_cur.reset(); _cur.reset();
} }
//static Cursor::Cursor(Surface surf,Point hotspot)
Cursor Cursor::CreateCursor(Surface surf,Point hotspot)
{ {
Cursor ns; Cursor ns;
SDL_Cursor* cursor=SDL_CreateColorCursor(surf._get(),hotspot.x,hotspot.y); SDL_Cursor* cursor=SDL_CreateColorCursor(surf._get(),hotspot.x,hotspot.y);
ns._set(cursor); ns._set(cursor);
return ns;
} }
//static Cursor::Cursor(SystemCursorType type)
Cursor Cursor::CreateSystemCursor(SystemCursorType type)
{ {
Cursor ns; Cursor ns;
ns._set(SDL_CreateSystemCursor(_internal::getSDLSystemCursorFromSystemCursorType(type))); ns._set(SDL_CreateSystemCursor(_internal::getSDLSystemCursorFromSystemCursorType(type)));
return ns;
} }
//static //static
Cursor Cursor::GetActiveCursor() Cursor Cursor::GetActiveCursor()
{ {
Cursor ns; Cursor ns;
ns._set(SDL_GetCursor()); ns._set_no_delete(SDL_GetCursor());
return ns; return ns;
} }
@ -1017,7 +1014,7 @@ namespace MiniEngine
Cursor Cursor::GetDefaultCursor() Cursor Cursor::GetDefaultCursor()
{ {
Cursor ns; Cursor ns;
ns._set(SDL_GetDefaultCursor()); ns._set_no_delete(SDL_GetDefaultCursor());
return ns; return ns;
} }
@ -1028,7 +1025,7 @@ namespace MiniEngine
} }
//static //static
void Cursor::show(bool Settings) void Cursor::setShow(bool Settings)
{ {
SDL_ShowCursor(Settings?SDL_ENABLE:SDL_DISABLE); SDL_ShowCursor(Settings?SDL_ENABLE:SDL_DISABLE);
} }
@ -1039,9 +1036,12 @@ namespace MiniEngine
} }
void Cursor::activate() void Cursor::activate()
{
if(_get()!=nullptr)
{ {
SDL_SetCursor(_get()); SDL_SetCursor(_get());
} }
}
void Window::_set(SDL_Window* p) void Window::_set(SDL_Window* p)
{ {

View File

@ -238,13 +238,14 @@ namespace MiniEngine
class Cursor class Cursor
{ {
public: public:
static Cursor CreateSystemCursor(SystemCursorType); Cursor()=default;
static Cursor CreateCursor(Surface surf,Point hotspot={0,0}); Cursor(SystemCursorType);
Cursor(Surface surf,Point hotspot={0,0});
static Cursor GetActiveCursor(); static Cursor GetActiveCursor();
static Cursor GetDefaultCursor(); static Cursor GetDefaultCursor();
static void show(bool); static void setShow(bool);
static bool isShow(); static bool isShow();
void activate(); void activate();
@ -333,7 +334,7 @@ namespace MiniEngine
void _setRenderer(int& refcalc,RendererType Type,Args&&... args) void _setRenderer(int& refcalc,RendererType Type,Args&&... args)
{ {
refcalc|=_render_caster(Type); refcalc|=_render_caster(Type);
_setRenderer(args...); _setRenderer(refcalc,args...);
} }
void _setRenderer(int& refcalc,RendererType Type) void _setRenderer(int& refcalc,RendererType Type)