Merged with trunk R1612.
[ardour.git] / libs / surfaces / tranzport / wheel_modes.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 <iostream>
22 #include <algorithm>
23 #include <cmath>
24
25 #define __STDC_FORMAT_MACROS
26 #include <inttypes.h>
27 #include <float.h>
28 #include <sys/time.h>
29 #include <errno.h>
30
31 #if HAVE_TRANZPORT_KERNEL_DRIVER
32 #include <fcntl.h>
33 #include <poll.h>
34 #endif
35
36 #include <pbd/pthread_utils.h>
37
38 #include <ardour/route.h>
39 #include <ardour/audio_track.h>
40 #include <ardour/session.h>
41 #include <ardour/tempo.h>
42 #include <ardour/location.h>
43 #include <ardour/dB.h>
44
45 #include <tranzport_control_protocol.h>
46
47 using namespace ARDOUR;
48 using namespace std;
49 using namespace sigc;
50 using namespace PBD;
51
52 #include "i18n.h"
53
54 #include <pbd/abstract_ui.cc>
55
56 void
57 TranzportControlProtocol::next_wheel_shift_mode ()
58 {
59 switch (wheel_shift_mode) {
60         case WheelShiftGain:
61                 wheel_shift_mode = WheelShiftPan;
62                 break;
63         case WheelShiftPan:
64                 wheel_shift_mode = WheelShiftMaster;
65                 break;
66         case WheelShiftMaster:
67                 wheel_shift_mode = WheelShiftGain;
68                 break;
69         case WheelShiftMarker: // Not done yet, disabled
70                 wheel_shift_mode = WheelShiftGain;
71                 break;
72         }
73
74         show_wheel_mode ();
75 }
76
77 void
78 TranzportControlProtocol::next_wheel_mode ()
79 {
80         switch (wheel_mode) {
81         case WheelTimeline:
82                 wheel_mode = WheelScrub;
83                 break;
84         case WheelScrub:
85                 wheel_mode = WheelShuttle;
86                 break;
87         case WheelShuttle:
88                 wheel_mode = WheelTimeline;
89         }
90
91         show_wheel_mode ();
92 }
93
94 void
95 TranzportControlProtocol::show_wheel_mode ()
96 {
97         string text;
98
99         // if(session->transport_speed() != 0) {
100         //    if session-transport_speed() < 1.0) show_big_bar/beat
101         //    if ? greater. dont
102
103         if(session->transport_speed() != 0) {
104                 show_mini_meter(); 
105         } else {
106                 
107                 switch (wheel_mode) {
108                 case WheelTimeline:
109                         text = "Time";
110                         break;
111                 case WheelScrub:
112                         text = "Scrb";
113                         break;
114                 case WheelShuttle:
115                         text = "Shtl";
116                         break;
117                 }
118                 
119                 switch (wheel_shift_mode) {
120                 case WheelShiftGain:
121                         text += ":Gain";
122                         break;
123                                         
124                 case WheelShiftPan:
125                         text += ":Pan ";
126                         break;
127                                         
128                 case WheelShiftMaster:
129                         text += ":Mstr";
130                         break;
131                                         
132                 case WheelShiftMarker:
133                         text += ":Mrkr";
134                         break;
135                 }
136                 
137                 print (1, 0, text.c_str());
138         } 
139 }