TGUI 1.13
Loading...
Searching...
No Matches
BackendGuiGLFW.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2026 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#ifndef TGUI_BACKEND_GUI_GLFW_HPP
26#define TGUI_BACKEND_GUI_GLFW_HPP
27
28#include <TGUI/Config.hpp>
29
30#include <TGUI/Backend/Window/BackendGui.hpp>
31
32#include <TGUI/Optional.hpp>
33
35
36using GLFWwindow = struct GLFWwindow;
37
39
40TGUI_IGNORE_DEPRECATED_WARNINGS_START // Required for VS2017 due to inheriting a function that we deprecated
41
42 namespace tgui
43{
45
46 class TGUI_API BackendGuiGLFW : public BackendGui
47 {
48 public:
55
59 ~BackendGuiGLFW() override;
60
66 bool windowFocusCallback(int focused);
67
74 bool sizeCallback(int width, int height);
75
81 bool charCallback(unsigned int codepoint);
82
91 bool keyCallback(int key, int scancode, int action, int mods);
92
99 bool scrollCallback(double xoffset, double yoffset);
100
107 bool cursorPosCallback(double xpos, double ypos);
108
116 bool mouseButtonCallback(int button, int action, int mods);
117
123 bool cursorEnterCallback(int entered);
124
147 void mainLoop(Color clearColor = {240, 240, 240}) override;
148
155 [[nodiscard]] Optional<Event> convertWindowFocusEvent(int focused);
156
164 [[nodiscard]] Optional<Event> convertSizeEvent(int width, int height);
165
172 [[nodiscard]] Optional<Event> convertCharEvent(unsigned int codepoint);
173
183 [[nodiscard]] Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
184
192 [[nodiscard]] Optional<Event> convertScrollEvent(double xoffset, double yoffset);
193
201 [[nodiscard]] Optional<Event> convertCursorPosEvent(double xpos, double ypos);
202
211 [[nodiscard]] Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
212
219 [[nodiscard]] Optional<Event> convertCursorEnterEvent(int entered);
220
226 GLFWwindow* getWindow() const;
227
237 void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos) override;
238
246 [[nodiscard]] bool isKeyboardModifierPressed(Event::KeyModifier modifierKey) const override;
247
249
250 protected:
256 void setGuiWindow(GLFWwindow* window);
257
259 // Updates the view and changes the size of the root container when needed
261 void updateContainerSize() override;
262
264
265 protected:
266 GLFWwindow* m_window = nullptr;
267 };
268} // namespace tgui
269
270TGUI_IGNORE_DEPRECATED_WARNINGS_END
271
272#endif // TGUI_BACKEND_GUI_GLFW_HPP
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.
bool isKeyboardModifierPressed(Event::KeyModifier modifierKey) const override
Checks the state for one of the modifier keys.
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() override
Destructor.
BackendGui()
Default constructor.
Wrapper for colors.
Definition Color.hpp:63
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:37
KeyModifier
Modifiers keys.
Definition Event.hpp:155