Use std::string instead of PBD::sys::path in pbd/search_path.h, pbd/file_utils.h...
[ardour.git] / gtk2_ardour / mixer_actor.cc
1 /*
2     Copyright (C) 2000-2004 Paul Davis
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 */
19
20 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23
24 #include <boost/foreach.hpp>
25
26 #include "pbd/filesystem.h"
27 #include "pbd/file_utils.h"
28 #include "pbd/search_path.h"
29 #include "pbd/error.h"
30
31 #include "ardour/filesystem_paths.h"
32
33 #include "actions.h"
34 #include "mixer_actor.h"
35 #include "mixer_strip.h"
36 #include "route_ui.h"
37
38 #include "i18n.h"
39
40 using namespace ARDOUR;
41 using namespace Gtk;
42 using namespace PBD;
43
44 MixerActor::MixerActor ()
45 {
46         register_actions ();
47         load_bindings ();
48 }
49
50 MixerActor::~MixerActor ()
51 {
52 }
53
54 void
55 MixerActor::register_actions ()
56 {
57         myactions.register_action ("Mixer", "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::solo_action));
58         myactions.register_action ("Mixer", "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::mute_action));
59         myactions.register_action ("Mixer", "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::rec_enable_action));
60         myactions.register_action ("Mixer", "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::step_gain_up_action));
61         myactions.register_action ("Mixer", "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::step_gain_down_action));
62         myactions.register_action ("Mixer", "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::unity_gain_action));
63
64
65         myactions.register_action ("Mixer", "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &MixerActor::copy_processors));
66         myactions.register_action ("Mixer", "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &MixerActor::cut_processors));
67         myactions.register_action ("Mixer", "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &MixerActor::paste_processors));
68         myactions.register_action ("Mixer", "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &MixerActor::delete_processors));
69         myactions.register_action ("Mixer", "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &MixerActor::select_all_processors));
70         myactions.register_action ("Mixer", "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &MixerActor::toggle_processors));
71         myactions.register_action ("Mixer", "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &MixerActor::ab_plugins));
72
73
74         myactions.register_action ("Mixer", "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &MixerActor::scroll_left));
75         myactions.register_action ("Mixer", "scroll-right", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &MixerActor::scroll_right));
76 }
77
78 void
79 MixerActor::load_bindings ()
80 {
81         /* XXX move this to a better place */
82         
83         bindings.set_action_map (myactions);
84
85         std::string binding_file;
86
87         if (find_file_in_search_path (ardour_config_search_path(), "mixer.bindings", binding_file)) {
88                 bindings.load (binding_file);
89                 info << string_compose (_("Loaded mixer bindings from %1"), binding_file) << endmsg;
90         } else {
91                 error << string_compose (_("Could not find mixer.bindings in search path %1"), ardour_config_search_path().to_string()) << endmsg;
92         }
93 }
94
95 void
96 MixerActor::solo_action ()
97 {
98         GdkEventButton ev;
99
100         ev.type = GDK_BUTTON_PRESS;
101         ev.button = 1;
102         ev.state = 0;
103
104         set_route_targets_for_operation ();
105
106         BOOST_FOREACH(RouteUI* r, _route_targets) {
107                 r->solo_press (&ev);
108         }
109 }
110
111 void
112 MixerActor::mute_action ()
113 {
114         GdkEventButton ev;
115
116         ev.type = GDK_BUTTON_PRESS;
117         ev.button = 1;
118         ev.state = 0;
119
120         set_route_targets_for_operation ();
121
122         BOOST_FOREACH(RouteUI* r, _route_targets) {
123                 r->mute_press (&ev);
124         }
125 }
126
127 void
128 MixerActor::rec_enable_action ()
129 {
130         GdkEventButton ev;
131
132         ev.type = GDK_BUTTON_PRESS;
133         ev.button = 1;
134         ev.state = 0;
135
136         set_route_targets_for_operation ();
137
138         BOOST_FOREACH(RouteUI* r, _route_targets) {
139                 r->rec_enable_press (&ev);
140         }
141 }
142
143 void
144 MixerActor::step_gain_up_action ()
145 {
146         set_route_targets_for_operation ();
147
148         BOOST_FOREACH(RouteUI* r, _route_targets) {
149                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
150                 if (ms) {
151                         ms->step_gain_up ();
152                 }
153         }
154 }
155
156 void
157 MixerActor::step_gain_down_action ()
158 {
159         set_route_targets_for_operation ();
160
161         BOOST_FOREACH(RouteUI* r, _route_targets) {
162                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
163                 if (ms) {
164                         ms->step_gain_down ();
165                 }
166         }
167 }
168
169 void
170 MixerActor::unity_gain_action ()
171 {
172         set_route_targets_for_operation ();
173
174         BOOST_FOREACH(RouteUI* r, _route_targets) {
175                 boost::shared_ptr<Route> rp = r->route();
176                 if (rp) {
177                         rp->set_gain (1.0, this);
178                 }
179         }
180 }
181
182 void
183 MixerActor::copy_processors ()
184 {
185         set_route_targets_for_operation ();
186
187         BOOST_FOREACH(RouteUI* r, _route_targets) {
188                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
189                 if (ms) {
190                         ms->copy_processors ();
191                 }
192         }
193 }
194 void
195 MixerActor::cut_processors ()
196 {
197         set_route_targets_for_operation ();
198
199         BOOST_FOREACH(RouteUI* r, _route_targets) {
200                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
201                 if (ms) {
202                         ms->cut_processors ();
203                 }
204         }
205 }
206 void
207 MixerActor::paste_processors ()
208 {
209         set_route_targets_for_operation ();
210
211         BOOST_FOREACH(RouteUI* r, _route_targets) {
212                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
213                 if (ms) {
214                         ms->paste_processors ();
215                 }
216         }
217 }
218 void
219 MixerActor::select_all_processors ()
220 {
221         set_route_targets_for_operation ();
222
223         BOOST_FOREACH(RouteUI* r, _route_targets) {
224                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
225                 if (ms) {
226                         ms->select_all_processors ();
227                 }
228         }
229 }
230 void
231 MixerActor::delete_processors ()
232 {
233         set_route_targets_for_operation ();
234
235         BOOST_FOREACH(RouteUI* r, _route_targets) {
236                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
237                 if (ms) {
238                         ms->delete_processors ();
239                 }
240         }
241 }
242 void
243 MixerActor::toggle_processors ()
244 {
245         set_route_targets_for_operation ();
246
247         BOOST_FOREACH(RouteUI* r, _route_targets) {
248                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
249                 if (ms) {
250                         ms->toggle_processors ();
251                 }
252         }
253 }
254 void
255 MixerActor::ab_plugins ()
256 {
257         set_route_targets_for_operation ();
258
259         BOOST_FOREACH(RouteUI* r, _route_targets) {
260                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
261                 if (ms) {
262                         ms->ab_plugins ();
263                 }
264         }
265 }