first compiling and theoretically correct version of Push2 canvas display.
[ardour.git] / libs / surfaces / push2 / knob.h
1 #ifndef __ardour_push2_knob_h__
2 #define __ardour_push2_knob_h__
3
4 #include <boost/shared_ptr.hpp>
5 #include <sigc++/trackable.h>
6
7 #include <cairomm/refptr.h>
8
9 #include "pbd/signals.h"
10
11 #include "canvas/item.h"
12 #include "canvas/text.h"
13
14 namespace ARDOUR {
15         class AutomationControl;
16 }
17
18 namespace Cairo {
19         class Context;
20         class Region;
21 }
22
23 namespace ArdourSurface {
24
25 class Push2;
26
27 class Push2Knob : public sigc::trackable, public ArdourCanvas::Item
28 {
29 public:
30         enum Element {
31                 Arc = 0x1,
32                 Bevel = 0x2,
33                 unused2 = 0x4,
34                 unused3 = 0x8,
35                 unused4 = 0x10,
36                 unused5 = 0x20,
37         };
38
39         enum Flags {
40                 NoFlags = 0,
41                 Detent = 0x1,
42                 ArcToZero = 0x2,
43         };
44
45         Push2Knob (Push2& p, ArdourCanvas::Item*, Element e = default_elements, Flags flags = NoFlags);
46         virtual ~Push2Knob ();
47
48         static Element default_elements;
49
50         void add_flag (Flags);
51         void remove_flag (Flags);
52
53         void set_controllable (boost::shared_ptr<ARDOUR::AutomationControl> c);
54         boost::shared_ptr<ARDOUR::AutomationControl> controllable() const { return _controllable; }
55
56         void set_text_color (ArdourCanvas::Color);
57         void set_arc_start_color (ArdourCanvas::Color);
58         void set_arc_end_color (ArdourCanvas::Color);
59         void set_position (double x, double y);
60         void set_radius (double r);
61
62         void render (ArdourCanvas::Rect const &, Cairo::RefPtr<Cairo::Context>) const;
63         void compute_bounding_box() const;
64
65   protected:
66         void controllable_changed ();
67         PBD::ScopedConnection watch_connection;
68         boost::shared_ptr<ARDOUR::AutomationControl> _controllable;
69
70   private:
71         Push2& p2;
72         Element _elements;
73         Flags   _flags;
74         double  _r;
75         float   _val; // current value [0..1]
76         float   _normal; // default value, arc
77
78         ArdourCanvas::Color text_color;
79         ArdourCanvas::Color arc_start_color;
80         ArdourCanvas::Color arc_end_color;
81         ArdourCanvas::Text  text;
82
83         void set_pan_azimuth_text (double);
84         void set_pan_width_text (double);
85         void set_gain_text (double);
86 };
87
88 } // namespace
89
90 #endif /* __ardour_push2_knob_h__ */