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.
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/send.h"
46 #include "ardour/processor.h"
47 #include "ardour/profile.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/user_bundle.h"
50 #include "ardour/port.h"
52 #include "ardour_ui.h"
53 #include "ardour_dialog.h"
54 #include "mixer_strip.h"
58 #include "public_editor.h"
60 #include "io_selector.h"
62 #include "gui_thread.h"
63 #include "route_group_menu.h"
67 using namespace ARDOUR;
70 using namespace Gtkmm2ext;
73 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
75 int MixerStrip::scrollbar_height = 0;
76 PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
78 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
82 , _mixer_owned (in_mixer)
83 , processor_box (sess, boost::bind (&MixerStrip::plugin_selector, this), mx.selection(), this, in_mixer)
87 , solo_led_table (2, 2)
88 , middle_button_table (1, 2)
89 , bottom_button_table (1, 2)
90 , meter_point_label (_("pre"))
95 /* the editor mixer strip: don't destroy it every time
96 the underlying route goes away.
99 self_destruct = false;
103 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Route> rt, bool in_mixer)
107 , _mixer_owned (in_mixer)
108 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
111 , button_table (3, 2)
112 , middle_button_table (1, 2)
113 , bottom_button_table (1, 2)
114 , meter_point_label (_("pre"))
126 _marked_for_display = false;
128 ignore_comment_edit = false;
129 ignore_toggle = false;
135 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
136 longest_label = "longest label";
140 img = manage (new Gtk::Image (::get_icon("strip_width")));
143 width_button.add (*img);
145 img = manage (new Gtk::Image (::get_icon("hide")));
148 hide_button.add (*img);
150 input_label.set_text (_("Input"));
151 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
152 input_button.add (input_label);
153 input_button.set_name ("MixerIOButton");
154 input_label.set_name ("MixerIOButtonLabel");
156 Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 4, 4);
158 output_label.set_text (_("Output"));
159 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
160 output_button.add (output_label);
161 output_button.set_name ("MixerIOButton");
162 output_label.set_name ("MixerIOButtonLabel");
163 Gtkmm2ext::set_size_request_to_display_given_text (output_button, longest_label.c_str(), 4, 4);
165 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
166 meter_point_button.add (meter_point_label);
167 meter_point_button.set_name ("MixerStripMeterPreButton");
168 meter_point_label.set_name ("MixerStripMeterPreButton");
170 /* TRANSLATORS: this string should be longest of the strings
171 used to describe meter points. In english, it's "input".
173 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
175 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
177 meter_point_button.signal_button_press_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_press), false);
178 meter_point_button.signal_button_release_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_release), false);
180 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
182 mute_button->set_name ("MixerMuteButton");
183 solo_button->set_name ("MixerSoloButton");
185 solo_isolated_led = manage (new LED);
186 solo_isolated_led->show ();
187 solo_isolated_led->set_diameter (6);
188 solo_isolated_led->set_no_show_all (true);
189 solo_isolated_led->set_name (X_("SoloIsolatedLED"));
190 solo_isolated_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
191 solo_isolated_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_isolate_button_release));
192 UI::instance()->set_tip (solo_isolated_led, _("Isolate Solo"), "");
194 solo_safe_led = manage (new LED);
195 solo_safe_led->show ();
196 solo_safe_led->set_diameter (6);
197 solo_safe_led->set_no_show_all (true);
198 solo_safe_led->set_name (X_("SoloSafeLED"));
199 solo_safe_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
200 solo_safe_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_safe_button_release));
201 UI::instance()->set_tip (solo_safe_led, _("Lock Solo Status"), "");
203 Label* iso_label = manage (new Label (_("iso")));
204 Label* safe_label = manage (new Label (_("lock")));
206 iso_label->set_name (X_("SoloLEDLabel"));
207 safe_label->set_name (X_("SoloLEDLabel"));
212 solo_led_table.set_spacings (0);
213 solo_led_table.set_border_width (1);
214 solo_led_table.attach (*iso_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
215 solo_led_table.attach (*solo_isolated_led, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
216 solo_led_table.attach (*safe_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
217 solo_led_table.attach (*solo_safe_led, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL);
219 solo_led_table.show ();
220 solo_led_box.pack_end (solo_led_table, false, false);
221 solo_led_box.show ();
223 button_table.set_homogeneous (true);
224 button_table.set_spacings (0);
226 button_table.attach (name_button, 0, 2, 0, 1);
227 button_table.attach (input_button, 0, 2, 1, 2);
228 button_table.attach (_invert_button_box, 0, 2, 3, 4);
230 middle_button_table.set_homogeneous (true);
231 middle_button_table.set_spacings (0);
232 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
233 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
235 bottom_button_table.set_col_spacings (0);
236 bottom_button_table.set_homogeneous (true);
237 bottom_button_table.attach (group_button, 0, 1, 0, 1);
239 name_button.add (name_label);
240 name_button.set_name ("MixerNameButton");
241 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
243 name_label.set_name ("MixerNameButtonLabel");
244 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
245 group_button.add (group_label);
246 group_button.set_name ("MixerGroupButton");
247 Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Group", 2, 2);
248 group_label.set_name ("MixerGroupButtonLabel");
250 global_vpacker.set_border_width (0);
251 global_vpacker.set_spacing (0);
253 width_button.set_name ("MixerWidthButton");
254 hide_button.set_name ("MixerHideButton");
255 top_event_box.set_name ("MixerTopEventBox");
257 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
258 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
260 width_hide_box.pack_start (width_button, false, true);
261 width_hide_box.pack_start (top_event_box, true, true);
262 width_hide_box.pack_end (hide_button, false, true);
263 gain_meter_alignment.set_padding(0, 4, 0, 0);
264 gain_meter_alignment.add(gpm);
266 whvbox.pack_start (width_hide_box, true, true);
268 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
269 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
270 global_vpacker.pack_start (processor_box, true, true);
271 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
272 global_vpacker.pack_start (solo_led_box,Gtk::PACK_SHRINK);
273 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
274 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
275 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
276 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
278 global_frame.add (global_vpacker);
279 global_frame.set_shadow_type (Gtk::SHADOW_IN);
280 global_frame.set_name ("BaseFrame");
284 /* force setting of visible selected status */
287 set_selected (false);
292 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_stopped, this), gui_context());
293 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_running, this), gui_context());
295 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
296 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
298 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
302 rec_enable_button->set_name ("MixerRecordEnableButton");
304 /* ditto for this button and busses */
306 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
307 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
311 /* start off as a passthru strip. we'll correct this, if necessary,
312 in update_diskstream_display().
315 /* start off as a passthru strip. we'll correct this, if necessary,
316 in update_diskstream_display().
320 set_name ("MidiTrackStripBase");
322 set_name ("AudioTrackStripBase");
324 add_events (Gdk::BUTTON_RELEASE_MASK|
325 Gdk::ENTER_NOTIFY_MASK|
326 Gdk::LEAVE_NOTIFY_MASK|
328 Gdk::KEY_RELEASE_MASK);
330 set_flags (get_flags() | Gtk::CAN_FOCUS);
332 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
334 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
335 *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context ()
339 MixerStrip::~MixerStrip ()
341 CatchDeletion (this);
343 delete input_selector;
344 delete output_selector;
345 delete comment_window;
349 MixerStrip::set_route (boost::shared_ptr<Route> rt)
351 if (rec_enable_button->get_parent()) {
352 button_table.remove (*rec_enable_button);
355 if (show_sends_button->get_parent()) {
356 button_table.remove (*show_sends_button);
359 processor_box.set_route (rt);
361 RouteUI::set_route (rt);
363 /* map the current state */
366 update_solo_display ();
368 delete input_selector;
371 delete output_selector;
374 revert_to_default_display ();
376 if (set_color_from_route()) {
377 set_color (unique_random_color());
380 if (route()->is_master()) {
381 solo_button->hide ();
382 solo_led_box.hide ();
384 solo_button->show ();
385 solo_led_box.show ();
388 if (_mixer_owned && (route()->is_master() || route()->is_monitor())) {
390 if (scrollbar_height == 0) {
391 HScrollbar scrollbar;
392 Gtk::Requisition requisition(scrollbar.size_request ());
393 scrollbar_height = requisition.height;
396 spacer = manage (new EventBox);
397 spacer->set_size_request (-1, scrollbar_height);
398 global_vpacker.pack_start (*spacer, false, false);
401 if (is_audio_track()) {
402 boost::shared_ptr<AudioTrack> at = audio_track();
403 at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context());
406 if (has_audio_outputs ()) {
414 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
415 rec_enable_button->set_sensitive (_session->writable());
416 rec_enable_button->show();
422 if (!_route->is_master()) {
423 button_table.attach (*show_sends_button, 0, 2, 2, 3);
424 show_sends_button->show();
428 switch (_route->meter_point()) {
430 meter_point_label.set_text (_("input"));
434 meter_point_label.set_text (_("pre"));
438 meter_point_label.set_text (_("post"));
442 meter_point_label.set_text (_("custom"));
446 delete route_ops_menu;
449 _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context());
450 _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
452 if (_route->panner()) {
453 _route->panner()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
456 if (is_audio_track()) {
457 audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
460 _route->comment_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
461 _route->gui_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
463 set_stuff_from_route ();
465 /* now force an update of all the various elements */
468 update_solo_display ();
471 route_group_changed ();
475 panners.setup_pan ();
477 update_diskstream_display ();
478 update_input_display ();
479 update_output_display ();
481 add_events (Gdk::BUTTON_RELEASE_MASK);
483 processor_box.show ();
485 if (!route()->is_master() && !route()->is_monitor()) {
486 /* we don't allow master or control routes to be hidden */
491 width_hide_box.show();
494 global_vpacker.show();
496 middle_button_table.show();
497 bottom_button_table.show();
499 gain_meter_alignment.show ();
500 gain_unit_button.show();
501 gain_unit_label.show();
502 meter_point_button.show();
503 meter_point_label.show();
504 diskstream_button.show();
505 diskstream_label.show();
508 output_button.show();
519 MixerStrip::set_stuff_from_route ()
525 /* if width is not set, it will be set by the MixerUI or editor */
527 if ((prop = xml_node->property ("strip-width")) != 0) {
528 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
531 if ((prop = xml_node->property ("shown-mixer")) != 0) {
532 if (prop->value() == "no") {
533 _marked_for_display = false;
535 _marked_for_display = true;
538 /* backwards compatibility */
539 _marked_for_display = true;
544 MixerStrip::set_width_enum (Width w, void* owner)
546 /* always set the gpm width again, things may be hidden */
549 panners.set_width (w);
551 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
553 _width_owner = owner;
559 if (_width_owner == this) {
560 xml_node->add_property ("strip-width", enum_2_string (_width));
567 if (show_sends_button) {
568 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
571 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
572 gpm.astyle_string(gain_automation->automation_style()));
573 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
574 gpm.astate_string(gain_automation->automation_state()));
576 if (_route->panner()) {
577 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
578 panners.astyle_string(_route->panner()->automation_style()));
579 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
580 panners.astate_string(_route->panner()->automation_state()));
583 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
584 set_size_request (-1, -1);
588 if (show_sends_button) {
589 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
592 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
593 gpm.short_astyle_string(gain_automation->automation_style()));
594 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
595 gpm.short_astate_string(gain_automation->automation_state()));
597 if (_route->panner()) {
598 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
599 panners.short_astyle_string(_route->panner()->automation_style()));
600 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
601 panners.short_astate_string(_route->panner()->automation_state()));
604 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
605 set_size_request (max (50, gpm.get_gm_width()), -1);
609 processor_box.set_width (w);
611 update_input_display ();
612 update_output_display ();
613 route_group_changed ();
619 MixerStrip::set_packed (bool yn)
626 xml_node->add_property ("shown-mixer", "yes");
628 xml_node->add_property ("shown-mixer", "no");
634 MixerStrip::output_press (GdkEventButton *ev)
636 using namespace Menu_Helpers;
637 if (!_session->engine().connected()) {
638 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
643 MenuList& citems = output_menu.items();
644 switch (ev->button) {
647 edit_output_configuration ();
652 output_menu.set_name ("ArdourContextMenu");
654 output_menu_bundles.clear ();
656 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
657 citems.push_back (SeparatorElem());
659 ARDOUR::BundleList current = _route->output()->bundles_connected ();
661 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
663 /* give user bundles first chance at being in the menu */
665 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
666 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
667 maybe_add_bundle_to_output_menu (*i, current);
671 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
672 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
673 maybe_add_bundle_to_output_menu (*i, current);
677 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
678 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->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 */
687 output_menu.popup (1, ev->time);
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();
709 output = _route->output ();
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();
721 output_selector->present ();
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();
735 input_selector->present ();
740 MixerStrip::input_press (GdkEventButton *ev)
742 using namespace Menu_Helpers;
744 MenuList& citems = input_menu.items();
745 input_menu.set_name ("ArdourContextMenu");
748 if (!_session->engine().connected()) {
749 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
754 if (_session->actively_recording() && _route->record_enabled())
757 switch (ev->button) {
760 edit_input_configuration ();
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 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
789 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
792 if (citems.size() == 2) {
793 /* no routes added; remove the separator */
797 input_menu.popup (1, ev->time);
807 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
813 ARDOUR::BundleList current = _route->input()->bundles_connected ();
815 if (std::find (current.begin(), current.end(), c) == current.end()) {
816 _route->input()->connect_ports_to_bundle (c, this);
818 _route->input()->disconnect_ports_from_bundle (c, this);
823 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
829 ARDOUR::BundleList current = _route->output()->bundles_connected ();
831 if (std::find (current.begin(), current.end(), c) == current.end()) {
832 _route->output()->connect_ports_to_bundle (c, this);
834 _route->output()->disconnect_ports_from_bundle (c, this);
839 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
841 using namespace Menu_Helpers;
843 if (b->ports_are_outputs() == false || b->nchannels() != _route->n_inputs()) {
847 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
848 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
852 if (i != input_menu_bundles.end()) {
856 input_menu_bundles.push_back (b);
858 MenuList& citems = input_menu.items();
860 std::string n = b->name ();
861 replace_all (n, "_", " ");
863 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
865 if (std::find (current.begin(), current.end(), b) != current.end()) {
866 ignore_toggle = true;
867 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
868 ignore_toggle = false;
873 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
875 using namespace Menu_Helpers;
877 if (b->ports_are_inputs() == false || b->nchannels() != _route->n_outputs()) {
881 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
882 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
886 if (i != output_menu_bundles.end()) {
890 output_menu_bundles.push_back (b);
892 MenuList& citems = output_menu.items();
894 std::string n = b->name ();
895 replace_all (n, "_", " ");
897 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
899 if (std::find (current.begin(), current.end(), b) != current.end()) {
900 ignore_toggle = true;
901 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
902 ignore_toggle = false;
907 MixerStrip::update_diskstream_display ()
911 if (input_selector) {
912 input_selector->hide_all ();
919 show_passthru_color ();
924 MixerStrip::connect_to_pan ()
926 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
928 panstate_connection.disconnect ();
929 panstyle_connection.disconnect ();
931 if (!_route->panner()) {
935 boost::shared_ptr<Pannable> p = _route->pannable ();
937 p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
938 p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
940 panners.panner_changed (this);
945 * Output port labelling
946 * =====================
948 * Case 1: Each output has one connection, all connections are to system:playback_%i
949 * out 1 -> system:playback_1
950 * out 2 -> system:playback_2
951 * out 3 -> system:playback_3
954 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
955 * out 1 -> ardour:track_x/in 1
956 * out 2 -> ardour:track_x/in 2
957 * Display as: track_x
959 * Case 3: Each output has one connection, all connections are to Jack client "program x"
960 * out 1 -> program x:foo
961 * out 2 -> program x:foo
962 * Display as: program x
964 * Case 4: No connections (Disconnected)
967 * Default case (unusual routing):
968 * Display as: *number of connections*
972 * .-----------------------------------------------.
974 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
975 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
976 * '-----------------------------------------------'
977 * .-----------------------------------------------.
980 * '-----------------------------------------------'
984 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
989 vector<string> port_connections;
991 uint32_t total_connection_count = 0;
992 uint32_t io_connection_count = 0;
993 uint32_t ardour_connection_count = 0;
994 uint32_t system_connection_count = 0;
995 uint32_t other_connection_count = 0;
1000 bool have_label = false;
1001 bool each_io_has_one_connection = true;
1003 string connection_name;
1004 string ardour_track_name;
1005 string other_connection_type;
1006 string system_ports;
1009 ostringstream tooltip;
1010 char * tooltip_cstr;
1012 tooltip << route->name();
1015 io_count = route->n_inputs().n_total();
1017 io_count = route->n_outputs().n_total();
1020 for (io_index = 0; io_index < io_count; ++io_index) {
1022 port = route->input()->nth (io_index);
1024 port = route->output()->nth (io_index);
1027 port_connections.clear ();
1028 port->get_connections(port_connections);
1029 io_connection_count = 0;
1031 if (!port_connections.empty()) {
1032 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1033 string& connection_name (*i);
1035 if (io_connection_count == 0) {
1036 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1038 tooltip << ", " << connection_name;
1041 if (connection_name.find("ardour:") == 0) {
1042 if (ardour_track_name.empty()) {
1043 // "ardour:Master/in 1" -> "ardour:Master/"
1044 string::size_type slash = connection_name.find("/");
1045 if (slash != string::npos) {
1046 ardour_track_name = connection_name.substr(0, slash + 1);
1050 if (connection_name.find(ardour_track_name) == 0) {
1051 ++ardour_connection_count;
1053 } else if (connection_name.find("system:") == 0) {
1055 // "system:capture_123" -> "123"
1056 system_port = connection_name.substr(15);
1058 // "system:playback_123" -> "123"
1059 system_port = connection_name.substr(16);
1062 if (system_ports.empty()) {
1063 system_ports += system_port;
1065 system_ports += "/" + system_port;
1068 ++system_connection_count;
1070 if (other_connection_type.empty()) {
1071 // "jamin:in 1" -> "jamin:"
1072 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1075 if (connection_name.find(other_connection_type) == 0) {
1076 ++other_connection_count;
1080 ++total_connection_count;
1081 ++io_connection_count;
1085 if (io_connection_count != 1) {
1086 each_io_has_one_connection = false;
1090 if (total_connection_count == 0) {
1091 tooltip << endl << _("Disconnected");
1094 tooltip_cstr = new char[tooltip.str().size() + 1];
1095 strcpy(tooltip_cstr, tooltip.str().c_str());
1098 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1100 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1103 if (each_io_has_one_connection) {
1104 if ((total_connection_count == ardour_connection_count)) {
1105 // all connections are to the same track in ardour
1106 // "ardour:Master/" -> "Master"
1107 string::size_type slash = ardour_track_name.find("/");
1108 if (slash != string::npos) {
1109 label << ardour_track_name.substr(7, slash - 7);
1113 else if (total_connection_count == system_connection_count) {
1114 // all connections are to system ports
1115 label << system_ports;
1118 else if (total_connection_count == other_connection_count) {
1119 // all connections are to the same external program eg jamin
1120 // "jamin:" -> "jamin"
1121 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1127 if (total_connection_count == 0) {
1131 // Odd configuration
1132 label << "*" << total_connection_count << "*";
1138 label_string = label.str().substr(0, 6);
1141 label_string = label.str().substr(0, 3);
1146 input_label.set_text (label_string);
1148 output_label.set_text (label_string);
1153 MixerStrip::update_input_display ()
1155 update_io_button (_route, _width, true);
1156 panners.setup_pan ();
1160 MixerStrip::update_output_display ()
1162 update_io_button (_route, _width, false);
1163 gpm.setup_meters ();
1164 panners.setup_pan ();
1168 MixerStrip::fast_update ()
1170 gpm.update_meters ();
1174 MixerStrip::diskstream_changed ()
1176 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
1180 MixerStrip::port_connected_or_disconnected (Port* a, Port* b)
1182 if (_route->input()->has_port (a) || _route->input()->has_port (b)) {
1183 update_input_display ();
1184 set_width_enum (_width, this);
1187 if (_route->output()->has_port (a) || _route->output()->has_port (b)) {
1188 update_output_display ();
1189 set_width_enum (_width, this);
1194 MixerStrip::comment_editor_done_editing ()
1196 ignore_toggle = true;
1197 _comment_menu_item->set_active (false);
1198 ignore_toggle = false;
1200 string const str = comment_area->get_buffer()->get_text();
1201 if (str == _route->comment ()) {
1205 _route->set_comment (str, this);
1209 MixerStrip::toggle_comment ()
1211 if (ignore_toggle) {
1215 if (comment_window == 0) {
1216 setup_comment_editor ();
1219 if (comment_window->is_visible ()) {
1220 comment_window->hide ();
1224 comment_window->show();
1225 comment_window->present();
1229 MixerStrip::setup_comment_editor ()
1232 title = _route->name();
1233 title += _(": comment editor");
1235 comment_window = new ArdourDialog (title, false);
1236 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1237 comment_window->set_skip_taskbar_hint (true);
1238 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1240 comment_area = manage (new TextView());
1241 comment_area->set_name ("MixerTrackCommentArea");
1242 comment_area->set_size_request (110, 178);
1243 comment_area->set_wrap_mode (WRAP_WORD);
1244 comment_area->set_editable (true);
1245 comment_area->get_buffer()->set_text (_route->comment());
1246 comment_area->show ();
1248 comment_window->get_vbox()->pack_start (*comment_area);
1249 comment_window->get_action_area()->hide();
1253 MixerStrip::comment_changed (void *src)
1255 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1258 ignore_comment_edit = true;
1260 comment_area->get_buffer()->set_text (_route->comment());
1262 ignore_comment_edit = false;
1266 /** Set the route group for this strip's route, or remove it from its current group.
1267 * @param rg New RouteGroup, or 0.
1270 MixerStrip::set_route_group (RouteGroup *rg)
1274 } else if (_route->route_group ()) {
1275 _route->route_group()->remove (_route);
1280 MixerStrip::select_route_group (GdkEventButton *ev)
1282 using namespace Menu_Helpers;
1284 if (ev->button == 1) {
1286 if (group_menu == 0) {
1288 PropertyList* plist = new PropertyList();
1290 plist->add (Properties::gain, true);
1291 plist->add (Properties::mute, true);
1292 plist->add (Properties::solo, true);
1294 group_menu = new RouteGroupMenu (_session, plist);
1295 group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
1298 group_menu->popup (1, ev->time);
1305 MixerStrip::route_group_changed ()
1307 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1309 RouteGroup *rg = _route->route_group();
1312 group_label.set_text (PBD::short_version (rg->name(), 5));
1316 group_label.set_text (_("Grp"));
1319 group_label.set_text (_("~G"));
1327 MixerStrip::route_gui_changed (string what_changed, void*)
1329 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1331 if (what_changed == "color") {
1332 if (set_color_from_route () == 0) {
1333 show_route_color ();
1339 MixerStrip::show_route_color ()
1341 name_button.modify_bg (STATE_NORMAL, color());
1342 top_event_box.modify_bg (STATE_NORMAL, color());
1343 route_active_changed ();
1347 MixerStrip::show_passthru_color ()
1349 route_active_changed ();
1353 MixerStrip::build_route_ops_menu ()
1355 using namespace Menu_Helpers;
1356 route_ops_menu = new Menu;
1357 route_ops_menu->set_name ("ArdourContextMenu");
1359 MenuList& items = route_ops_menu->items();
1361 items.push_back (CheckMenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::toggle_comment)));
1362 _comment_menu_item = dynamic_cast<CheckMenuItem*> (&items.back ());
1363 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1364 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1365 rename_menu_item = &items.back();
1366 items.push_back (SeparatorElem());
1367 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
1368 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1369 route_active_menu_item->set_active (_route->active());
1371 items.push_back (SeparatorElem());
1373 items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1375 items.push_back (SeparatorElem());
1376 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1377 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1378 denormal_menu_item->set_active (_route->denormal_protection());
1380 if (!Profile->get_sae()) {
1381 items.push_back (SeparatorElem());
1382 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1385 items.push_back (SeparatorElem());
1386 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
1390 MixerStrip::name_button_button_press (GdkEventButton* ev)
1392 if (ev->button == 3) {
1393 list_route_operations ();
1395 /* do not allow rename if the track is record-enabled */
1396 rename_menu_item->set_sensitive (!_route->record_enabled());
1397 route_ops_menu->popup (1, ev->time);
1399 } else if (ev->button == 1) {
1400 revert_to_default_display ();
1407 MixerStrip::list_route_operations ()
1409 if (route_ops_menu == 0) {
1410 build_route_ops_menu ();
1415 MixerStrip::set_selected (bool yn)
1417 AxisView::set_selected (yn);
1419 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1420 global_frame.set_name ("MixerStripSelectedFrame");
1422 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1423 global_frame.set_name ("MixerStripFrame");
1425 global_frame.queue_draw ();
1429 MixerStrip::name_changed ()
1433 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1436 name_label.set_text (PBD::short_version (_route->name(), 5));
1442 MixerStrip::width_clicked ()
1446 set_width_enum (Narrow, this);
1449 set_width_enum (Wide, this);
1455 MixerStrip::hide_clicked ()
1457 // LAME fix to reset the button status for when it is redisplayed (part 1)
1458 hide_button.set_sensitive(false);
1461 Hiding(); /* EMIT_SIGNAL */
1463 _mixer.hide_strip (this);
1467 hide_button.set_sensitive(true);
1471 MixerStrip::set_embedded (bool yn)
1477 MixerStrip::map_frozen ()
1479 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1481 boost::shared_ptr<AudioTrack> at = audio_track();
1484 switch (at->freeze_state()) {
1485 case AudioTrack::Frozen:
1486 processor_box.set_sensitive (false);
1487 hide_redirect_editors ();
1490 processor_box.set_sensitive (true);
1491 // XXX need some way, maybe, to retoggle redirect editors
1498 MixerStrip::hide_redirect_editors ()
1500 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1504 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1506 boost::shared_ptr<Processor> processor (p.lock ());
1511 Gtk::Window* w = processor_box.get_processor_ui (processor);
1519 MixerStrip::route_active_changed ()
1521 RouteUI::route_active_changed ();
1522 reset_strip_style ();
1526 MixerStrip::reset_strip_style ()
1528 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1530 gpm.set_fader_name ("SendStripBase");
1534 if (is_midi_track()) {
1535 if (_route->active()) {
1536 set_name ("MidiTrackStripBase");
1537 gpm.set_meter_strip_name ("MidiTrackMetrics");
1539 set_name ("MidiTrackStripBaseInactive");
1540 gpm.set_meter_strip_name ("MidiTrackMetricsInactive");
1542 gpm.set_fader_name ("MidiTrackFader");
1543 } else if (is_audio_track()) {
1544 if (_route->active()) {
1545 set_name ("AudioTrackStripBase");
1546 gpm.set_meter_strip_name ("AudioTrackMetrics");
1548 set_name ("AudioTrackStripBaseInactive");
1549 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1551 gpm.set_fader_name ("AudioTrackFader");
1553 if (_route->active()) {
1554 set_name ("AudioBusStripBase");
1555 gpm.set_meter_strip_name ("AudioBusMetrics");
1557 set_name ("AudioBusStripBaseInactive");
1558 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1560 gpm.set_fader_name ("AudioBusFader");
1562 /* (no MIDI busses yet) */
1568 MixerStrip::route_group() const
1570 return _route->route_group();
1574 MixerStrip::engine_stopped ()
1579 MixerStrip::engine_running ()
1583 /** Called when the metering point has changed */
1585 MixerStrip::meter_changed ()
1587 ENSURE_GUI_THREAD (*this, &MixerStrip::meter_changed)
1589 switch (_route->meter_point()) {
1591 meter_point_label.set_text (_("input"));
1595 meter_point_label.set_text (_("pre"));
1598 case MeterPostFader:
1599 meter_point_label.set_text (_("post"));
1603 meter_point_label.set_text (_("custom"));
1607 gpm.setup_meters ();
1608 // reset peak when meter point changes
1609 gpm.reset_peak_display();
1613 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1615 /* don't respond to switch IO signal outside of the mixer window */
1617 if (!_mixer_owned) {
1621 if (_route == target || _route->is_master()) {
1622 /* don't change the display for the target or the master bus */
1624 } else if (!is_track() && show_sends_button) {
1625 /* make sure our show sends button is inactive, and we no longer blink,
1626 since we're not the target.
1628 send_blink_connection.disconnect ();
1629 show_sends_button->set_active (false);
1630 show_sends_button->set_state (STATE_NORMAL);
1634 /* switch back to default */
1635 revert_to_default_display ();
1639 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1644 revert_to_default_display ();
1649 MixerStrip::drop_send ()
1651 boost::shared_ptr<Send> current_send;
1653 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1654 current_send->set_metering (false);
1657 send_gone_connection.disconnect ();
1658 input_button.set_sensitive (true);
1659 output_button.set_sensitive (true);
1660 group_button.set_sensitive (true);
1661 set_invert_sensitive (true);
1662 meter_point_button.set_sensitive (true);
1663 mute_button->set_sensitive (true);
1664 solo_button->set_sensitive (true);
1665 rec_enable_button->set_sensitive (true);
1666 solo_isolated_led->set_sensitive (true);
1667 solo_safe_led->set_sensitive (true);
1671 MixerStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1673 _current_delivery = d;
1674 DeliveryChanged (_current_delivery);
1678 MixerStrip::show_send (boost::shared_ptr<Send> send)
1684 set_current_delivery (send);
1686 send->set_metering (true);
1687 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1689 gain_meter().set_controls (_route, send->meter(), send->amp());
1690 gain_meter().setup_meters ();
1692 panner_ui().set_panner (_current_delivery->panner());
1693 panner_ui().setup_pan ();
1695 input_button.set_sensitive (false);
1696 group_button.set_sensitive (false);
1697 set_invert_sensitive (false);
1698 meter_point_button.set_sensitive (false);
1699 mute_button->set_sensitive (false);
1700 solo_button->set_sensitive (false);
1701 rec_enable_button->set_sensitive (false);
1702 solo_isolated_led->set_sensitive (false);
1703 solo_safe_led->set_sensitive (false);
1705 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1706 output_button.set_sensitive (false);
1709 reset_strip_style ();
1713 MixerStrip::revert_to_default_display ()
1715 if (show_sends_button) {
1716 show_sends_button->set_active (false);
1721 set_current_delivery (_route->main_outs ());
1723 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1724 gain_meter().setup_meters ();
1726 panner_ui().set_panner (_route->main_outs()->panner());
1727 panner_ui().setup_pan ();
1729 reset_strip_style ();
1733 MixerStrip::set_button_names ()
1737 rec_enable_button_label.set_text (_("Rec"));
1738 mute_button_label.set_text (_("Mute"));
1739 if (_route && _route->solo_safe()) {
1740 solo_button_label.set_text (X_("!"));
1742 if (!Config->get_solo_control_is_listen_control()) {
1743 solo_button_label.set_text (_("Solo"));
1745 switch (Config->get_listen_position()) {
1746 case AfterFaderListen:
1747 solo_button_label.set_text (_("AFL"));
1749 case PreFaderListen:
1750 solo_button_label.set_text (_("PFL"));
1758 rec_enable_button_label.set_text (_("R"));
1759 mute_button_label.set_text (_("M"));
1760 if (_route && _route->solo_safe()) {
1761 solo_button_label.set_text (X_("!"));
1762 if (!Config->get_solo_control_is_listen_control()) {
1763 solo_button_label.set_text (_("S"));
1765 switch (Config->get_listen_position()) {
1766 case AfterFaderListen:
1767 solo_button_label.set_text (_("A"));
1769 case PreFaderListen:
1770 solo_button_label.set_text (_("P"));
1781 MixerStrip::on_key_press_event (GdkEventKey* ev)
1783 GdkEventButton fake;
1784 fake.type = GDK_BUTTON_PRESS;
1786 fake.state = ev->state;
1788 switch (ev->keyval) {
1800 cerr << "Stole that r\n";
1801 rec_enable_press (&fake);
1806 show_sends_press (&fake);
1811 if (ev->state & Keyboard::PrimaryModifier) {
1821 _route->set_gain (1.0, this);
1834 MixerStrip::on_key_release_event (GdkEventKey* ev)
1836 GdkEventButton fake;
1837 fake.type = GDK_BUTTON_RELEASE;
1839 fake.state = ev->state;
1841 switch (ev->keyval) {
1843 mute_release (&fake);
1848 solo_release (&fake);
1853 cerr << "Stole that r\n";
1854 rec_enable_release (&fake);
1859 show_sends_release (&fake);
1875 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1877 Keyboard::magic_widget_grab_focus ();
1882 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1884 switch (ev->detail) {
1885 case GDK_NOTIFY_INFERIOR:
1888 Keyboard::magic_widget_drop_focus ();
1895 MixerStrip::plugin_selector()
1897 return _mixer.plugin_selector();