TGUI  1.3-dev
Loading...
Searching...
No Matches
BackendGuiSFML.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 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#include <TGUI/Config.hpp>
30#if !TGUI_BUILD_AS_CXX_MODULE
31 #include <TGUI/Backend/Window/BackendGui.hpp>
32#endif
33
34#include <SFML/Window.hpp>
35
37
38TGUI_MODULE_EXPORT namespace tgui
39{
41
42 class TGUI_API BackendGuiSFML : public BackendGui
43 {
44 public:
45
52
53
58
59
76 bool handleEvent(sf::Event event);
77 using BackendGui::handleEvent;
78
79
106 void mainLoop(Color clearColor = {240, 240, 240}) override;
107
108
117 TGUI_NODISCARD bool convertEvent(const sf::Event& eventSFML, Event& eventTGUI);
118
119
125 sf::Window* getWindow() const;
126
127
134 void startTextInput(FloatRect inputRect) override;
135
136
141 void stopTextInput() override;
142
143
153 void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override;
154
155
157 protected:
158
164 void setGuiWindow(sf::Window& window);
165
166
168 // Updates the view and changes the size of the root container when needed
170 void updateContainerSize() override;
171
172
174 protected:
175
176 sf::Window* m_window = nullptr;
177
179 };
180}
181
183
184#endif // TGUI_BACKEND_GUI_SFML_HPP
Definition BackendGuiSFML.hpp:43
~BackendGuiSFML()
Destructor.
void setGuiWindow(sf::Window &window)
Sets the window which the gui should use.
sf::Window * getWindow() const
Returns the window that was provided to the gui.
bool handleEvent(sf::Event event)
Passes the event to the widgets.
void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override
This function is called by TGUI when the position of the caret changes in a text field (EditBox or Te...
BackendGuiSFML()
Default constructor.
void mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
TGUI_NODISCARD bool convertEvent(const sf::Event &eventSFML, Event &eventTGUI)
Helper function that converts an SFML event to a TGUI event.
void startTextInput(FloatRect inputRect) override
This function is called by TGUI when focusing a text field (EditBox or TextArea). It will result in t...
void stopTextInput() override
This function is called by TGUI when unfocusing a text field (EditBox or TextArea)....
Base class for the Gui.
Definition BackendGui.hpp:48
Wrapper for colors.
Definition Color.hpp:72
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
Definition Event.hpp:39