TGUI  0.9.5
Loading...
Searching...
No Matches
GuiSFML.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_SFML_HPP
27#define TGUI_BACKEND_GUI_SFML_HPP
28
29
30#include <TGUI/GuiBase.hpp>
31
32#if TGUI_HAS_BACKEND_SFML
33 #include <SFML/Window/Event.hpp>
34#endif
35
37
38namespace tgui
39{
40 class BackendRenderTargetSFML;
41
45 class TGUI_API GuiSFML : public GuiBase
46 {
47 public:
48
55
56
64 GuiSFML(sf::RenderTarget& target);
65
66
72 void setTarget(sf::RenderTarget& target);
73
74
80 sf::RenderTarget* getTarget() const;
81
82
99 bool handleEvent(sf::Event event);
100 using GuiBase::handleEvent;
101
102
106 void draw() override;
107
108
133 void mainLoop() override;
134
135
144 bool convertEvent(const sf::Event& eventSFML, Event& eventTGUI);
145
146
148 protected:
149
151 // Function that is called when constructing the Gui
153 void init() override;
154
155
157 // Updates the view and changes the size of the root container when needed
159 void updateContainerSize() override;
160
161
163 protected:
164
165 std::shared_ptr<BackendRenderTargetSFML> m_renderTarget = nullptr;
166
167
169 };
170}
171
173
174#endif // TGUI_BACKEND_GUI_SFML_HPP
Base class for the Gui.
Definition GuiBase.hpp:45
Gui class for the SFML backend.
Definition GuiSFML.hpp:46
sf::RenderTarget * getTarget() const
Returns the render target on which the gui is being drawn.
void mainLoop() override
Give the gui control over the main loop.
GuiSFML(sf::RenderTarget &target)
Constructs the gui and set the target on which the gui should be drawn.
void draw() override
Draws all the widgets that were added to the gui.
bool convertEvent(const sf::Event &eventSFML, Event &eventTGUI)
Helper function that converts an SFML event to a TGUI event.
GuiSFML()
Default constructor.
bool handleEvent(sf::Event event)
Passes the event to the widgets.
void setTarget(sf::RenderTarget &target)
Sets the target on which the gui should be drawn.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
Definition Event.hpp:37