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);
105 size_t default_ibl_resolution = 256;
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
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
Viewer(const std::string &window_title, int window_width, int window_height)
Creates a window with given title and size and default options.
Definition Viewer.cpp:107
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:23
Main namespace for Lagrange.
Window creation options.
Definition Viewer.h:70
int monitor_index
Which monitor to create window on.
Definition Viewer.h:89
std::string window_title
Window title.
Definition Viewer.h:72
bool vsync
Enable vertical sync to limit framerate.
Definition Viewer.h:87
Color selection_color
Color for selection silhouette.
Definition Viewer.h:116
int width
Initial window width.
Definition Viewer.h:79
bool fullscreen
Fullscreen mode - not recommended.
Definition Viewer.h:85
std::string imgui_ini_path
Path to imgui .ini file If not set, the .ini file will be at APPDATA%/_window_title....
Definition Viewer.h:113
int pos_y
Initial window Y position. Set -1 for automatic position.
Definition Viewer.h:77
bool window_fullscreen
Maximizes window (with current resolution)
Definition Viewer.h:83
int gl_version_major
Major OpenGL Version.
Definition Viewer.h:92
int pos_x
Initial window X position. Set -1 for automatic position.
Definition Viewer.h:75
bool show_default_ibl
Default Image Based Light environment map to load.
Definition Viewer.h:104
bool focus_on_show
Focus the window.
Definition Viewer.h:96
int height
Initial window height.
Definition Viewer.h:81
int gl_version_minor
Minor OpenGL Version.
Definition Viewer.h:94
bool show_topbar_menu
Enable rendering of the default menu.
Definition Viewer.h:108
bool use_srgb
Use sRGB framebuffer if supported.
Definition Viewer.h:119