3#include <cgv/base/base.h>
4#include <cgv/type/info/type_name.h>
5#include <cgv/signal/rebind.h>
6#include <cgv/utils/convert.h>
9#include "gui_creator.h"
37 typedef const T* pointer_type;
38 static pointer_type get_value_ptr(
const T& value) {
return &value; }
39 static int get_index(
const T& value) {
return -1; }
45 typedef const T* pointer_type;
51typename with_index_traits<T>::pointer_type wi_get_value_ptr(
const T& value)
57int wi_get_index(
const T& value)
59 return with_index_traits<T>::get_index(value);
63class CGV_API
provider :
virtual public cgv::signal::tacker
83 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);
85 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);
89 void align(
const std::string& _align);
97 std::string concat_enum_def(
const std::vector<std::string>& names,
const std::string& additional_first_name =
"",
const std::string& additional_last_name =
"");
99 gui_group_ptr add_object_gui(
cgv::base::base_ptr object,
const std::string& label,
const std::string& group_type,
const std::string& options,
const std::string& align);
105 gui_group_ptr add_group(
const std::string& label,
const std::string& group_type,
const std::string& options =
"",
const std::string& align =
"\n");
107 cgv::base::base_ptr add_decorator(
const std::string& label,
const std::string& decorator_type,
const std::string& options =
"",
const std::string& align =
"\n");
109 button_ptr add_button(
const std::string& label,
const std::string& options =
"",
const std::string& align =
"\n");
111 template <
typename T>
112 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") {
113 if (parent_group.
empty())
115 return parent_group->add_view(label, value, gui_type, options, align);
118 template <
typename T>
120 if (parent_group.
empty())
122 return parent_group->add_control(label, value, gui_type, options,align);
125 template <
typename T>
128 const std::string& options =
"",
const std::string& align =
"\n",
void* user_data = 0) {
129 if (parent_group.
empty())
131 return parent_group->add_control(label,
provider, gui_type, options,align,user_data);
136 template <
typename T>
140 connect_copy(cp->value_change,
165 bool add_tree_node(
const std::string& label,
bool& toggle,
int level,
const std::string& a=
"\n",
gui_group_ptr ggp =
gui_group_ptr());
211 template <
typename T>
212 bool begin_tree_node(
const std::string& label,
const T& value,
bool initial_visibility =
false,
const std::string& options =
"",
gui_group_ptr ggp =
gui_group_ptr()) {
return begin_tree_node_void(label, wi_get_value_ptr(value), wi_get_index(value), initial_visibility, options, ggp); }
216 template <
typename T>
217 static bool&
ref_tree_node_visible_flag(
const T& value) {
return ref_tree_node_visible_flag_void(wi_get_value_ptr(value), wi_get_index(value)); }
221 template <
typename T>
222 void end_tree_node(
const T& value) { end_tree_node_void(wi_get_value_ptr(value), wi_get_index(value)); }
224 template <
typename T>
225 bool is_tree_node_visible(
const T& value)
const {
return is_tree_node_visible_void(wi_get_value_ptr(value), wi_get_index(value)); }
227 template <
typename T>
228 void set_tree_node_visibility(
const T& value,
bool is_visible) { set_tree_node_visibility_void(wi_get_value_ptr(value), wi_get_index(value), is_visible); }
230 bool begin_tree_node_void(
const std::string& label,
const void* value_ptr,
int index = -1,
bool initial_visibility =
false,
const std::string& options =
"",
gui_group_ptr ggp =
gui_group_ptr());
232 static bool& ref_tree_node_visible_flag_void(
const void* value_ptr,
int index = -1);
234 void end_tree_node_void(
const void* value_ptr,
int index = -1);
236 bool is_tree_node_visible_void(
const void* value_ptr,
int index)
const;
238 void set_tree_node_visibility_void(
const void* value_ptr,
int index,
bool is_visible);
246 template <
typename T>
247 bool add_gui(
const std::string& label, T& value,
const std::string& gui_type =
"",
const std::string& options =
"")
256 virtual void on_select();
258 virtual void on_deselect();
277 virtual std::string get_gui_name()
const;
281 virtual std::string get_parent_type()
const;
283 virtual bool ensure_selected_in_tab_group_parent();
285 virtual void update_member(
void* member_ptr);
287 virtual void update_all_members();
289 virtual std::string get_menu_path()
const;
291 virtual shortcut get_shortcut()
const;
301 virtual void recreate_gui();
305 virtual void post_recreate_gui();
312 void remove_all_elements();
319 template <
typename T>
321 if (parent_group.
empty())
323 return parent_group->find_view(value,idx_ptr);
329 template <
typename T>
331 if (parent_group.
empty())
333 return parent_group->find_control(value,idx_ptr);
336 control_ptr find_control_void(
void* value_ptr,
int* idx_ptr);
338 view_ptr find_view_void(
void* value_ptr,
int* idx_ptr);
342 template <
typename T>
360#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
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 derive...
bool empty() const
check if pointer is not yet set
gui independent group class which is a container for gui elements
derive from this class to provide a gui to the current viewer
bool add_gui(const std::string &label, T &value, const std::string &gui_type="", const std::string &options="")
Add a composed gui of the given gui_type for the given value.
gui_group_ptr get_parent_group() const
use the parent group to append to be managed elements that should be destroyed in a post_recreate_gui...
virtual void create_gui()=0
you must overload this for gui creation
void set_tree_node_visibility(const T &value, bool is_visible)
set the visibility status of sub tree attached to a value. This calls the post_recreate method if nee...
data::ref_ptr< view< T > > find_view(const T &value, int *idx_ptr=0)
find a view of a given class member
bool begin_tree_node(const std::string &label, const T &value, bool initial_visibility=false, const std::string &options="", gui_group_ptr ggp=gui_group_ptr())
Begin a sub tree of a tree structured gui.
data::ref_ptr< control< T > > add_member_control(cgv::base::base *base_ptr, const std::string &label, T &value, const std::string &gui_type="", const std::string &options="", const std::string &align="\n")
add control with callback to cgv::base::on_set method on cgv::gui::control::value_change
void end_tree_node(const T &value)
template specialization that allows to specify value reference plus node_instance by using the result...
void set_control_property(T &value, const std::string &property_name, const std::string &property_value)
Set the property value of all controls of a given class member.
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)
use this to add a new control to the gui, where the control is implemented with a control provider cl...
bool is_tree_node_visible(const T &value) const
return whether the sub tree attached to a value is visible
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")
use this to add a new view to the gui with a given value type, gui type and init options
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")
use this to add a new control to the gui with a given value type, gui type and init options
static bool & ref_tree_node_visible_flag(const T &value)
return a reference to the boolean flag, that tells whether the tree node for the passed value is visi...
data::ref_ptr< control< T > > find_control(T &value, int *idx_ptr=0)
find a control of a given class member
gui_group_ptr parent_group
driver specific handle for the group gui element managing the gui built in the provider
the shortcut class encapsulates a key with modifiers
with_index_struct< T > with_index(const T &_value, int _index)
helper function to support value references as well as value references with index for the tree_node ...
bool create_gui(provider *p, const std::string &label, void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, bool *toggles)
create the gui for a composed structure
type independent base class of control provider interface
helper struct to support value references as well as value references with index
traits class with a static function get_name() of type const char* that returns the type name of the ...