TGUI  1.3-dev
Loading...
Searching...
No Matches
BackendGuiGLFW.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_GLFW_HPP
27#define TGUI_BACKEND_GUI_GLFW_HPP
28
29#include <TGUI/Config.hpp>
30#if !TGUI_BUILD_AS_CXX_MODULE
31 #include <TGUI/Backend/Window/BackendGui.hpp>
32 #include <TGUI/Optional.hpp>
33#endif
34
36
37#if !TGUI_BUILD_AS_CXX_MODULE
38 using GLFWwindow = struct GLFWwindow;
39#endif
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
64
70 bool windowFocusCallback(int focused);
71
78 bool sizeCallback(int width, int height);
79
85 bool charCallback(unsigned int codepoint);
86
95 bool keyCallback(int key, int scancode, int action, int mods);
96
103 bool scrollCallback(double xoffset, double yoffset);
104
111 bool cursorPosCallback(double xpos, double ypos);
112
120 bool mouseButtonCallback(int button, int action, int mods);
121
127 bool cursorEnterCallback(int entered);
128
151 void mainLoop(Color clearColor = {240, 240, 240}) override;
152
159 TGUI_NODISCARD Optional<Event> convertWindowFocusEvent(int focused);
160
168 TGUI_NODISCARD Optional<Event> convertSizeEvent(int width, int height);
169
176 TGUI_NODISCARD Optional<Event> convertCharEvent(unsigned int codepoint);
177
187 TGUI_NODISCARD Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
188
196 TGUI_NODISCARD Optional<Event> convertScrollEvent(double xoffset, double yoffset);
197
205 TGUI_NODISCARD Optional<Event> convertCursorPosEvent(double xpos, double ypos);
206
215 TGUI_NODISCARD Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
216
223 TGUI_NODISCARD Optional<Event> convertCursorEnterEvent(int entered);
224
230 GLFWwindow* getWindow() const;
231
241 void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override;
242
244 protected:
245
251 void setGuiWindow(GLFWwindow* window);
252
254 // Updates the view and changes the size of the root container when needed
256 void updateContainerSize() override;
257
259 protected:
260
261 GLFWwindow* m_window = nullptr;
262
264 };
265}
266
267TGUI_IGNORE_DEPRECATED_WARNINGS_END
268
270
271#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 cursorEnterCallback(int entered)
Inform the gui that the mouse has left or entered the window when a callback from glfwSetCursorEnterC...
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