a metric ton of changes
[ardour.git] / gtk2_ardour / mixer_strip.cc
1 /*
2     Copyright (C) 2000-2002 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     $Id$
19 */
20
21 #include <cmath>
22 #include <glib.h>
23
24 #include <sigc++/bind.h>
25
26 #include <gtkmm2ext/gtk_ui.h>
27 #include <gtkmm2ext/utils.h>
28 #include <gtkmm2ext/choice.h>
29 #include <gtkmm2ext/slider_controller.h>
30 #include <gtkmm2ext/stop_signal.h>
31 #include <gtkmm2ext/bindable_button.h>
32 #include <gtkmm2ext/doi.h>
33
34 #include <ardour/ardour.h>
35 #include <ardour/session.h>
36 #include <ardour/audioengine.h>
37 #include <ardour/route.h>
38 #include <ardour/audio_track.h>
39 #include <ardour/diskstream.h>
40 #include <ardour/panner.h>
41 #include <ardour/send.h>
42 #include <ardour/insert.h>
43 #include <ardour/ladspa_plugin.h>
44 #include <ardour/connection.h>
45 #include <ardour/session_connection.h>
46
47 #include "ardour_ui.h"
48 #include "ardour_dialog.h"
49 #include "ardour_message.h"
50 #include "mixer_strip.h"
51 #include "mixer_ui.h"
52 #include "keyboard.h"
53 #include "plugin_selector.h"
54 #include "public_editor.h"
55
56 #include "plugin_ui.h"
57 #include "send_ui.h"
58 #include "io_selector.h"
59 #include "utils.h"
60 #include "gui_thread.h"
61
62 #include "i18n.h"
63
64 using namespace sigc;
65 using namespace ARDOUR;
66 using namespace Gtk;
67 using namespace Gtkmm2ext;
68
69 /* XPM */
70 static const gchar * small_x_xpm[] = {
71 "11 11 2 1",
72 "       c None",
73 ".      c #cccc99",
74 "           ",
75 "           ",
76 "  .     .  ",
77 "   .   .   ",
78 "    . .    ",
79 "     .     ",
80 "    . .    ",
81 "   .   .   ",
82 "  .     .  ",
83 "           ",
84 "           "};
85
86 /* XPM */
87 static const gchar * lr_xpm[] = {
88 "11 11 2 1",
89 "       c None",
90 ".      c #cccc99",
91 "           ",
92 "           ",
93 "   .   .   ",
94 "  .     .  ",
95 " .       . ",
96 "...........",
97 " .       . ",
98 "  .     .  ",
99 "   .   .   ",
100 "           ",
101 "           "};
102
103 static void 
104 speed_printer (char buf[32], Gtk::Adjustment& adj, void* arg)
105 {
106         float val = adj.get_value ();
107
108         if (val == 1.0) {
109                 strcpy (buf, "1");
110         } else {
111                 snprintf (buf, 32, "%.3f", val);
112         }
113 }
114
115 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, Route& rt, bool in_mixer)
116         : AxisView(sess),
117           RouteUI (rt, sess, _("mute"), _("solo"), _("RECORD")),
118           _mixer(mx),
119           pre_redirect_box (PreFader, sess, rt, mx.plugin_selector(), mx.selection(), in_mixer),
120           post_redirect_box (PostFader, sess, rt, mx.plugin_selector(), mx.selection(), in_mixer),
121           gpm (_route, sess),
122           panners (_route, sess),
123           button_table (8, 2),
124           gain_automation_style_button (""),
125           gain_automation_state_button (""),
126           pan_automation_style_button (""),
127           pan_automation_state_button (""),
128           polarity_button (_("polarity")),
129           comment_button (_("comments")),
130           speed_adjustment (1.0, 0.001, 4.0, 0.001, 0.1),
131           speed_spinner (&speed_adjustment, "MixerStripSpeedBase", true)
132
133 {
134         if (set_color_from_route()) {
135                 set_color (unique_random_color());
136         }
137
138         input_selector = 0;
139         output_selector = 0;
140         group_menu = 0;
141         _marked_for_display = false;
142         route_ops_menu = 0;
143         ignore_comment_edit = false;
144         ignore_toggle = false;
145         ignore_speed_adjustment = false;
146         comment_window = 0;
147         comment_area = 0;
148
149         width_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(lr_xpm)))));
150         hide_button.add (*(manage (new Gtk::Image (Gdk::Pixbuf::create_from_xpm_data(small_x_xpm)))));
151
152
153         input_label.set_text (_("INPUT"));
154         input_button.add (input_label);
155         input_button.set_name ("MixerIOButton");
156         input_label.set_name ("MixerIOButtonLabel");
157
158         output_label.set_text (_("OUTPUT"));
159         output_button.add (output_label);
160         output_button.set_name ("MixerIOButton");
161         output_label.set_name ("MixerIOButtonLabel");
162
163         rec_enable_button->set_name ("MixerRecordEnableButton");
164         rec_enable_button->unset_flags (Gtk::CAN_FOCUS);
165
166         solo_button->set_name ("MixerSoloButton");
167         mute_button->set_name ("MixerMuteButton");
168         gain_automation_style_button.set_name ("MixerAutomationModeButton");
169         gain_automation_state_button.set_name ("MixerAutomationPlaybackButton");
170         pan_automation_style_button.set_name ("MixerAutomationModeButton");
171         pan_automation_state_button.set_name ("MixerAutomationPlaybackButton");
172         polarity_button.set_name ("MixerPhaseInvertButton");
173
174         ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("Pan automation mode"));
175         ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("Gain automation mode"));
176
177         ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("Pan automation type"));
178         ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("Gain automation type"));
179
180         hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
181
182         width_button.unset_flags (Gtk::CAN_FOCUS);
183         hide_button.unset_flags (Gtk::CAN_FOCUS);
184         input_button.unset_flags (Gtk::CAN_FOCUS);
185         output_button.unset_flags (Gtk::CAN_FOCUS);
186         solo_button->unset_flags (Gtk::CAN_FOCUS);
187         mute_button->unset_flags (Gtk::CAN_FOCUS);
188         gain_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
189         gain_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
190         pan_automation_style_button.unset_flags (Gtk::CAN_FOCUS);
191         pan_automation_state_button.unset_flags (Gtk::CAN_FOCUS);
192         polarity_button.unset_flags (Gtk::CAN_FOCUS);
193
194         button_table.set_homogeneous (true);
195
196         button_table.attach (name_button, 0, 2, 0, 1);
197         button_table.attach (group_button, 0, 2, 1, 2);
198         button_table.attach (input_button, 0, 2, 2, 3);
199
200         button_table.attach (polarity_button, 0, 2, 3, 4);
201
202         button_table.attach (*solo_button, 0, 1, 4, 5);
203         button_table.attach (*mute_button, 1, 2, 4, 5);
204
205         // button_table.attach (gain_automation_style_button, 0, 1, 5, 6);
206         button_table.attach (gain_automation_state_button, 0, 1, 5, 6);
207         // button_table.attach (pan_automation_style_button, 0, 1, 6, 7);
208         button_table.attach (pan_automation_state_button, 1, 2, 5, 6);
209
210         using namespace Menu_Helpers;
211         
212         gain_astate_menu.items().push_back (MenuElem (_("off"), 
213                                                       bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Off)));
214         gain_astate_menu.items().push_back (MenuElem (_("play"),
215                                                       bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Play)));
216         gain_astate_menu.items().push_back (MenuElem (_("write"),
217                                                       bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Write)));
218         gain_astate_menu.items().push_back (MenuElem (_("touch"),
219                                                       bind (mem_fun (_route, &IO::set_gain_automation_state), (AutoState) Touch)));
220         
221         gain_astyle_menu.items().push_back (MenuElem (_("trim")));
222         gain_astyle_menu.items().push_back (MenuElem (_("abs")));
223
224         pan_astate_menu.items().push_back (MenuElem (_("off"), 
225                                                      bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Off)));
226         pan_astate_menu.items().push_back (MenuElem (_("play"),
227                                                      bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Play)));
228         pan_astate_menu.items().push_back (MenuElem (_("write"),
229                                                      bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Write)));
230         pan_astate_menu.items().push_back (MenuElem (_("touch"),
231                                                      bind (mem_fun (_route.panner(), &Panner::set_automation_state), (AutoState) Touch)));
232
233         pan_astyle_menu.items().push_back (MenuElem (_("trim")));
234         pan_astyle_menu.items().push_back (MenuElem (_("abs")));
235         
236         gain_astate_menu.set_name ("ArdourContextMenu");
237         gain_astyle_menu.set_name ("ArdourContextMenu");
238         pan_astate_menu.set_name ("ArdourContextMenu");
239         pan_astyle_menu.set_name ("ArdourContextMenu");
240
241         ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_style_button, _("gain automation mode"));
242         ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_style_button, _("pan automation mode"));
243         ARDOUR_UI::instance()->tooltips().set_tip (gain_automation_state_button, _("gain automation state"));
244         ARDOUR_UI::instance()->tooltips().set_tip (pan_automation_state_button, _("pan automation state"));
245
246         if (is_audio_track()) {
247                 
248                 AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
249
250                 at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen));
251
252                 speed_adjustment.signal_value_changed().connect (mem_fun(*this, &MixerStrip::speed_adjustment_changed));
253                 
254                 speed_frame.set_name ("BaseFrame");
255                 speed_frame.set_shadow_type (Gtk::SHADOW_IN);
256                 speed_frame.add (speed_spinner);
257                 
258                 speed_spinner.set_print_func (speed_printer, 0);
259
260                 ARDOUR_UI::instance()->tooltips().set_tip (speed_spinner, _("varispeed"));
261
262                 button_table.attach (speed_frame, 0, 2, 6, 7);
263                 button_table.attach (*rec_enable_button, 0, 2, 7, 8);
264         }
265
266         name_button.add (name_label);
267         name_button.set_name ("MixerNameButton");
268         Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
269
270         name_label.set_name ("MixerNameButtonLabel");
271         name_label.set_text (_route.name());
272
273         group_button.add (group_label);
274         group_button.set_name ("MixerGroupButton");
275         group_label.set_name ("MixerGroupButtonLabel");
276
277         comment_button.set_name ("MixerCommentButton");
278         ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route.comment()=="" ?
279                                                         _("click to add/edit comments"):
280                                                         _route.comment());
281         comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
282         
283         global_vpacker.set_border_width (4);
284         global_vpacker.set_spacing (4);
285
286         Gtk::VBox *whvbox = manage (new Gtk::VBox);
287
288         width_button.set_name ("MixerWidthButton");
289         hide_button.set_name ("MixerHideButton");
290
291         width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
292         hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
293
294         width_hide_box.pack_start (width_button, false, true);
295         width_hide_box.pack_end (hide_button, false, true);
296
297         whvbox->pack_start (width_hide_box, true, true);
298
299         global_vpacker.pack_start (*whvbox, Gtk::PACK_SHRINK);
300         global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
301         global_vpacker.pack_start (pre_redirect_box, true, true);
302         global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK);
303         global_vpacker.pack_start (post_redirect_box, true, true);
304         global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
305         global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
306         global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
307
308         global_frame.add (global_vpacker);
309         global_frame.set_shadow_type (Gtk::SHADOW_IN);
310         global_frame.set_name ("BaseFrame");
311
312         add (global_frame);
313
314         /* force setting of visible selected status */
315
316         _selected = true;
317         set_selected (false);
318
319         _packed = false;
320         _embedded = false;
321
322         _route.input_changed.connect (mem_fun(*this, &MixerStrip::input_changed));
323         _route.output_changed.connect (mem_fun(*this, &MixerStrip::output_changed));
324         _route.mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed));
325         _route.solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
326         _route.solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed));
327         _route.mix_group_changed.connect (mem_fun(*this, &MixerStrip::mix_group_changed));
328         _route.gain_automation_curve().automation_state_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_state_changed));
329         _route.gain_automation_curve().automation_style_changed.connect (mem_fun(*this, &MixerStrip::gain_automation_style_changed));
330         _route.panner().Changed.connect (mem_fun(*this, &MixerStrip::connect_to_pan));
331
332         if (is_audio_track()) {
333                 audio_track()->diskstream_changed.connect (mem_fun(*this, &MixerStrip::diskstream_changed));
334                 get_diskstream()->speed_changed.connect (mem_fun(*this, &MixerStrip::speed_changed));
335         }
336
337         _route.name_changed.connect (mem_fun(*this, &RouteUI::name_changed));
338         _route.comment_changed.connect (mem_fun(*this, &MixerStrip::comment_changed));
339         _route.gui_changed.connect (mem_fun(*this, &MixerStrip::route_gui_changed));
340
341         input_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
342         output_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
343
344         rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press));
345         solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press));
346         solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release));
347         mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press));
348         mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release));
349
350         gain_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
351         gain_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_style_button_event), false);
352         pan_automation_style_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
353         pan_automation_style_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_style_button_event), false);
354
355         gain_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
356         gain_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::gain_automation_state_button_event), false);
357         pan_automation_state_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
358         pan_automation_state_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::pan_automation_state_button_event), false);
359
360         polarity_button.signal_toggled().connect (mem_fun(*this, &MixerStrip::polarity_toggled));
361
362         name_button.signal_button_release_event().connect (mem_fun(*this, &MixerStrip::name_button_button_release), false);
363
364         group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
365
366         _width = (Width) -1;
367         set_stuff_from_route ();
368
369         /* start off as a passthru strip. we'll correct this, if necessary,
370            in update_diskstream_display().
371         */
372
373         set_name ("AudioTrackStripBase");
374
375         /* now force an update of all the various elements */
376
377         pre_redirect_box.update();
378         post_redirect_box.update();
379         mute_changed (0);
380         solo_changed (0);
381         name_changed (0);
382         comment_changed (0);
383         mix_group_changed (0);
384         gain_automation_state_changed ();
385         pan_automation_state_changed ();
386         connect_to_pan ();
387
388         panners.setup_pan ();
389
390         if (is_audio_track()) {
391                 speed_changed ();
392         }
393
394         /* XXX hack: no phase invert changed signal */
395
396         polarity_button.set_active (_route.phase_invert());
397
398         update_diskstream_display ();
399         update_input_display ();
400         update_output_display ();
401
402         add_events (Gdk::BUTTON_RELEASE_MASK);
403 }
404
405 MixerStrip::~MixerStrip ()
406 {
407         GoingAway(); /* EMIT_SIGNAL */
408
409         if (input_selector) {
410                 delete input_selector;
411         }
412
413         if (output_selector) {
414                 delete output_selector;
415         }
416 }
417
418 void
419 MixerStrip::set_stuff_from_route ()
420 {
421         XMLProperty *prop;
422         
423         ensure_xml_node ();
424
425         if ((prop = xml_node->property ("strip_width")) != 0) {
426                 if (prop->value() == "wide") {
427                         set_width (Wide);
428                 } else if (prop->value() == "narrow") {
429                         set_width (Narrow);
430                 }
431                 else {
432                         error << string_compose(_("unknown strip width \"%1\" in XML GUI information"), prop->value()) << endmsg;
433                         set_width (Wide);
434                 }
435         }
436         else {
437                 set_width (Wide);
438         }
439
440         if ((prop = xml_node->property ("shown_mixer")) != 0) {
441                 if (prop->value() == "no") {
442                         _marked_for_display = false;
443                 } else {
444                         _marked_for_display = true;
445                 }
446         }
447         else {
448                 /* backwards compatibility */
449                 _marked_for_display = true;
450         }
451 }
452
453 void
454 MixerStrip::set_width (Width w)
455 {
456         /* always set the gpm width again, things may be hidden */
457         gpm.set_width (w);
458         panners.set_width (w);
459         pre_redirect_box.set_width (w);
460         post_redirect_box.set_width (w);
461         
462         if (_width == w) {
463                 return;
464         }
465
466         ensure_xml_node ();
467         
468         _width = w;
469
470         switch (w) {
471         case Wide:
472                 set_size_request (-1, -1);
473                 xml_node->add_property ("strip_width", "wide");
474
475                 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("RECORD"));
476                 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("mute"));
477                 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("solo"));
478                 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("comments"));
479                 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
480                 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
481                 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
482                 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
483                 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("polarity"));
484                 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
485                 break;
486
487         case Narrow:
488                 set_size_request (50, -1);
489                 xml_node->add_property ("strip_width", "narrow");
490
491                 static_cast<Gtk::Label*> (rec_enable_button->get_child())->set_text (_("REC"));
492                 static_cast<Gtk::Label*> (mute_button->get_child())->set_text (_("m"));
493                 static_cast<Gtk::Label*> (solo_button->get_child())->set_text (_("s"));
494                 static_cast<Gtk::Label*> (comment_button.get_child())->set_text (_("cmt"));
495                 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
496                 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
497                 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
498                 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
499                 static_cast<Gtk::Label*> (polarity_button.get_child())->set_text (_("pol"));
500                 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
501                 break;
502         }
503
504         update_input_display ();
505         update_output_display ();
506         mix_group_changed (0);
507         name_changed (0);
508 }
509
510 void
511 MixerStrip::set_packed (bool yn)
512 {
513         _packed = yn;
514
515         ensure_xml_node ();
516
517         if (_packed) {
518                 xml_node->add_property ("shown_mixer", "yes");
519         } else {
520                 xml_node->add_property ("shown_mixer", "no");
521         }
522 }
523
524
525 gint
526 MixerStrip::output_press (GdkEventButton *ev)
527 {
528         using namespace Menu_Helpers;
529
530         if (!_session.engine().connected()) {
531                 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
532                 return TRUE;
533         }
534
535         MenuList& citems = output_menu.items();
536         output_menu.set_name ("ArdourContextMenu");
537         citems.clear();
538
539         citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_output_configuration)));
540         citems.push_back (SeparatorElem());
541         citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
542         citems.push_back (SeparatorElem());
543
544         _session.foreach_connection (this, &MixerStrip::add_connection_to_output_menu);
545
546         output_menu.popup (1, ev->time);
547
548         return TRUE;
549 }
550
551 void
552 MixerStrip::edit_output_configuration ()
553 {
554         if (output_selector == 0) {
555                 output_selector = new IOSelectorWindow (_session, _route, false);
556         } 
557
558         if (output_selector->is_visible()) {
559                 output_selector->get_toplevel()->get_window()->raise();
560         } else {
561                 output_selector->show_all ();
562         }
563 }
564
565 void
566 MixerStrip::edit_input_configuration ()
567 {
568         if (input_selector == 0) {
569                 input_selector = new IOSelectorWindow (_session, _route, true);
570         } 
571
572         if (input_selector->is_visible()) {
573                 input_selector->get_toplevel()->get_window()->raise();
574         } else {
575                 input_selector->show_all ();
576         }
577 }
578
579 gint
580 MixerStrip::input_press (GdkEventButton *ev)
581 {
582         using namespace Menu_Helpers;
583
584         MenuList& citems = input_menu.items();
585         input_menu.set_name ("ArdourContextMenu");
586         citems.clear();
587
588         if (!_session.engine().connected()) {
589                 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
590                 return TRUE;
591         }
592
593 #if ADVANCED_ROUTE_DISKSTREAM_CONNECTIVITY
594         if (is_audio_track()) {
595                 citems.push_back (MenuElem (_("Track"), mem_fun(*this, &MixerStrip::select_stream_input)));
596         }
597 #endif
598         citems.push_back (MenuElem (_("Edit"), mem_fun(*this, &MixerStrip::edit_input_configuration)));
599         citems.push_back (SeparatorElem());
600         citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
601         citems.push_back (SeparatorElem());
602
603         _session.foreach_connection (this, &MixerStrip::add_connection_to_input_menu);
604         input_menu.popup (1, ev->time);
605
606         return TRUE;
607 }
608
609 void
610 MixerStrip::connection_input_chosen (ARDOUR::Connection *c)
611 {
612         if (!ignore_toggle) {
613
614                 try { 
615                         _route.use_input_connection (*c, this);
616                 }
617
618                 catch (AudioEngine::PortRegistrationFailure& err) {
619                         error << _("could not register new ports required for that connection")
620                               << endmsg;
621                 }
622         }
623 }
624
625 void
626 MixerStrip::connection_output_chosen (ARDOUR::Connection *c)
627 {
628         if (!ignore_toggle) {
629
630                 try { 
631                         _route.use_output_connection (*c, this);
632                 }
633
634                 catch (AudioEngine::PortRegistrationFailure& err) {
635                         error << _("could not register new ports required for that connection")
636                               << endmsg;
637                 }
638         }
639 }
640
641 void
642 MixerStrip::add_connection_to_input_menu (ARDOUR::Connection* c)
643 {
644         using namespace Menu_Helpers;
645
646         if (dynamic_cast<InputConnection *> (c) == 0) {
647                 return;
648         }
649
650         MenuList& citems = input_menu.items();
651         
652         if (c->nports() == _route.n_inputs()) {
653
654                 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_input_chosen), c)));
655                 
656                 ARDOUR::Connection *current = _route.input_connection();
657                 
658                 if (current == c) {
659                         ignore_toggle = true;
660                         dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
661                         ignore_toggle = false;
662                 }
663         }
664 }
665
666 void
667 MixerStrip::add_connection_to_output_menu (ARDOUR::Connection* c)
668 {
669         using namespace Menu_Helpers;
670
671         if (dynamic_cast<OutputConnection *> (c) == 0) {
672                 return;
673         }
674
675         if (c->nports() == _route.n_outputs()) {
676
677                 MenuList& citems = output_menu.items();
678                 citems.push_back (CheckMenuElem (c->name(), bind (mem_fun(*this, &MixerStrip::connection_output_chosen), c)));
679                 
680                 ARDOUR::Connection *current = _route.output_connection();
681                 
682                 if (current == c) {
683                         ignore_toggle = true;
684                         dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
685                         ignore_toggle = false;
686                 }
687         }
688 }
689
690 void
691 MixerStrip::select_stream_input ()
692 {
693         using namespace Menu_Helpers;
694
695         Menu *stream_menu = manage (new Menu);
696         MenuList& items = stream_menu->items();
697         stream_menu->set_name ("ArdourContextMenu");
698         
699         Session::DiskStreamList streams = _session.disk_streams();
700
701         for (Session::DiskStreamList::iterator i = streams.begin(); i != streams.end(); ++i) {
702
703                 if (!(*i)->hidden()) {
704
705                         items.push_back (CheckMenuElem ((*i)->name(), bind (mem_fun(*this, &MixerStrip::stream_input_chosen), *i)));
706                         
707                         if (get_diskstream() == *i) {
708                                 ignore_toggle = true;
709                                 static_cast<CheckMenuItem *> (&items.back())->set_active (true);
710                                 ignore_toggle = false;
711                         } 
712                 }
713         }
714         
715         stream_menu->popup (1, 0);
716 }
717
718 void
719 MixerStrip::stream_input_chosen (DiskStream *stream)
720 {
721         if (is_audio_track()) {
722                 audio_track()->set_diskstream (*stream, this);
723         }
724 }
725
726 void
727 MixerStrip::update_diskstream_display ()
728 {
729         if (is_audio_track()) {
730
731                 map_frozen ();
732
733                 update_input_display ();
734
735                 if (input_selector) {
736                         input_selector->hide_all ();
737                 }
738
739                 show_route_color ();
740
741         } else {
742
743                 map_frozen ();
744
745                 update_input_display ();
746                 show_passthru_color ();
747         }
748 }
749
750 void
751 MixerStrip::connect_to_pan ()
752 {
753         ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
754         
755         panstate_connection.disconnect ();
756         panstyle_connection.disconnect ();
757
758         if (!_route.panner().empty()) {
759                 StreamPanner* sp = _route.panner().front();
760
761                 panstate_connection = sp->automation().automation_state_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_state_changed));
762                 panstyle_connection = sp->automation().automation_style_changed.connect (mem_fun(*this, &MixerStrip::pan_automation_style_changed));
763         }
764
765         panners.pan_changed (this);
766 }
767
768 void
769 MixerStrip::update_input_display ()
770 {
771         ARDOUR::Connection *c;
772
773         if ((c = _route.input_connection()) != 0) {
774                 input_label.set_text (c->name());
775         } else {
776                 switch (_width) {
777                 case Wide:
778                         input_label.set_text (_("INPUT"));
779                         break;
780                 case Narrow:
781                         input_label.set_text (_("IN"));
782                         break;
783                 }
784         }
785
786         panners.setup_pan ();
787 }
788
789 void
790 MixerStrip::update_output_display ()
791 {
792         ARDOUR::Connection *c;
793
794         if ((c = _route.output_connection()) != 0) {
795                 output_label.set_text (c->name());
796         } else {
797                 switch (_width) {
798                 case Wide:
799                         output_label.set_text (_("OUTPUT"));
800                         break;
801                 case Narrow:
802                         output_label.set_text (_("OUT"));
803                         break;
804                 }
805         }
806
807         gpm.setup_meters ();
808         panners.setup_pan ();
809 }
810
811 void
812 MixerStrip::update ()
813 {
814         gpm.update_meters ();
815 }
816
817 void
818 MixerStrip::fast_update ()
819 {
820         if (_session.meter_falloff() > 0.0f) {
821                 gpm.update_meters_falloff ();
822         }
823 }
824
825 gint
826 MixerStrip::gain_automation_state_button_event (GdkEventButton *ev)
827 {
828         if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
829                 return TRUE;
830         }
831         
832         switch (ev->button) {
833         case 1:
834                 switch (ev->button) {
835                 case 1:
836                         gain_astate_menu.popup (1, ev->time);
837                         break;
838                 default:
839                         break;
840                 }
841         }
842
843         return TRUE;
844 }
845
846 gint
847 MixerStrip::gain_automation_style_button_event (GdkEventButton *ev)
848 {
849         if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
850                 return TRUE;
851         }
852
853         switch (ev->button) {
854         case 1:
855                 gain_astyle_menu.popup (1, ev->time);
856                 break;
857         default:
858                 break;
859         }
860         return TRUE;
861 }
862
863 gint
864 MixerStrip::pan_automation_state_button_event (GdkEventButton *ev)
865 {
866         using namespace Menu_Helpers;
867
868         if (ev->type == GDK_BUTTON_PRESS || ev->type == GDK_2BUTTON_PRESS) {
869                 return TRUE;
870         }
871
872         switch (ev->button) {
873         case 1:
874                 pan_astate_menu.popup (1, ev->time);
875                 break;
876         default:
877                 break;
878         }
879
880         return TRUE;
881 }
882
883 gint
884 MixerStrip::pan_automation_style_button_event (GdkEventButton *ev)
885 {
886         switch (ev->button) {
887         case 1:
888                 pan_astyle_menu.popup (1, ev->time);
889                 break;
890         default:
891                 break;
892         }
893         return TRUE;
894 }
895
896 string
897 MixerStrip::astate_string (AutoState state)
898 {
899         return _astate_string (state, false);
900 }
901
902 string
903 MixerStrip::short_astate_string (AutoState state)
904 {
905         return _astate_string (state, true);
906 }
907
908 string
909 MixerStrip::_astate_string (AutoState state, bool shrt)
910 {
911         string sstr;
912
913         switch (state) {
914         case Off:
915                 sstr = (shrt ? "--" : _("off"));
916                 break;
917         case Play:
918                 sstr = (shrt ? "P" : _("aplay"));
919                 break;
920         case Touch:
921                 sstr = (shrt ? "T" : _("touch"));
922                 break;
923         case Write:
924                 sstr = (shrt ? "W" : _("awrite"));
925                 break;
926         }
927
928         return sstr;
929 }
930
931 string
932 MixerStrip::astyle_string (AutoStyle style)
933 {
934         return _astyle_string (style, false);
935 }
936
937 string
938 MixerStrip::short_astyle_string (AutoStyle style)
939 {
940         return _astyle_string (style, true);
941 }
942
943 string
944 MixerStrip::_astyle_string (AutoStyle style, bool shrt)
945 {
946         if (style & Trim) {
947                 return _("trim");
948         } else {
949                 /* XXX it might different in different languages */
950
951                 return (shrt ? _("abs") : _("abs"));
952         }
953 }
954
955 void
956 MixerStrip::diskstream_changed (void *src)
957 {
958         Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
959 }       
960
961 void
962 MixerStrip::gain_automation_style_changed ()
963 {
964         switch (_width) {
965         case Wide:
966                 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (astyle_string(_route.gain_automation_curve().automation_style()));
967                 break;
968         case Narrow:
969                 static_cast<Gtk::Label*> (gain_automation_style_button.get_child())->set_text (short_astyle_string(_route.gain_automation_curve().automation_style()));
970                 break;
971         }
972 }
973
974 void
975 MixerStrip::gain_automation_state_changed ()
976 {
977         ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::gain_automation_state_changed));
978         
979         bool x;
980
981         switch (_width) {
982         case Wide:
983                 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (astate_string(_route.gain_automation_curve().automation_state()));
984                 break;
985         case Narrow:
986                 static_cast<Gtk::Label*> (gain_automation_state_button.get_child())->set_text (short_astate_string(_route.gain_automation_curve().automation_state()));
987                 break;
988         }
989
990         x = (_route.gain_automation_state() != Off);
991         
992         if (gain_automation_state_button.get_active() != x) {
993                 ignore_toggle = true;
994                 gain_automation_state_button.set_active (x);
995                 ignore_toggle = false;
996         }
997
998         gpm.update_gain_sensitive ();
999         
1000         /* start watching automation so that things move */
1001         
1002         gain_watching.disconnect();
1003
1004         if (x) {
1005                 gain_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (gpm, &GainMeter::effective_gain_display));
1006         }
1007 }
1008
1009 void
1010 MixerStrip::pan_automation_style_changed ()
1011 {
1012         ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_style_changed));
1013         
1014         switch (_width) {
1015         case Wide:
1016                 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (astyle_string(_route.panner().automation_style()));
1017                 break;
1018         case Narrow:
1019                 static_cast<Gtk::Label*> (pan_automation_style_button.get_child())->set_text (short_astyle_string(_route.panner().automation_style()));
1020                 break;
1021         }
1022 }
1023
1024 void
1025 MixerStrip::pan_automation_state_changed ()
1026 {
1027         ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::pan_automation_state_changed));
1028         
1029         bool x;
1030
1031         switch (_width) {
1032         case Wide:
1033                 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (astate_string(_route.panner().automation_state()));
1034                 break;
1035         case Narrow:
1036                 static_cast<Gtk::Label*> (pan_automation_state_button.get_child())->set_text (short_astate_string(_route.panner().automation_state()));
1037                 break;
1038         }
1039
1040         /* when creating a new session, we get to create busses (and
1041            sometimes tracks) with no outputs by the time they get
1042            here.
1043         */
1044
1045         if (_route.panner().empty()) {
1046                 return;
1047         }
1048
1049         x = (_route.panner().front()->automation().automation_state() != Off);
1050
1051         if (pan_automation_state_button.get_active() != x) {
1052                 ignore_toggle = true;
1053                 pan_automation_state_button.set_active (x);
1054                 ignore_toggle = false;
1055         }
1056
1057         panners.update_pan_sensitive ();
1058         
1059         /* start watching automation so that things move */
1060         
1061         pan_watching.disconnect();
1062
1063         if (x) {
1064                 pan_watching = ARDOUR_UI::RapidScreenUpdate.connect (mem_fun (panners, &PannerUI::effective_pan_display));
1065         }
1066 }
1067
1068 void
1069 MixerStrip::input_changed (IOChange change, void *src)
1070 {
1071         Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1072 }
1073
1074 void
1075 MixerStrip::output_changed (IOChange change, void *src)
1076 {
1077         Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1078 }
1079
1080 void
1081 MixerStrip::comment_button_clicked ()
1082 {
1083         if (comment_window == 0) {
1084                 setup_comment_editor ();
1085         }
1086
1087         if (comment_window->is_visible()) {
1088                 comment_window->hide ();
1089                 return;
1090         } 
1091
1092         comment_window->set_position (Gtk::WIN_POS_MOUSE);
1093         comment_window->show_all ();
1094         comment_window->present();
1095         
1096         ResponseType response = (ResponseType) comment_window->run();
1097         comment_window->hide ();
1098
1099         switch (response) {
1100         case RESPONSE_ACCEPT:
1101                 break;
1102         default:
1103                 return;
1104         }
1105
1106         string str =  comment_area->get_buffer()->get_text();
1107         _route.set_comment (str, this);
1108         ARDOUR_UI::instance()->tooltips().set_tip (comment_button, 
1109                                                    str.empty() ? _("click to add/edit comments") : str);
1110 }
1111
1112 void
1113 MixerStrip::setup_comment_editor ()
1114 {
1115         string title;
1116         title = _route.name();
1117         title += _(": comment editor");
1118
1119         comment_window = new ArdourDialog (title, false);
1120         comment_area = manage (new TextView());
1121
1122         comment_area->set_name ("MixerTrackCommentArea");
1123         comment_area->set_editable (true);
1124         comment_area->get_buffer()->set_text (_route.comment());
1125         comment_area->set_size_request (200,100);
1126         comment_area->show ();
1127
1128         comment_window->get_vbox()->pack_start (*comment_area);
1129         comment_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1130         comment_window->add_button (Stock::OK, RESPONSE_ACCEPT);
1131 }
1132
1133 void
1134 MixerStrip::comment_changed (void *src)
1135 {
1136         ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1137         
1138         if (src != this) {
1139                 ignore_comment_edit = true;
1140                 if (comment_area) {
1141                         comment_area->get_buffer()->set_text (_route.comment());
1142                 }
1143                 ignore_comment_edit = false;
1144         }
1145 }
1146
1147 void
1148 MixerStrip::set_mix_group (RouteGroup *rg)
1149
1150 {
1151         _route.set_mix_group (rg, this);
1152         delete group_menu;
1153         group_menu = 0;
1154 }
1155
1156 void
1157 MixerStrip::add_mix_group_to_menu (RouteGroup *rg)
1158 {
1159         using namespace Menu_Helpers;
1160
1161         MenuList& items = group_menu->items();
1162         items.push_back (MenuElem (rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1163 }
1164
1165 gint
1166 MixerStrip::select_mix_group (GdkEventButton *ev)
1167 {
1168         using namespace Menu_Helpers;
1169
1170         group_menu = new Menu;
1171         group_menu->set_name ("ArdourContextMenu");
1172         MenuList& items = group_menu->items();
1173
1174         items.push_back (MenuElem (_("no group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1175         _session.foreach_mix_group (this, &MixerStrip::add_mix_group_to_menu);
1176
1177         group_menu->popup (ev->button, 0);
1178         return stop_signal (group_button, "button_press_event");
1179 }       
1180
1181 void
1182 MixerStrip::mix_group_changed (void *ignored)
1183 {
1184         ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1185         
1186         RouteGroup *rg = _route.mix_group();
1187         
1188         if (rg) {
1189                 group_label.set_text (rg->name());
1190         } else {
1191                 switch (_width) {
1192                 case Wide:
1193                         group_label.set_text (_("no group"));
1194                         break;
1195                 case Narrow:
1196                         group_label.set_text (_("~G"));
1197                         break;
1198                 }
1199         }
1200 }
1201
1202 void
1203 MixerStrip::polarity_toggled ()
1204 {
1205         bool x;
1206
1207         if ((x = polarity_button.get_active()) != _route.phase_invert()) {
1208                 _route.set_phase_invert (x, this);
1209         }
1210 }
1211
1212
1213 void 
1214 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1215 {
1216         ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1217         
1218         if (what_changed == "color") {
1219                 if (set_color_from_route () == 0) {
1220                         show_route_color ();
1221                 }
1222         }
1223 }
1224
1225 void
1226 MixerStrip::show_route_color ()
1227 {
1228         name_button.ensure_style ();
1229         Glib::RefPtr<Gtk::Style> style = name_button.get_style()->copy();
1230         style->set_bg (Gtk::STATE_NORMAL, color());
1231         name_button.set_style (style);
1232
1233         route_active_changed ();
1234 }
1235
1236 void
1237 MixerStrip::show_passthru_color ()
1238 {
1239         route_active_changed ();
1240 }
1241
1242 void
1243 MixerStrip::build_route_ops_menu ()
1244 {
1245         using namespace Menu_Helpers;
1246
1247         route_ops_menu = manage (new Menu);
1248         route_ops_menu->set_name ("ArdourContextMenu");
1249
1250         MenuList& items = route_ops_menu->items();
1251         
1252         items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1253         items.push_back (SeparatorElem());
1254         items.push_back (CheckMenuElem (_("Active"), mem_fun(*this, &RouteUI::toggle_route_active)));
1255         route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1256         route_active_menu_item->set_active (_route.active());
1257
1258         build_remote_control_menu ();
1259         
1260         items.push_back (SeparatorElem());
1261         items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1262
1263         items.push_back (SeparatorElem());
1264         items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1265 }
1266
1267 gint
1268 MixerStrip::name_button_button_release (GdkEventButton* ev)
1269 {
1270         if (ev->button == 3) {
1271                 list_route_operations ();
1272         }
1273         return FALSE;
1274 }
1275
1276 void
1277 MixerStrip::list_route_operations ()
1278 {
1279         if (route_ops_menu == 0) {
1280                 build_route_ops_menu ();
1281         }
1282         
1283         refresh_remote_control_menu();
1284
1285         route_ops_menu->popup (1, 0);
1286 }
1287
1288
1289 void
1290 MixerStrip::speed_adjustment_changed ()
1291 {
1292         /* since there is a usable speed adjustment, there has to be a diskstream */
1293         if (!ignore_speed_adjustment) {
1294                 get_diskstream()->set_speed (speed_adjustment.get_value());
1295         }
1296 }
1297
1298 void
1299 MixerStrip::speed_changed ()
1300 {
1301         Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_speed_display));
1302 }
1303
1304 void
1305 MixerStrip::update_speed_display ()
1306 {
1307         float val;
1308         
1309         val = get_diskstream()->speed();
1310
1311         if (val != 1.0) {
1312                 speed_spinner.set_name ("MixerStripSpeedBaseNotOne");
1313         } else {
1314                 speed_spinner.set_name ("MixerStripSpeedBase");
1315         }
1316
1317         if (speed_adjustment.get_value() != val) {
1318                 ignore_speed_adjustment = true;
1319                 speed_adjustment.set_value (val);
1320                 ignore_speed_adjustment = false;
1321         }
1322 }                       
1323
1324
1325 void
1326 MixerStrip::set_selected (bool yn)
1327 {
1328         AxisView::set_selected (yn);
1329         if (_selected) {
1330                 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1331                 global_frame.set_name ("MixerStripSelectedFrame");
1332         } else {
1333                 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1334                 global_frame.set_name ("MixerStripFrame");
1335         }
1336         global_frame.queue_draw ();
1337 }
1338
1339 void
1340 MixerStrip::name_changed (void *src)
1341 {
1342         switch (_width) {
1343         case Wide:
1344                 RouteUI::name_changed (src);
1345                 break;
1346         case Narrow:
1347                 name_label.set_text (short_version (_route.name(), 5));
1348                 break;
1349         }
1350 }
1351
1352 void
1353 MixerStrip::width_clicked ()
1354 {
1355         switch (_width) {
1356         case Wide:
1357                 set_width (Narrow);
1358                 break;
1359         case Narrow:
1360                 set_width (Wide);
1361                 break;
1362         }
1363 }
1364
1365 void
1366 MixerStrip::hide_clicked ()
1367 {
1368         if (_embedded) {
1369                  Hiding(); /* EMIT_SIGNAL */
1370         } else {
1371                 _mixer.unselect_strip_in_display (this);
1372         }
1373 }
1374
1375 void
1376 MixerStrip::set_embedded (bool yn)
1377 {
1378         _embedded = yn;
1379 }
1380
1381 void
1382 MixerStrip::map_frozen ()
1383 {
1384         ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1385
1386         AudioTrack* at = dynamic_cast<AudioTrack*>(&_route);
1387
1388         if (at) {
1389                 switch (at->freeze_state()) {
1390                 case AudioTrack::Frozen:
1391                         pre_redirect_box.set_sensitive (false);
1392                         post_redirect_box.set_sensitive (false);
1393                         speed_spinner.set_sensitive (false);
1394                         break;
1395                 default:
1396                         pre_redirect_box.set_sensitive (true);
1397                         post_redirect_box.set_sensitive (true);
1398                         speed_spinner.set_sensitive (true);
1399                         break;
1400                 }
1401         }
1402         _route.foreach_redirect (this, &MixerStrip::hide_redirect_editor);
1403 }
1404
1405 void
1406 MixerStrip::hide_redirect_editor (Redirect* redirect)
1407 {
1408         void* gui = redirect->get_gui ();
1409         
1410         if (gui) {
1411                 static_cast<Gtk::Widget*>(gui)->hide ();
1412         }
1413 }
1414
1415 void
1416 MixerStrip::route_active_changed ()
1417 {
1418         RouteUI::route_active_changed ();
1419
1420         if (is_audio_track()) {
1421                 if (_route.active()) {
1422                         set_name ("AudioTrackStripBase");
1423                         gpm.set_meter_strip_name ("AudioTrackStripBase");
1424                 } else {
1425                         set_name ("AudioTrackStripBaseInactive");
1426                         gpm.set_meter_strip_name ("AudioTrackStripBaseInactive");
1427                 }
1428                 gpm.set_fader_name ("AudioTrackFader");
1429         } else {
1430                 if (_route.active()) {
1431                         set_name ("AudioBusStripBase");
1432                         gpm.set_meter_strip_name ("AudioBusStripBase");
1433                 } else {
1434                         set_name ("AudioBusStripBaseInactive");
1435                         gpm.set_meter_strip_name ("AudioBusStripBaseInactive");
1436                 }
1437                 gpm.set_fader_name ("AudioBusFader");
1438         }
1439 }