|
@@ -20,7 +20,7 @@
|
|
|
#include "../CMT.h"
|
|
|
|
|
|
CursorHandler::CursorHandler()
|
|
|
- : cursorSW(new CursorSoftware())
|
|
|
+ : cursorSW(new CursorHardware())
|
|
|
, frameTime(0.f)
|
|
|
, showing(false)
|
|
|
, pos(0,0)
|
|
@@ -52,6 +52,9 @@ void CursorHandler::changeGraphic(Cursor::Type type, size_t index)
|
|
|
{
|
|
|
assert(dndObject == nullptr);
|
|
|
|
|
|
+ if (type == this->type && index == this->frame)
|
|
|
+ return;
|
|
|
+
|
|
|
this->type = type;
|
|
|
this->frame = index;
|
|
|
|
|
@@ -346,3 +349,39 @@ CursorSoftware::~CursorSoftware()
|
|
|
SDL_FreeSurface(cursorSurface);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+CursorHardware::CursorHardware():
|
|
|
+ cursor(nullptr)
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+CursorHardware::~CursorHardware()
|
|
|
+{
|
|
|
+ if(cursor)
|
|
|
+ SDL_FreeCursor(cursor);
|
|
|
+}
|
|
|
+
|
|
|
+void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
|
|
|
+{
|
|
|
+ auto cursorSurface = CSDL_Ext::newSurface(image->dimensions().x, image->dimensions().y);
|
|
|
+
|
|
|
+ image->draw(cursorSurface);
|
|
|
+
|
|
|
+ cursor = SDL_CreateColorCursor(cursorSurface, pivotOffset.x, pivotOffset.y);
|
|
|
+
|
|
|
+ if (!cursor)
|
|
|
+ logGlobal->error("Failed to set cursor! SDL says %s", SDL_GetError());
|
|
|
+
|
|
|
+ SDL_FreeSurface(cursorSurface);
|
|
|
+ SDL_SetCursor(cursor);
|
|
|
+}
|
|
|
+
|
|
|
+void CursorHardware::setCursorPosition( const Point & newPos )
|
|
|
+{
|
|
|
+ //no-op
|
|
|
+}
|
|
|
+
|
|
|
+void CursorHardware::render()
|
|
|
+{
|
|
|
+ //no-op
|
|
|
+}
|