remove redundant MackieButtonHandler class, implement initial zoom support for cursor...
[ardour.git] / libs / surfaces / mackie / surface.h
1 #ifndef mackie_surface_h
2 #define mackie_surface_h
3
4 #include "controls.h"
5 #include "types.h"
6 #include <stdint.h>
7
8 namespace Mackie
9 {
10
11 class MackieButtonHandler;
12 class SurfacePort;
13 class MackieMidiBuilder;
14 class Button;
15 class Meter;
16 class Fader;
17 class Jog;
18 class Pot;
19 class Led;
20 class LedRing;
21
22 /**
23         This represents an entire control surface, made up of Groups,
24         Strips and Controls. There are several collections for
25         ease of addressing in different ways, but only one collection
26         has definitive ownership.
27
28         It handles mapping button ids to press_ and release_ calls.
29
30         There are various emulations of the Mackie around, so specific
31         emulations will inherit from this to change button mapping, or 
32         have 7 fader channels instead of 8, or whatever.
33
34         Currently there are BcfSurface and MackieSurface.
35
36         TODO maybe make Group inherit from Control, for ease of ownership.
37 */
38 class Surface
39 {
40 public:
41         /**
42                 A Surface can be made up of multiple units. eg one Mackie MCU plus
43                 one or more Mackie MCU extenders.
44                 
45                 \param max_strips is the number of strips for the entire surface.
46                 \param unit_strips is the number of strips per unit.
47         */
48
49         Surface (uint32_t max_strips, uint32_t unit_strips);
50         virtual ~Surface();
51
52         /// Calls the virtual initialisation methods. This *must* be called after
53         /// construction, because c++ is too dumb to call virtual methods from
54         /// inside a constructor
55         void init();
56
57         typedef std::vector<Control*> Controls;
58         
59         /// This collection has ownership of all the controls
60         Controls controls;
61
62         /**
63                 These are alternative addressing schemes
64                 They use maps because the indices aren't always
65                 0-based.
66                 
67                 Indexed by raw_id not by id. @see Control for the distinction.
68         */
69         std::map<int,Fader*> faders;
70         std::map<int,Pot*> pots;
71         std::map<int,Button*> buttons;
72         std::map<int,Led*> leds;
73         std::map<int,Meter*> meters;
74
75         /// no strip controls in here because they usually
76         /// have the same names.
77         std::map<std::string,Control*> controls_by_name;
78
79         /// The collection of all numbered strips. No master
80         /// strip in here.
81         typedef std::vector<Strip*> Strips;
82         Strips strips;
83
84         /// This collection owns the groups
85         typedef std::map<std::string,Group*> Groups;
86         Groups groups;
87
88         uint32_t max_strips() const { return _max_strips; }
89         
90 public:
91         /// display an indicator of the first switched-in Route. Do nothing by default.
92         virtual void display_bank_start( SurfacePort &, MackieMidiBuilder &, uint32_t /*current_bank*/ ) {};
93                 
94         /// called from MackieControlPRotocol::zero_all to turn things off
95         virtual void zero_all( SurfacePort &, MackieMidiBuilder & ) {};
96
97         /// turn off leds around the jog wheel. This is for surfaces that use a pot
98         /// pretending to be a jog wheel.
99         virtual void blank_jog_ring( SurfacePort &, MackieMidiBuilder & ) {};
100
101         virtual bool has_timecode_display() const = 0;
102         virtual void display_timecode( SurfacePort &, MackieMidiBuilder &, const std::string & /*timecode*/, const std::string & /*timecode_last*/) {};
103         
104 public:
105         /**
106                 This is used to calculate the clicks per second that define
107                 a transport speed of 1.0 for the jog wheel. 100.0 is 10 clicks
108                 per second, 50.5 is 5 clicks per second.
109         */
110         virtual float scrub_scaling_factor() = 0;
111
112         /**
113                 The scaling factor function for speed increase and decrease. At
114                 low transport speeds this should return a small value, for high transport
115                 speeds, this should return an exponentially larger value. This provides
116                 high definition control at low speeds and quick speed changes to/from
117                 higher speeds.
118         */
119         virtual float scaled_delta( const ControlState & state, float current_speed ) = 0;
120
121 protected:
122         virtual void init_controls();
123         virtual void init_strips ();
124
125         const uint32_t _max_strips;
126         const uint32_t _unit_strips;
127 };
128
129 }
130
131 #endif