-
Notifications
You must be signed in to change notification settings - Fork 15
/
window.h
executable file
·87 lines (61 loc) · 2.06 KB
/
window.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef _WINDOW_H_
#define _WINDOW_H_
#include <SDL.h>
#include "controller_buttons.h"
#include "sdl_backports.h"
class CWindow
{
public:
// Destructor
virtual ~CWindow(void);
// Execute main loop of the window
int execute();
// Draw window
virtual void render(const bool p_focus) const = 0;
// Is window full screen?
virtual bool isFullScreen(void) const;
// Call SDL_Start/StopTextInput accordingly.
virtual bool handlesTextInput() const;
protected:
// Constructor
CWindow(void);
// Window resized.
virtual void onResize();
// Mouse down event.
// Return true if re-render is needed after handling this.
virtual bool mouseDown(int button, int x, int y);
// Mouse wheel event.
// `dx` - the amount scrolled horizontally, positive to the right and negative to the left.
// `dy` - the amount scrolled vertically, positive away from the user and negative towards the user.
// Return true if re-render is needed after handling this.
virtual bool mouseWheel(int dx, int dy);
// Key press management
virtual bool keyPress(
const SDL_Event &event, SDLC_Keycode key, ControllerButton button);
// Key hold management
virtual bool keyHold();
#if SDL_VERSION_ATLEAST(2, 0, 0)
virtual bool gamepadHold(SDL_GameController *controller);
#endif
// SDL2 text input events: SDL_TEXTINPUT and SDL_TEXTEDITING
virtual bool textInput(const SDL_Event &event);
// Timer tick
bool tick(SDLC_Keycode p_held);
#if SDL_VERSION_ATLEAST(2, 0, 0)
bool tick(SDL_GameController *controller, ControllerButton button);
#endif
// Timers for repeated events
unsigned int m_keyHoldCountdown;
unsigned int m_controllerButtonCountdown;
SDLC_Keycode m_lastPressed;
ControllerButton m_lastPressedButton;
// Return value
int m_retVal;
private:
bool handleZoomTrigger(const SDL_Event &event);
void triggerOnResize();
// Forbidden
CWindow(const CWindow &p_source);
const CWindow &operator =(const CWindow &p_source);
};
#endif