MCP: better display of parameter values, off by one error when collecting controls...
[ardour.git] / libs / surfaces / mackie / strip.h
1 #ifndef __ardour_mackie_control_protocol_strip_h__
2 #define __ardour_mackie_control_protocol_strip_h__
3
4 #include <string>
5 #include <iostream>
6
7 #include "pbd/property_basics.h"
8 #include "pbd/signals.h"
9
10 #include "ardour/types.h"
11 #include "control_protocol/types.h"
12
13 #include "control_group.h"
14 #include "types.h"
15 #include "midi_byte_array.h"
16
17 namespace ARDOUR {
18         class Route;
19 }
20
21 namespace Mackie {
22
23 class Control;
24 class Surface;
25 class Button;
26 class Pot;
27 class Fader;
28 class Meter;
29 class SurfacePort;
30
31 struct StripControlDefinition {
32     const char* name;
33     uint32_t base_id;
34     Control* (*factory)(Surface&, int index, const char* name, Group&);
35 };
36
37 struct GlobalControlDefinition {
38     const char* name;
39     uint32_t id;
40     Control* (*factory)(Surface&, int index, const char* name, Group&);
41     const char* group_name;
42 };
43
44 /**
45         This is the set of controls that make up a strip.
46 */
47 class Strip : public Group
48 {
49 public:
50         Strip (Surface&, const std::string & name, int index, StripControlDefinition* ctls);
51         ~Strip();
52
53         boost::shared_ptr<ARDOUR::Route> route() const { return _route; }
54
55         void add (Control & control);
56         int index() const { return _index; } // zero based
57         
58         void set_route (boost::shared_ptr<ARDOUR::Route>);
59
60         // call all signal handlers manually
61         void notify_all();
62
63         void handle_button (Button&, ButtonState bs);
64         void handle_fader (Fader&, float position);
65         void handle_pot (Pot&, float delta);
66
67         void periodic (uint64_t now_usecs);
68
69         MidiByteArray display (uint32_t line_number, const std::string&);
70         MidiByteArray blank_display (uint32_t line_number);
71         MidiByteArray zero ();
72
73         void flip_mode_changed (bool notify=false);
74
75         void lock_controls ();
76         void unlock_controls ();
77         
78         MidiByteArray gui_selection_changed (ARDOUR::RouteNotificationListPtr);
79
80 private:
81         Button*  _solo;
82         Button*  _recenable;
83         Button*  _mute;
84         Button*  _select;
85         Button*  _vselect;
86         Button*  _fader_touch;
87         Pot*     _vpot;
88         Fader*   _fader;
89         Meter*   _meter;
90         int      _index;
91         Surface* _surface;
92         bool     _controls_locked;
93         uint64_t _reset_display_at;
94
95         boost::shared_ptr<ARDOUR::Route> _route;
96         PBD::ScopedConnectionList route_connections;
97
98         float _last_gain_position_written;
99         float _last_pan_position_written;
100
101         void notify_solo_changed ();
102         void notify_mute_changed ();
103         void notify_record_enable_changed ();
104         void notify_gain_changed (bool force_update = true);
105         void notify_property_changed (const PBD::PropertyChange&);
106         void notify_panner_changed (bool force_update = true);
107         void notify_active_changed ();
108         void notify_route_deleted ();
109         
110         void update_automation ();
111         void update_meter ();
112
113         std::string static_display_string () const;
114
115         void queue_display_reset (uint32_t msecs);
116         void clear_display_reset ();
117         void reset_display ();
118         void do_parameter_display (ARDOUR::AutomationType, float val);
119 };
120
121 }
122
123 #endif /* __ardour_mackie_control_protocol_strip_h__ */