cgv
Loading...
Searching...
No Matches
cgv::gui::gui_group Class Reference

gui independent group class which is a container for gui elements More...

#include <gui_group.h>

Inheritance diagram for cgv::gui::gui_group:
cgv::base::group cgv::base::registration_listener cgv::base::node cgv::base::named cgv::base::base cgv::data::ref_counted cgv::reflect::self_reflection_tag cgv::gui::window

Public Member Functions

void register_object (cgv::base::base_ptr object, const std::string &options)
 interface of adding an object
 
void unregister_object (cgv::base::base_ptr object, const std::string &options)
 overload to handle unregistration events
 
 gui_group (const std::string &name="")
 construct from name
 
std::string get_type_name () const
 overload to return the type name of this object
 
managed objects
void add_managed_objects (cgv::base::base_ptr object)
 add the passed object as an managed object.
 
void release_all_managed_objects ()
 release all managed objects
 
void release_managed_objects (cgv::base::base_ptr object)
 release a specific managed object
 
bool is_managed_object (cgv::base::base_ptr object)
 check whether an object is managed by this gui group
 
adding new elements to the group
virtual void align (const std::string &_align)
 send pure alignment information
 
virtual gui_group_ptr add_group (const std::string &label, const std::string &group_type, const std::string &options, const std::string &align)
 add a new group to the given parent group
 
virtual cgv::base::base_ptr add_decorator (const std::string &label, const std::string &decorator_type, const std::string &options, const std::string &align)
 add a newly created decorator to the group
 
virtual button_ptr add_button (const std::string &label, const std::string &options, const std::string &align)
 add a newly created button to the group
 
virtual view_ptr add_view_void (const std::string &label, const void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, const std::string &align)
 add a newly created view to the group
 
virtual control_ptr add_control_void (const std::string &label, void *value_ptr, abst_control_provider *acp, const std::string &value_type, const std::string &gui_type, const std::string &options, const std::string &align, void *user_data)
 add a newly created control to the group
 
template<typename T >
data::ref_ptr< view< T > > add_view (const std::string &label, const T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
 add a newly created view to the group for the given value with the given gui type, init and align options
 
template<typename T >
data::ref_ptr< control< T > > add_control (const std::string &label, T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
 add a newly created control to the group for the given value with the given gui type, init and align options
 
template<typename T >
data::ref_ptr< control< T > > add_control (const std::string &label, control_provider< T > *provider, const std::string &gui_type="", const std::string &options="", const std::string &align="\n", void *user_data=0)
 add a newly created control to the group which is controlled by a control_provider
 
finding elements in the group
cgv::base::base_ptr find_element (const std::string &name)
 find a gui element by name, return empty pointer if not found
 
view_ptr find_view_void (const void *value_ptr, int *idx_ptr)
 find a view in the group based on a const void pointer
 
control_ptr find_control_void (void *value_ptr, int *idx_ptr)
 find a control in the group based on a const void pointer
 
template<typename T >
data::ref_ptr< view< T > > find_view (const T &value, int *idx_ptr=0)
 find the next view of the given value in the current group.
 
template<typename T >
data::ref_ptr< control< T > > find_control (T &value, int *idx_ptr=0)
 find the next control of the given value in the current group.
 
- Public Member Functions inherited from cgv::base::group
 group (const std::string &name="")
 construct from name
 
unsigned int get_nr_children () const
 return the number of children
 
base_ptr get_child (unsigned int i) const
 return the i-th child
 
template<typename T >
data::ref_ptr< Tcreate_and_append_child (const std::string &name="", unsigned int *index=nullptr)
 create and append an instance of a child node and return pointer to appended child; optionally set name and get index
 
virtual unsigned int append_child (base_ptr child)
 append child and return index of appended child
 
virtual unsigned int remove_child (base_ptr child)
 remove all elements of the vector that point to child, return the number of removed children
 
virtual void remove_all_children ()
 remove all children
 
virtual void insert_child (unsigned int i, base_ptr child)
 insert a child at the given position
 
group_ptr get_group ()
 cast upward to group
 
const_group_ptr get_group_const ()
 cast upward to const group
 
- Public Member Functions inherited from cgv::base::node
 node (const std::string &name="")
 construct from name
 
node_ptr get_parent () const
 return the parent node
 
base_ptr get_root () const
 return the root node by traversing parents until no more parent is available
 
void set_parent (node_ptr _parent)
 set a new parent node
 
node_ptr get_node ()
 cast upward to node
 
const_node_ptr get_node_const ()
 cast upward to const node
 
- Public Member Functions inherited from cgv::base::named
 named (const std::string &name="")
 construct from name
 
const std::string & get_name () const
 return the parent node
 
void set_name (const std::string &_name)
 set a new parent node
 
named_ptr get_named ()
 cast upward to named
 
const_named_ptr get_named_const ()
 cast upward to const named
 
- Public Member Functions inherited from cgv::base::base
virtual std::string get_default_options () const
 overload to provide default options for registration
 
std::string get_name_or_type_name () const
 determine name of instance by checking cgv::base::named interface and in failure fallback to get_type_name()
 
virtual void on_register ()
 overload to handle register events that is sent after the instance has been registered
 
virtual void unregister ()
 overload to handle unregistration of instances
 
virtual bool on_exit_request ()
 overload to handle the appication exit request, return true if exiting is allowed and false otherwise
 
virtual void stream_stats (std::ostream &)
 overload to show the content of this object
 
virtual data::ref_ptr< const named, trueget_named_const () const
 perform downcast to const named
 
virtual data::ref_ptr< const node, trueget_node_const () const
 perform downcast to const node
 
virtual data::ref_ptr< const group, trueget_group_const () const
 perform downcast to const group
 
template<class T >
data::ref_ptr< T, truecast ()
 cast to arbitrary class, but use the casts to named, node and group from the interface
 
template<class T >
data::ref_ptr< const T, truecast_const ()
 const cast to arbitrary class, but use the casts to named, node and group from the interface
 
template<class T >
Tget_interface ()
 use dynamic type cast to check for the given interface
 
template<class T >
const Tget_const_interface () const
 use dynamic type cast to check for the given interface
 
virtual void update ()
 this virtual update allows for example to ask a view to update the viewed value. The default implementation is empty.
 
virtual voidget_user_data () const
 this virtual method allows to pass application specific data for internal purposes
 
virtual bool self_reflect (cgv::reflect::reflection_handler &)
 used for simple self reflection
 
virtual std::string get_property_declarations ()
 return a semicolon separated list of property declarations
 
virtual bool set_void (const std::string &property, const std::string &value_type, const void *value_ptr)
 abstract interface for the setter of a dynamic property.
 
virtual void on_set (void *member_ptr)
 this callback is called when the set_void method has changed a member and can be overloaded in derived class
 
virtual bool get_void (const std::string &property, const std::string &value_type, void *value_ptr)
 abstract interface for the getter of a dynamic property.
 
virtual bool call_void (const std::string &method, const std::vector< std::string > &param_value_types, const std::vector< const void * > &param_value_ptrs, const std::string &result_type="", void *result_value_ptr=0)
 abstract interface to call an action
 
void set (const std::string &property, const char *value)
 specialization of set method to support const char* as strings
 
template<typename T >
void set (const std::string &property, const T &value)
 set a property of the element to the given value and perform standard conversions if necessary.
 
template<typename T >
T get (const std::string &property)
 query a property of the element and perform standard conversions if necessary.
 
void multi_set (const std::string &property_assignments, bool report_error=true)
 set several properties
 
bool is_property (const std::string &property_name, std::string *type_name=0)
 check if the given name specifies a property.
 
voidfind_member_ptr (const std::string &property_name, std::string *type_name=0)
 find a member pointer by name.
 
- Public Member Functions inherited from cgv::data::ref_counted
int get_ref_count () const
 read access to current count
 

Static Protected Member Functions

static void set_provider_parent (provider *p, gui_group_ptr g)
 access to protected provider method
 
static gui_group_ptr get_provider_parent (const provider *p)
 driver specific handle for the group gui element managing the gui built in the provider
 
- Static Protected Member Functions inherited from cgv::base::base
template<class T >
static data::ref_ptr< T, truecast_dynamic (base *b)
 use dynamic cast for upcast to given class
 

Protected Attributes

std::vector< cgv::base::base_ptrmanaged_objects
 managed objects can be add to the group such that
 
- Protected Attributes inherited from cgv::base::group
std::vector< base_ptrchildren
 store a list of children
 
- Protected Attributes inherited from cgv::base::node
node_ptr parent
 store a pointer to the parent node
 
- Protected Attributes inherited from cgv::base::named
std::string name
 store the name as a string
 

Friends

class provider
 

selection of children

cgv::signal::signal< cgv::base::base_ptr, bool > on_selection_change
 This signal is emitted for every change of the selection of a child.
 
virtual bool multiple_selection () const
 return whether several children of the group can be selected at the same time
 
virtual void select_child (unsigned ci, bool exclusive=false)
 select the ci-th child of the group.
 
virtual void select_child (cgv::base::base_ptr ci, bool exclusive=false)
 same as version with child index
 
virtual bool unselect_child (unsigned ci)
 unselect the ci-th child.
 
virtual bool unselect_child (cgv::base::base_ptr ci)
 same as version with child index
 
virtual int get_selected_child_index () const
 return the index of the currently selected child.
 
virtual cgv::base::base_ptr get_selected_child () const
 return the currently selected child.
 
virtual bool is_selected (cgv::base::base_ptr c) const
 return whether the given child is selected
 
bool is_selected (unsigned ci) const
 return whether the given child is selected.
 

opening and closing of child groups

cgv::signal::signal< gui_group_ptr, bool > on_open_state_change
 this signal is emitted, when a child group is opened or closed
 
virtual bool can_open_and_close () const
 returns whether open and close of sub groups is allowed
 
virtual bool is_open_child_group (gui_group_ptr g) const
 return whether the given child is open
 
bool is_open_child_group (unsigned ci) const
 return whether the ci-th child is an open gui group
 
virtual bool open_child_group (gui_group_ptr g)
 try to open given child group and return whether this was successful
 
virtual bool close_child_group (gui_group_ptr g)
 try to close given child group and return whether this was successful
 

Additional Inherited Members

- Protected Member Functions inherited from cgv::base::group
void link (base_ptr b)
 check if the base class is a node and set the parent of the node
 
void unlink (base_ptr b)
 check if the base class is a node and clear the parent of the node
 
- Protected Member Functions inherited from cgv::base::base
virtual ~base ()
 make destructor virtual and not accessible from outside
 
- Protected Member Functions inherited from cgv::data::ref_counted
 ref_counted ()
 constructor initializes the count to 0
 
void set_ref_count (int c) const
 write access is also const to allow ref counted pointers to const instances
 

Detailed Description

gui independent group class which is a container for gui elements

Definition at line 37 of file gui_group.h.

Constructor & Destructor Documentation

◆ gui_group()

cgv::gui::gui_group::gui_group ( const std::string &  name = "")

construct from name

Definition at line 11 of file gui_group.cxx.

Member Function Documentation

◆ add_button()

button_ptr cgv::gui::gui_group::add_button ( const std::string &  label,
const std::string &  options,
const std::string &  align 
)
virtual

add a newly created button to the group

Definition at line 228 of file gui_group.cxx.

References align(), and cgv::gui::get_gui_driver().

◆ add_control() [1/2]

template<typename T >
data::ref_ptr< control< T > > cgv::gui::gui_group::add_control ( const std::string &  label,
control_provider< T > *  provider,
const std::string &  gui_type = "",
const std::string &  options = "",
const std::string &  align = "\n",
void *  user_data = 0 
)
inline

add a newly created control to the group which is controlled by a control_provider

Definition at line 161 of file gui_group.h.

References cgv::data::ref_ptr< T, is_ref_counted >::down_cast().

◆ add_control() [2/2]

template<typename T >
data::ref_ptr< control< T > > cgv::gui::gui_group::add_control ( const std::string &  label,
T &  value,
const std::string &  gui_type = "",
const std::string &  options = "",
const std::string &  align = "\n" 
)
inline

add a newly created control to the group for the given value with the given gui type, init and align options

Definition at line 153 of file gui_group.h.

References cgv::data::ref_ptr< T, is_ref_counted >::down_cast().

◆ add_control_void()

control_ptr cgv::gui::gui_group::add_control_void ( const std::string &  label,
void *  value_ptr,
abst_control_provider acp,
const std::string &  value_type,
const std::string &  gui_type,
const std::string &  options,
const std::string &  align,
void *  user_data 
)
virtual

add a newly created control to the group

Definition at line 130 of file gui_group.cxx.

References align(), and cgv::gui::get_gui_driver().

◆ add_decorator()

cgv::base::base_ptr cgv::gui::gui_group::add_decorator ( const std::string &  label,
const std::string &  decorator_type,
const std::string &  options,
const std::string &  align 
)
virtual

add a newly created decorator to the group

Definition at line 220 of file gui_group.cxx.

References align(), and cgv::gui::get_gui_driver().

◆ add_group()

gui_group_ptr cgv::gui::gui_group::add_group ( const std::string &  label,
const std::string &  group_type,
const std::string &  options,
const std::string &  align 
)
virtual

add a new group to the given parent group

Definition at line 212 of file gui_group.cxx.

References align(), and cgv::gui::get_gui_driver().

◆ add_managed_objects()

void cgv::gui::gui_group::add_managed_objects ( cgv::base::base_ptr  object)

add the passed object as an managed object.

This will simply add a reference counted pointer to the object into a list of managed elements. This pointer is released whenever the gui group is destroyed or when the gui is recreated. This functionality can be used by gui_creators to manage objects that are not managed by the user of the gui library. An example usage can be found in the bit_field_controler found in the plugin plugins/cg_ext.

Definition at line 178 of file gui_group.cxx.

References is_managed_object(), and managed_objects.

◆ add_view()

template<typename T >
data::ref_ptr< view< T > > cgv::gui::gui_group::add_view ( const std::string &  label,
const T &  value,
const std::string &  gui_type = "",
const std::string &  options = "",
const std::string &  align = "\n" 
)
inline

add a newly created view to the group for the given value with the given gui type, init and align options

Definition at line 145 of file gui_group.h.

References cgv::data::ref_ptr< T, is_ref_counted >::down_cast().

◆ add_view_void()

view_ptr cgv::gui::gui_group::add_view_void ( const std::string &  label,
const void *  value_ptr,
const std::string &  value_type,
const std::string &  gui_type,
const std::string &  options,
const std::string &  align 
)
virtual

add a newly created view to the group

Definition at line 122 of file gui_group.cxx.

References align(), and cgv::gui::get_gui_driver().

◆ align()

void cgv::gui::gui_group::align ( const std::string &  _align)
virtual

send pure alignment information

Definition at line 207 of file gui_group.cxx.

Referenced by add_button(), add_control_void(), add_decorator(), add_group(), and add_view_void().

◆ can_open_and_close()

bool cgv::gui::gui_group::can_open_and_close ( ) const
virtual

returns whether open and close of sub groups is allowed

Definition at line 91 of file gui_group.cxx.

◆ close_child_group()

bool cgv::gui::gui_group::close_child_group ( gui_group_ptr  g)
virtual

try to close given child group and return whether this was successful

close the given child group

Definition at line 116 of file gui_group.cxx.

◆ find_control()

template<typename T >
data::ref_ptr< control< T > > cgv::gui::gui_group::find_control ( T &  value,
int *  idx_ptr = 0 
)
inline

find the next control of the given value in the current group.

If the index pointer is given, start at the index to which the pointer points and set this index to the index of the child index of the found control

Definition at line 193 of file gui_group.h.

References cgv::data::ref_ptr< T, is_ref_counted >::down_cast().

◆ find_control_void()

control_ptr cgv::gui::gui_group::find_control_void ( void *  value_ptr,
int *  idx_ptr 
)

find a control in the group based on a const void pointer

Definition at line 164 of file gui_group.cxx.

References cgv::gui::get_gui_driver().

◆ find_element()

cgv::base::base_ptr cgv::gui::gui_group::find_element ( const std::string &  name)

find a gui element by name, return empty pointer if not found

Definition at line 141 of file gui_group.cxx.

References cgv::base::group::get_child(), cgv::base::group::get_nr_children(), and cgv::base::named::name.

◆ find_view()

template<typename T >
data::ref_ptr< view< T > > cgv::gui::gui_group::find_view ( const T &  value,
int *  idx_ptr = 0 
)
inline

find the next view of the given value in the current group.

If the index pointer is given, start at the index to which the pointer points and set this index to the index of the child index of the found view

Definition at line 184 of file gui_group.h.

References cgv::data::ref_ptr< T, is_ref_counted >::down_cast().

◆ find_view_void()

view_ptr cgv::gui::gui_group::find_view_void ( const void *  value_ptr,
int *  idx_ptr 
)

find a view in the group based on a const void pointer

Definition at line 156 of file gui_group.cxx.

References cgv::gui::get_gui_driver().

◆ get_provider_parent()

gui_group_ptr cgv::gui::gui_group::get_provider_parent ( const provider p)
staticprotected

driver specific handle for the group gui element managing the gui built in the provider

Definition at line 28 of file gui_group.cxx.

References cgv::gui::provider::parent_group.

◆ get_selected_child()

cgv::base::base_ptr cgv::gui::gui_group::get_selected_child ( ) const
virtual

return the currently selected child.

In case of multiple_selection, this function returns the first selected child. In this case it can also happen that the returned base_ptr is empty if no child is selected.

Definition at line 72 of file gui_group.cxx.

References cgv::base::group::get_child(), and get_selected_child_index().

Referenced by is_selected(), and select_child().

◆ get_selected_child_index()

int cgv::gui::gui_group::get_selected_child_index ( ) const
virtual

return the index of the currently selected child.

In case of multiple_selection, this function returns the index of the first selected child. In this case it can also happen that the returned index is -1 if no child is selected.

Definition at line 67 of file gui_group.cxx.

Referenced by get_selected_child().

◆ get_type_name()

std::string cgv::gui::gui_group::get_type_name ( ) const
virtual

overload to return the type name of this object

Reimplemented from cgv::base::group.

Reimplemented in cgv::gui::window.

Definition at line 173 of file gui_group.cxx.

◆ is_managed_object()

bool cgv::gui::gui_group::is_managed_object ( cgv::base::base_ptr  object)

check whether an object is managed by this gui group

Definition at line 200 of file gui_group.cxx.

References managed_objects.

Referenced by add_managed_objects().

◆ is_open_child_group() [1/2]

bool cgv::gui::gui_group::is_open_child_group ( gui_group_ptr  g) const
virtual

return whether the given child is open

Definition at line 97 of file gui_group.cxx.

◆ is_open_child_group() [2/2]

bool cgv::gui::gui_group::is_open_child_group ( unsigned  ci) const

return whether the ci-th child is an open gui group

Definition at line 103 of file gui_group.cxx.

References cgv::base::group::get_child().

◆ is_selected() [1/2]

bool cgv::gui::gui_group::is_selected ( cgv::base::base_ptr  c) const
virtual

return whether the given child is selected

Definition at line 80 of file gui_group.cxx.

References get_selected_child().

Referenced by is_selected(), select_child(), and unselect_child().

◆ is_selected() [2/2]

bool cgv::gui::gui_group::is_selected ( unsigned  ci) const

return whether the given child is selected.

the implementation simply calls the virtual variant with get_child(ci).

Definition at line 85 of file gui_group.cxx.

References cgv::base::group::get_child(), and is_selected().

◆ multiple_selection()

bool cgv::gui::gui_group::multiple_selection ( ) const
virtual

return whether several children of the group can be selected at the same time

Definition at line 33 of file gui_group.cxx.

Referenced by select_child().

◆ open_child_group()

bool cgv::gui::gui_group::open_child_group ( gui_group_ptr  g)
virtual

try to open given child group and return whether this was successful

open the given child group

Definition at line 110 of file gui_group.cxx.

◆ register_object()

void cgv::gui::gui_group::register_object ( cgv::base::base_ptr  object,
const std::string &  options 
)
virtual

interface of adding an object

Implements cgv::base::registration_listener.

Definition at line 19 of file gui_group.cxx.

◆ release_all_managed_objects()

void cgv::gui::gui_group::release_all_managed_objects ( )

release all managed objects

Definition at line 185 of file gui_group.cxx.

References cgv::data::ref_ptr< T, is_ref_counted >::clear(), and managed_objects.

◆ release_managed_objects()

void cgv::gui::gui_group::release_managed_objects ( cgv::base::base_ptr  object)

release a specific managed object

Definition at line 191 of file gui_group.cxx.

References managed_objects.

◆ select_child() [1/2]

void cgv::gui::gui_group::select_child ( cgv::base::base_ptr  ci,
bool  exclusive = false 
)
virtual

same as version with child index

Definition at line 44 of file gui_group.cxx.

References get_selected_child(), is_selected(), multiple_selection(), and on_selection_change.

◆ select_child() [2/2]

void cgv::gui::gui_group::select_child ( unsigned  ci,
bool  exclusive = false 
)
virtual

select the ci-th child of the group.

If multiple_selection() returns true, the exclusive flag can be used to unselect all other previously selected children except the newly selected one. Typically, an exclusively selected child will gain input focus.

Definition at line 38 of file gui_group.cxx.

References cgv::base::group::get_child(), and select_child().

Referenced by select_child().

◆ set_provider_parent()

void cgv::gui::gui_group::set_provider_parent ( provider p,
gui_group_ptr  g 
)
staticprotected

access to protected provider method

Definition at line 14 of file gui_group.cxx.

References cgv::gui::provider::set_parent().

◆ unregister_object()

void cgv::gui::gui_group::unregister_object ( cgv::base::base_ptr  object,
const std::string &  options 
)
virtual

overload to handle unregistration events

Implements cgv::base::registration_listener.

Definition at line 23 of file gui_group.cxx.

◆ unselect_child() [1/2]

bool cgv::gui::gui_group::unselect_child ( cgv::base::base_ptr  ci)
virtual

same as version with child index

Definition at line 58 of file gui_group.cxx.

References is_selected(), and on_selection_change.

◆ unselect_child() [2/2]

bool cgv::gui::gui_group::unselect_child ( unsigned  ci)
virtual

unselect the ci-th child.

If no multiple_selection is allowed, unselection can fail if the group does not support an empty selection.

Definition at line 53 of file gui_group.cxx.

References cgv::base::group::get_child(), and unselect_child().

Referenced by unselect_child().

Friends And Related Symbol Documentation

◆ provider

friend class provider
friend

Definition at line 40 of file gui_group.h.

Member Data Documentation

◆ managed_objects

std::vector<cgv::base::base_ptr> cgv::gui::gui_group::managed_objects
protected

managed objects can be add to the group such that

Definition at line 42 of file gui_group.h.

Referenced by add_managed_objects(), is_managed_object(), release_all_managed_objects(), and release_managed_objects().

◆ on_open_state_change

cgv::signal::signal<gui_group_ptr,bool> cgv::gui::gui_group::on_open_state_change

this signal is emitted, when a child group is opened or closed

The first argument specifies the group and the second whether it has been opened.

Definition at line 126 of file gui_group.h.

◆ on_selection_change

cgv::signal::signal<cgv::base::base_ptr, bool> cgv::gui::gui_group::on_selection_change

This signal is emitted for every change of the selection of a child.

The first argument is simply the pointer to the child whose selection state has been changed. The second argument is the new selection state.

Definition at line 108 of file gui_group.h.

Referenced by select_child(), and unselect_child().


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