Only show user-presets in favorite sidebar
[ardour.git] / libs / surfaces / faderport8 / fp8_controls.h
1 /*
2  * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef _ardour_surfaces_fp8controls_h_
20 #define _ardour_surfaces_fp8controls_h_
21
22 #include <map>
23
24 #include "fp8_base.h"
25 #include "fp8_button.h"
26 #include "fp8_strip.h"
27
28 namespace ArdourSurface { namespace FP_NAMESPACE {
29
30 class FP8Controls
31 {
32 public:
33         FP8Controls (FP8Base&);
34         virtual ~FP8Controls ();
35
36         enum ButtonId {
37                 BtnPlay,
38                 BtnStop,
39                 BtnRecord,
40                 BtnLoop,
41                 BtnRewind,
42                 BtnFastForward,
43
44                 BtnALatch,
45                 BtnATrim,
46                 BtnAOff,
47                 BtnATouch,
48                 BtnAWrite,
49                 BtnARead,
50
51                 // Automation
52                 BtnSave,
53                 BtnRedo,
54                 BtnUndo,
55                 BtnUser1,
56                 BtnUser2,
57                 BtnUser3,
58
59 #ifndef FADERPORT2
60                 BtnFootswitch,
61 #endif
62
63                 // Pan/Param encoder press
64                 BtnParam,
65
66                 // Navigation
67                 BtnPrev,
68                 BtnNext,
69                 BtnEncoder,
70
71                 BtnChannel,
72                 BtnZoom,
73                 BtnScroll,
74                 BtnBank,
75                 BtnMaster,
76                 BtnClick,
77                 BtnSection,
78                 BtnMarker,
79
80                 BtnF1, BtnF2, BtnF3, BtnF4,
81                 BtnF5, BtnF6, BtnF7, BtnF8,
82 #ifdef FADERPORT2
83                 BtnFootswitch,
84 #endif
85
86                 // FaderMode
87                 BtnTrack,
88                 BtnPlugins,
89                 BtnSend,
90                 BtnPan,
91
92                 BtnTimecode,
93
94                 // Mix Management
95                 BtnMAudio,
96                 BtnMVI,
97                 BtnMBus,
98                 BtnMVCA,
99                 BtnMAll,
100
101                 BtnMInputs,
102                 BtnMMIDI,
103                 BtnMOutputs,
104                 BtnMFX,
105                 BtnMUser,
106
107                 // General Controls
108                 BtnArm,
109                 BtnArmAll,
110                 BtnSoloClear,
111                 BtnMuteClear,
112
113                 BtnBypass,
114                 BtnBypassAll,
115                 BtnMacro,
116                 BtnOpen,
117                 BtnLink,
118                 BtnLock,
119
120                 /* FP2 only */
121                 BtnChanLock,
122                 BtnFlip
123
124         };
125
126         typedef std::map <ButtonId, std::string> UserButtonMap;
127
128         UserButtonMap const& user_buttons () const {
129                 return _user_buttons;
130         }
131
132         bool button_name_to_enum (std::string const&, ButtonId&) const;
133         bool button_enum_to_name (ButtonId, std::string&) const;
134
135         PBD::Signal0<void> FaderModeChanged;
136         PBD::Signal0<void> MixModeChanged;
137
138 #ifdef FADERPORT2
139         FP8Types::FaderMode fader_mode () const { return FP8Types::ModeTrack; }
140         FP8Types::MixMode mix_mode () const { return FP8Types::MixUser; }
141 #else
142         FP8Types::FaderMode fader_mode () const { return _fadermode; }
143         FP8Types::MixMode mix_mode () const { return _mixmode; }
144 #endif
145
146         FP8Types::NavigationMode nav_mode () const { return _navmode; }
147         bool display_timecode () const { return _display_timecode; }
148
149         FP8ButtonInterface& button (ButtonId id);
150         FP8Strip& strip (uint8_t id);
151
152         bool midi_event (uint8_t id, uint8_t val);
153         bool midi_touch (uint8_t id, uint8_t val);
154         bool midi_fader (uint8_t id, unsigned short val);
155
156         void initialize ();
157         void all_lights_off () const;
158
159         void set_fader_mode (FP8Types::FaderMode);
160 protected:
161         typedef std::map <uint8_t, FP8ButtonInterface*> MidiButtonMap;
162         typedef std::map <ButtonId, FP8ButtonInterface*> CtrlButtonMap;
163
164         void set_nav_mode (FP8Types::NavigationMode);
165         void set_mix_mode (FP8Types::MixMode);
166         void toggle_timecode ();
167
168         MidiButtonMap _midimap;
169         CtrlButtonMap _ctrlmap;
170         MidiButtonMap _midimap_strip;
171
172         FP8Strip* chanstrip[N_STRIPS];
173
174         FP8Types::FaderMode      _fadermode;
175         FP8Types::NavigationMode _navmode;
176         FP8Types::MixMode        _mixmode;
177         bool                     _display_timecode;
178
179         UserButtonMap  _user_buttons;
180         FP8DummyButton _dummy_button;
181
182         std::map<std::string, ButtonId> _user_str_to_enum;
183         std::map<ButtonId, std::string> _user_enum_to_str;
184
185         PBD::ScopedConnectionList button_connections;
186 };
187
188 } } /* namespace */
189 #endif /* _ardour_surfaces_fp8controls_h_ */