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 "export.hpp"
35#include "nomlib/config.hpp"
36#include "nomlib/math/Point2.hpp"
37
38// Forward declarations
39struct SDL_Cursor;
40
41namespace nom {
42
43namespace priv {
44
45NOM_EXPORT void free_cursor( SDL_Cursor* c );
46
47} // namespace priv
48
49struct NOM_EXPORT MouseState
50{
53 Point2i pos;
54
56 uint32 state;
57};
58
63class NOM_EXPORT Cursor
64{
65 public:
66 typedef Cursor self_type;
67
68 typedef self_type* raw_ptr;
69
90
92 Cursor( void );
93
95 ~Cursor( void );
96
104 SDL_Cursor* cursor( void ) const;
105
109 SDL_Cursor* default_cursor( void ) const;
110
114 NOM_EXPORT static MouseState mouse_state( void );
115
116 Type system_cursor( void ) const;
117
122
127 bool cursor_state( void ) const;
128
132 void show_cursor( bool state );
133
134 private:
139 void set_cursor( SDL_Cursor* cursor );
140
143
144 // std::unique_ptr<SDL_Cursor, void(*) (SDL_Cursor*)> cursor_;
145};
146
147} // namespace nom
148
149#endif // include guard defined
Type
The mouse cursor types.
Definition Cursor.hpp:74
@ No
Four pointed arrow pointing north, south, east and west.
Definition Cursor.hpp:86
@ SizeWE
Double arrow pointing northeast and southwest.
Definition Cursor.hpp:83
@ CrossHair
Wait.
Definition Cursor.hpp:78
@ SizeAll
Double arrow pointing north and south.
Definition Cursor.hpp:85
@ Wait
Infrared-beam.
Definition Cursor.hpp:77
@ NumSystemCursors
Hand.
Definition Cursor.hpp:88
@ SizeNS
Double arrow pointing west and east.
Definition Cursor.hpp:84
@ Beam
Arrow.
Definition Cursor.hpp:76
@ WaitArrow
Crosshair.
Definition Cursor.hpp:79
@ SizeNESW
Double arrow pointing northwest and southeast.
Definition Cursor.hpp:82
@ Hand
Slashed circle or crossbones.
Definition Cursor.hpp:87
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:142
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.
static NOM_EXPORT MouseState mouse_state(void)
Retrieve the current state of the mouse.
uint32 state
32-bit button bit-mask of the current button state.
Definition Cursor.hpp:56
Point2i pos
The X & Y coordinates of the mouse cursor position, relative to the focused window.
Definition Cursor.hpp:53