![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
A mouse cursor. More...
#include <gf/Cursor.h>
Public Types | |
enum | Type { Arrow , ArrowWait , Wait , Text , Hand , SizeHorizontal , SizeVertical , SizeTopLeftBottomRight , SizeBottomLeftTopRight , SizeAll , Cross , NotAllowed } |
Enumeration of the native system cursor types. More... | |
Public Member Functions | |
Cursor () | |
Default constructor. More... | |
Cursor (const uint8_t *pixels, Vector2i size, Vector2i hotspot) | |
Create a cursor with the provided pixels. More... | |
Cursor (const Image &image, Vector2i hotspot) | |
Create a cursor from the provided image. More... | |
Cursor (const Path &path, Vector2i hotspot) | |
Create a cursor from an image stored in a file. More... | |
Cursor (Type type) | |
Create a native system cursor. More... | |
Cursor (const Cursor &)=delete | |
Deleted copy constructor. More... | |
Cursor & | operator= (const Cursor &)=delete |
Deleted copy assignment. More... | |
Cursor (Cursor &&other) noexcept | |
Move constructor. More... | |
Cursor & | operator= (Cursor &&other) noexcept |
Move assignment. More... | |
~Cursor () | |
Destructor. More... | |
A mouse cursor.
This class abstracts the operating system resources associated with either a native system cursor or a custom cursor.
After construction, the cursor can be changed with gf::Window::setMouseCursor().
The behaviour is undefined if the cursor is destroyed while in use by the window.
Usage example:
enum gf::Cursor::Type |
Enumeration of the native system cursor types.
Enumerator | |
---|---|
Arrow | Arrow cursor (default) |
ArrowWait | Busy arrow cursor. |
Wait | Busy cursor. |
Text | I-beam, cursor when hovering over a field allowing text entry. |
Hand | Pointing hand cursor. |
SizeHorizontal | Horizontal double arrow cursor. |
SizeVertical | Vertical double arrow cursor. |
SizeTopLeftBottomRight | Double arrow cursor going from top-left to bottom-right. |
SizeBottomLeftTopRight | Double arrow cursor going from bottom-left to top-right. |
SizeAll | Combination of SizeHorizontal and SizeVertical. |
Cross | Crosshair cursor. |
NotAllowed | Action not allowed cursor. |
gf::Cursor::Cursor | ( | ) |
Default constructor.
This constructor doesn't actually create the cursor.
Create a cursor with the provided pixels.
pixels must be an array of width by height pixels in 32-bit RGBA format. If not, this will cause undefined behavior.
If pixels is null or either width or height are 0, the current cursor is left unchanged and the function will return false.
In addition to specifying the pixel data, you can also specify the location of the hotspot of the cursor. The hotspot is the pixel coordinate within the cursor image which will be located exactly where the mouse pointer position is. Any mouse actions that are performed will return the window/screen location of the hotspot.
pixels | An array of pixels of the image |
size | The width and height of the image |
hotspot | The location of the hotspot |
Create a cursor from the provided image.
image | The image |
hotspot | THe location of the hotspot |
Create a cursor from an image stored in a file.
path | The path to the image |
hotspot | THe location of the hotspot |
gf::Cursor::Cursor | ( | Type | type | ) |
Create a native system cursor.
type | The native system cursor type |
|
delete |
Deleted copy constructor.
|
noexcept |
Move constructor.
gf::Cursor::~Cursor | ( | ) |
Destructor.
This destructor releases the system resources associated with this cursor, if any.