fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / gtk2_ardour / transport_control.cc
1 /*
2  * Copyright (C) 2017-2019 Robin Gareus <robin@gareus.org>
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 along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #include "actions.h"
20 #include "ardour_ui.h"
21 #include "transport_control.h"
22
23 #include "pbd/i18n.h"
24
25 using namespace Gtk;
26
27 TransportControlProvider::TransportControlProvider ()
28         : roll_controllable (new TransportControllable ("transport roll", TransportControllable::Roll))
29         , stop_controllable (new TransportControllable ("transport stop", TransportControllable::Stop))
30         , goto_start_controllable (new TransportControllable ("transport goto start", TransportControllable::GotoStart))
31         , goto_end_controllable (new TransportControllable ("transport goto end", TransportControllable::GotoEnd))
32         , auto_loop_controllable (new TransportControllable ("transport auto loop", TransportControllable::AutoLoop))
33         , play_selection_controllable (new TransportControllable ("transport play selection", TransportControllable::PlaySelection))
34         , rec_controllable (new TransportControllable ("transport rec-enable", TransportControllable::RecordEnable))
35 {
36 }
37
38 TransportControlProvider::TransportControllable::TransportControllable (std::string name, ToggleType tp)
39         : Controllable (name), type(tp)
40 {
41 }
42
43 void
44 TransportControlProvider::TransportControllable::set_value (double val, PBD::Controllable::GroupControlDisposition /*group_override*/)
45 {
46         if (val < 0.5) {
47                 /* do nothing: these are radio-style actions */
48                 return;
49         }
50
51         const char *action = 0;
52
53         switch (type) {
54         case Roll:
55                 action = X_("Roll");
56                 break;
57         case Stop:
58                 action = X_("Stop");
59                 break;
60         case GotoStart:
61                 action = X_("GotoStart");
62                 break;
63         case GotoEnd:
64                 action = X_("GotoEnd");
65                 break;
66         case AutoLoop:
67                 action = X_("Loop");
68                 break;
69         case PlaySelection:
70                 action = X_("PlaySelection");
71                 break;
72         case RecordEnable:
73                 action = X_("Record");
74                 break;
75         default:
76                 break;
77         }
78
79         if (action == 0) {
80                 return;
81         }
82
83         Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", action);
84
85         if (act) {
86                 act->activate ();
87         }
88 }