lxgui
Public Member Functions | Public Attributes | List of all members
lxgui::gui::manager Class Reference

Manages the user interface. More...

#include <gui_manager.hpp>

Inheritance diagram for lxgui::gui::manager:

Public Member Functions

 manager (utils::control_block &block, std::unique_ptr< input::source > src, std::unique_ptr< renderer > rdr)
 Constructor. More...
 
 ~manager () override
 Destructor. More...
 
 manager (const manager &)=delete
 
 manager (manager &&)=delete
 
manageroperator= (const manager &)=delete
 
manageroperator= (manager &&)=delete
 
void set_interface_scaling_factor (float scaling_factor)
 Sets the global UI scaling factor. More...
 
float get_interface_scaling_factor () const
 Returns the current UI scaling factor. More...
 
void enable_caching (bool enable_caching)
 Enables or disables interface caching. More...
 
void toggle_caching ()
 Toggles interface caching. More...
 
bool is_caching_enabled () const
 Checks if interface caching is enabled. More...
 
void add_addon_directory (const std::string &directory)
 Adds a new directory to be parsed for UI addons. More...
 
void clear_addon_directory_list ()
 Clears the addon directory list. More...
 
void add_localization_directory (const std::string &directory)
 Adds a new directory to be parsed for localization. More...
 
void clear_localization_directory_list ()
 Clears the localization directory list. More...
 
std::string print_ui () const
 Prints debug information in the log file. More...
 
void load_ui ()
 Loads the UI. More...
 
void close_ui ()
 Closes the UI safely (at the end of update_ui()). More...
 
void close_ui_now ()
 Closes the UI (immediately). More...
 
void reload_ui ()
 Closes the UI and load it again safely (at the end of update_ui()). More...
 
void reload_ui_now ()
 Closes the UI and load it again (immediately). More...
 
bool is_loaded () const
 Checks if the UI has been loaded. More...
 
void render_ui () const
 Renders the UI into the current render target. More...
 
void update_ui (float delta)
 Updates this manager and its regions. More...
 
sol::state & get_lua ()
 Returns the GUI Lua state (sol wrapper). More...
 
const sol::state & get_lua () const
 Returns the GUI Lua state (sol wrapper). More...
 
const rendererget_renderer () const
 Returns the renderer implementation. More...
 
rendererget_renderer ()
 Returns the renderer implementation. More...
 
const input::windowget_window () const
 Returns the window in which this gui is being displayed. More...
 
input::windowget_window ()
 Returns the window in which this gui is being displayed. More...
 
const input::dispatcherget_input_dispatcher () const
 Returns the input manager associated to this gui. More...
 
input::dispatcherget_input_dispatcher ()
 Returns the input manager associated to this gui. More...
 
const input::world_dispatcherget_world_input_dispatcher () const
 Returns the input manager associated to this gui. More...
 
input::world_dispatcherget_world_input_dispatcher ()
 Returns the input manager associated to this gui. More...
 
const event_emitterget_event_emitter () const
 Returns the gui event emitter. More...
 
event_emitterget_event_emitter ()
 Returns the gui event emitter. More...
 
localizerget_localizer ()
 Returns the object used for localizing strings. More...
 
const localizerget_localizer () const
 Returns the object used for localizing strings. More...
 
rootget_root ()
 Returns the UI root object, which contains root frames. More...
 
const rootget_root () const
 Returns the UI root object, which contains root frames. More...
 
virtual_rootget_virtual_root ()
 Returns the UI root object, which contains root frames. More...
 
const virtual_rootget_virtual_root () const
 Returns the UI root object, which contains root frames. More...
 
factoryget_factory ()
 Returns the UI object factory, which is used to create new objects. More...
 
const factoryget_factory () const
 Returns the UI object factory, which is used to create new objects. More...
 
addon_registryget_addon_registry ()
 Returns the addon registry, which keeps track of loaded addons. More...
 
const addon_registryget_addon_registry () const
 Returns the addon registry, which keeps track of loaded addons. More...
 

Public Attributes

utils::signal< void(sol::state &)> on_create_lua
 Triggers on each fresh Lua state (e.g., on startup or after a UI re-load). More...
 

Detailed Description

Manages the user interface.

Definition at line 44 of file gui_manager.hpp.

Constructor & Destructor Documentation

◆ manager() [1/3]

lxgui::gui::manager::manager ( utils::control_block &  block,
std::unique_ptr< input::source src,
std::unique_ptr< renderer rdr 
)

Constructor.

Parameters
blockThe owner pointer control block
srcThe input source to use
rdrThe renderer implementation

Definition at line 36 of file gui_manager.cpp.

◆ ~manager()

lxgui::gui::manager::~manager ( )
override

Destructor.

Definition at line 66 of file gui_manager.cpp.

◆ manager() [2/3]

lxgui::gui::manager::manager ( const manager )
delete

◆ manager() [3/3]

lxgui::gui::manager::manager ( manager &&  )
delete

Member Function Documentation

◆ add_addon_directory()

void lxgui::gui::manager::add_addon_directory ( const std::string &  directory)

Adds a new directory to be parsed for UI addons.

Parameters
directoryThe new directory
Note
If the UI is already loaded, this change will only take effect after the UI is reloaded, see reload_ui().

Definition at line 110 of file gui_manager.cpp.

◆ add_localization_directory()

void lxgui::gui::manager::add_localization_directory ( const std::string &  directory)

Adds a new directory to be parsed for localization.

Parameters
directoryThe new directory
Note
If the UI is already loaded, this change will only take effect after the UI is reloaded, see reload_ui().

Definition at line 119 of file gui_manager.cpp.

◆ clear_addon_directory_list()

void lxgui::gui::manager::clear_addon_directory_list ( )

Clears the addon directory list.

Note
This is useful whenever you need to reload a completely different UI (for example, when switching from your game's main menu to the real game).
If the UI is already loaded, this change will only take effect after the UI is reloaded, see reload_ui().

Definition at line 115 of file gui_manager.cpp.

◆ clear_localization_directory_list()

void lxgui::gui::manager::clear_localization_directory_list ( )

Clears the localization directory list.

Note
This is useful whenever you need to reload a completely different UI (for example, when switching from your game's main menu to the real game).
If the UI is already loaded, this change will only take effect after the UI is reloaded, see reload_ui().

Definition at line 124 of file gui_manager.cpp.

◆ close_ui()

void lxgui::gui::manager::close_ui ( )

Closes the UI safely (at the end of update_ui()).

Note
The actual closing will be deferred until the end of update_ui(), therefore it is safe to call this function at any time. If you need to close the UI without delay, use close_ui_now().

Definition at line 165 of file gui_manager.cpp.

◆ close_ui_now()

void lxgui::gui::manager::close_ui_now ( )

Closes the UI (immediately).

Note
All regions will be deleted, and the Lua state will be closed.
Warning
Do not call this function while the manager is running update_ui() (i.e., do not call this directly from a frame's callback, C++ or Lua).

Definition at line 169 of file gui_manager.cpp.

◆ enable_caching()

void lxgui::gui::manager::enable_caching ( bool  enable_caching)

Enables or disables interface caching.

Parameters
enable_caching'true' to enable, 'false' to disable
See also
toggle_caching()

Definition at line 91 of file gui_manager.cpp.

◆ get_addon_registry() [1/2]

addon_registry* lxgui::gui::manager::get_addon_registry ( )
inline

Returns the addon registry, which keeps track of loaded addons.

Returns
The registry object

Definition at line 383 of file gui_manager.hpp.

◆ get_addon_registry() [2/2]

const addon_registry* lxgui::gui::manager::get_addon_registry ( ) const
inline

Returns the addon registry, which keeps track of loaded addons.

Returns
The registry object

Definition at line 391 of file gui_manager.hpp.

◆ get_event_emitter() [1/2]

event_emitter& lxgui::gui::manager::get_event_emitter ( )
inline

Returns the gui event emitter.

Returns
The gui event emitter

Definition at line 311 of file gui_manager.hpp.

◆ get_event_emitter() [2/2]

const event_emitter& lxgui::gui::manager::get_event_emitter ( ) const
inline

Returns the gui event emitter.

Returns
The gui event emitter

Definition at line 303 of file gui_manager.hpp.

◆ get_factory() [1/2]

factory& lxgui::gui::manager::get_factory ( )
inline

Returns the UI object factory, which is used to create new objects.

Returns
The factory object

Definition at line 367 of file gui_manager.hpp.

◆ get_factory() [2/2]

const factory& lxgui::gui::manager::get_factory ( ) const
inline

Returns the UI object factory, which is used to create new objects.

Returns
The factory object

Definition at line 375 of file gui_manager.hpp.

◆ get_input_dispatcher() [1/2]

input::dispatcher& lxgui::gui::manager::get_input_dispatcher ( )
inline

Returns the input manager associated to this gui.

Returns
The input manager associated to this gui

Definition at line 279 of file gui_manager.hpp.

◆ get_input_dispatcher() [2/2]

const input::dispatcher& lxgui::gui::manager::get_input_dispatcher ( ) const
inline

Returns the input manager associated to this gui.

Returns
The input manager associated to this gui

Definition at line 271 of file gui_manager.hpp.

◆ get_interface_scaling_factor()

float lxgui::gui::manager::get_interface_scaling_factor ( ) const

Returns the current UI scaling factor.

Returns
The current UI scaling factor
See also
set_interface_scaling_factor()

Definition at line 87 of file gui_manager.cpp.

◆ get_localizer() [1/2]

localizer& lxgui::gui::manager::get_localizer ( )
inline

Returns the object used for localizing strings.

Returns
The current localizer

Definition at line 319 of file gui_manager.hpp.

◆ get_localizer() [2/2]

const localizer& lxgui::gui::manager::get_localizer ( ) const
inline

Returns the object used for localizing strings.

Returns
The current localizer

Definition at line 327 of file gui_manager.hpp.

◆ get_lua() [1/2]

sol::state & lxgui::gui::manager::get_lua ( )

Returns the GUI Lua state (sol wrapper).

Returns
The GUI Lua state

Definition at line 128 of file gui_manager.cpp.

◆ get_lua() [2/2]

const sol::state & lxgui::gui::manager::get_lua ( ) const

Returns the GUI Lua state (sol wrapper).

Returns
The GUI Lua state

Definition at line 132 of file gui_manager.cpp.

◆ get_renderer() [1/2]

renderer& lxgui::gui::manager::get_renderer ( )
inline

Returns the renderer implementation.

Returns
The renderer implementation

Definition at line 247 of file gui_manager.hpp.

◆ get_renderer() [2/2]

const renderer& lxgui::gui::manager::get_renderer ( ) const
inline

Returns the renderer implementation.

Returns
The renderer implementation

Definition at line 239 of file gui_manager.hpp.

◆ get_root() [1/2]

root& lxgui::gui::manager::get_root ( )
inline

Returns the UI root object, which contains root frames.

Returns
The root object

Definition at line 335 of file gui_manager.hpp.

◆ get_root() [2/2]

const root& lxgui::gui::manager::get_root ( ) const
inline

Returns the UI root object, which contains root frames.

Returns
The root object

Definition at line 343 of file gui_manager.hpp.

◆ get_virtual_root() [1/2]

virtual_root& lxgui::gui::manager::get_virtual_root ( )
inline

Returns the UI root object, which contains root frames.

Returns
The root object

Definition at line 351 of file gui_manager.hpp.

◆ get_virtual_root() [2/2]

const virtual_root& lxgui::gui::manager::get_virtual_root ( ) const
inline

Returns the UI root object, which contains root frames.

Returns
The root object

Definition at line 359 of file gui_manager.hpp.

◆ get_window() [1/2]

input::window& lxgui::gui::manager::get_window ( )
inline

Returns the window in which this gui is being displayed.

Returns
The window in which this gui is being displayed

Definition at line 263 of file gui_manager.hpp.

◆ get_window() [2/2]

const input::window& lxgui::gui::manager::get_window ( ) const
inline

Returns the window in which this gui is being displayed.

Returns
The window in which this gui is being displayed

Definition at line 255 of file gui_manager.hpp.

◆ get_world_input_dispatcher() [1/2]

input::world_dispatcher& lxgui::gui::manager::get_world_input_dispatcher ( )
inline

Returns the input manager associated to this gui.

Returns
The input manager associated to this gui

Definition at line 295 of file gui_manager.hpp.

◆ get_world_input_dispatcher() [2/2]

const input::world_dispatcher& lxgui::gui::manager::get_world_input_dispatcher ( ) const
inline

Returns the input manager associated to this gui.

Returns
The input manager associated to this gui

Definition at line 287 of file gui_manager.hpp.

◆ is_caching_enabled()

bool lxgui::gui::manager::is_caching_enabled ( ) const

Checks if interface caching is enabled.

Returns
'true' if interface caching is enabled
See also
toggle_caching()

Definition at line 103 of file gui_manager.cpp.

◆ is_loaded()

bool lxgui::gui::manager::is_loaded ( ) const

Checks if the UI has been loaded.

Returns
'true' if the UI has being loaded

Definition at line 211 of file gui_manager.cpp.

◆ load_ui()

void lxgui::gui::manager::load_ui ( )

Loads the UI.

Note
Creates the Lua state and loads addon files (if any). Calling this function if the UI is already loaded will have no effect. If your intent is to re-load the UI, use reload_ui() instead.

Definition at line 150 of file gui_manager.cpp.

◆ operator=() [1/2]

manager& lxgui::gui::manager::operator= ( const manager )
delete

◆ operator=() [2/2]

manager& lxgui::gui::manager::operator= ( manager &&  )
delete

◆ print_ui()

std::string lxgui::gui::manager::print_ui ( ) const

Prints debug information in the log file.

Note
Calls region::serialize().

Definition at line 234 of file gui_manager.cpp.

◆ reload_ui()

void lxgui::gui::manager::reload_ui ( )

Closes the UI and load it again safely (at the end of update_ui()).

Note
The actual re-loading will be deferred until the end of update_ui(), therefore it is safe to call this function at any time. If you need to reload the UI without delay, use reload_ui_now().

Definition at line 189 of file gui_manager.cpp.

◆ reload_ui_now()

void lxgui::gui::manager::reload_ui_now ( )

Closes the UI and load it again (immediately).

Note
Calls close_ui_now() then load_ui().
Warning
Do not call this function while the manager is running update_ui() (i.e., do not call this directly from a frame's callback, C++ or Lua).

Definition at line 193 of file gui_manager.cpp.

◆ render_ui()

void lxgui::gui::manager::render_ui ( ) const

Renders the UI into the current render target.

Note
This should be called after update_ui().

Definition at line 203 of file gui_manager.cpp.

◆ set_interface_scaling_factor()

void lxgui::gui::manager::set_interface_scaling_factor ( float  scaling_factor)

Sets the global UI scaling factor.

Parameters
scaling_factorThe factor to use for rescaling (1: no rescaling, default)
Note
This value determines how to convert sizing units or position coordinates into actual number of pixels. By default, units specified for sizes and positions are 1:1 mapping with pixels on the screen. If designing the UI on a "traditional" display (say, 1080p resolution monitor), the UI will not scale correctly when running on high-DPI displays unless the scaling factor is adjusted accordingly. The value of the scaling factor should be the ratio DPI_target/DPI_dev, where DPI_dev is the DPI of the display used for development, and DPI_target is the DPI of the display used to run the program. In addition, the scaling factor can also be used to improve accessibility of the interface to users with poorer eye sight, which would benefit from larger font sizes and larger icons.

Definition at line 70 of file gui_manager.cpp.

◆ toggle_caching()

void lxgui::gui::manager::toggle_caching ( )

Toggles interface caching.

Note
Disabled by default. Enabling this will most likely improve performances, at the expense of higher GPU memory usage. The UI will be cached into large render targets, which are only redrawn when the UI changes, rather than redrawn on each frame.

Definition at line 97 of file gui_manager.cpp.

◆ update_ui()

void lxgui::gui::manager::update_ui ( float  delta)

Updates this manager and its regions.

Parameters
deltaThe time elapsed since the last call

Definition at line 215 of file gui_manager.cpp.

Member Data Documentation

◆ on_create_lua

utils::signal<void(sol::state&)> lxgui::gui::manager::on_create_lua

Triggers on each fresh Lua state (e.g., on startup or after a UI re-load).

Note
This signal is useful if you need to create additionnal resources on the Lua state before the GUI files are loaded. This signal will be triggered each time the Lua state is created (e.g., when the GUI is re-loaded, see reload_ui()). If the UI is already loaded, any new callback connected to this signal will only take effect after the UI is reloaded.

Definition at line 157 of file gui_manager.hpp.


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