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