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;
33 bool self_reflect(cgv::reflect::reflection_handler& rh);
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>
interface for all classes that want to receive events
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.
the cgv namespace
Definition print.h:11