lxgui
|
Root of the UI object hierarchy. More...
#include <gui_root.hpp>
Public Types | |
using | root_frame_list = std::list< utils::owner_ptr< frame > > |
Type of the root frame list. | |
using | root_frame_list_view = utils::view::adaptor< root_frame_list, utils::view::smart_ptr_dereferencer, utils::view::non_null_filter > |
using | const_root_frame_list_view = utils::view::adaptor< const root_frame_list, utils::view::smart_ptr_dereferencer, utils::view::non_null_filter > |
Public Member Functions | |
root (utils::control_block &block, manager &mgr) | |
Constructor. | |
~root () override | |
Destructor. | |
root (const root &)=delete | |
root (root &&)=delete | |
root & | operator= (const root &)=delete |
root & | operator= (root &&)=delete |
vector2f | get_target_dimensions () const override |
Returns the width and height of this renderer's main render target (e.g., screen). | |
void | render () const |
Renders the UI into the current render target. | |
void | enable_caching (bool enable) |
Enables or disables interface caching. | |
void | toggle_caching () |
Toggles interface caching. | |
bool | is_caching_enabled () const |
Checks if interface caching is enabled. | |
void | update (float delta) |
updates this root and its regions. | |
void | notify_scaling_factor_updated () |
Tells this object that the global interface scaling factor has changed. | |
void | notify_hovered_frame_dirty () |
Notifies the root that it should update the hovered frame. | |
const utils::observer_ptr< frame > & | get_hovered_frame () |
Returns the currently hovered frame, if any. | |
utils::observer_ptr< const frame > | get_hovered_frame () const |
Returns the currently hovered frame, if any. | |
bool | is_hovered (const frame &obj) const |
Check if a given frame is being hovered. | |
const utils::observer_ptr< frame > & | get_dragged_frame () |
Returns the currently dragged frame, if any. | |
utils::observer_ptr< const frame > | get_dragged_frame () const |
Returns the currently dragged frame, if any. | |
bool | is_dragged (const frame &obj) const |
Check if a given frame is being dragged. | |
void | start_moving (utils::observer_ptr< region > obj, anchor *a=nullptr, constraint constraint=constraint::none, std::function< void()> apply_constraint_func=nullptr) |
Start manually moving a region with the mouse. | |
void | stop_moving () |
Stops movement for the current object. | |
bool | is_moving (const region &obj) const |
Checks if the given object is allowed to move. | |
void | start_sizing (utils::observer_ptr< region > obj, point p) |
Starts manually resizing a region with the mouse. | |
void | stop_sizing () |
Stops sizing for the current object. | |
bool | is_sizing (const region &obj) const |
Checks if the given object is allowed to be resized. | |
void | request_focus (utils::observer_ptr< frame > receiver) |
Sets whether keyboard input should be focused. | |
void | release_focus (const frame &receiver) |
Give up focus of keyboard input. | |
void | clear_focus () |
Release all requested focus. | |
bool | is_focused () const |
Checks whether keyboard input is focused somewhere, to prevent multiple inputs. | |
utils::observer_ptr< const frame > | get_focused_frame () const |
Returns the currently focused frame (nullptr if none). | |
utils::observer_ptr< frame > | get_focused_frame () |
Returns the currently focused frame (nullptr if none). | |
manager & | get_manager () |
Returns the manager instance associated with this root. | |
const manager & | get_manager () const |
Returns the manager instance associated with this root. | |
registry & | get_registry () |
Returns the UI object registry, which keeps track of all objects in the UI. | |
const registry & | get_registry () const |
Returns the UI object registry, which keeps track of all objects in the UI. | |
key_binder & | get_key_binder () |
Returns the key_binder object, which enables binding global actions to key presses. | |
const key_binder & | get_key_binder () const |
Returns the key_binder object, which enables binding global actions to key presses. | |
virtual void | notify_strata_needs_redraw (strata strata_id) |
Tells this renderer that one of its region requires redraw. | |
virtual void | notify_rendered_frame (const utils::observer_ptr< frame > &obj, bool rendered) |
Tells this renderer that it should (or not) render another frame. | |
virtual void | notify_strata_changed (const utils::observer_ptr< frame > &obj, strata old_strata_id, strata new_strata_id) |
Tells this renderer that a frame has changed strata. | |
virtual void | notify_level_changed (const utils::observer_ptr< frame > &obj, int old_level, int new_level) |
Tells this renderer that a frame has changed level. | |
utils::observer_ptr< const frame > | find_topmost_frame (const std::function< bool(const frame &)> &predicate) const |
Find the top-most frame matching the provided predicate. | |
utils::observer_ptr< frame > | find_topmost_frame (const std::function< bool(const frame &)> &predicate) |
Find the top-most frame matching the provided predicate. | |
int | get_highest_level (strata strata_id) const |
Returns the highest level on the provided strata. | |
utils::observer_ptr< frame > | create_root_frame (frame_core_attributes attr) |
Creates a new frame, ready for use, and owned by this frame_container. | |
template<typename FrameType , typename Enable = typename std::enable_if<std::is_base_of<gui::frame, FrameType>::value>::type> | |
utils::observer_ptr< frame > | create_root_frame (frame_core_attributes attr) |
Creates a new frame, ready for use, and owned by this frame_container. | |
template<typename FrameType , typename Enable = typename std::enable_if<std::is_base_of<gui::frame, FrameType>::value>::type> | |
utils::observer_ptr< frame > | create_root_frame (const std::string &name) |
Creates a new frame, ready for use, and owned by this frame_container. | |
utils::observer_ptr< frame > | add_root_frame (utils::owner_ptr< frame > obj) |
Make a frame owned by this frame_container. | |
utils::owner_ptr< frame > | remove_root_frame (const utils::observer_ptr< frame > &obj) |
Remove a frame from the list of frames owned by this frame_container. | |
root_frame_list_view | get_root_frames () |
Returns the root frame list. | |
const_root_frame_list_view | get_root_frames () const |
Returns the root frame list. | |
void | garbage_collect () |
Clean deleted entries from the frame list. | |
factory & | get_factory () |
Returns the GUI object factory. | |
const factory & | get_factory () const |
Returns the GUI object factory. | |
Protected Types | |
using | frame_list_type = utils::sorted_vector< frame *, frame_comparator > |
using | frame_list_iterator = frame_list_type::iterator |
Protected Member Functions | |
void | clear_strata_list_ () |
bool | has_strata_list_changed_ () const |
void | reset_strata_list_changed_flag_ () |
void | render_strata_ (const strata_data &strata_obj) const |
std::pair< std::size_t, std::size_t > | get_strata_range_ (strata strata_id) const |
virtual utils::observer_ptr< frame > | create_root_frame_ (frame_core_attributes attr) |
void | clear_frames_ () |
Protected Attributes | |
std::array< strata_data, num_strata > | strata_list_ |
frame_list_type | sorted_frame_list_ |
bool | frame_list_updated_ = false |
Static Protected Attributes | |
static constexpr std::size_t | num_strata = magic_enum::enum_count<strata>() |
Root of the UI object hierarchy.
This class contains and owns all "root" frames (frames with no parents) and is responsible for their lifetime, update, and rendering.
Definition at line 36 of file gui_root.hpp.
|
inherited |
Definition at line 42 of file gui_frame_container.hpp.
|
protectedinherited |
Definition at line 106 of file gui_frame_renderer.hpp.
|
protectedinherited |
Definition at line 105 of file gui_frame_renderer.hpp.
|
inherited |
Type of the root frame list.
Definition at line 37 of file gui_frame_container.hpp.
|
inherited |
Definition at line 39 of file gui_frame_container.hpp.
|
explicit |
Constructor.
block | The owner pointer control block |
mgr | The GUI manager |
Definition at line 19 of file gui_root.cpp.
|
override |
Destructor.
Definition at line 112 of file gui_root.cpp.
|
delete |
|
delete |
|
inherited |
Make a frame owned by this frame_container.
obj | The frame to add to the root frame list |
Definition at line 27 of file gui_frame_container.cpp.
void lxgui::gui::root::clear_focus | ( | ) |
Release all requested focus.
Definition at line 475 of file gui_root.cpp.
|
protectedinherited |
Definition at line 63 of file gui_frame_container.cpp.
|
protectedinherited |
Definition at line 183 of file gui_frame_renderer.cpp.
|
inlineinherited |
Creates a new frame, ready for use, and owned by this frame_container.
name | The name of this frame |
Definition at line 112 of file gui_frame_container.hpp.
|
inlineinherited |
Creates a new frame, ready for use, and owned by this frame_container.
attr | The core attributes of the frame (parent will be ignored) |
Definition at line 71 of file gui_frame_container.hpp.
|
inlineinherited |
Creates a new frame, ready for use, and owned by this frame_container.
attr | The core attributes of the frame (object_type and parent will be ignored) |
Definition at line 91 of file gui_frame_container.hpp.
|
protectedvirtualinherited |
Definition at line 17 of file gui_frame_container.cpp.
void lxgui::gui::root::enable_caching | ( | bool | enable | ) |
Enables or disables interface caching.
enable | 'true' to enable, 'false' to disable |
Definition at line 266 of file gui_root.cpp.
|
inlineinherited |
Find the top-most frame matching the provided predicate.
predicate | A function returning 'true' if the frame can be selected |
Definition at line 82 of file gui_frame_renderer.hpp.
|
inherited |
Find the top-most frame matching the provided predicate.
predicate | A function returning 'true' if the frame can be selected |
Definition at line 149 of file gui_frame_renderer.cpp.
|
inherited |
Clean deleted entries from the frame list.
Definition at line 56 of file gui_frame_container.cpp.
|
inline |
Returns the currently dragged frame, if any.
Definition at line 129 of file gui_root.hpp.
|
inline |
Returns the currently dragged frame, if any.
Definition at line 137 of file gui_root.hpp.
|
inlineinherited |
Returns the GUI object factory.
Definition at line 158 of file gui_frame_container.hpp.
|
inlineinherited |
Returns the GUI object factory.
Definition at line 166 of file gui_frame_container.hpp.
|
inline |
Returns the currently focused frame (nullptr if none).
Definition at line 237 of file gui_root.hpp.
utils::observer_ptr< const frame > lxgui::gui::root::get_focused_frame | ( | ) | const |
Returns the currently focused frame (nullptr if none).
Definition at line 487 of file gui_root.cpp.
|
inherited |
Returns the highest level on the provided strata.
strata_id | The strata to inspect |
Definition at line 161 of file gui_frame_renderer.cpp.
|
inline |
Returns the currently hovered frame, if any.
Definition at line 105 of file gui_root.hpp.
|
inline |
Returns the currently hovered frame, if any.
Definition at line 113 of file gui_root.hpp.
|
inline |
Returns the key_binder object, which enables binding global actions to key presses.
Definition at line 277 of file gui_root.hpp.
|
inline |
Returns the key_binder object, which enables binding global actions to key presses.
Definition at line 285 of file gui_root.hpp.
|
inline |
Returns the manager instance associated with this root.
Definition at line 245 of file gui_root.hpp.
|
inline |
Returns the manager instance associated with this root.
Definition at line 253 of file gui_root.hpp.
|
inline |
Returns the UI object registry, which keeps track of all objects in the UI.
Definition at line 261 of file gui_root.hpp.
|
inline |
Returns the UI object registry, which keeps track of all objects in the UI.
Definition at line 269 of file gui_root.hpp.
|
inherited |
Returns the root frame list.
Definition at line 48 of file gui_frame_container.cpp.
|
inherited |
Returns the root frame list.
Definition at line 52 of file gui_frame_container.cpp.
|
protectedinherited |
Definition at line 125 of file gui_frame_renderer.cpp.
|
overridevirtual |
Returns the width and height of this renderer's main render target (e.g., screen).
Implements lxgui::gui::frame_renderer.
Definition at line 117 of file gui_root.cpp.
|
protectedinherited |
Definition at line 188 of file gui_frame_renderer.cpp.
bool lxgui::gui::root::is_caching_enabled | ( | ) | const |
Checks if interface caching is enabled.
Definition at line 271 of file gui_root.cpp.
|
inline |
Check if a given frame is being dragged.
Definition at line 145 of file gui_root.hpp.
bool lxgui::gui::root::is_focused | ( | ) | const |
Checks whether keyboard input is focused somewhere, to prevent multiple inputs.
Definition at line 483 of file gui_root.cpp.
|
inline |
Check if a given frame is being hovered.
Definition at line 121 of file gui_root.hpp.
bool lxgui::gui::root::is_moving | ( | const region & | obj | ) | const |
Checks if the given object is allowed to move.
obj | The object to check |
Definition at line 336 of file gui_root.cpp.
bool lxgui::gui::root::is_sizing | ( | const region & | obj | ) | const |
Checks if the given object is allowed to be resized.
obj | The object to check |
Definition at line 410 of file gui_root.cpp.
void lxgui::gui::root::notify_hovered_frame_dirty | ( | ) |
Notifies the root that it should update the hovered frame.
Definition at line 299 of file gui_root.cpp.
|
virtualinherited |
Tells this renderer that a frame has changed level.
obj | The frame which has changed |
old_level | The old frame level |
new_level | The new frame level |
Definition at line 132 of file gui_frame_renderer.cpp.
|
virtualinherited |
Tells this renderer that it should (or not) render another frame.
obj | The frame to render |
rendered | 'true' if this renderer needs to render that new object |
Definition at line 82 of file gui_frame_renderer.cpp.
void lxgui::gui::root::notify_scaling_factor_updated | ( | ) |
Tells this object that the global interface scaling factor has changed.
Definition at line 275 of file gui_root.cpp.
|
virtualinherited |
Tells this renderer that a frame has changed strata.
obj | The frame which has changed |
old_strata_id | The old frame strata |
new_strata_id | The new frame strata |
Definition at line 110 of file gui_frame_renderer.cpp.
|
virtualinherited |
Tells this renderer that one of its region requires redraw.
Reimplemented in lxgui::gui::scroll_frame.
Definition at line 78 of file gui_frame_renderer.cpp.
void lxgui::gui::root::release_focus | ( | const frame & | receiver | ) |
Give up focus of keyboard input.
receiver | The event receiver that releases focus |
Definition at line 461 of file gui_root.cpp.
|
inherited |
Remove a frame from the list of frames owned by this frame_container.
obj | The frame to be released |
Definition at line 33 of file gui_frame_container.cpp.
void lxgui::gui::root::render | ( | ) | const |
Renders the UI into the current render target.
Definition at line 121 of file gui_root.cpp.
|
protectedinherited |
Definition at line 174 of file gui_frame_renderer.cpp.
void lxgui::gui::root::request_focus | ( | utils::observer_ptr< frame > | receiver | ) |
Sets whether keyboard input should be focused.
receiver | The frame that requires focus |
Definition at line 447 of file gui_root.cpp.
|
protectedinherited |
Definition at line 192 of file gui_frame_renderer.cpp.
void lxgui::gui::root::start_moving | ( | utils::observer_ptr< region > | obj, |
anchor * | a = nullptr , |
||
constraint | constraint = constraint::none , |
||
std::function< void()> | apply_constraint_func = nullptr |
||
) |
Start manually moving a region with the mouse.
obj | The object to move |
a | The reference anchor |
constraint | The constraint axis if any |
apply_constraint_func | Optional function to implement further constraints |
Definition at line 303 of file gui_root.cpp.
Starts manually resizing a region with the mouse.
obj | The object to resize |
p | The sizing point |
Definition at line 340 of file gui_root.cpp.
void lxgui::gui::root::stop_moving | ( | ) |
Stops movement for the current object.
Definition at line 331 of file gui_root.cpp.
void lxgui::gui::root::stop_sizing | ( | ) |
Stops sizing for the current object.
Definition at line 406 of file gui_root.cpp.
void lxgui::gui::root::toggle_caching | ( | ) |
Toggles interface caching.
Definition at line 257 of file gui_root.cpp.
void lxgui::gui::root::update | ( | float | delta | ) |
updates this root and its regions.
delta | The time elapsed since the last call |
Definition at line 184 of file gui_root.cpp.
|
protectedinherited |
Definition at line 114 of file gui_frame_renderer.hpp.
|
staticconstexprprotectedinherited |
Definition at line 110 of file gui_frame_renderer.hpp.
|
protectedinherited |
Definition at line 113 of file gui_frame_renderer.hpp.
|
protectedinherited |
Definition at line 112 of file gui_frame_renderer.hpp.