TGUI  0.9-dev
BackendGuiGLFW.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2021 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
61 BackendGuiGLFW(GLFWwindow* window);
62
63
69 virtual void setWindow(GLFWwindow* window);
70
71
76 void windowFocusCallback(int focused);
77
78
84 void sizeCallback(int width, int height);
85
86
91 void charCallback(unsigned int codepoint);
92
93
101 void keyCallback(int key, int scancode, int action, int mods);
102
103
109 void scrollCallback(double xoffset, double yoffset);
110
111
117 void cursorPosCallback(double xpos, double ypos);
118
119
126 void mouseButtonCallback(int button, int action, int mods);
127
128
149 void mainLoop() override;
150
151
158 Optional<Event> convertWindowFocusEvent(int focused);
159
160
168 Optional<Event> convertSizeEvent(int width, int height);
169
170
177 Optional<Event> convertCharEvent(unsigned int codepoint);
178
179
189 Optional<Event> convertKeyEvent(int key, int scancode, int action, int mods);
190
191
199 Optional<Event> convertScrollEvent(double xoffset, double yoffset);
200
201
209 Optional<Event> convertCursorPosEvent(double xpos, double ypos);
210
211
220 Optional<Event> convertMouseButtonEvent(int button, int action, int mods);
221
222
224 protected:
225
227 // Updates the view and changes the size of the root container when needed
229 void updateContainerSize() override;
230
231
233 protected:
234
235 GLFWwindow* m_window = nullptr;
236
238 };
239}
240
242
243#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 windowFocusCallback(int focused)
Inform the gui about a focus event when a callback from glfwSetWindowFocusCallback occurs.
BackendGuiGLFW()=default
Default constructor.
virtual void setWindow(GLFWwindow *window)
Sets the window on which the gui should be drawn.
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() 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.
BackendGuiGLFW(GLFWwindow *window)
Constructs the gui and set the window on which the gui should be drawn.
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
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36