TGUI  1.0-alpha
BackendGuiSDL.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2022 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#include <TGUI/Backend/Window/BackendGui.hpp>
30#include <TGUI/extlibs/IncludeSDL.hpp>
31#include <SDL_touch.h>
32
34
35namespace tgui
36{
38
39 class TGUI_API BackendGuiSDL : public BackendGui
40 {
41 public:
42
48 BackendGuiSDL() = default;
49
50
67 bool handleEvent(const SDL_Event& event);
69
70
98 void mainLoop(Color clearColor = {240, 240, 240}) override;
99
100
109 bool convertEvent(const SDL_Event& eventSDL, Event& eventTGUI);
110
111
113 protected:
114
120 void setGuiWindow(SDL_Window* window);
121
122
124 // Updates the view and changes the size of the root container when needed
126 void updateContainerSize() override;
127
128
130 protected:
131
135 virtual void presentScreen() = 0;
136
137
139 protected:
140
141 SDL_Window* m_window = nullptr;
142
143 bool m_touchFirstFingerDown = false;
144 SDL_FingerID m_touchFirstFingerId = 0; // Only valid if m_touchFirstFingerDown is true
145 SDL_TouchID m_touchFirstFingerTouchId = 0; // Only valid if m_touchFirstFingerDown is true
146
148 };
149}
150
152
153#endif // TGUI_BACKEND_GUI_SDL_HPP
Definition: BackendGuiSDL.hpp:40
void mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
BackendGuiSDL()=default
Default constructor.
void setGuiWindow(SDL_Window *window)
Sets the window on which the gui should be drawn.
bool convertEvent(const SDL_Event &eventSDL, Event &eventTGUI)
Helper function that converts an SDL event to a TGUI event.
bool handleEvent(const SDL_Event &event)
Passes the event to the widgets.
virtual void presentScreen()=0
Shows the drawn content with SDL_GL_SwapWindow or SDL_RenderPresent, depending on the renderer.
Base class for the Gui.
Definition: BackendGui.hpp:45
bool handleEvent(Event event)
Passes the event to the widgets.
Wrapper for colors.
Definition: Color.hpp:63
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
Definition: Event.hpp:37