Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Cursor.h
1/*
2 * Gamedev Framework (gf)
3 * Copyright (C) 2016-2022 Julien Bernard
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 * 2. Altered source versions must be plainly marked as such, and must not be
18 * misrepresented as being the original software.
19 * 3. This notice may not be removed or altered from any source distribution.
20 *
21 * Part of this file comes from SFML, with the same license:
22 * Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
23 */
24#ifndef GF_CURSOR_H
25#define GF_CURSOR_H
26
27#include <cstdint>
28
29#include "GraphicsApi.h"
30#include "Path.h"
31#include "Vector.h"
32
33struct SDL_Cursor;
34struct SDL_Surface;
35
36namespace gf {
37#ifndef DOXYGEN_SHOULD_SKIP_THIS
38inline namespace v1 {
39#endif
40
41 class Image;
42
63 class GF_GRAPHICS_API Cursor {
64 public:
65
69 enum Type {
81 NotAllowed
82 };
83
90
113 Cursor(const uint8_t* pixels, Vector2i size, Vector2i hotspot);
114
121 Cursor(const Image& image, Vector2i hotspot);
122
129 Cursor(const Path& path, Vector2i hotspot);
130
137
141 Cursor(const Cursor&) = delete;
142
146 Cursor& operator=(const Cursor&) = delete;
147
151 Cursor(Cursor&& other) noexcept;
152
156 Cursor& operator=(Cursor&& other) noexcept;
157
165
166 private:
167 friend class Window;
168 SDL_Cursor *m_cursor;
169 };
170
171#ifndef DOXYGEN_SHOULD_SKIP_THIS
172}
173#endif
174}
175
176#endif // GF_CURSOR_H
A mouse cursor.
Definition: Cursor.h:63
Cursor(const uint8_t *pixels, Vector2i size, Vector2i hotspot)
Create a cursor with the provided pixels.
Cursor(const Image &image, Vector2i hotspot)
Create a cursor from the provided image.
Cursor & operator=(const Cursor &)=delete
Deleted copy assignment.
Cursor(Cursor &&other) noexcept
Move constructor.
Cursor(const Cursor &)=delete
Deleted copy constructor.
Cursor(const Path &path, Vector2i hotspot)
Create a cursor from an image stored in a file.
Type
Enumeration of the native system cursor types.
Definition: Cursor.h:69
@ Arrow
Arrow cursor (default)
Definition: Cursor.h:70
@ SizeTopLeftBottomRight
Double arrow cursor going from top-left to bottom-right.
Definition: Cursor.h:77
@ SizeAll
Combination of SizeHorizontal and SizeVertical.
Definition: Cursor.h:79
@ SizeVertical
Vertical double arrow cursor.
Definition: Cursor.h:76
@ Cross
Crosshair cursor.
Definition: Cursor.h:80
@ SizeBottomLeftTopRight
Double arrow cursor going from bottom-left to top-right.
Definition: Cursor.h:78
@ Hand
Pointing hand cursor.
Definition: Cursor.h:74
@ SizeHorizontal
Horizontal double arrow cursor.
Definition: Cursor.h:75
@ Wait
Busy cursor.
Definition: Cursor.h:72
@ ArrowWait
Busy arrow cursor.
Definition: Cursor.h:71
@ Text
I-beam, cursor when hovering over a field allowing text entry.
Definition: Cursor.h:73
~Cursor()
Destructor.
Cursor()
Default constructor.
Cursor(Type type)
Create a native system cursor.
Cursor & operator=(Cursor &&other) noexcept
Move assignment.
Class for loading, manipulating and saving images.
Definition: Image.h:81
An OS window.
Definition: Window.h:97
std::filesystem::path Path
A path in the filesystem.
Definition: Path.h:40
The namespace for gf classes.