Puls der Zeit
[ardour.git] / libs / surfaces / maschine2 / ui_knob.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18
19 #ifndef _ardour_maschine2_knob_h_
20 #define _ardour_maschine2_knob_h_
21
22 #include <boost/shared_ptr.hpp>
23 #include <sigc++/trackable.h>
24
25 #include <cairomm/refptr.h>
26
27 #include "pbd/signals.h"
28
29 #include "canvas/container.h"
30
31 namespace ArdourCanvas {
32         class Text;
33 }
34
35 namespace ARDOUR {
36         class AutomationControl;
37 }
38
39 namespace Cairo {
40         class Context;
41         class Region;
42 }
43
44 namespace ArdourSurface {
45
46 class Maschine2;
47 class M2EncoderInterface;
48
49 class Maschine2Knob : public sigc::trackable, public ArdourCanvas::Container
50 {
51         public:
52                 Maschine2Knob (PBD::EventLoop*, ArdourCanvas::Item*);
53                 virtual ~Maschine2Knob ();
54
55                 void set_controllable (boost::shared_ptr<ARDOUR::AutomationControl>);
56                 void set_control (M2EncoderInterface*);
57                 boost::shared_ptr<ARDOUR::AutomationControl> controllable() const { return _controllable; }
58
59                 void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
60                 void compute_bounding_box() const;
61
62         protected:
63                 void controllable_changed ();
64                 void encoder_changed (int);
65
66                 PBD::ScopedConnection watch_connection;
67                 PBD::ScopedConnection encoder_connection;
68
69                 boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
70                 M2EncoderInterface* _ctrl;
71
72         private:
73                 PBD::EventLoop* _eventloop;
74
75                 float  _radius;
76                 float  _val; // current value [0..1]
77                 float  _normal; // default value, arc
78
79                 ArdourCanvas::Text* text;
80 };
81
82 } // namespace
83
84 #endif