enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / tranzport / button_events.cc
1 /*
2  *   Copyright (C) 2006 Paul Davis
3  *   Copyright (C) 2007 Michael Taht
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *   GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  *   */
20
21 #include <tranzport_common.h>
22 #include <tranzport_control_protocol.h>
23
24 using namespace ARDOUR;
25 using namespace std;
26 using namespace sigc;
27 using namespace PBD;
28
29 #include "pbd/i18n.h"
30
31 #include <pbd/abstract_ui.cc>
32
33
34
35 void
36 TranzportControlProtocol::button_event_battery_press (bool shifted)
37 {
38 }
39
40 void
41 TranzportControlProtocol::button_event_battery_release (bool shifted)
42 {
43 }
44
45 void
46 TranzportControlProtocol::button_event_backlight_press (bool shifted)
47 {
48 }
49
50 void
51 TranzportControlProtocol::button_event_backlight_release (bool shifted)
52 {
53 #if DEBUG_TRANZPORT
54         printf("backlight released, redrawing (and possibly crashing) display\n");
55 #endif
56         if (shifted) {
57                 lcd_damage();
58                 lcd_clear();
59                 last_where += 1; /* force time redisplay */
60                 last_track_gain = FLT_MAX;
61         }
62 }
63
64 void
65 TranzportControlProtocol::button_event_trackleft_press (bool shifted)
66 {
67         prev_track ();
68         // not really the right layer for this
69         if(display_mode == DisplayBigMeter) {
70                 if (route_table[0] != 0) {
71                         notify(route_get_name (0).substr (0, 15).c_str());
72                 }
73         }
74 }
75
76 void
77 TranzportControlProtocol::button_event_trackleft_release (bool shifted)
78 {
79 }
80
81 void
82 TranzportControlProtocol::button_event_trackright_press (bool shifted)
83 {
84         next_track ();
85         // not really the right layer for this
86         if(display_mode == DisplayBigMeter) {
87                 if (route_table[0] != 0) {
88                         notify(route_get_name (0).substr (0, 15).c_str());
89                 }
90         }
91 }
92
93 void
94 TranzportControlProtocol::button_event_trackright_release (bool shifted)
95 {
96 }
97
98 void
99 TranzportControlProtocol::button_event_trackrec_press (bool shifted)
100 {
101         if (shifted) {
102                 toggle_all_rec_enables ();
103         } else {
104                 route_set_rec_enable (0, !route_get_rec_enable (0));
105         }
106 }
107
108 void
109 TranzportControlProtocol::button_event_trackrec_release (bool shifted)
110 {
111 }
112
113 void
114 TranzportControlProtocol::button_event_trackmute_press (bool shifted)
115 {
116         if (shifted) {
117                 // Mute ALL? Something useful when a phone call comes in. Mute master?
118         } else {
119                 route_set_muted (0, !route_get_muted (0));
120         }
121 }
122
123 void
124 TranzportControlProtocol::button_event_trackmute_release (bool shifted)
125 {
126 }
127
128 void
129 TranzportControlProtocol::button_event_tracksolo_press (bool shifted)
130 {
131 #if DEBUG_TRANZPORT
132         printf("solo pressed\n");
133 #endif
134         if (display_mode == DisplayBigMeter) {
135                 light_off (LightAnysolo);
136                 return;
137         }
138
139         if (shifted) {
140                 session->set_all_solo (!session->soloing());
141         } else {
142                 route_set_soloed (0, !route_get_soloed (0));
143         }
144 }
145
146 void
147 TranzportControlProtocol::button_event_tracksolo_release (bool shifted)
148 {
149 #if DEBUG_TRANZPORT
150         printf("solo released\n");
151 #endif
152 }
153
154 void
155 TranzportControlProtocol::button_event_undo_press (bool shifted)
156 {
157 // undohistory->get_state(1);
158 //XMLNode&
159 //UndoHistory::get_state (uint32_t depth)
160
161         if (shifted) {
162                 redo (); // someday flash the screen with what was redone
163                 notify("Redone!!");
164         } else {
165                 undo (); // someday flash the screen with what was undone
166                 notify("Undone!!");
167         }
168 }
169
170 void
171 TranzportControlProtocol::button_event_undo_release (bool shifted)
172 {
173 }
174
175 void
176 TranzportControlProtocol::button_event_in_press (bool shifted)
177 {
178         if (shifted) {
179                 toggle_punch_in ();
180         } else {
181                 ControlProtocol::ZoomIn (); /* EMIT SIGNAL */
182         }
183 }
184
185 void
186 TranzportControlProtocol::button_event_in_release (bool shifted)
187 {
188 }
189
190 void
191 TranzportControlProtocol::button_event_out_press (bool shifted)
192 {
193         if (shifted) {
194                 toggle_punch_out ();
195         } else {
196                 ControlProtocol::ZoomOut (); /* EMIT SIGNAL */
197         }
198 }
199
200 void
201 TranzportControlProtocol::button_event_out_release (bool shifted)
202 {
203 }
204
205 void
206 TranzportControlProtocol::button_event_punch_press (bool shifted)
207 {
208 }
209
210 void
211 TranzportControlProtocol::button_event_punch_release (bool shifted)
212 {
213 }
214
215 void
216 TranzportControlProtocol::button_event_loop_press (bool shifted)
217 {
218         if (shifted) {
219                 next_wheel_shift_mode ();
220         } else {
221                 loop_toggle ();
222         }
223 }
224
225 void
226 TranzportControlProtocol::button_event_loop_release (bool shifted)
227 {
228 }
229
230 void
231 TranzportControlProtocol::button_event_prev_press (bool shifted)
232 {
233         if (shifted) {
234                 ControlProtocol::ZoomToSession (); /* EMIT SIGNAL */
235         } else {
236                 prev_marker ();
237         }
238 }
239
240 void
241 TranzportControlProtocol::button_event_prev_release (bool shifted)
242 {
243 }
244
245 // Note - add_marker should adhere to the snap to setting
246 // maybe session->audible_frame does that
247
248 void
249 TranzportControlProtocol::button_event_add_press (bool shifted)
250 {
251         add_marker ();
252 }
253
254 void
255 TranzportControlProtocol::button_event_add_release (bool shifted)
256 {
257 }
258
259 void
260 TranzportControlProtocol::button_event_next_press (bool shifted)
261 {
262         if (shifted) {
263                 next_wheel_mode ();
264         } else {
265                 next_marker ();
266         }
267 }
268
269 void
270 TranzportControlProtocol::button_event_next_release (bool shifted)
271 {
272 }
273
274 void
275 TranzportControlProtocol::button_event_rewind_press (bool shifted)
276 {
277         if (shifted) {
278                 goto_start ();
279         } else {
280                 rewind ();
281         }
282 }
283
284 void
285 TranzportControlProtocol::button_event_rewind_release (bool shifted)
286 {
287 }
288
289 void
290 TranzportControlProtocol::button_event_fastforward_press (bool shifted)
291 {
292         if (shifted) {
293                 goto_end ();
294         } else {
295                 ffwd ();
296         }
297 }
298
299 void
300 TranzportControlProtocol::button_event_fastforward_release (bool shifted)
301 {
302 }
303
304 void
305 TranzportControlProtocol::button_event_stop_press (bool shifted)
306 {
307         if (shifted) {
308                 next_display_mode ();
309         } else {
310                 transport_stop ();
311         }
312 }
313
314 void
315 TranzportControlProtocol::button_event_stop_release (bool shifted)
316 {
317 }
318
319 void
320 TranzportControlProtocol::button_event_play_press (bool shifted)
321 {
322         if (shifted) {
323                 set_transport_speed (1.0f);
324         } else {
325                 transport_play ();
326         }
327 }
328
329 void
330 TranzportControlProtocol::button_event_play_release (bool shifted)
331 {
332 }
333
334 void
335 TranzportControlProtocol::button_event_record_press (bool shifted)
336 {
337         if (shifted) {
338                 save_state ();
339         } else {
340                 rec_enable_toggle ();
341         }
342 }
343
344 void
345 TranzportControlProtocol::button_event_record_release (bool shifted)
346 {
347 }
348
349 void
350 TranzportControlProtocol::button_event_footswitch_press (bool shifted)
351 {
352         if (shifted) {
353                 next_marker (); // think this through, we could also do punch in
354         } else {
355                 prev_marker (); // think this through, we could also do punch in
356         }
357 }
358
359 void
360 TranzportControlProtocol::button_event_footswitch_release (bool shifted)
361 {
362         if(session->transport_speed() == 0.0)
363         {
364                 transport_play ();
365         }
366 }
367
368 // Possible new api example
369 // tries harder to do the right thing if we somehow missed a button down event
370 // which currently happens... a lot.
371
372 void button_event_mute (bool pressed, bool shifted)
373 {
374         static int was_pressed = 0;
375         if((!pressed && !was_pressed) || pressed) {
376                 was_pressed = 1;
377         }
378
379         was_pressed = 0;
380 }