Added cursor support
This commit is contained in:
parent
c66cae17f2
commit
1ec25d036c
6 changed files with 110 additions and 45 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <graphics/Graphics.hpp>
|
||||
#include <structures/Mouse.hpp>
|
||||
#include <structures/Cursor.hpp>
|
||||
|
||||
namespace sdlu {
|
||||
// TODO: Eventually we should initialize things once the object gets created
|
||||
|
|
38
include/structures/Cursor.hpp
Normal file
38
include/structures/Cursor.hpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
#pragma once
|
||||
|
||||
#include "Vector2.hpp"
|
||||
#include "Util.hpp"
|
||||
|
||||
struct SDL_Cursor;
|
||||
struct SDL_Surface;
|
||||
|
||||
SDLU_BEGIN
|
||||
|
||||
class Cursor
|
||||
{
|
||||
public:
|
||||
enum class Type {
|
||||
Arrow, IBeam, Wait, Crosshair, WaitArrow,
|
||||
SizeNWSE, SizeNESW, SizeWE, SizeNS, SizeAll,
|
||||
No, Hand
|
||||
};
|
||||
|
||||
friend class Window;
|
||||
|
||||
public:
|
||||
Cursor();
|
||||
Cursor(Type type);
|
||||
Cursor(const Cursor& other) = delete;
|
||||
Cursor(Cursor&& other) noexcept;
|
||||
|
||||
~Cursor();
|
||||
|
||||
bool LoadFromPixels(const Uint8* pixels, Vector2u size, Vector2u hotspot);
|
||||
bool LoadFromSurface(SDL_Surface* surface, Vector2u hotspot);
|
||||
bool LoadFromSystem(Type type);
|
||||
|
||||
private:
|
||||
SDL_Cursor* cursor;
|
||||
};
|
||||
|
||||
SDLU_END
|
|
@ -17,6 +17,8 @@ struct SDL_Surface;
|
|||
struct SDL_Cursor;
|
||||
|
||||
SDLU_BEGIN
|
||||
class Cursor;
|
||||
|
||||
/**
|
||||
* @brief Stores information about a window. You probably want RenderWindow.
|
||||
*/
|
||||
|
@ -230,28 +232,9 @@ public:
|
|||
/**
|
||||
* @brief Changes the mouse cursor
|
||||
*
|
||||
* @param[in] surface A pointer to a SDL_Surface containing sprite data
|
||||
* @param[in] clickspot The effective position of the cursor relative to the top left of the sprite
|
||||
* @param[in] cursor The cursor object holding cursor data
|
||||
*/
|
||||
void SetMouseCursor(SDL_Surface* surface, Vector2u clickspot);
|
||||
|
||||
/**
|
||||
* @brief Changes the mouse cursor
|
||||
*
|
||||
* @param[in] pixels An array of color data (RGBA as seperate 8-bit values)
|
||||
* @param[in] size Size of the cursor
|
||||
* @param[in] clickspot The effective position of the cursor relative to the top left of the sprite
|
||||
*/
|
||||
void SetMouseCursor(const Uint8* pixels, Vector2u size, Vector2u clickspot);
|
||||
|
||||
/**
|
||||
* @brief Changes the mouse cursor
|
||||
*
|
||||
* @param[in] pixels An array of color data (RGBA as one 32-bit value)
|
||||
* @param[in] size Size of the cursor
|
||||
* @param[in] clickspot The effective position of the cursor relative to the top left of the sprite
|
||||
*/
|
||||
void SetMouseCursor(const Uint32* pixels, Vector2u size, Vector2u clickspot);
|
||||
void SetMouseCursor(const Cursor& cursor);
|
||||
|
||||
protected:
|
||||
SDL_Window* window;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue