TGUI  0.10-beta
BackendGuiGLFW.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_GLFW_HPP
27#define TGUI_BACKEND_GUI_GLFW_HPP
28
29#include <TGUI/Backend/Window/BackendGui.hpp>
30#include <TGUI/Optional.hpp>
31
33
34typedef struct GLFWwindow GLFWwindow;
35
37
38namespace tgui
39{
41
42 class TGUI_API BackendGuiGLFW : public BackendGui
43 {
44 public:
45
51 BackendGuiGLFW() = default;
52
53
58 void windowFocusCallback(int focused);
59
60
66 void sizeCallback(int width, int height);
67
68
73 void charCallback(unsigned int codepoint);
74
75
83 void keyCallback(int key, int scancode, int action, int mods);
84
85
91 void scrollCallback(double xoffset, double yoffset);
92
93
99 void cursorPosCallback(double xpos, double ypos);
100
101
108 void mouseButtonCallback(int button, int action, int mods);
109
110
133 void mainLoop(Color clearColor = {240, 240, 240}) override;
134
135
142 Optional<Event> convertWindowFocusEvent(int focused);
143
144
152 Optional<Event> convertSizeEvent(int width, int height);
153
154
161 Optional<Event> convertCharEvent(unsigned int codepoint);
162
163
173 Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
174
175
183 Optional<Event> convertScrollEvent(double xoffset, double yoffset);
184
185
193 Optional<Event> convertCursorPosEvent(double xpos, double ypos);
194
195
204 Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
205
206
208 protected:
209
215 void setGuiWindow(GLFWwindow* window);
216
217
219 // Updates the view and changes the size of the root container when needed
221 void updateContainerSize() override;
222
223
225 protected:
226
227 GLFWwindow* m_window = nullptr;
228
230 };
231}
232
234
235#endif // TGUI_BACKEND_GUI_GLFW_HPP
Definition: BackendGuiGLFW.hpp:43
void keyCallback(int key, int scancode, int action, int mods)
Inform the gui about a key event when a callback from glfwSetKeyCallback occurs.
void setGuiWindow(GLFWwindow *window)
Sets the window on which the gui should be drawn.
void windowFocusCallback(int focused)
Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs.
BackendGuiGLFW()=default
Default constructor.
void charCallback(unsigned int codepoint)
Inform the gui about a char event when a callback from glfwSetCharCallback occurs.
void sizeCallback(int width, int height)
Inform the gui about a framebuffer size event when a callback from glfwSetFramebufferSizeCallback occ...
void mainLoop(Color clearColor={240, 240, 240}) override
Give the gui control over the main loop.
void mouseButtonCallback(int button, int action, int mods)
Inform the gui about a mouse button event when a callback from glfwSetMouseButtonCallback occurs.
void cursorPosCallback(double xpos, double ypos)
Inform the gui about a cursor position event when a callback from glfwSetCursorPosCallback occurs.
void scrollCallback(double xoffset, double yoffset)
Inform the gui about a scroll event when a callback from glfwSetScrollCallback occurs.
Base class for the Gui.
Definition: BackendGui.hpp:45
Wrapper for colors.
Definition: Color.hpp:63
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36