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