galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
NuklearUI.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_UI_NUKLEARUI_HPP_
9#define GALAXY_UI_NUKLEARUI_HPP_
10
11#include <ankerl/unordered_dense.h>
12#include <Nuklear.hpp>
13
14#include "galaxy/events/ContentScale.hpp"
15#include "galaxy/events/KeyChar.hpp"
16#include "galaxy/events/KeyPress.hpp"
17#include "galaxy/events/MousePressed.hpp"
18#include "galaxy/events/MouseWheel.hpp"
19
20namespace galaxy
21{
22 namespace ui
23 {
27 class NuklearUI final
28 {
29 public:
33 NuklearUI();
34
38 ~NuklearUI();
39
45 void on_mouse_pressed(events::MousePressed& e);
46
52 void on_mouse_wheel(events::MouseWheel& e);
53
59 void on_key_char(events::KeyChar& e);
60
66 void on_key_press(events::KeyPress& e);
67
73 void on_content_scale(const events::ContentScale& e);
74
78 void begin_input() const;
79
83 void end_input() const;
84
88 void poll_input() const;
89
93 void new_frame();
94
98 void render();
99
105 void set_font(const std::string& id);
106
112 void toggle_input(const bool enable);
113
121 void show_loading_bar(const char* text, nk_size total, nk_size current);
122
126 void show_building_atlas();
127
133 [[nodiscard]] nk_context* ctx() const;
134
135 private:
141 void scale(const float scale);
142
143 private:
147 nk_glfw* m_ctx;
148
152 nk_font_atlas* m_atlas;
153
157 std::array<int, 4> m_viewport_backup;
158
162 ankerl::unordered_dense::map<std::string, nk_font*> m_fonts;
163 };
164 } // namespace ui
165} // namespace galaxy
166
167#endif
Manages the nuklear ui state.
Definition NuklearUI.hpp:28
void on_mouse_pressed(events::MousePressed &e)
On mouse pressed event handler.
Definition NuklearUI.cpp:45
void show_building_atlas()
Part of the loading screen. Informs the user that the atlas is being built.
void on_mouse_wheel(events::MouseWheel &e)
On mouse wheel event handler.
Definition NuklearUI.cpp:54
void poll_input() const
Calls begin, end and glfwPollEvents.
void toggle_input(const bool enable)
Control the input.
void show_loading_bar(const char *text, nk_size total, nk_size current)
Shows a progress bar for loading screens.
void on_key_press(events::KeyPress &e)
On keyboad press event.
Definition NuklearUI.cpp:72
void end_input() const
Called after glfwPollEvents.
void scale(const float scale)
Scale UI to monitor/window.
~NuklearUI()
Destructor.
Definition NuklearUI.cpp:38
void on_content_scale(const events::ContentScale &e)
On content scale event.
Definition NuklearUI.cpp:92
void on_key_char(events::KeyChar &e)
On typing event handler.
Definition NuklearUI.cpp:63
nk_context * ctx() const
Nuklear Context.
nk_font_atlas * m_atlas
Nuklear atlas pointer.
ankerl::unordered_dense::map< std::string, nk_font * > m_fonts
Fonts used by nuklear.
void begin_input() const
Called before glfwPollEvents.
Definition NuklearUI.cpp:97
nk_glfw * m_ctx
Nuklear context pointer.
void new_frame()
Called before any nuklear code.
void render()
Render nuklear.
std::array< int, 4 > m_viewport_backup
Viewport backup when rendering.
NuklearUI()
Constructor.
Definition NuklearUI.cpp:25
void set_font(const std::string &id)
Change the active font.
Timer.hpp galaxy.
Definition Async.hpp:17