TGUI  1.0.0
Loading...
Searching...
No Matches
BackendGuiGLFW.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2023 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_GLFW_HPP
27#define TGUI_BACKEND_GUI_GLFW_HPP
28
29#include <TGUI/Config.hpp>
30#if TGUI_BUILD_AS_CXX_MODULE
31 import tgui;
32#else
33 #include <TGUI/Backend/Window/BackendGui.hpp>
34 #include <TGUI/Optional.hpp>
35#endif
36
38
39using GLFWwindow = struct GLFWwindow;
40
42
43TGUI_IGNORE_DEPRECATED_WARNINGS_START // Required for VS2017 due to inheriting a function that we deprecated
44
45TGUI_MODULE_EXPORT namespace tgui
46{
48
49 class TGUI_API BackendGuiGLFW : public BackendGui
50 {
51 public:
52
59
60
65
66
72 bool windowFocusCallback(int focused);
73
74
81 bool sizeCallback(int width, int height);
82
83
89 bool charCallback(unsigned int codepoint);
90
91
100 bool keyCallback(int key, int scancode, int action, int mods);
101
102
109 bool scrollCallback(double xoffset, double yoffset);
110
111
118 bool cursorPosCallback(double xpos, double ypos);
119
120
128 bool mouseButtonCallback(int button, int action, int mods);
129
130
153 void mainLoop(Color clearColor = {240, 240, 240}) override;
154
155
162 TGUI_NODISCARD Optional<Event> convertWindowFocusEvent(int focused);
163
164
172 TGUI_NODISCARD Optional<Event> convertSizeEvent(int width, int height);
173
174
181 TGUI_NODISCARD Optional<Event> convertCharEvent(unsigned int codepoint);
182
183
193 TGUI_NODISCARD Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
194
195
203 TGUI_NODISCARD Optional<Event> convertScrollEvent(double xoffset, double yoffset);
204
205
213 TGUI_NODISCARD Optional<Event> convertCursorPosEvent(double xpos, double ypos);
214
215
224 TGUI_NODISCARD Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
225
226
232 GLFWwindow* getWindow() const;
233
234
244 void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override;
245
246
248 protected:
249
255 void setGuiWindow(GLFWwindow* window);
256
257
259 // Updates the view and changes the size of the root container when needed
261 void updateContainerSize() override;
262
263
265 protected:
266
267 GLFWwindow* m_window = nullptr;
268
270 };
271}
272
273TGUI_IGNORE_DEPRECATED_WARNINGS_END
274
276
277#endif // TGUI_BACKEND_GUI_GLFW_HPP
Definition BackendGuiGLFW.hpp:50
GLFWwindow * getWindow() const
Returns the window that was provided to the gui.
bool mouseButtonCallback(int button, int action, int mods)
Inform the gui about a mouse button event when a callback from glfwSetMouseButtonCallback occurs.
void setGuiWindow(GLFWwindow *window)
Sets the window on which the gui should be drawn.
bool scrollCallback(double xoffset, double yoffset)
Inform the gui about a scroll event when a callback from glfwSetScrollCallback occurs.
bool charCallback(unsigned int codepoint)
Inform the gui about a char event when a callback from glfwSetCharCallback occurs.
BackendGuiGLFW()
Default constructor.
void mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
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...
bool keyCallback(int key, int scancode, int action, int mods)
Inform the gui about a key event when a callback from glfwSetKeyCallback occurs.
bool sizeCallback(int width, int height)
Inform the gui about a framebuffer size event when a callback from glfwSetFramebufferSizeCallback occ...
bool cursorPosCallback(double xpos, double ypos)
Inform the gui about a cursor position event when a callback from glfwSetCursorPosCallback occurs.
bool windowFocusCallback(int focused)
Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs.
~BackendGuiGLFW()
Destructor.
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