cgv
Loading...
Searching...
No Matches
key_control.h
1#pragma once
2
3#include <cgv/base/node.h>
4#include "shortcut.h"
5#include "control.h"
6#include "event.h"
7#include "event_handler.h"
8
9#include "lib_begin.h"
10
11namespace cgv {
12 namespace gui {
13
14
15template <typename T>
16class CGV_API key_control : public control<T>, public event_handler, virtual public cgv::signal::tacker
17{
18private:
19 double increase_pressed_time;
20 double decrease_pressed_time;
21protected:
22 T speed;
23 T min_value;
24 T max_value;
25 bool log_scale;
26 bool no_limits;
27 shortcut more;
28 shortcut less;
29 void change_value(double dt);
30public:
31 key_control(const std::string& name, T& _value, const std::string& options = "");
32 std::string get_type_name() const;
34 std::string get_property_declarations();
35 bool set_void(const std::string& property, const std::string& value_type, const void* value_ptr);
36 bool get_void(const std::string& property, const std::string& value_type, void* value_ptr);
37 void on_set(void* member_ptr);
38 bool handle(event& e);
39 void stream_help(std::ostream& os);
40 void timer_event(double time, double dt);
41};
42
43template <> class CGV_API key_control<bool> : public control<bool>, public event_handler
44{
45protected:
46 shortcut toggle;
47 void change_value(double dt);
48public:
49 key_control(const std::string& name, bool& _value, const std::string& options = "");
50 std::string get_type_name() const;
51 std::string get_property_declarations();
52 bool set_void(const std::string& property, const std::string& value_type, const void* value_ptr);
53 bool get_void(const std::string& property, const std::string& value_type, void* value_ptr);
54 bool handle(event& e);
55 void stream_help(std::ostream& os);
56};
57
58
59 }
60}
61
62#include <cgv/config/lib_end.h>
std::string name
store the name as a string
Definition named.h:25
control(const std::string &_name, T &_value)
construct abstract element from reference to value
Definition control.h:110
event_handler()
default construction
bool get_void(const std::string &property, const std::string &value_type, void *value_ptr)
abstract interface for the getter of a dynamic property.
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.
std::string get_type_name() const
overload to return the type name of this object
bool handle(event &e)
overload and implement this method to handle events
std::string get_property_declarations()
return a semicolon separated list of property declarations
void stream_help(std::ostream &os)
overload to stream help information to the given output stream
std::string get_property_declarations()
return a semicolon separated list of property declarations
void stream_help(std::ostream &os)
overload to stream help information to the given output stream
bool self_reflect(cgv::reflect::reflection_handler &rh)
used for simple self reflection
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 set_void(const std::string &property, const std::string &value_type, const void *value_ptr)
abstract interface for the setter of a dynamic property.
std::string get_type_name() const
overload to return the type name of this object
bool handle(event &e)
overload and implement this method to handle events
bool get_void(const std::string &property, const std::string &value_type, void *value_ptr)
abstract interface for the getter of a dynamic property.
the shortcut class encapsulates a key with modifiers
Definition shortcut.h:84
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
this header is dependency free
Definition print.h:11