nomlib
Loading...
Searching...
No Matches
Cursor.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_GRAPHICS_CURSOR_HPP
30#define NOMLIB_GRAPHICS_CURSOR_HPP
31
32#include <memory>
33
34#include "nomlib/config.hpp"
35#include "nomlib/math/Point2.hpp"
36
37// Forward declarations
38struct SDL_Cursor;
39
40namespace nom {
41
42namespace priv {
43
44void free_cursor( SDL_Cursor* c );
45
46} // namespace priv
47
49{
52 Point2i pos;
53
55 uint32 state;
56};
57
62class Cursor
63{
64 public:
65 typedef Cursor self_type;
66
67 typedef self_type* raw_ptr;
68
89
91 Cursor( void );
92
94 ~Cursor( void );
95
103 SDL_Cursor* cursor( void ) const;
104
108 SDL_Cursor* default_cursor( void ) const;
109
113 static MouseState mouse_state( void );
114
115 Type system_cursor( void ) const;
116
121
126 bool cursor_state( void ) const;
127
131 void show_cursor( bool state );
132
133 private:
138 void set_cursor( SDL_Cursor* cursor );
139
142
143 // std::unique_ptr<SDL_Cursor, void(*) (SDL_Cursor*)> cursor_;
144};
145
146} // namespace nom
147
148#endif // include guard defined
static MouseState mouse_state(void)
Retrieve the current state of the mouse.
Type
The mouse cursor types.
Definition Cursor.hpp:73
@ No
Four pointed arrow pointing north, south, east and west.
Definition Cursor.hpp:85
@ SizeWE
Double arrow pointing northeast and southwest.
Definition Cursor.hpp:82
@ CrossHair
Wait.
Definition Cursor.hpp:77
@ SizeAll
Double arrow pointing north and south.
Definition Cursor.hpp:84
@ Wait
Infrared-beam.
Definition Cursor.hpp:76
@ NumSystemCursors
Hand.
Definition Cursor.hpp:87
@ SizeNS
Double arrow pointing west and east.
Definition Cursor.hpp:83
@ Beam
Arrow.
Definition Cursor.hpp:75
@ WaitArrow
Crosshair.
Definition Cursor.hpp:78
@ SizeNESW
Double arrow pointing northwest and southeast.
Definition Cursor.hpp:81
@ Hand
Slashed circle or crossbones.
Definition Cursor.hpp:86
SDL_Cursor * cursor(void) const
Get the active mouse cursor.
void set_system_cursor(Type id)
Set a platform-dependent system cursor.
void show_cursor(bool state)
Toggle the visibility state of the cursor.
void set_cursor(SDL_Cursor *cursor)
Set the active cursor.
Type system_cursor_
Track the active system cursor in use.
Definition Cursor.hpp:141
bool cursor_state(void) const
Get the state of the cursor.
~Cursor(void)
Destructor.
SDL_Cursor * default_cursor(void) const
Get the default mouse cursor.
Cursor(void)
Default constructor.
uint32 state
32-bit button bit-mask of the current button state.
Definition Cursor.hpp:55
Point2i pos
The X & Y coordinates of the mouse cursor position, relative to the focused window.
Definition Cursor.hpp:52