Gamedev Framework (gf)  0.7.0
A C++14 framework for 2D games
Cursor.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2018 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 "Portability.h"
30 #include "Vector.h"
31 
32 struct SDL_Cursor;
33 struct SDL_Surface;
34 
35 namespace gf {
36 #ifndef DOXYGEN_SHOULD_SKIP_THIS
37 inline namespace v1 {
38 #endif
39 
40  class Image;
41 
72  class GF_API Cursor {
73  public:
74 
78  enum Type {
81  Wait,
82  Text,
83  Hand,
90  NotAllowed
91  };
92 
101  Cursor();
102 
106  Cursor(const Cursor&) = delete;
107 
111  Cursor& operator=(const Cursor&) = delete;
112 
116  Cursor(Cursor&& other) noexcept;
117 
121  Cursor& operator=(Cursor&& other) noexcept;
122 
129  ~Cursor();
130 
156  bool loadFromPixels(const uint8_t* pixels, Vector2u size, Vector2u hotspot);
157 
167  bool loadFromImage(const Image& image, Vector2u hotspot);
168 
175  bool loadFromSystem(Type type);
176 
177  private:
178  friend class Window;
179  SDL_Cursor *m_cursor;
180  };
181 
182 #ifndef DOXYGEN_SHOULD_SKIP_THIS
183 }
184 #endif
185 }
186 
187 #endif // GF_CURSOR_H
Vertical double arrow cursor.
Definition: Cursor.h:85
Arrow cursor (default)
Definition: Cursor.h:79
Type
Enumeration of the native system cursor types.
Definition: Cursor.h:78
Double arrow cursor going from bottom-left to top-right.
Definition: Cursor.h:87
Busy arrow cursor.
Definition: Cursor.h:80
Horizontal double arrow cursor.
Definition: Cursor.h:84
Crosshair cursor.
Definition: Cursor.h:89
Combination of SizeHorizontal and SizeVertical.
Definition: Cursor.h:88
Busy cursor.
Definition: Cursor.h:81
Class for loading, manipulating and saving images.
Definition: Image.h:92
The namespace for gf classes.
Definition: Action.h:34
An OS window.
Definition: Window.h:88
I-beam, cursor when hovering over a field allowing text entry.
Definition: Cursor.h:82
Pointing hand cursor.
Definition: Cursor.h:83
Double arrow cursor going from top-left to bottom-right.
Definition: Cursor.h:86
A mouse cursor.
Definition: Cursor.h:72