5#include <cgv/signal/signal.h>
17 static bool access_on_release(
const void* value_ptr,
char access_mode);
20 static bool on_release(
const void* value_ptr);
24 bool shows(
const void* ptr)
const;
26 virtual bool controls(
const void* ptr)
const = 0;
46 virtual bool controls(
const void* ptr,
void* user_data)
const = 0;
59 virtual void set_value(
const T& value,
void* user_data) = 0;
61 virtual const T
get_value(
void* user_data)
const = 0;
63 virtual bool controls(
const void* ptr,
void* user_data)
const {
return false; }
94 void set_value(
const T& v) {
103 const T* get_value_ptr()
const {
return cp ? 0 : value_ptr; }
110 control(
const std::string& _name, T& _value) :
abst_control(_name), value_ptr(&_value), new_value(_value), cp(0) {
111 attach_to_reference(value_ptr);
118 attach_to_reference(value_ptr);
126 (
void*&)value_ptr = user_data;
130 value_ptr = (T*)user_data;
131 new_value = *value_ptr;
132 attach_to_reference(value_ptr);
153 if (check_value(*
this)) {
154 T tmp_value = get_value();
155 set_value(this->get_new_value());
156 set_new_value(tmp_value);
163 bool controls(
const void* ptr)
const {
return cp ? cp->
controls(ptr,value_ptr) : (value_ptr == ptr); }
166 value_change.connect_abst(func);
170 check_value.connect_abst(bool_func);
177#include <cgv/config/lib_end.h>
reference counted pointer, which can work together with types that are derived from ref_counted,...
gui and type independent base class of all controls
virtual bool controls(const void *ptr) const =0
return whether the control controls the value pointed to by ptr
virtual void attach_to_value_change(cgv::signal::functor_base *func)=0
attach a functor to the value change signal
virtual void attach_to_check_value(cgv::signal::functor_base *bool_func)=0
attach a functor to the value change signal
type independent &base class of all views
control(const std::string &_name, T *_value)
construct abstract element from control_provider
cgv::signal::bool_signal< control< T > & > value_check_signal_type
type of the value check signal
bool check_and_set_value(const T &nv)
set new value only if check_value signal succeeds and send value_change signal. Return true if value ...
const T & get_new_value() const
return the new value to the callbacks attached to the check_value signal
void set_new_value(const T &nv)
set a different new value from the callbacks attached to the check_value signal
cgv::signal::signal< control< T > & > value_change
this signal is sent after the user triggered a change of value and the check_value succeeded.
const T get_value() const
return a reference to the current value
control(const std::string &_name, T &_value)
construct abstract element from reference to value
const T & get_old_value() const
return the old value to the callbacks attached to the change_value signal
cgv::signal::bool_signal< control< T > & > check_value
this signal is sent when the user triggered a change of value in order to check whether the new value...
void attach_to_value_change(cgv::signal::functor_base *func)
attach a functor to the value change signal
void attach_to_check_value(cgv::signal::functor_base *bool_func)
attach a functor to the value change signal
bool controls(const void *ptr) const
check whether the value represented by this element is pointing to the passed pointer
control(const std::string &_name, abst_control_provider *_cp, void *user_data)
this constructor allows contruction from control_provider with user data or if the pointer to the con...
cgv::signal::signal< control< T > & > value_change_signal_type
type of the value change signal
data::ref_ptr< abst_control > control_ptr
ref counted pointer to abst control
type independent base class of control provider interface
virtual bool controls(const void *ptr, void *user_data) const =0
overload to check if ptr points to the controlled value
virtual void set_value(const T &value, void *user_data)=0
overload to set the value
virtual bool controls(const void *ptr, void *user_data) const
the default implementation compares ptr to &get_value().
virtual const T get_value(void *user_data) const =0
overload to get the value