lxgui
Public Types | Public Member Functions | Protected Member Functions | List of all members
lxgui::gui::frame_container Class Reference

Container of frames. More...

#include <gui_frame_container.hpp>

Inheritance diagram for lxgui::gui::frame_container:
lxgui::gui::root lxgui::gui::virtual_root

Public Types

using root_frame_list = std::list< utils::owner_ptr< frame > >
 Type of the root frame list. More...
 
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

 frame_container (factory &fac, registry &reg, utils::observer_ptr< frame_renderer > rdr)
 Constructor. More...
 
virtual ~frame_container ()=default
 
 frame_container (const frame_container &)=delete
 
 frame_container (frame_container &&)=delete
 
frame_containeroperator= (const frame_container &)=delete
 
frame_containeroperator= (frame_container &&)=delete
 
utils::observer_ptr< framecreate_root_frame (frame_core_attributes attr)
 Creates a new frame, ready for use, and owned by this frame_container. More...
 
template<typename FrameType , typename Enable = typename std::enable_if<std::is_base_of<gui::frame, FrameType>::value>::type>
utils::observer_ptr< framecreate_root_frame (frame_core_attributes attr)
 Creates a new frame, ready for use, and owned by this frame_container. More...
 
template<typename FrameType , typename Enable = typename std::enable_if<std::is_base_of<gui::frame, FrameType>::value>::type>
utils::observer_ptr< framecreate_root_frame (const std::string &name)
 Creates a new frame, ready for use, and owned by this frame_container. More...
 
utils::observer_ptr< frameadd_root_frame (utils::owner_ptr< frame > obj)
 Make a frame owned by this frame_container. More...
 
utils::owner_ptr< frameremove_root_frame (const utils::observer_ptr< frame > &obj)
 Remove a frame from the list of frames owned by this frame_container. More...
 
root_frame_list_view get_root_frames ()
 Returns the root frame list. More...
 
const_root_frame_list_view get_root_frames () const
 Returns the root frame list. More...
 
void garbage_collect ()
 Clean deleted entries from the frame list. More...
 
factoryget_factory ()
 Returns the GUI object factory. More...
 
const factoryget_factory () const
 Returns the GUI object factory. More...
 
registryget_registry ()
 Returns the UI object registry, which keeps track of all objects in the UI. More...
 
const registryget_registry () const
 Returns the UI object registry, which keeps track of all objects in the UI. More...
 

Protected Member Functions

virtual utils::observer_ptr< framecreate_root_frame_ (frame_core_attributes attr)
 
void clear_frames_ ()
 

Detailed Description

Container of frames.

This class contains and owns "root" frames (frames with no parents) and is responsible for their lifetime.

Definition at line 26 of file gui_frame_container.hpp.

Member Typedef Documentation

◆ const_root_frame_list_view

Definition at line 42 of file gui_frame_container.hpp.

◆ root_frame_list

Type of the root frame list.

Note
Constraints on the choice container type:
  • must not invalidate iterators on back insertion
  • must allow forward iteration
  • iterators can be invalidated on removal
  • most common use is iteration, not addition or removal
  • ordering of elements is irrelevant

Definition at line 37 of file gui_frame_container.hpp.

◆ root_frame_list_view

Definition at line 39 of file gui_frame_container.hpp.

Constructor & Destructor Documentation

◆ frame_container() [1/3]

lxgui::gui::frame_container::frame_container ( factory fac,
registry reg,
utils::observer_ptr< frame_renderer rdr 
)
explicit

Constructor.

Parameters
facThe GUI object factory
regThe registry in which new frames should be registered
rdrThe frame_renderer that will render these frames (nullptr if none).

Definition at line 13 of file gui_frame_container.cpp.

◆ ~frame_container()

virtual lxgui::gui::frame_container::~frame_container ( )
virtualdefault

◆ frame_container() [2/3]

lxgui::gui::frame_container::frame_container ( const frame_container )
delete

◆ frame_container() [3/3]

lxgui::gui::frame_container::frame_container ( frame_container &&  )
delete

Member Function Documentation

◆ add_root_frame()

utils::observer_ptr< frame > lxgui::gui::frame_container::add_root_frame ( utils::owner_ptr< frame obj)

Make a frame owned by this frame_container.

Parameters
objThe frame to add to the root frame list
Returns
Raw pointer to the frame

Definition at line 27 of file gui_frame_container.cpp.

◆ clear_frames_()

void lxgui::gui::frame_container::clear_frames_ ( )
protected

Definition at line 63 of file gui_frame_container.cpp.

◆ create_root_frame() [1/3]

template<typename FrameType , typename Enable = typename std::enable_if<std::is_base_of<gui::frame, FrameType>::value>::type>
utils::observer_ptr<frame> lxgui::gui::frame_container::create_root_frame ( const std::string &  name)
inline

Creates a new frame, ready for use, and owned by this frame_container.

Parameters
nameThe name of this frame
Returns
The new frame
Note
This function takes care of the basic initializing: the frame is directly usable. However, you still need to call notify_loaded() when you are done with any extra initialization you require on this frame. If you do not, the frame's OnLoad callback will not fire.

Definition at line 112 of file gui_frame_container.hpp.

◆ create_root_frame() [2/3]

utils::observer_ptr<frame> lxgui::gui::frame_container::create_root_frame ( frame_core_attributes  attr)
inline

Creates a new frame, ready for use, and owned by this frame_container.

Parameters
attrThe core attributes of the frame (parent will be ignored)
Returns
The new frame
Note
This function takes care of the basic initializing: the frame is directly usable. However, you still need to call notify_loaded() when you are done with any extra initialization you require on this frame. If you do not, the frame's OnLoad callback will not fire.

Definition at line 71 of file gui_frame_container.hpp.

◆ create_root_frame() [3/3]

template<typename FrameType , typename Enable = typename std::enable_if<std::is_base_of<gui::frame, FrameType>::value>::type>
utils::observer_ptr<frame> lxgui::gui::frame_container::create_root_frame ( frame_core_attributes  attr)
inline

Creates a new frame, ready for use, and owned by this frame_container.

Parameters
attrThe core attributes of the frame (object_type and parent will be ignored)
Returns
The new frame
Note
This function takes care of the basic initializing: the frame is directly usable. However, you still need to call notify_loaded() when you are done with any extra initialization you require on this frame. If you do not, the frame's OnLoad callback will not fire.

Definition at line 91 of file gui_frame_container.hpp.

◆ create_root_frame_()

utils::observer_ptr< frame > lxgui::gui::frame_container::create_root_frame_ ( frame_core_attributes  attr)
protectedvirtual

Definition at line 17 of file gui_frame_container.cpp.

◆ garbage_collect()

void lxgui::gui::frame_container::garbage_collect ( )

Clean deleted entries from the frame list.

Note
This must not be called while the root frames are being iterated on. All this does is free up "nullptr" entries from the list, to speed up future iteration.

Definition at line 56 of file gui_frame_container.cpp.

◆ get_factory() [1/2]

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

Returns the GUI object factory.

Returns
The GUI object factory

Definition at line 158 of file gui_frame_container.hpp.

◆ get_factory() [2/2]

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

Returns the GUI object factory.

Returns
The GUI object factory

Definition at line 166 of file gui_frame_container.hpp.

◆ get_registry() [1/2]

registry& lxgui::gui::frame_container::get_registry ( )
inline

Returns the UI object registry, which keeps track of all objects in the UI.

Returns
The registry object

Definition at line 174 of file gui_frame_container.hpp.

◆ get_registry() [2/2]

const registry& lxgui::gui::frame_container::get_registry ( ) const
inline

Returns the UI object registry, which keeps track of all objects in the UI.

Returns
The registry object

Definition at line 182 of file gui_frame_container.hpp.

◆ get_root_frames() [1/2]

frame_container::root_frame_list_view lxgui::gui::frame_container::get_root_frames ( )

Returns the root frame list.

Returns
The root frame list

Definition at line 48 of file gui_frame_container.cpp.

◆ get_root_frames() [2/2]

frame_container::const_root_frame_list_view lxgui::gui::frame_container::get_root_frames ( ) const

Returns the root frame list.

Returns
The root frame list

Definition at line 52 of file gui_frame_container.cpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ remove_root_frame()

utils::owner_ptr< frame > lxgui::gui::frame_container::remove_root_frame ( const utils::observer_ptr< frame > &  obj)

Remove a frame from the list of frames owned by this frame_container.

Parameters
objThe frame to be released
Returns
A unique_ptr to the previously owned frame, ignore it to destroy it.

Definition at line 33 of file gui_frame_container.cpp.


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