TGUI  0.9.2
GuiSDL.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2021 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages 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 freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25
26#ifndef TGUI_BACKEND_GUI_SDL_HPP
27#define TGUI_BACKEND_GUI_SDL_HPP
28
29
30#include <TGUI/GuiBase.hpp>
31
32#include <SDL.h>
33#include <SDL_touch.h>
34
36
37namespace tgui
38{
39 class BackendRenderTargetSDL;
40
44 class TGUI_API GuiSDL : public GuiBase
45 {
46 public:
47
54
55
63 GuiSDL(SDL_Window* window);
64
65
71 void setWindow(SDL_Window* window);
72
73
90 bool handleEvent(const SDL_Event& event);
92
93
97 void draw() override;
98
99
125 void mainLoop() override;
126
127
136 bool convertEvent(const SDL_Event& eventSDL, Event& eventTGUI);
137
138
140 protected:
141
143 // Function that is called when constructing the Gui
145 void init() override;
146
147
149 // Updates the view and changes the size of the root container when needed
151 void updateContainerSize() override;
152
153
155 protected:
156
157 std::shared_ptr<BackendRenderTargetSDL> m_renderTarget = nullptr;
158
159 Vector2i m_windowSize;
160
161 bool m_touchFirstFingerDown = false;
162 SDL_FingerID m_touchFirstFingerId = 0; // Only valid if m_touchFirstFingerDown is true
163 SDL_TouchID m_touchFirstFingerTouchId = 0; // Only valid if m_touchFirstFingerDown is true
164
166 };
167}
168
170
171#endif // TGUI_BACKEND_GUI_SDL_HPP
Base class for the Gui.
Definition: GuiBase.hpp:45
bool handleEvent(Event event)
Passes the event to the widgets.
Gui class for the SDL backend.
Definition: GuiSDL.hpp:45
bool convertEvent(const SDL_Event &eventSDL, Event &eventTGUI)
Helper function that converts an SDL event to a TGUI event.
GuiSDL(SDL_Window *window)
Constructs the gui and set the window on which the gui should be drawn.
void draw() override
Draws all the widgets that were added to the gui.
GuiSDL()
Default constructor.
bool handleEvent(const SDL_Event &event)
Passes the event to the widgets.
void mainLoop() override
Give the gui control over the main loop.
void setWindow(SDL_Window *window)
Sets the window on which the gui should be drawn.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Definition: Event.hpp:37