start shaping up VCA assign process
[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 "gtkmm2ext/bindings.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 using Gtkmm2ext::Bindings;
45
46 MixerActor::MixerActor ()
47         : myactions (X_("mixer"))
48 {
49         register_actions ();
50         load_bindings ();
51 }
52
53 MixerActor::~MixerActor ()
54 {
55 }
56
57 void
58 MixerActor::register_actions ()
59 {
60         Glib::RefPtr<ActionGroup> group = myactions.create_action_group (X_("Mixer"));
61
62         myactions.register_action (group, "solo", _("Toggle Solo on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::solo_action));
63         myactions.register_action (group, "mute", _("Toggle Mute on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::mute_action));
64         myactions.register_action (group, "recenable", _("Toggle Rec-enable on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::rec_enable_action));
65         myactions.register_action (group, "increment-gain", _("Decrease Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::step_gain_up_action));
66         myactions.register_action (group, "decrement-gain", _("Increase Gain on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::step_gain_down_action));
67         myactions.register_action (group, "unity-gain", _("Set Gain to 0dB on Mixer-Selected Tracks/Busses"), sigc::mem_fun (*this, &MixerActor::unity_gain_action));
68
69
70         myactions.register_action (group, "copy-processors", _("Copy Selected Processors"), sigc::mem_fun (*this, &MixerActor::copy_processors));
71         myactions.register_action (group, "cut-processors", _("Cut Selected Processors"), sigc::mem_fun (*this, &MixerActor::cut_processors));
72         myactions.register_action (group, "paste-processors", _("Paste Selected Processors"), sigc::mem_fun (*this, &MixerActor::paste_processors));
73         myactions.register_action (group, "delete-processors", _("Delete Selected Processors"), sigc::mem_fun (*this, &MixerActor::delete_processors));
74         myactions.register_action (group, "select-all-processors", _("Select All (visible) Processors"), sigc::mem_fun (*this, &MixerActor::select_all_processors));
75         myactions.register_action (group, "toggle-processors", _("Toggle Selected Processors"), sigc::mem_fun (*this, &MixerActor::toggle_processors));
76         myactions.register_action (group, "ab-plugins", _("Toggle Selected Plugins"), sigc::mem_fun (*this, &MixerActor::ab_plugins));
77         myactions.register_action (group, "select-none", _("Deselect all strips and processors"), sigc::mem_fun (*this, &MixerActor::select_none));
78
79         myactions.register_action (group, "scroll-left", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &MixerActor::scroll_left));
80         myactions.register_action (group, "scroll-right", _("Scroll Mixer Window to the left"), sigc::mem_fun (*this, &MixerActor::scroll_right));
81
82         myactions.register_action (group, "toggle-midi-input-active", _("Toggle MIDI Input Active for Mixer-Selected Tracks/Busses"),
83                                    sigc::bind (sigc::mem_fun (*this, &MixerActor::toggle_midi_input_active), false));
84 }
85
86 void
87 MixerActor::load_bindings ()
88 {
89         bindings = Bindings::get_bindings (X_("Mixer"), myactions);
90 }
91
92 void
93 MixerActor::solo_action ()
94 {
95         GdkEventButton ev;
96
97         ev.type = GDK_BUTTON_PRESS;
98         ev.button = 1;
99         ev.state = 0;
100
101         set_route_targets_for_operation ();
102
103         BOOST_FOREACH(RouteUI* r, _route_targets) {
104                 r->solo_press (&ev);
105         }
106 }
107
108 void
109 MixerActor::mute_action ()
110 {
111         GdkEventButton ev;
112
113         ev.type = GDK_BUTTON_PRESS;
114         ev.button = 1;
115         ev.state = 0;
116
117         set_route_targets_for_operation ();
118
119         BOOST_FOREACH(RouteUI* r, _route_targets) {
120                 r->mute_press (&ev);
121         }
122 }
123
124 void
125 MixerActor::rec_enable_action ()
126 {
127         GdkEventButton ev;
128
129         ev.type = GDK_BUTTON_PRESS;
130         ev.button = 1;
131         ev.state = 0;
132
133         set_route_targets_for_operation ();
134
135         BOOST_FOREACH(RouteUI* r, _route_targets) {
136                 r->rec_enable_press (&ev);
137         }
138 }
139
140 void
141 MixerActor::step_gain_up_action ()
142 {
143         set_route_targets_for_operation ();
144
145         BOOST_FOREACH(RouteUI* r, _route_targets) {
146                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
147                 if (ms) {
148                         ms->step_gain_up ();
149                 }
150         }
151 }
152
153 void
154 MixerActor::step_gain_down_action ()
155 {
156         set_route_targets_for_operation ();
157
158         BOOST_FOREACH(RouteUI* r, _route_targets) {
159                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
160                 if (ms) {
161                         ms->step_gain_down ();
162                 }
163         }
164 }
165
166 void
167 MixerActor::unity_gain_action ()
168 {
169         set_route_targets_for_operation ();
170
171 printf("setting gain to unity (?)");
172         BOOST_FOREACH(RouteUI* r, _route_targets) {
173                 boost::shared_ptr<Route> rp = r->route();
174                 if (rp) {
175                         rp->set_gain (1.0, Controllable::NoGroup);
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::toggle_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->toggle_processors ();
237                 }
238         }
239 }
240 void
241 MixerActor::ab_plugins ()
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->ab_plugins ();
249                 }
250         }
251 }
252
253 void
254 MixerActor::vca_assign (boost::shared_ptr<VCA> vca)
255 {
256         set_route_targets_for_operation ();
257
258         BOOST_FOREACH(RouteUI* r, _route_targets) {
259                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
260                 if (ms) {
261                         ms->vca_assign (vca);
262                 }
263         }
264 }
265
266 void
267 MixerActor::vca_unassign (boost::shared_ptr<VCA> vca)
268 {
269         set_route_targets_for_operation ();
270
271         BOOST_FOREACH(RouteUI* r, _route_targets) {
272                 MixerStrip* ms = dynamic_cast<MixerStrip*> (r);
273                 if (ms) {
274                         ms->vca_unassign (vca);
275                 }
276         }
277 }
278
279