ifdefs for debug output. Fix host.rb
[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 #define DEBUG 1
22
23 namespace Mackie
24 {
25
26 /**
27         This started off as an enum, but it got really annoying
28         typing ? on : off
29 */
30 class LedState
31 {
32 public:
33         enum state_t { none, off, flashing, on };
34         LedState()  : _state( none ) {}
35         LedState( bool yn ): _state( yn ? on : off ) {}
36         LedState( state_t state ): _state( state ) {}
37
38         bool operator == ( const LedState & other ) const
39         {
40                 return state() == other.state();
41         }
42         
43         bool operator != ( const LedState & other ) const
44         {
45                 return state() != other.state();
46         }
47         
48         state_t state() const { return _state; }
49         
50 private:
51         state_t _state;
52 };
53
54 extern LedState on;
55 extern LedState off;
56 extern LedState flashing;
57 extern LedState none;
58
59 enum ButtonState { neither = -1, release = 0, press = 1 };
60
61 /**
62         Contains the state for a control, with some convenience
63         constructors
64 */
65 struct ControlState
66 {
67         ControlState(): pos(0.0), delta(0.0), button_state(neither) {}
68         
69         ControlState( LedState ls ): pos(0.0), delta(0.0), led_state(ls), button_state(neither) {}
70         
71         // Note that this sets both pos and delta to the flt value
72         ControlState( LedState ls, float flt ): pos(flt), delta(flt), ticks(0), led_state(ls), button_state(neither) {}
73         ControlState( float flt ): pos(flt), delta(flt), ticks(0), led_state(none), button_state(neither) {}
74         ControlState( float flt, int tcks ): pos(flt), delta(flt), ticks(tcks), led_state(none), button_state(neither) {}
75         ControlState( ButtonState bs ): pos(0.0), delta(0.0), ticks(0), led_state(none), button_state(bs) {}
76         
77         float pos;
78         float delta;
79         int ticks;
80         LedState led_state;
81         ButtonState button_state;
82 };
83
84 class Control;
85 class Fader;
86 class Button;
87 class Strip;
88 class Group;
89 class Pot;
90 class Led;
91 class LedRing;
92
93 }
94
95 #endif