globally remove all trailing whitespace from ardour code base.
[ardour.git] / libs / surfaces / mackie / types.h
1 /*
2         Copyright (C) 2006,2007 John Anderson
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 of the License, or
7         (at your option) 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
16         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */
18 #ifndef mackie_types_h
19 #define mackie_types_h
20
21 #include <iostream>
22
23 namespace ArdourSurface  {
24 namespace Mackie {
25
26 enum surface_type_t {
27         mcu,
28         ext,
29 };
30
31 /**
32         This started off as an enum, but it got really annoying
33         typing ? on : off
34 */
35 class LedState
36 {
37 public:
38         enum state_t { none, off, flashing, on };
39         LedState()  : _state (none) {}
40         LedState (bool yn): _state (yn ? on : off) {}
41         LedState (state_t state): _state (state) {}
42
43         LedState& operator= (state_t s) { _state = s; return *this;  }
44                 
45         bool operator ==  (const LedState & other) const
46         {
47                 return state() == other.state();
48         }
49         
50         bool operator !=  (const LedState & other) const
51         {
52                 return state() != other.state();
53         }
54         
55         state_t state() const { return _state; }
56         
57 private:
58         state_t _state;
59 };
60
61 extern LedState on;
62 extern LedState off;
63 extern LedState flashing;
64 extern LedState none;
65
66 enum ButtonState { neither = -1, release = 0, press = 1 };
67
68 /**
69         Contains the state for a control, with some convenience
70         constructors
71 */
72 struct ControlState
73 {
74         ControlState(): pos(0.0), sign(0), delta(0.0), ticks(0), led_state(off), button_state(neither) {}
75         
76         ControlState (LedState ls): pos(0.0), delta(0.0), led_state(ls), button_state(neither) {}
77         
78         // Note that this sets both pos and delta to the flt value
79         ControlState (LedState ls, float flt): pos(flt), delta(flt), ticks(0), led_state(ls), button_state(neither) {}
80         ControlState (float flt): pos(flt), delta(flt), ticks(0), led_state(none), button_state(neither) {}
81         ControlState (float flt, unsigned int tcks): pos(flt), delta(flt), ticks(tcks), led_state(none), button_state(neither) {}
82         ControlState (ButtonState bs): pos(0.0), delta(0.0), ticks(0), led_state(none), button_state(bs) {}
83         
84         /// For faders. Between 0 and 1.
85         float pos;
86                 
87         /// For pots. Sign. Either -1 or 1;
88         int sign;
89
90         /// For pots. Signed value of total movement. Between 0 and 1
91         float delta;
92                 
93         /// For pots. Unsigned number of ticks. Usually between 1 and 16.
94         unsigned int ticks;
95                 
96         LedState led_state;
97         ButtonState button_state;
98 };
99
100 std::ostream & operator <<  (std::ostream &, const ControlState &);
101
102 class Control;
103 class Fader;
104 class Button;
105 class Strip;
106 class Group;
107 class Pot;
108 class Led;
109
110 }
111 }
112
113 #endif