Fix broken meter style on MIDI tracks.
[ardour2.git] / gtk2_ardour / mixer_strip.cc
blob115b81879029461e409b68e5f50b6255848bcb21
1 /*
2 Copyright (C) 2000-2006 Paul Davis
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.
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.
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.
19 #include <cmath>
20 #include <algorithm>
22 #include <sigc++/bind.h>
24 #include "pbd/convert.h"
25 #include "pbd/enumwriter.h"
26 #include "pbd/replace_all.h"
28 #include <gtkmm2ext/gtk_ui.h>
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/choice.h>
31 #include <gtkmm2ext/doi.h>
32 #include <gtkmm2ext/slider_controller.h>
33 #include <gtkmm2ext/bindable_button.h>
35 #include "ardour/ardour.h"
36 #include "ardour/amp.h"
37 #include "ardour/session.h"
38 #include "ardour/audioengine.h"
39 #include "ardour/internal_send.h"
40 #include "ardour/route.h"
41 #include "ardour/route_group.h"
42 #include "ardour/audio_track.h"
43 #include "ardour/pannable.h"
44 #include "ardour/panner.h"
45 #include "ardour/panner_shell.h"
46 #include "ardour/send.h"
47 #include "ardour/processor.h"
48 #include "ardour/profile.h"
49 #include "ardour/ladspa_plugin.h"
50 #include "ardour/user_bundle.h"
51 #include "ardour/port.h"
53 #include "ardour_ui.h"
54 #include "ardour_dialog.h"
55 #include "mixer_strip.h"
56 #include "mixer_ui.h"
57 #include "keyboard.h"
58 #include "led.h"
59 #include "public_editor.h"
60 #include "send_ui.h"
61 #include "io_selector.h"
62 #include "utils.h"
63 #include "gui_thread.h"
64 #include "route_group_menu.h"
66 #include "i18n.h"
68 using namespace ARDOUR;
69 using namespace PBD;
70 using namespace Gtk;
71 using namespace Gtkmm2ext;
72 using namespace std;
74 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
76 int MixerStrip::scrollbar_height = 0;
77 PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
79 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
80 : AxisView(sess)
81 , RouteUI (sess)
82 , _mixer(mx)
83 , _mixer_owned (in_mixer)
84 , processor_box (sess, boost::bind (&MixerStrip::plugin_selector, this), mx.selection(), this, in_mixer)
85 , gpm (sess, 250)
86 , panners (sess)
87 , button_table (3, 1)
88 , solo_led_table (2, 2)
89 , middle_button_table (1, 2)
90 , bottom_button_table (1, 2)
91 , meter_point_label (_("pre"))
93 init ();
95 if (!_mixer_owned) {
96 /* the editor mixer strip: don't destroy it every time
97 the underlying route goes away.
100 self_destruct = false;
104 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Route> rt, bool in_mixer)
105 : AxisView(sess)
106 , RouteUI (sess)
107 , _mixer(mx)
108 , _mixer_owned (in_mixer)
109 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
110 , gpm (sess, 250)
111 , panners (sess)
112 , button_table (3, 1)
113 , middle_button_table (1, 2)
114 , bottom_button_table (1, 2)
115 , meter_point_label (_("pre"))
117 init ();
118 set_route (rt);
121 void
122 MixerStrip::init ()
124 input_selector = 0;
125 output_selector = 0;
126 group_menu = 0;
127 _marked_for_display = false;
128 route_ops_menu = 0;
129 ignore_comment_edit = false;
130 ignore_toggle = false;
131 comment_window = 0;
132 comment_area = 0;
133 _width_owner = 0;
134 spacer = 0;
136 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
137 longest_label = "longest label";
139 Gtk::Image* img;
141 img = manage (new Gtk::Image (::get_icon("strip_width")));
142 img->show ();
144 width_button.add (*img);
146 img = manage (new Gtk::Image (::get_icon("hide")));
147 img->show ();
149 hide_button.add (*img);
151 input_label.set_text (_("Input"));
152 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
153 input_button.add (input_label);
154 input_button.set_name ("MixerIOButton");
155 input_label.set_name ("MixerIOButtonLabel");
157 Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 4, 4);
159 output_label.set_text (_("Output"));
160 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
161 output_button.add (output_label);
162 output_button.set_name ("MixerIOButton");
163 output_label.set_name ("MixerIOButtonLabel");
164 Gtkmm2ext::set_size_request_to_display_given_text (output_button, longest_label.c_str(), 4, 4);
166 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
167 meter_point_button.add (meter_point_label);
168 meter_point_button.set_name ("MixerStripMeterPreButton");
169 meter_point_label.set_name ("MixerStripMeterPreButton");
171 /* TRANSLATORS: this string should be longest of the strings
172 used to describe meter points. In english, it's "input".
174 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
176 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
178 meter_point_button.signal_button_press_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_press), false);
179 meter_point_button.signal_button_release_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_release), false);
181 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
183 mute_button->set_name ("MixerMuteButton");
184 solo_button->set_name ("MixerSoloButton");
186 solo_isolated_led = manage (new LED);
187 solo_isolated_led->show ();
188 solo_isolated_led->set_diameter (6);
189 solo_isolated_led->set_no_show_all (true);
190 solo_isolated_led->set_name (X_("SoloIsolatedLED"));
191 solo_isolated_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
192 solo_isolated_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_isolate_button_release));
193 UI::instance()->set_tip (solo_isolated_led, _("Isolate Solo"), "");
195 solo_safe_led = manage (new LED);
196 solo_safe_led->show ();
197 solo_safe_led->set_diameter (6);
198 solo_safe_led->set_no_show_all (true);
199 solo_safe_led->set_name (X_("SoloSafeLED"));
200 solo_safe_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
201 solo_safe_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_safe_button_release));
202 UI::instance()->set_tip (solo_safe_led, _("Lock Solo Status"), "");
204 _iso_label = manage (new Label (_("iso")));
205 _safe_label = manage (new Label (_("lock")));
207 _iso_label->set_name (X_("SoloLEDLabel"));
208 _safe_label->set_name (X_("SoloLEDLabel"));
210 _iso_label->show ();
211 _safe_label->show ();
213 solo_led_table.set_spacings (0);
214 solo_led_table.set_border_width (1);
215 solo_led_table.attach (*_iso_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
216 solo_led_table.attach (*solo_isolated_led, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
217 solo_led_table.attach (*_safe_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
218 solo_led_table.attach (*solo_safe_led, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL);
220 solo_led_table.show ();
221 below_panner_box.set_border_width (2);
222 below_panner_box.set_spacing (2);
223 below_panner_box.pack_end (solo_led_table, false, false);
224 below_panner_box.show ();
226 button_table.set_homogeneous (true);
227 button_table.set_spacings (0);
229 button_table.attach (name_button, 0, 1, 0, 1);
230 button_table.attach (input_button, 0, 1, 1, 2);
231 button_table.attach (_invert_button_box, 0, 1, 2, 3);
233 middle_button_table.set_homogeneous (true);
234 middle_button_table.set_spacings (0);
235 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
236 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
238 bottom_button_table.set_col_spacings (0);
239 bottom_button_table.set_homogeneous (true);
240 bottom_button_table.attach (group_button, 0, 1, 0, 1);
242 name_button.add (name_label);
243 name_button.set_name ("MixerNameButton");
244 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
246 name_label.set_name ("MixerNameButtonLabel");
247 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
248 group_button.add (group_label);
249 group_button.set_name ("MixerGroupButton");
250 Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Group", 2, 2);
251 group_label.set_name ("MixerGroupButtonLabel");
253 global_vpacker.set_border_width (0);
254 global_vpacker.set_spacing (0);
256 width_button.set_name ("MixerWidthButton");
257 hide_button.set_name ("MixerHideButton");
258 top_event_box.set_name ("MixerTopEventBox");
260 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
261 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
263 width_hide_box.pack_start (width_button, false, true);
264 width_hide_box.pack_start (top_event_box, true, true);
265 width_hide_box.pack_end (hide_button, false, true);
266 gain_meter_alignment.set_padding(0, 4, 0, 0);
267 gain_meter_alignment.add(gpm);
269 whvbox.pack_start (width_hide_box, true, true);
271 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
272 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
273 global_vpacker.pack_start (processor_box, true, true);
274 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
275 global_vpacker.pack_start (below_panner_box, Gtk::PACK_SHRINK);
276 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
277 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
278 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
279 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
281 global_frame.add (global_vpacker);
282 global_frame.set_shadow_type (Gtk::SHADOW_IN);
283 global_frame.set_name ("BaseFrame");
285 add (global_frame);
287 /* force setting of visible selected status */
289 _selected = true;
290 set_selected (false);
292 _packed = false;
293 _embedded = false;
295 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_stopped, this), gui_context());
296 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_running, this), gui_context());
298 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
299 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
301 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
302 hurt (much).
305 rec_enable_button->set_name ("MixerRecordEnableButton");
307 /* ditto for this button and busses */
309 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
310 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
312 _width = (Width) -1;
314 /* start off as a passthru strip. we'll correct this, if necessary,
315 in update_diskstream_display().
318 /* start off as a passthru strip. we'll correct this, if necessary,
319 in update_diskstream_display().
322 if (is_midi_track())
323 set_name ("MidiTrackStripBase");
324 else
325 set_name ("AudioTrackStripBase");
327 add_events (Gdk::BUTTON_RELEASE_MASK|
328 Gdk::ENTER_NOTIFY_MASK|
329 Gdk::LEAVE_NOTIFY_MASK|
330 Gdk::KEY_PRESS_MASK|
331 Gdk::KEY_RELEASE_MASK);
333 set_flags (get_flags() | Gtk::CAN_FOCUS);
335 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
337 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
338 *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context ()
342 MixerStrip::~MixerStrip ()
344 CatchDeletion (this);
346 delete input_selector;
347 delete output_selector;
348 delete comment_window;
351 void
352 MixerStrip::set_route (boost::shared_ptr<Route> rt)
354 if (rec_enable_button->get_parent()) {
355 below_panner_box.remove (*rec_enable_button);
358 if (show_sends_button->get_parent()) {
359 below_panner_box.remove (*show_sends_button);
362 processor_box.set_route (rt);
364 RouteUI::set_route (rt);
366 /* map the current state */
368 mute_changed (0);
369 update_solo_display ();
371 delete input_selector;
372 input_selector = 0;
374 delete output_selector;
375 output_selector = 0;
377 revert_to_default_display ();
379 if (set_color_from_route()) {
380 set_color (unique_random_color());
383 if (route()->is_master()) {
384 solo_button->hide ();
385 below_panner_box.hide ();
386 } else {
387 solo_button->show ();
388 below_panner_box.show ();
391 if (_mixer_owned && (route()->is_master() || route()->is_monitor())) {
393 if (scrollbar_height == 0) {
394 HScrollbar scrollbar;
395 Gtk::Requisition requisition(scrollbar.size_request ());
396 scrollbar_height = requisition.height;
399 spacer = manage (new EventBox);
400 spacer->set_size_request (-1, scrollbar_height);
401 global_vpacker.pack_start (*spacer, false, false);
404 if (is_audio_track()) {
405 boost::shared_ptr<AudioTrack> at = audio_track();
406 at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context());
409 if (has_audio_outputs ()) {
410 panners.show_all ();
411 } else {
412 panners.hide_all ();
415 if (is_track ()) {
417 below_panner_box.pack_start (*rec_enable_button);
418 rec_enable_button->set_sensitive (_session->writable());
419 rec_enable_button->show();
421 } else {
423 /* non-master bus */
425 if (!_route->is_master()) {
426 below_panner_box.pack_start (*show_sends_button);
427 show_sends_button->show();
431 meter_point_label.set_text (meter_point_string (_route->meter_point()));
433 delete route_ops_menu;
434 route_ops_menu = 0;
436 _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context());
437 _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
439 if (_route->panner()) {
440 _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
443 if (is_audio_track()) {
444 audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
447 _route->comment_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
448 _route->gui_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
450 set_stuff_from_route ();
452 /* now force an update of all the various elements */
454 mute_changed (0);
455 update_solo_display ();
456 name_changed ();
457 comment_changed (0);
458 route_group_changed ();
460 connect_to_pan ();
461 panners.setup_pan ();
463 update_diskstream_display ();
464 update_input_display ();
465 update_output_display ();
467 add_events (Gdk::BUTTON_RELEASE_MASK);
469 processor_box.show ();
471 if (!route()->is_master() && !route()->is_monitor()) {
472 /* we don't allow master or control routes to be hidden */
473 hide_button.show();
476 width_button.show();
477 width_hide_box.show();
478 whvbox.show ();
479 global_frame.show();
480 global_vpacker.show();
481 button_table.show();
482 middle_button_table.show();
483 bottom_button_table.show();
484 gpm.show_all ();
485 gain_meter_alignment.show ();
486 gain_unit_button.show();
487 gain_unit_label.show();
488 meter_point_button.show();
489 meter_point_label.show();
490 diskstream_button.show();
491 diskstream_label.show();
492 input_button.show();
493 input_label.show();
494 output_button.show();
495 output_label.show();
496 name_label.show();
497 name_button.show();
498 group_button.show();
499 group_label.show();
501 show ();
504 void
505 MixerStrip::set_stuff_from_route ()
507 XMLProperty *prop;
509 ensure_xml_node ();
511 /* if width is not set, it will be set by the MixerUI or editor */
513 if ((prop = xml_node->property ("strip-width")) != 0) {
514 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
517 if ((prop = xml_node->property ("shown-mixer")) != 0) {
518 if (prop->value() == "no") {
519 _marked_for_display = false;
520 } else {
521 _marked_for_display = true;
523 } else {
524 /* backwards compatibility */
525 _marked_for_display = true;
529 void
530 MixerStrip::set_width_enum (Width w, void* owner)
532 /* always set the gpm width again, things may be hidden */
534 gpm.set_width (w);
535 panners.set_width (w);
537 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
539 _width_owner = owner;
541 ensure_xml_node ();
543 _width = w;
545 if (_width_owner == this) {
546 xml_node->add_property ("strip-width", enum_2_string (_width));
549 set_button_names ();
551 switch (w) {
552 case Wide:
553 if (show_sends_button) {
554 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
557 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
558 gpm.astyle_string(gain_automation->automation_style()));
559 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
560 gpm.astate_string(gain_automation->automation_state()));
562 if (_route->panner()) {
563 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
564 panners.astyle_string(_route->panner()->automation_style()));
565 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
566 panners.astate_string(_route->panner()->automation_state()));
569 _iso_label->show ();
570 _safe_label->show ();
572 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
573 set_size_request (-1, -1);
574 break;
576 case Narrow:
577 if (show_sends_button) {
578 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
581 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
582 gpm.short_astyle_string(gain_automation->automation_style()));
583 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
584 gpm.short_astate_string(gain_automation->automation_state()));
586 if (_route->panner()) {
587 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
588 panners.short_astyle_string(_route->panner()->automation_style()));
589 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
590 panners.short_astate_string(_route->panner()->automation_state()));
593 _iso_label->hide ();
594 _safe_label->hide ();
596 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
597 set_size_request (max (50, gpm.get_gm_width()), -1);
598 break;
601 processor_box.set_width (w);
603 update_input_display ();
604 update_output_display ();
605 route_group_changed ();
606 name_changed ();
607 WidthChanged ();
610 void
611 MixerStrip::set_packed (bool yn)
613 _packed = yn;
615 ensure_xml_node ();
617 if (_packed) {
618 xml_node->add_property ("shown-mixer", "yes");
619 } else {
620 xml_node->add_property ("shown-mixer", "no");
625 struct RouteCompareByName {
626 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
627 return a->name().compare (b->name()) < 0;
631 gint
632 MixerStrip::output_press (GdkEventButton *ev)
634 using namespace Menu_Helpers;
635 if (!_session->engine().connected()) {
636 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
637 msg.run ();
638 return true;
641 MenuList& citems = output_menu.items();
642 switch (ev->button) {
644 case 1:
645 edit_output_configuration ();
646 break;
648 case 3:
650 output_menu.set_name ("ArdourContextMenu");
651 citems.clear ();
652 output_menu_bundles.clear ();
654 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
655 citems.push_back (SeparatorElem());
657 ARDOUR::BundleList current = _route->output()->bundles_connected ();
659 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
661 /* give user bundles first chance at being in the menu */
663 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
664 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
665 maybe_add_bundle_to_output_menu (*i, current);
669 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
670 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
671 maybe_add_bundle_to_output_menu (*i, current);
675 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
676 RouteList copy = *routes;
677 copy.sort (RouteCompareByName ());
678 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
679 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
682 if (citems.size() == 2) {
683 /* no routes added; remove the separator */
684 citems.pop_back ();
687 output_menu.popup (1, ev->time);
688 break;
691 default:
692 break;
694 return TRUE;
697 void
698 MixerStrip::edit_output_configuration ()
700 if (output_selector == 0) {
702 boost::shared_ptr<Send> send;
703 boost::shared_ptr<IO> output;
705 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
706 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
707 output = send->output();
708 } else {
709 output = _route->output ();
711 } else {
712 output = _route->output ();
715 output_selector = new IOSelectorWindow (_session, output);
718 if (output_selector->is_visible()) {
719 output_selector->get_toplevel()->get_window()->raise();
720 } else {
721 output_selector->present ();
725 void
726 MixerStrip::edit_input_configuration ()
728 if (input_selector == 0) {
729 input_selector = new IOSelectorWindow (_session, _route->input());
732 if (input_selector->is_visible()) {
733 input_selector->get_toplevel()->get_window()->raise();
734 } else {
735 input_selector->present ();
739 gint
740 MixerStrip::input_press (GdkEventButton *ev)
742 using namespace Menu_Helpers;
744 MenuList& citems = input_menu.items();
745 input_menu.set_name ("ArdourContextMenu");
746 citems.clear();
748 if (!_session->engine().connected()) {
749 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
750 msg.run ();
751 return true;
754 if (_session->actively_recording() && _route->record_enabled())
755 return true;
757 switch (ev->button) {
759 case 1:
760 edit_input_configuration ();
761 break;
763 case 3:
765 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
766 citems.push_back (SeparatorElem());
767 input_menu_bundles.clear ();
769 ARDOUR::BundleList current = _route->input()->bundles_connected ();
771 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
773 /* give user bundles first chance at being in the menu */
775 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
776 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
777 maybe_add_bundle_to_input_menu (*i, current);
781 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
782 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
783 maybe_add_bundle_to_input_menu (*i, current);
787 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
788 RouteList copy = *routes;
789 copy.sort (RouteCompareByName ());
790 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
791 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
794 if (citems.size() == 2) {
795 /* no routes added; remove the separator */
796 citems.pop_back ();
799 input_menu.popup (1, ev->time);
800 break;
802 default:
803 break;
805 return TRUE;
808 void
809 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
811 if (ignore_toggle) {
812 return;
815 ARDOUR::BundleList current = _route->input()->bundles_connected ();
817 if (std::find (current.begin(), current.end(), c) == current.end()) {
818 _route->input()->connect_ports_to_bundle (c, this);
819 } else {
820 _route->input()->disconnect_ports_from_bundle (c, this);
824 void
825 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
827 if (ignore_toggle) {
828 return;
831 ARDOUR::BundleList current = _route->output()->bundles_connected ();
833 if (std::find (current.begin(), current.end(), c) == current.end()) {
834 _route->output()->connect_ports_to_bundle (c, this);
835 } else {
836 _route->output()->disconnect_ports_from_bundle (c, this);
840 void
841 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
843 using namespace Menu_Helpers;
845 if (b->ports_are_outputs() == false || b->nchannels() != _route->n_inputs()) {
846 return;
849 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
850 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
851 ++i;
854 if (i != input_menu_bundles.end()) {
855 return;
858 input_menu_bundles.push_back (b);
860 MenuList& citems = input_menu.items();
862 std::string n = b->name ();
863 replace_all (n, "_", " ");
865 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
867 if (std::find (current.begin(), current.end(), b) != current.end()) {
868 ignore_toggle = true;
869 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
870 ignore_toggle = false;
874 void
875 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
877 using namespace Menu_Helpers;
879 if (b->ports_are_inputs() == false || b->nchannels() != _route->n_outputs()) {
880 return;
883 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
884 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
885 ++i;
888 if (i != output_menu_bundles.end()) {
889 return;
892 output_menu_bundles.push_back (b);
894 MenuList& citems = output_menu.items();
896 std::string n = b->name ();
897 replace_all (n, "_", " ");
899 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
901 if (std::find (current.begin(), current.end(), b) != current.end()) {
902 ignore_toggle = true;
903 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
904 ignore_toggle = false;
908 void
909 MixerStrip::update_diskstream_display ()
911 if (is_track()) {
913 if (input_selector) {
914 input_selector->hide_all ();
917 show_route_color ();
919 } else {
921 show_passthru_color ();
925 void
926 MixerStrip::connect_to_pan ()
928 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
930 panstate_connection.disconnect ();
931 panstyle_connection.disconnect ();
933 if (!_route->panner()) {
934 return;
937 boost::shared_ptr<Pannable> p = _route->pannable ();
939 p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
940 p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
942 panners.panshell_changed ();
947 * Output port labelling
948 * =====================
950 * Case 1: Each output has one connection, all connections are to system:playback_%i
951 * out 1 -> system:playback_1
952 * out 2 -> system:playback_2
953 * out 3 -> system:playback_3
954 * Display as: 1/2/3
956 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
957 * out 1 -> ardour:track_x/in 1
958 * out 2 -> ardour:track_x/in 2
959 * Display as: track_x
961 * Case 3: Each output has one connection, all connections are to Jack client "program x"
962 * out 1 -> program x:foo
963 * out 2 -> program x:foo
964 * Display as: program x
966 * Case 4: No connections (Disconnected)
967 * Display as: -
969 * Default case (unusual routing):
970 * Display as: *number of connections*
972 * Tooltips
973 * ========
974 * .-----------------------------------------------.
975 * | Mixdown |
976 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
977 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
978 * '-----------------------------------------------'
979 * .-----------------------------------------------.
980 * | Guitar SM58 |
981 * | Disconnected |
982 * '-----------------------------------------------'
985 void
986 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
988 uint32_t io_count;
989 uint32_t io_index;
990 Port *port;
991 vector<string> port_connections;
993 uint32_t total_connection_count = 0;
994 uint32_t io_connection_count = 0;
995 uint32_t ardour_connection_count = 0;
996 uint32_t system_connection_count = 0;
997 uint32_t other_connection_count = 0;
999 ostringstream label;
1000 string label_string;
1002 bool have_label = false;
1003 bool each_io_has_one_connection = true;
1005 string connection_name;
1006 string ardour_track_name;
1007 string other_connection_type;
1008 string system_ports;
1009 string system_port;
1011 ostringstream tooltip;
1012 char * tooltip_cstr;
1014 tooltip << route->name();
1016 if (for_input) {
1017 io_count = route->n_inputs().n_total();
1018 } else {
1019 io_count = route->n_outputs().n_total();
1022 for (io_index = 0; io_index < io_count; ++io_index) {
1023 if (for_input) {
1024 port = route->input()->nth (io_index);
1025 } else {
1026 port = route->output()->nth (io_index);
1029 port_connections.clear ();
1030 port->get_connections(port_connections);
1031 io_connection_count = 0;
1033 if (!port_connections.empty()) {
1034 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1035 string& connection_name (*i);
1037 if (io_connection_count == 0) {
1038 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1039 } else {
1040 tooltip << ", " << connection_name;
1043 if (connection_name.find("ardour:") == 0) {
1044 if (ardour_track_name.empty()) {
1045 // "ardour:Master/in 1" -> "ardour:Master/"
1046 string::size_type slash = connection_name.find("/");
1047 if (slash != string::npos) {
1048 ardour_track_name = connection_name.substr(0, slash + 1);
1052 if (connection_name.find(ardour_track_name) == 0) {
1053 ++ardour_connection_count;
1055 } else if (connection_name.find("system:") == 0) {
1056 if (for_input) {
1057 // "system:capture_123" -> "123"
1058 system_port = connection_name.substr(15);
1059 } else {
1060 // "system:playback_123" -> "123"
1061 system_port = connection_name.substr(16);
1064 if (system_ports.empty()) {
1065 system_ports += system_port;
1066 } else {
1067 system_ports += "/" + system_port;
1070 ++system_connection_count;
1071 } else {
1072 if (other_connection_type.empty()) {
1073 // "jamin:in 1" -> "jamin:"
1074 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1077 if (connection_name.find(other_connection_type) == 0) {
1078 ++other_connection_count;
1082 ++total_connection_count;
1083 ++io_connection_count;
1087 if (io_connection_count != 1) {
1088 each_io_has_one_connection = false;
1092 if (total_connection_count == 0) {
1093 tooltip << endl << _("Disconnected");
1096 tooltip_cstr = new char[tooltip.str().size() + 1];
1097 strcpy(tooltip_cstr, tooltip.str().c_str());
1099 if (for_input) {
1100 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1101 } else {
1102 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1105 if (each_io_has_one_connection) {
1106 if ((total_connection_count == ardour_connection_count)) {
1107 // all connections are to the same track in ardour
1108 // "ardour:Master/" -> "Master"
1109 string::size_type slash = ardour_track_name.find("/");
1110 if (slash != string::npos) {
1111 label << ardour_track_name.substr(7, slash - 7);
1112 have_label = true;
1115 else if (total_connection_count == system_connection_count) {
1116 // all connections are to system ports
1117 label << system_ports;
1118 have_label = true;
1120 else if (total_connection_count == other_connection_count) {
1121 // all connections are to the same external program eg jamin
1122 // "jamin:" -> "jamin"
1123 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1124 have_label = true;
1128 if (!have_label) {
1129 if (total_connection_count == 0) {
1130 // Disconnected
1131 label << "-";
1132 } else {
1133 // Odd configuration
1134 label << "*" << total_connection_count << "*";
1138 switch (width) {
1139 case Wide:
1140 label_string = label.str().substr(0, 6);
1141 break;
1142 case Narrow:
1143 label_string = label.str().substr(0, 3);
1144 break;
1147 if (for_input) {
1148 input_label.set_text (label_string);
1149 } else {
1150 output_label.set_text (label_string);
1154 void
1155 MixerStrip::update_input_display ()
1157 update_io_button (_route, _width, true);
1158 panners.setup_pan ();
1161 void
1162 MixerStrip::update_output_display ()
1164 update_io_button (_route, _width, false);
1165 gpm.setup_meters ();
1166 panners.setup_pan ();
1169 void
1170 MixerStrip::fast_update ()
1172 gpm.update_meters ();
1175 void
1176 MixerStrip::diskstream_changed ()
1178 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
1181 void
1182 MixerStrip::port_connected_or_disconnected (Port* a, Port* b)
1184 if (_route->input()->has_port (a) || _route->input()->has_port (b)) {
1185 update_input_display ();
1186 set_width_enum (_width, this);
1189 if (_route->output()->has_port (a) || _route->output()->has_port (b)) {
1190 update_output_display ();
1191 set_width_enum (_width, this);
1195 void
1196 MixerStrip::comment_editor_done_editing ()
1198 ignore_toggle = true;
1199 _comment_menu_item->set_active (false);
1200 ignore_toggle = false;
1202 string const str = comment_area->get_buffer()->get_text();
1203 if (str == _route->comment ()) {
1204 return;
1207 _route->set_comment (str, this);
1210 void
1211 MixerStrip::toggle_comment ()
1213 if (ignore_toggle) {
1214 return;
1217 if (comment_window == 0) {
1218 setup_comment_editor ();
1221 if (comment_window->is_visible ()) {
1222 comment_window->hide ();
1223 return;
1226 string title;
1227 title = _route->name();
1228 title += _(": comment editor");
1230 comment_window->set_title (title);
1231 comment_window->present();
1234 void
1235 MixerStrip::setup_comment_editor ()
1237 comment_window = new ArdourDialog ("", false); // title will be reset to show route
1238 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1239 comment_window->set_skip_taskbar_hint (true);
1240 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1241 comment_window->set_default_size (400, 200);
1243 comment_area = manage (new TextView());
1244 comment_area->set_name ("MixerTrackCommentArea");
1245 comment_area->set_wrap_mode (WRAP_WORD);
1246 comment_area->set_editable (true);
1247 comment_area->get_buffer()->set_text (_route->comment());
1248 comment_area->show ();
1250 comment_window->get_vbox()->pack_start (*comment_area);
1251 comment_window->get_action_area()->hide();
1254 void
1255 MixerStrip::comment_changed (void *src)
1257 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1259 if (src != this) {
1260 ignore_comment_edit = true;
1261 if (comment_area) {
1262 comment_area->get_buffer()->set_text (_route->comment());
1264 ignore_comment_edit = false;
1268 bool
1269 MixerStrip::select_route_group (GdkEventButton *ev)
1271 using namespace Menu_Helpers;
1273 if (ev->button == 1) {
1275 if (group_menu == 0) {
1277 PropertyList* plist = new PropertyList();
1279 plist->add (Properties::gain, true);
1280 plist->add (Properties::mute, true);
1281 plist->add (Properties::solo, true);
1283 group_menu = new RouteGroupMenu (_session, plist);
1286 WeakRouteList r;
1287 r.push_back (route ());
1288 group_menu->build (r);
1289 group_menu->menu()->popup (1, ev->time);
1292 return true;
1295 void
1296 MixerStrip::route_group_changed ()
1298 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1300 RouteGroup *rg = _route->route_group();
1302 if (rg) {
1303 group_label.set_text (PBD::short_version (rg->name(), 5));
1304 } else {
1305 switch (_width) {
1306 case Wide:
1307 group_label.set_text (_("Grp"));
1308 break;
1309 case Narrow:
1310 group_label.set_text (_("~G"));
1311 break;
1317 void
1318 MixerStrip::route_gui_changed (string what_changed, void*)
1320 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1322 if (what_changed == "color") {
1323 if (set_color_from_route () == 0) {
1324 show_route_color ();
1329 void
1330 MixerStrip::show_route_color ()
1332 name_button.modify_bg (STATE_NORMAL, color());
1333 top_event_box.modify_bg (STATE_NORMAL, color());
1334 reset_strip_style ();
1337 void
1338 MixerStrip::show_passthru_color ()
1340 reset_strip_style ();
1343 void
1344 MixerStrip::build_route_ops_menu ()
1346 using namespace Menu_Helpers;
1347 route_ops_menu = new Menu;
1348 route_ops_menu->set_name ("ArdourContextMenu");
1350 MenuList& items = route_ops_menu->items();
1352 items.push_back (CheckMenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::toggle_comment)));
1353 _comment_menu_item = dynamic_cast<CheckMenuItem*> (&items.back ());
1354 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1355 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1356 rename_menu_item = &items.back();
1357 items.push_back (SeparatorElem());
1358 items.push_back (CheckMenuElem (_("Active")));
1359 CheckMenuItem* i = dynamic_cast<CheckMenuItem *> (&items.back());
1360 i->set_active (_route->active());
1361 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
1363 items.push_back (SeparatorElem());
1365 items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1367 items.push_back (SeparatorElem());
1368 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1369 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1370 denormal_menu_item->set_active (_route->denormal_protection());
1372 if (!Profile->get_sae()) {
1373 items.push_back (SeparatorElem());
1374 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1377 items.push_back (SeparatorElem());
1378 items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), false)));
1381 gboolean
1382 MixerStrip::name_button_button_press (GdkEventButton* ev)
1384 if (ev->button == 3) {
1385 list_route_operations ();
1387 /* do not allow rename if the track is record-enabled */
1388 rename_menu_item->set_sensitive (!_route->record_enabled());
1389 route_ops_menu->popup (1, ev->time);
1391 } else if (ev->button == 1) {
1392 revert_to_default_display ();
1395 return false;
1398 void
1399 MixerStrip::list_route_operations ()
1401 delete route_ops_menu;
1402 build_route_ops_menu ();
1405 void
1406 MixerStrip::set_selected (bool yn)
1408 AxisView::set_selected (yn);
1409 if (_selected) {
1410 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1411 global_frame.set_name ("MixerStripSelectedFrame");
1412 } else {
1413 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1414 global_frame.set_name ("MixerStripFrame");
1416 global_frame.queue_draw ();
1419 void
1420 MixerStrip::name_changed ()
1422 switch (_width) {
1423 case Wide:
1424 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1425 break;
1426 case Narrow:
1427 name_label.set_text (PBD::short_version (_route->name(), 5));
1428 break;
1432 void
1433 MixerStrip::width_clicked ()
1435 switch (_width) {
1436 case Wide:
1437 set_width_enum (Narrow, this);
1438 break;
1439 case Narrow:
1440 set_width_enum (Wide, this);
1441 break;
1445 void
1446 MixerStrip::hide_clicked ()
1448 // LAME fix to reset the button status for when it is redisplayed (part 1)
1449 hide_button.set_sensitive(false);
1451 if (_embedded) {
1452 Hiding(); /* EMIT_SIGNAL */
1453 } else {
1454 _mixer.hide_strip (this);
1457 // (part 2)
1458 hide_button.set_sensitive(true);
1461 void
1462 MixerStrip::set_embedded (bool yn)
1464 _embedded = yn;
1467 void
1468 MixerStrip::map_frozen ()
1470 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1472 boost::shared_ptr<AudioTrack> at = audio_track();
1474 if (at) {
1475 switch (at->freeze_state()) {
1476 case AudioTrack::Frozen:
1477 processor_box.set_sensitive (false);
1478 hide_redirect_editors ();
1479 break;
1480 default:
1481 processor_box.set_sensitive (true);
1482 // XXX need some way, maybe, to retoggle redirect editors
1483 break;
1488 void
1489 MixerStrip::hide_redirect_editors ()
1491 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1494 void
1495 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1497 boost::shared_ptr<Processor> processor (p.lock ());
1498 if (!processor) {
1499 return;
1502 Gtk::Window* w = processor_box.get_processor_ui (processor);
1504 if (w) {
1505 w->hide ();
1509 void
1510 MixerStrip::reset_strip_style ()
1512 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1514 gpm.set_fader_name ("SendStripBase");
1516 } else {
1518 if (is_midi_track()) {
1519 if (_route->active()) {
1520 set_name ("MidiTrackStripBase");
1521 gpm.set_meter_strip_name ("MidiTrackMetrics");
1522 } else {
1523 set_name ("MidiTrackStripBaseInactive");
1524 gpm.set_meter_strip_name ("MidiTrackMetricsInactive");
1526 gpm.set_fader_name ("MidiTrackFader");
1527 } else if (is_audio_track()) {
1528 if (_route->active()) {
1529 set_name ("AudioTrackStripBase");
1530 gpm.set_meter_strip_name ("AudioTrackMetrics");
1531 } else {
1532 set_name ("AudioTrackStripBaseInactive");
1533 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1535 gpm.set_fader_name ("AudioTrackFader");
1536 } else {
1537 if (_route->active()) {
1538 set_name ("AudioBusStripBase");
1539 gpm.set_meter_strip_name ("AudioBusMetrics");
1540 } else {
1541 set_name ("AudioBusStripBaseInactive");
1542 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1544 gpm.set_fader_name ("AudioBusFader");
1546 /* (no MIDI busses yet) */
1551 RouteGroup*
1552 MixerStrip::route_group() const
1554 return _route->route_group();
1557 void
1558 MixerStrip::engine_stopped ()
1562 void
1563 MixerStrip::engine_running ()
1567 string
1568 MixerStrip::meter_point_string (MeterPoint mp)
1570 switch (mp) {
1571 case MeterInput:
1572 return _("in");
1573 break;
1575 case MeterPreFader:
1576 return _("pre");
1577 break;
1579 case MeterPostFader:
1580 return _("post");
1581 break;
1583 case MeterOutput:
1584 return _("out");
1585 break;
1587 case MeterCustom:
1588 default:
1589 return _("custom");
1590 break;
1594 /** Called when the metering point has changed */
1595 void
1596 MixerStrip::meter_changed ()
1598 meter_point_label.set_text (meter_point_string (_route->meter_point()));
1599 gpm.setup_meters ();
1600 // reset peak when meter point changes
1601 gpm.reset_peak_display();
1604 void
1605 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1607 /* don't respond to switch IO signal outside of the mixer window */
1609 if (!_mixer_owned) {
1610 return;
1613 if (_route == target || _route->is_master()) {
1614 /* don't change the display for the target or the master bus */
1615 return;
1616 } else if (!is_track() && show_sends_button) {
1617 /* make sure our show sends button is inactive, and we no longer blink,
1618 since we're not the target.
1620 send_blink_connection.disconnect ();
1621 show_sends_button->set_active (false);
1622 show_sends_button->set_state (STATE_NORMAL);
1625 if (!target) {
1626 /* switch back to default */
1627 revert_to_default_display ();
1628 return;
1631 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1633 if (send) {
1634 show_send (send);
1635 } else {
1636 revert_to_default_display ();
1640 void
1641 MixerStrip::drop_send ()
1643 boost::shared_ptr<Send> current_send;
1645 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1646 current_send->set_metering (false);
1649 send_gone_connection.disconnect ();
1650 input_button.set_sensitive (true);
1651 output_button.set_sensitive (true);
1652 group_button.set_sensitive (true);
1653 set_invert_sensitive (true);
1654 meter_point_button.set_sensitive (true);
1655 mute_button->set_sensitive (true);
1656 solo_button->set_sensitive (true);
1657 rec_enable_button->set_sensitive (true);
1658 solo_isolated_led->set_sensitive (true);
1659 solo_safe_led->set_sensitive (true);
1662 void
1663 MixerStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1665 _current_delivery = d;
1666 DeliveryChanged (_current_delivery);
1669 void
1670 MixerStrip::show_send (boost::shared_ptr<Send> send)
1672 assert (send != 0);
1674 drop_send ();
1676 set_current_delivery (send);
1678 send->set_metering (true);
1679 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1681 gain_meter().set_controls (_route, send->meter(), send->amp());
1682 gain_meter().setup_meters ();
1684 panner_ui().set_panner (_current_delivery->panner_shell(), _current_delivery->panner());
1685 panner_ui().setup_pan ();
1687 input_button.set_sensitive (false);
1688 group_button.set_sensitive (false);
1689 set_invert_sensitive (false);
1690 meter_point_button.set_sensitive (false);
1691 mute_button->set_sensitive (false);
1692 solo_button->set_sensitive (false);
1693 rec_enable_button->set_sensitive (false);
1694 solo_isolated_led->set_sensitive (false);
1695 solo_safe_led->set_sensitive (false);
1697 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1698 output_button.set_sensitive (false);
1701 reset_strip_style ();
1704 void
1705 MixerStrip::revert_to_default_display ()
1707 if (show_sends_button) {
1708 show_sends_button->set_active (false);
1711 drop_send ();
1713 set_current_delivery (_route->main_outs ());
1715 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1716 gain_meter().setup_meters ();
1718 panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
1719 panner_ui().setup_pan ();
1721 reset_strip_style ();
1724 void
1725 MixerStrip::set_button_names ()
1727 switch (_width) {
1728 case Wide:
1729 rec_enable_button_label.set_text (_("Rec"));
1730 mute_button_label.set_text (_("Mute"));
1731 if (_route && _route->solo_safe()) {
1732 solo_button_label.set_text (X_("!"));
1733 } else {
1734 if (!Config->get_solo_control_is_listen_control()) {
1735 solo_button_label.set_text (_("Solo"));
1736 } else {
1737 switch (Config->get_listen_position()) {
1738 case AfterFaderListen:
1739 solo_button_label.set_text (_("AFL"));
1740 break;
1741 case PreFaderListen:
1742 solo_button_label.set_text (_("PFL"));
1743 break;
1747 break;
1749 default:
1750 rec_enable_button_label.set_text (_("R"));
1751 mute_button_label.set_text (_("M"));
1752 if (_route && _route->solo_safe()) {
1753 solo_button_label.set_text (X_("!"));
1754 if (!Config->get_solo_control_is_listen_control()) {
1755 solo_button_label.set_text (_("S"));
1756 } else {
1757 switch (Config->get_listen_position()) {
1758 case AfterFaderListen:
1759 solo_button_label.set_text (_("A"));
1760 break;
1761 case PreFaderListen:
1762 solo_button_label.set_text (_("P"));
1763 break;
1767 break;
1772 bool
1773 MixerStrip::on_key_press_event (GdkEventKey* ev)
1775 GdkEventButton fake;
1776 fake.type = GDK_BUTTON_PRESS;
1777 fake.button = 1;
1778 fake.state = ev->state;
1780 switch (ev->keyval) {
1781 case GDK_m:
1782 mute_press (&fake);
1783 return true;
1784 break;
1786 case GDK_s:
1787 solo_press (&fake);
1788 return true;
1789 break;
1791 case GDK_r:
1792 cerr << "Stole that r\n";
1793 rec_enable_press (&fake);
1794 return true;
1795 break;
1797 case GDK_e:
1798 show_sends_press (&fake);
1799 return true;
1800 break;
1802 case GDK_g:
1803 if (ev->state & Keyboard::PrimaryModifier) {
1804 step_gain_down ();
1805 } else {
1806 step_gain_up ();
1808 return true;
1809 break;
1811 case GDK_0:
1812 if (_route) {
1813 _route->set_gain (1.0, this);
1815 return true;
1817 default:
1818 break;
1821 return false;
1825 bool
1826 MixerStrip::on_key_release_event (GdkEventKey* ev)
1828 GdkEventButton fake;
1829 fake.type = GDK_BUTTON_RELEASE;
1830 fake.button = 1;
1831 fake.state = ev->state;
1833 switch (ev->keyval) {
1834 case GDK_m:
1835 mute_release (&fake);
1836 return true;
1837 break;
1839 case GDK_s:
1840 solo_release (&fake);
1841 return true;
1842 break;
1844 case GDK_r:
1845 cerr << "Stole that r\n";
1846 rec_enable_release (&fake);
1847 return true;
1848 break;
1850 case GDK_e:
1851 show_sends_release (&fake);
1852 return true;
1853 break;
1855 case GDK_g:
1856 return true;
1857 break;
1859 default:
1860 break;
1863 return false;
1866 bool
1867 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1869 Keyboard::magic_widget_grab_focus ();
1870 return false;
1873 bool
1874 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1876 switch (ev->detail) {
1877 case GDK_NOTIFY_INFERIOR:
1878 break;
1879 default:
1880 Keyboard::magic_widget_drop_focus ();
1883 return false;
1886 PluginSelector*
1887 MixerStrip::plugin_selector()
1889 return _mixer.plugin_selector();
1892 void
1893 MixerStrip::hide_things ()
1895 processor_box.hide_things ();