From 1b2ba7b2d8e8c316a74ddff03e077bfa943c30d6 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Mon, 22 May 2017 19:17:02 +0800 Subject: [PATCH] Update class Cursor. Fix compile bug in class Window --- MiniEngine.cpp | 20 ++++++++++---------- MiniEngine.h | 9 +++++---- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 6610d61..bc3f8a3 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -983,33 +983,30 @@ namespace MiniEngine return _cur.get(); } + //private void Cursor::_clear() { _cur.reset(); } - //static - Cursor Cursor::CreateCursor(Surface surf,Point hotspot) + Cursor::Cursor(Surface surf,Point hotspot) { Cursor ns; SDL_Cursor* cursor=SDL_CreateColorCursor(surf._get(),hotspot.x,hotspot.y); ns._set(cursor); - return ns; } - //static - Cursor Cursor::CreateSystemCursor(SystemCursorType type) + Cursor::Cursor(SystemCursorType type) { Cursor ns; ns._set(SDL_CreateSystemCursor(_internal::getSDLSystemCursorFromSystemCursorType(type))); - return ns; } //static Cursor Cursor::GetActiveCursor() { Cursor ns; - ns._set(SDL_GetCursor()); + ns._set_no_delete(SDL_GetCursor()); return ns; } @@ -1017,7 +1014,7 @@ namespace MiniEngine Cursor Cursor::GetDefaultCursor() { Cursor ns; - ns._set(SDL_GetDefaultCursor()); + ns._set_no_delete(SDL_GetDefaultCursor()); return ns; } @@ -1028,7 +1025,7 @@ namespace MiniEngine } //static - void Cursor::show(bool Settings) + void Cursor::setShow(bool Settings) { SDL_ShowCursor(Settings?SDL_ENABLE:SDL_DISABLE); } @@ -1040,7 +1037,10 @@ namespace MiniEngine void Cursor::activate() { - SDL_SetCursor(_get()); + if(_get()!=nullptr) + { + SDL_SetCursor(_get()); + } } void Window::_set(SDL_Window* p) diff --git a/MiniEngine.h b/MiniEngine.h index 1641f8b..20de1aa 100644 --- a/MiniEngine.h +++ b/MiniEngine.h @@ -238,13 +238,14 @@ namespace MiniEngine class Cursor { public: - static Cursor CreateSystemCursor(SystemCursorType); - static Cursor CreateCursor(Surface surf,Point hotspot={0,0}); + Cursor()=default; + Cursor(SystemCursorType); + Cursor(Surface surf,Point hotspot={0,0}); static Cursor GetActiveCursor(); static Cursor GetDefaultCursor(); - static void show(bool); + static void setShow(bool); static bool isShow(); void activate(); @@ -333,7 +334,7 @@ namespace MiniEngine void _setRenderer(int& refcalc,RendererType Type,Args&&... args) { refcalc|=_render_caster(Type); - _setRenderer(args...); + _setRenderer(refcalc,args...); } void _setRenderer(int& refcalc,RendererType Type)