2017-06-18 17:43:23 +08:00
|
|
|
#include "Cursor.h"
|
2017-06-18 20:37:45 +08:00
|
|
|
#include "_caster.h"
|
2017-06-18 17:43:23 +08:00
|
|
|
#include "begin_code.h"
|
|
|
|
//private
|
|
|
|
void Cursor::_set(SDL_Cursor* p)
|
|
|
|
{
|
|
|
|
_cur.reset(p,SDL_FreeCursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
//private
|
|
|
|
void Cursor::_set_no_delete(SDL_Cursor* p)
|
|
|
|
{
|
|
|
|
_cur.reset(p,[](SDL_Cursor* p) {});
|
|
|
|
}
|
|
|
|
|
|
|
|
//private
|
|
|
|
SDL_Cursor* Cursor::_get()
|
|
|
|
{
|
|
|
|
return _cur.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
//private
|
|
|
|
void Cursor::_clear()
|
|
|
|
{
|
2017-07-30 17:48:22 +08:00
|
|
|
_cur.release();
|
2017-06-18 17:43:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Cursor::Cursor(Surface surf,Point hotspot)
|
|
|
|
{
|
2017-07-30 17:48:22 +08:00
|
|
|
_set(SDL_CreateColorCursor(surf._get(),hotspot.x,hotspot.y));
|
2017-06-18 17:43:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Cursor::Cursor(SystemCursorType type)
|
|
|
|
{
|
2017-07-30 17:48:22 +08:00
|
|
|
_set(SDL_CreateSystemCursor(_internal::getSDLSystemCursorFromSystemCursorType(type)));
|
2017-06-18 17:43:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
2017-07-30 17:48:22 +08:00
|
|
|
Cursor&& Cursor::GetActiveCursor()
|
2017-06-18 17:43:23 +08:00
|
|
|
{
|
|
|
|
Cursor ns;
|
|
|
|
ns._set_no_delete(SDL_GetCursor());
|
2017-07-30 17:48:22 +08:00
|
|
|
return std::move(ns);
|
2017-06-18 17:43:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
2017-07-30 17:48:22 +08:00
|
|
|
Cursor&& Cursor::GetDefaultCursor()
|
2017-06-18 17:43:23 +08:00
|
|
|
{
|
|
|
|
Cursor ns;
|
|
|
|
ns._set_no_delete(SDL_GetDefaultCursor());
|
2017-07-30 17:48:22 +08:00
|
|
|
return std::move(ns);
|
2017-06-18 17:43:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
|
|
|
bool Cursor::isShow()
|
|
|
|
{
|
|
|
|
return (SDL_ShowCursor(SDL_QUERY)==SDL_ENABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
//static
|
|
|
|
void Cursor::setShow(bool Settings)
|
|
|
|
{
|
|
|
|
SDL_ShowCursor(Settings?SDL_ENABLE:SDL_DISABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cursor::release()
|
|
|
|
{
|
|
|
|
_clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cursor::activate()
|
|
|
|
{
|
|
|
|
if(_get()!=nullptr)
|
|
|
|
{
|
|
|
|
SDL_SetCursor(_get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#include "end_code.h"
|