15#include <lagrange/ui/Entity.h>
16#include <lagrange/ui/api.h>
17#include <lagrange/ui/default_components.h>
18#include <lagrange/ui/default_keybinds.h>
19#include <lagrange/ui/panels/ViewportPanel.h>
20#include <lagrange/ui/types/Camera.h>
21#include <lagrange/ui/types/Systems.h>
22#include <lagrange/ui/types/Tools.h>
23#include <lagrange/ui/utils/input.h>
24#include <lagrange/ui/utils/layer.h>
25#include <lagrange/ui/utils/uipanel.h>
53 bool is_key_down(ImGuiKey key);
54 bool is_key_pressed(ImGuiKey key);
55 bool is_key_released(ImGuiKey key);
56 bool is_mouse_down(ImGuiKey key);
57 bool is_mouse_clicked(ImGuiKey key);
58 bool is_mouse_released(ImGuiKey key);
72 std::string window_title =
"";
83 bool window_fullscreen =
false;
85 bool fullscreen =
false;
89 int monitor_index = 0;
92 int gl_version_major = 3;
94 int gl_version_minor = 3;
96 bool focus_on_show =
true;
104 bool show_default_ibl =
true;
105 size_t default_ibl_resolution = 256;
108 bool show_topbar_menu =
true;
113 std::string imgui_ini_path =
"";
116 Color selection_color =
Color(252.0f / 255.0f, 86.0f / 255.0f, 3.0f / 255.0f, 1.0f);
119 bool use_srgb =
true;
130 Viewer(
const std::string& window_title,
int window_width,
int window_height);
139 Viewer(
int argc,
char** argv);
150 operator ui::Registry&() {
return registry(); }
152 operator const ui::Registry&()
const {
return registry(); }
158 bool should_close()
const;
163 bool run(
const std::function<
bool(Registry& r)>& main_loop);
168 bool run(
const std::function<
void(
void)>& main_loop = {});
171 bool is_initialized()
const;
180 double get_frame_elapsed_time()
const;
183 int get_width()
const {
return m_width; }
186 int get_height()
const {
return m_height; }
188 const std::string& get_imgui_config_path()
const;
191 float get_window_scaling()
const;
194 Keybinds& get_keybinds();
197 const Keybinds& get_keybinds()
const;
203 const Registry&
registry()
const {
return m_registry; }
212 std::future<void> run_on_main_thread(std::function<
void(
void)> fn);
217 return m_main_thread_max_func_per_frame;
224 m_main_thread_max_func_per_frame = limit;
227 static std::string get_config_folder();
230 virtual void draw_menu();
233 void render_one_frame(
const std::function<
bool(Registry& r)>& main_loop);
235 bool init_glfw(
const WindowOptions& options);
237 bool init_imgui_fonts();
240 void resize(
int window_width,
int window_height);
241 void move(
int x,
int y);
243 void drop(
int count,
const char** paths);
245 void process_input();
249 void start_imgui_frame();
251 void end_imgui_frame();
255 void start_dockspace();
256 void end_dockspace();
258 void show_last_shader_error();
260 WindowOptions m_initial_window_options;
262 GLFWwindow* m_window;
263 ImGuiContext* m_imgui_context;
266 bool m_initialized =
false;
268 static bool m_instance_initialized;
270 std::string m_imgui_ini_path;
276 float m_ui_scaling = 1.0f;
279 std::string m_last_shader_error;
280 std::string m_last_shader_error_desc;
282 bool m_show_imgui_demo =
false;
283 bool m_show_imgui_style =
false;
284 bool m_show_topbar_menu =
true;
286 entt::registry m_registry;
289 Entity m_main_viewport;
294 std::queue<std::pair<std::promise<void>, std::function<void(
void)>>> m_main_thread_fn;
295 std::atomic_uint m_main_thread_max_func_per_frame = std::numeric_limits<unsigned int>::max();
Container for Systems.
Definition: Systems.h:34
Viewer use systems() to add functions that should be called every frame use registry() or util functi...
Definition: Viewer.h:48
bool is_show_topbar_menu() const
Returns true if the default menu is rendered.
Definition: Viewer.h:174
Systems & systems()
Returns reference to the systems.
Definition: Viewer.h:209
bool run(const std::function< bool(Registry &r)> &main_loop)
Runs the viewer until closed by the user or main_loop returns false.
const Systems & systems() const
Returns reference to the systems.
Definition: Viewer.h:206
InputState & get_input()
Returns keyboard and mouse state.
Definition: Viewer.h:61
const InputState & get_input() const
Returns keyboard and mouse state.
Definition: Viewer.h:64
void set_show_topbar_menu(bool show_topbar_menu)
Set if the default menu is rendered.
Definition: Viewer.h:177
void set_main_thread_max_func_per_frame(unsigned int limit)
Sets the limit of how many enqueued functions can be run during a single frame on the main thread Use...
Definition: Viewer.h:222
Registry & registry()
Returns reference to the registry.
Definition: Viewer.h:200
const Registry & registry() const
Returns reference to the registry.
Definition: Viewer.h:203
unsigned int get_main_thread_max_func_per_frame() const
Returns the limit of how many enqueued functions can be run during a single frame on the main thread.
Definition: Viewer.h:215
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
Main namespace for Lagrange.
Definition: AABBIGL.h:30
Window creation options.
Definition: Viewer.h:70