Lagrange
Viewer Class Reference

Viewer use systems() to add functions that should be called every frame use registry() or util functions to read and manipulate application's state. More...

#include <lagrange/ui/Viewer.h>

Classes

struct  WindowOptions
 Window creation options. More...
 

Public Member Functions

bool is_key_down (ImGuiKey key)
 
bool is_key_pressed (ImGuiKey key)
 
bool is_key_released (ImGuiKey key)
 
bool is_mouse_down (ImGuiKey key)
 
bool is_mouse_clicked (ImGuiKey key)
 
bool is_mouse_released (ImGuiKey key)
 
InputStateget_input ()
 Returns keyboard and mouse state.
 
const InputStateget_input () const
 Returns keyboard and mouse state.
 
 Viewer (const std::string &window_title, int window_width, int window_height)
 Creates a window with given title and size and default options. More...
 
 Viewer (int argc, char **argv)
 Creates a window with filename as title. More...
 
 Viewer (const WindowOptions &window_options)
 Creates a window with given options. More...
 
 operator ui::Registry & ()
 
 operator const ui::Registry & () const
 
bool should_close () const
 UI action wants the window to close. More...
 
bool run (const std::function< bool(Registry &r)> &main_loop)
 Runs the viewer until closed by the user or main_loop returns false.
 
bool run (const std::function< void(void)> &main_loop={})
 Runs the viewer until closed by the user.
 
bool is_initialized () const
 Returns true if viewer initialized succesfully.
 
bool is_show_topbar_menu () const
 Returns true if the default menu is rendered.
 
void set_show_topbar_menu (bool show_topbar_menu)
 Set if the default menu is rendered.
 
double get_frame_elapsed_time () const
 Returns elapsed time in seconds from the last frame.
 
int get_width () const
 
int get_height () const
 
const std::string & get_imgui_config_path () const
 
float get_window_scaling () const
 Returns UI window scaling (when Windows or retina scaling is active)
 
Keybindsget_keybinds ()
 Returns keybinds object.
 
const Keybindsget_keybinds () const
 Returns keybinds object.
 
Registry & registry ()
 Returns reference to the registry.
 
const Registry & registry () const
 Returns reference to the registry.
 
const Systemssystems () const
 Returns reference to the systems.
 
Systemssystems ()
 Returns reference to the systems.
 
std::future< void > run_on_main_thread (std::function< void(void)> fn)
 Enqueues fn to be run on the main thread.
 
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.
 
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 std::numeric_limits<unsigned int>::max() for no limit.
 

Static Public Member Functions

static std::string get_config_folder ()
 

Protected Member Functions

virtual void draw_menu ()
 

Detailed Description

Viewer use systems() to add functions that should be called every frame use registry() or util functions to read and manipulate application's state.

Constructor & Destructor Documentation

◆ Viewer() [1/3]

Viewer ( const std::string &  window_title,
int  window_width,
int  window_height 
)

Creates a window with given title and size and default options.

Parameters
[in]window_titleWindow title
[in]window_widthInitial window width
[in]window_heightInitial window height

◆ Viewer() [2/3]

Viewer ( int  argc,
char **  argv 
)

Creates a window with filename as title.

Parameters
[in]argcCLI argument count
[in]argvCLI argument array

◆ Viewer() [3/3]

Viewer ( const WindowOptions window_options)

Creates a window with given options.

Parameters
[in]window_optionsWindow creation options

Member Function Documentation

◆ should_close()

bool should_close ( ) const

UI action wants the window to close.

Returns
window should close

The documentation for this class was generated from the following files: