mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-27 21:49:10 +02:00
Hardware cursor can now be hidden
This commit is contained in:
parent
5484efde90
commit
fd05036f3b
@ -288,6 +288,24 @@ void CursorHandler::render()
|
||||
cursor->render();
|
||||
}
|
||||
|
||||
void CursorHandler::hide()
|
||||
{
|
||||
if (!showing)
|
||||
return;
|
||||
|
||||
showing = false;
|
||||
cursor->setVisible(false);
|
||||
}
|
||||
|
||||
void CursorHandler::show()
|
||||
{
|
||||
if (showing)
|
||||
return;
|
||||
|
||||
showing = true;
|
||||
cursor->setVisible(true);
|
||||
}
|
||||
|
||||
void CursorSoftware::render()
|
||||
{
|
||||
//texture must be updated in the main (renderer) thread, but changes to cursor type may come from other threads
|
||||
@ -348,10 +366,16 @@ void CursorSoftware::setCursorPosition( const Point & newPos )
|
||||
pos = newPos;
|
||||
}
|
||||
|
||||
void CursorSoftware::setVisible(bool on)
|
||||
{
|
||||
visible = on;
|
||||
}
|
||||
|
||||
CursorSoftware::CursorSoftware():
|
||||
cursorTexture(nullptr),
|
||||
cursorSurface(nullptr),
|
||||
needUpdate(false),
|
||||
visible(false),
|
||||
pivot(0,0)
|
||||
{
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
@ -364,12 +388,12 @@ CursorSoftware::~CursorSoftware()
|
||||
|
||||
if (cursorSurface)
|
||||
SDL_FreeSurface(cursorSurface);
|
||||
|
||||
}
|
||||
|
||||
CursorHardware::CursorHardware():
|
||||
cursor(nullptr)
|
||||
{
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
}
|
||||
|
||||
CursorHardware::~CursorHardware()
|
||||
@ -378,6 +402,14 @@ CursorHardware::~CursorHardware()
|
||||
SDL_FreeCursor(cursor);
|
||||
}
|
||||
|
||||
void CursorHardware::setVisible(bool on)
|
||||
{
|
||||
if (on)
|
||||
SDL_ShowCursor(SDL_ENABLE);
|
||||
else
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
}
|
||||
|
||||
void CursorHardware::setImage(std::shared_ptr<IImage> image, const Point & pivotOffset)
|
||||
{
|
||||
auto cursorSurface = CSDL_Ext::newSurface(image->dimensions().x, image->dimensions().y);
|
||||
|
@ -120,6 +120,7 @@ public:
|
||||
virtual void setImage(std::shared_ptr<IImage> image, const Point & pivotOffset) = 0;
|
||||
virtual void setCursorPosition( const Point & newPos ) = 0;
|
||||
virtual void render() = 0;
|
||||
virtual void setVisible( bool on) = 0;
|
||||
};
|
||||
|
||||
class CursorHardware : public ICursor
|
||||
@ -135,6 +136,7 @@ public:
|
||||
void setImage(std::shared_ptr<IImage> image, const Point & pivotOffset) override;
|
||||
void setCursorPosition( const Point & newPos ) override;
|
||||
void render() override;
|
||||
void setVisible( bool on) override;
|
||||
};
|
||||
|
||||
class CursorSoftware : public ICursor
|
||||
@ -147,6 +149,7 @@ class CursorSoftware : public ICursor
|
||||
Point pos;
|
||||
Point pivot;
|
||||
bool needUpdate;
|
||||
bool visible;
|
||||
|
||||
void createTexture(const Point & dimensions);
|
||||
void updateTexture();
|
||||
@ -157,6 +160,7 @@ public:
|
||||
void setImage(std::shared_ptr<IImage> image, const Point & pivotOffset) override;
|
||||
void setCursorPosition( const Point & newPos ) override;
|
||||
void render() override;
|
||||
void setVisible( bool on) override;
|
||||
};
|
||||
|
||||
/// handles mouse cursor
|
||||
@ -222,8 +226,8 @@ public:
|
||||
|
||||
void render();
|
||||
|
||||
void hide() { showing=false; };
|
||||
void show() { showing=true; };
|
||||
void hide();
|
||||
void show();
|
||||
|
||||
/// change cursor's positions to (x, y)
|
||||
void cursorMove(const int & x, const int & y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user