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/stop_signal.h>
32 #include <gtkmm2ext/doi.h>
33 #include <gtkmm2ext/slider_controller.h>
34 #include <gtkmm2ext/bindable_button.h>
36 #include "ardour/ardour.h"
37 #include "ardour/amp.h"
38 #include "ardour/session.h"
39 #include "ardour/audioengine.h"
40 #include "ardour/route.h"
41 #include "ardour/route_group.h"
42 #include "ardour/audio_track.h"
43 #include "ardour/audio_diskstream.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"
51 #include "ardour_ui.h"
52 #include "ardour_dialog.h"
53 #include "mixer_strip.h"
56 #include "public_editor.h"
58 #include "io_selector.h"
60 #include "gui_thread.h"
61 #include "route_group_menu.h"
66 using namespace ARDOUR;
69 using namespace Gtkmm2ext;
72 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
74 int MixerStrip::scrollbar_height = 0;
76 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
80 , _mixer_owned (in_mixer)
81 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
84 , _mono_button (_("Mono"))
86 , middle_button_table (1, 2)
87 , bottom_button_table (1, 2)
88 , meter_point_label (_("pre"))
89 , comment_button (_("Comments"))
94 /* the editor mixer strip: don't destroy it every time
95 the underlying route goes away.
98 self_destruct = false;
102 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt, bool in_mixer)
106 , _mixer_owned (in_mixer)
107 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
110 , button_table (3, 2)
111 , middle_button_table (1, 2)
112 , bottom_button_table (1, 2)
113 , meter_point_label (_("pre"))
114 , comment_button (_("Comments"))
127 _marked_for_display = false;
129 ignore_comment_edit = false;
130 ignore_toggle = false;
138 img = manage (new Gtk::Image (::get_icon("strip_width")));
141 width_button.add (*img);
143 img = manage (new Gtk::Image (::get_icon("hide")));
146 hide_button.add (*img);
148 input_label.set_text (_("Input"));
149 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
150 input_button.add (input_label);
151 input_button.set_name ("MixerIOButton");
152 input_label.set_name ("MixerIOButtonLabel");
153 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
155 output_label.set_text (_("Output"));
156 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
157 output_button.add (output_label);
158 output_button.set_name ("MixerIOButton");
159 output_label.set_name ("MixerIOButtonLabel");
160 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
162 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
163 meter_point_button.add (meter_point_label);
164 meter_point_button.set_name ("MixerStripMeterPreButton");
165 meter_point_label.set_name ("MixerStripMeterPreButton");
167 /* TRANSLATORS: this string should be longest of the strings
168 used to describe meter points. In english, it's "input".
170 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
172 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
174 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
175 meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
177 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
179 mute_button->set_name ("MixerMuteButton");
180 solo_button->set_name ("MixerSoloButton");
182 button_table.set_homogeneous (true);
183 button_table.set_spacings (0);
185 button_table.attach (name_button, 0, 2, 0, 1);
186 button_table.attach (input_button, 0, 2, 1, 2);
188 middle_button_table.set_homogeneous (true);
189 middle_button_table.set_spacings (0);
190 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
191 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
193 bottom_button_table.set_col_spacings (0);
194 bottom_button_table.set_homogeneous (true);
195 bottom_button_table.attach (group_button, 0, 1, 0, 1);
197 name_button.add (name_label);
198 name_button.set_name ("MixerNameButton");
199 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
201 name_label.set_name ("MixerNameButtonLabel");
202 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
203 group_button.add (group_label);
204 group_button.set_name ("MixerGroupButton");
205 group_label.set_name ("MixerGroupButtonLabel");
207 comment_button.set_name ("MixerCommentButton");
209 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
211 global_vpacker.set_border_width (0);
212 global_vpacker.set_spacing (0);
214 width_button.set_name ("MixerWidthButton");
215 hide_button.set_name ("MixerHideButton");
216 top_event_box.set_name ("MixerTopEventBox");
218 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
219 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
221 width_hide_box.pack_start (width_button, false, true);
222 width_hide_box.pack_start (top_event_box, true, true);
223 width_hide_box.pack_end (hide_button, false, true);
224 gain_meter_alignment.set_padding(0, 4, 0, 0);
225 gain_meter_alignment.add(gpm);
227 whvbox.pack_start (width_hide_box, true, true);
229 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
230 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
231 global_vpacker.pack_start (processor_box, true, true);
232 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
233 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
234 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
235 if (!is_midi_track()) {
236 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
238 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
239 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
242 global_frame.add (global_vpacker);
243 global_frame.set_shadow_type (Gtk::SHADOW_IN);
244 global_frame.set_name ("BaseFrame");
248 /* force setting of visible selected status */
251 set_selected (false);
256 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
257 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
259 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
260 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
262 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
263 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
264 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
265 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
267 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
271 rec_enable_button->set_name ("MixerRecordEnableButton");
272 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
273 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
275 /* ditto for this button and busses */
277 show_sends_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::show_sends_press), false);
278 show_sends_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::show_sends_release));
280 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
281 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_route_group), false);
285 /* start off as a passthru strip. we'll correct this, if necessary,
286 in update_diskstream_display().
289 /* start off as a passthru strip. we'll correct this, if necessary,
290 in update_diskstream_display().
294 set_name ("MidiTrackStripBase");
296 set_name ("AudioTrackStripBase");
298 add_events (Gdk::BUTTON_RELEASE_MASK|
299 Gdk::ENTER_NOTIFY_MASK|
300 Gdk::LEAVE_NOTIFY_MASK|
302 Gdk::KEY_RELEASE_MASK);
304 set_flags (get_flags() | Gtk::CAN_FOCUS);
306 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
309 MixerStrip::~MixerStrip ()
311 GoingAway(); /* EMIT_SIGNAL */
313 delete input_selector;
314 delete output_selector;
315 delete comment_window;
319 MixerStrip::set_route (boost::shared_ptr<Route> rt)
321 if (rec_enable_button->get_parent()) {
322 button_table.remove (*rec_enable_button);
325 if (show_sends_button->get_parent()) {
326 button_table.remove (*show_sends_button);
329 RouteUI::set_route (rt);
331 delete input_selector;
334 delete output_selector;
337 boost::shared_ptr<Send> send;
339 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
340 send->set_metering (false);
343 _current_delivery = _route->main_outs ();
345 panners.set_panner (rt->main_outs()->panner());
346 gpm.set_controls (rt, rt->shared_peak_meter(), rt->amp());
347 processor_box.set_route (rt);
349 if (set_color_from_route()) {
350 set_color (unique_random_color());
353 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
355 if (scrollbar_height == 0) {
356 HScrollbar scrollbar;
357 Gtk::Requisition requisition(scrollbar.size_request ());
358 scrollbar_height = requisition.height;
361 spacer = manage (new EventBox);
362 spacer->set_size_request (-1, scrollbar_height);
363 global_vpacker.pack_start (*spacer, false, false);
366 if (is_audio_track()) {
368 boost::shared_ptr<AudioTrack> at = audio_track();
370 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
372 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
373 rec_enable_button->set_sensitive (_session.writable());
374 rec_enable_button->show();
376 } else if (!is_track()) {
379 if (!_route->is_master()) {
380 button_table.attach (*show_sends_button, 0, 2, 2, 3);
381 show_sends_button->show();
385 if (_route->phase_invert()) {
386 name_label.set_text (X_("Ø ") + name_label.get_text());
388 name_label.set_text (_route->name());
391 _mono_button.set_name ("MixerMonoButton");
392 _mono_button.signal_clicked().connect (mem_fun (*this, &MixerStrip::mono_button_clicked));
394 switch (_route->meter_point()) {
396 meter_point_label.set_text (_("input"));
400 meter_point_label.set_text (_("pre"));
404 meter_point_label.set_text (_("post"));
408 delete route_ops_menu;
411 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
412 _("Click to Add/Edit Comments"):
415 connections.push_back (_route->meter_change.connect (
416 mem_fun(*this, &MixerStrip::meter_changed)));
417 connections.push_back (_route->input()->changed.connect (
418 mem_fun(*this, &MixerStrip::input_changed)));
419 connections.push_back (_route->output()->changed.connect (
420 mem_fun(*this, &MixerStrip::output_changed)));
421 connections.push_back (_route->route_group_changed.connect (
422 mem_fun(*this, &MixerStrip::route_group_changed)));
424 if (_route->panner()) {
425 connections.push_back (_route->panner()->Changed.connect (
426 mem_fun(*this, &MixerStrip::connect_to_pan)));
429 if (is_audio_track()) {
430 connections.push_back (audio_track()->DiskstreamChanged.connect (
431 mem_fun(*this, &MixerStrip::diskstream_changed)));
434 connections.push_back (_route->NameChanged.connect (
435 mem_fun(*this, &RouteUI::name_changed)));
436 connections.push_back (_route->comment_changed.connect (
437 mem_fun(*this, &MixerStrip::comment_changed)));
438 connections.push_back (_route->gui_changed.connect (
439 mem_fun(*this, &MixerStrip::route_gui_changed)));
441 set_stuff_from_route ();
443 /* now force an update of all the various elements */
445 processor_box.update();
450 route_group_changed (0);
454 panners.setup_pan ();
456 update_diskstream_display ();
457 update_input_display ();
458 update_output_display ();
460 add_events (Gdk::BUTTON_RELEASE_MASK);
462 processor_box.show();
464 if (!route()->is_master() && !route()->is_control()) {
465 /* we don't allow master or control routes to be hidden */
470 width_hide_box.show();
473 global_vpacker.show();
475 middle_button_table.show();
476 bottom_button_table.show();
477 processor_box.show_all ();
480 gain_meter_alignment.show ();
481 gain_unit_button.show();
482 gain_unit_label.show();
483 meter_point_button.show();
484 meter_point_label.show();
485 diskstream_button.show();
486 diskstream_label.show();
489 output_button.show();
493 comment_button.show();
501 MixerStrip::set_stuff_from_route ()
507 /* if width is not set, it will be set by the MixerUI or editor */
509 if ((prop = xml_node->property ("strip-width")) != 0) {
510 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
513 if ((prop = xml_node->property ("shown-mixer")) != 0) {
514 if (prop->value() == "no") {
515 _marked_for_display = false;
517 _marked_for_display = true;
520 /* backwards compatibility */
521 _marked_for_display = true;
526 MixerStrip::set_width_enum (Width w, void* owner)
528 /* always set the gpm width again, things may be hidden */
531 panners.set_width (w);
532 processor_box.set_width (w);
534 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
536 _width_owner = owner;
542 if (_width_owner == this) {
543 xml_node->add_property ("strip-width", enum_2_string (_width));
550 if (show_sends_button) {
551 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
554 if (_route->comment() == "") {
555 comment_button.unset_bg (STATE_NORMAL);
556 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
558 comment_button.modify_bg (STATE_NORMAL, color());
559 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
562 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
563 gpm.astyle_string(gain_automation->automation_style()));
564 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
565 gpm.astate_string(gain_automation->automation_state()));
567 if (_route->panner()) {
568 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
569 panners.astyle_string(_route->panner()->automation_style()));
570 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
571 panners.astate_string(_route->panner()->automation_state()));
574 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
575 set_size_request (-1, -1);
579 if (show_sends_button) {
580 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
583 if (_route->comment() == "") {
584 comment_button.unset_bg (STATE_NORMAL);
585 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
587 comment_button.modify_bg (STATE_NORMAL, color());
588 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
591 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
592 gpm.short_astyle_string(gain_automation->automation_style()));
593 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
594 gpm.short_astate_string(gain_automation->automation_state()));
596 if (_route->panner()) {
597 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
598 panners.short_astyle_string(_route->panner()->automation_style()));
599 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
600 panners.short_astate_string(_route->panner()->automation_state()));
603 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
604 set_size_request (max (50, gpm.get_gm_width()), -1);
607 update_input_display ();
608 update_output_display ();
609 route_group_changed (0);
615 MixerStrip::set_packed (bool yn)
622 xml_node->add_property ("shown-mixer", "yes");
624 xml_node->add_property ("shown-mixer", "no");
630 MixerStrip::output_press (GdkEventButton *ev)
632 using namespace Menu_Helpers;
633 if (!_session.engine().connected()) {
634 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
639 MenuList& citems = output_menu.items();
640 switch (ev->button) {
643 edit_output_configuration ();
648 output_menu.set_name ("ArdourContextMenu");
650 output_menu_bundles.clear ();
652 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
653 citems.push_back (SeparatorElem());
655 ARDOUR::BundleList current = _route->output()->bundles_connected ();
657 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
659 /* give user bundles first chance at being in the menu */
661 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
662 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
663 maybe_add_bundle_to_output_menu (*i, current);
667 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
668 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
669 maybe_add_bundle_to_output_menu (*i, current);
673 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
674 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
675 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
678 if (citems.size() == 2) {
679 /* no routes added; remove the separator */
683 output_menu.popup (1, ev->time);
694 MixerStrip::edit_output_configuration ()
696 if (output_selector == 0) {
697 output_selector = new IOSelectorWindow (_session, _route->output());
700 if (output_selector->is_visible()) {
701 output_selector->get_toplevel()->get_window()->raise();
703 output_selector->present ();
708 MixerStrip::edit_input_configuration ()
710 if (input_selector == 0) {
711 input_selector = new IOSelectorWindow (_session, _route->input());
714 if (input_selector->is_visible()) {
715 input_selector->get_toplevel()->get_window()->raise();
717 input_selector->present ();
722 MixerStrip::input_press (GdkEventButton *ev)
724 using namespace Menu_Helpers;
726 MenuList& citems = input_menu.items();
727 input_menu.set_name ("ArdourContextMenu");
730 if (!_session.engine().connected()) {
731 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
736 switch (ev->button) {
739 edit_input_configuration ();
744 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
745 citems.push_back (SeparatorElem());
746 input_menu_bundles.clear ();
748 ARDOUR::BundleList current = _route->input()->bundles_connected ();
750 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
752 /* give user bundles first chance at being in the menu */
754 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
755 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
756 maybe_add_bundle_to_input_menu (*i, current);
760 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
761 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
762 maybe_add_bundle_to_input_menu (*i, current);
766 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
767 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
768 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
771 if (citems.size() == 2) {
772 /* no routes added; remove the separator */
776 input_menu.popup (1, ev->time);
786 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
792 ARDOUR::BundleList current = _route->input()->bundles_connected ();
794 if (std::find (current.begin(), current.end(), c) == current.end()) {
795 _route->input()->connect_ports_to_bundle (c, this);
797 _route->input()->disconnect_ports_from_bundle (c, this);
802 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
808 ARDOUR::BundleList current = _route->output()->bundles_connected ();
810 if (std::find (current.begin(), current.end(), c) == current.end()) {
811 _route->output()->connect_ports_to_bundle (c, this);
813 _route->output()->disconnect_ports_from_bundle (c, this);
818 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
820 using namespace Menu_Helpers;
822 if (b->ports_are_outputs() == false ||
823 route()->input()->default_type() != b->type() ||
824 b->nchannels() != _route->n_inputs().get (b->type ())) {
829 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
830 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
834 if (i != input_menu_bundles.end()) {
838 input_menu_bundles.push_back (b);
840 MenuList& citems = input_menu.items();
842 std::string n = b->name ();
843 replace_all (n, "_", " ");
845 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
847 if (std::find (current.begin(), current.end(), b) != current.end()) {
848 ignore_toggle = true;
849 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
850 ignore_toggle = false;
855 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
857 using namespace Menu_Helpers;
859 if (b->ports_are_inputs() == false ||
860 route()->output()->default_type() != b->type() ||
861 b->nchannels() != _route->n_outputs().get (b->type ())) {
866 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
867 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
871 if (i != output_menu_bundles.end()) {
875 output_menu_bundles.push_back (b);
877 MenuList& citems = output_menu.items();
879 std::string n = b->name ();
880 replace_all (n, "_", " ");
882 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
884 if (std::find (current.begin(), current.end(), b) != current.end()) {
885 ignore_toggle = true;
886 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
887 ignore_toggle = false;
892 MixerStrip::update_diskstream_display ()
896 if (input_selector) {
897 input_selector->hide_all ();
904 show_passthru_color ();
909 MixerStrip::connect_to_pan ()
911 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
913 panstate_connection.disconnect ();
914 panstyle_connection.disconnect ();
916 if (!_route->panner()) {
920 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
921 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
922 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
925 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
926 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
929 panners.pan_changed (this);
934 * Output port labelling
935 * =====================
937 * Case 1: Each output has one connection, all connections are to system:playback_%i
938 * out 1 -> system:playback_1
939 * out 2 -> system:playback_2
940 * out 3 -> system:playback_3
943 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
944 * out 1 -> ardour:track_x/in 1
945 * out 2 -> ardour:track_x/in 2
946 * Display as: track_x
948 * Case 3: Each output has one connection, all connections are to Jack client "program x"
949 * out 1 -> program x:foo
950 * out 2 -> program x:foo
951 * Display as: program x
953 * Case 4: No connections (Disconnected)
956 * Default case (unusual routing):
957 * Display as: *number of connections*
961 * .-----------------------------------------------.
963 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
964 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
965 * '-----------------------------------------------'
966 * .-----------------------------------------------.
969 * '-----------------------------------------------'
973 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
978 vector<string> connections;
980 uint32_t total_connection_count = 0;
981 uint32_t io_connection_count = 0;
982 uint32_t ardour_connection_count = 0;
983 uint32_t system_connection_count = 0;
984 uint32_t other_connection_count = 0;
990 bool have_label = false;
991 bool each_io_has_one_connection = true;
993 string connection_name;
994 string ardour_track_name;
995 string other_connection_type;
999 ostringstream tooltip;
1000 char * tooltip_cstr;
1002 tooltip << route->name();
1005 io_count = route->n_inputs().n_total();
1007 io_count = route->n_outputs().n_total();
1010 for (io_index = 0; io_index < io_count; ++io_index) {
1012 port = route->input()->nth (io_index);
1014 port = route->output()->nth (io_index);
1017 connections.clear ();
1018 port->get_connections(connections);
1019 io_connection_count = 0;
1021 if (!connections.empty()) {
1022 for (vector<string>::iterator i = connections.begin(); i != connections.end(); ++i) {
1023 string& connection_name (*i);
1025 if (io_connection_count == 0) {
1026 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1028 tooltip << ", " << connection_name;
1031 if (connection_name.find("ardour:") == 0) {
1032 if (ardour_track_name.empty()) {
1033 // "ardour:Master/in 1" -> "ardour:Master/"
1034 string::size_type slash = connection_name.find("/");
1035 if (slash != string::npos) {
1036 ardour_track_name = connection_name.substr(0, slash + 1);
1040 if (connection_name.find(ardour_track_name) == 0) {
1041 ++ardour_connection_count;
1043 } else if (connection_name.find("system:") == 0) {
1045 // "system:capture_123" -> "123"
1046 system_port = connection_name.substr(15);
1048 // "system:playback_123" -> "123"
1049 system_port = connection_name.substr(16);
1052 if (system_ports.empty()) {
1053 system_ports += system_port;
1055 system_ports += "/" + system_port;
1058 ++system_connection_count;
1060 if (other_connection_type.empty()) {
1061 // "jamin:in 1" -> "jamin:"
1062 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1065 if (connection_name.find(other_connection_type) == 0) {
1066 ++other_connection_count;
1070 ++total_connection_count;
1071 ++io_connection_count;
1075 if (io_connection_count != 1) {
1076 each_io_has_one_connection = false;
1080 if (total_connection_count == 0) {
1081 tooltip << endl << _("Disconnected");
1084 tooltip_cstr = new char[tooltip.str().size() + 1];
1085 strcpy(tooltip_cstr, tooltip.str().c_str());
1088 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1090 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1093 if (each_io_has_one_connection) {
1094 if ((total_connection_count == ardour_connection_count)) {
1095 // all connections are to the same track in ardour
1096 // "ardour:Master/" -> "Master"
1097 string::size_type slash = ardour_track_name.find("/");
1098 if (slash != string::npos) {
1099 label << ardour_track_name.substr(7, slash - 7);
1103 else if (total_connection_count == system_connection_count) {
1104 // all connections are to system ports
1105 label << system_ports;
1108 else if (total_connection_count == other_connection_count) {
1109 // all connections are to the same external program eg jamin
1110 // "jamin:" -> "jamin"
1111 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1117 if (total_connection_count == 0) {
1121 // Odd configuration
1122 label << "*" << total_connection_count << "*";
1128 label_string = label.str().substr(0, 6);
1131 label_string = label.str().substr(0, 3);
1135 label_cstr = new char[label_string.size() + 1];
1136 strcpy(label_cstr, label_string.c_str());
1139 input_label.set_text (label_cstr);
1141 output_label.set_text (label_cstr);
1146 MixerStrip::update_input_display ()
1148 update_io_button (_route, _width, true);
1149 panners.setup_pan ();
1153 MixerStrip::update_output_display ()
1155 update_io_button (_route, _width, false);
1156 gpm.setup_meters ();
1157 panners.setup_pan ();
1161 MixerStrip::fast_update ()
1163 gpm.update_meters ();
1167 MixerStrip::diskstream_changed ()
1169 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
1173 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1175 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1176 set_width_enum (_width, this);
1180 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1182 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1183 set_width_enum (_width, this);
1188 MixerStrip::comment_editor_done_editing()
1190 string str = comment_area->get_buffer()->get_text();
1191 if (_route->comment() != str) {
1192 _route->set_comment (str, this);
1197 if (! str.empty()) {
1198 comment_button.modify_bg (STATE_NORMAL, color());
1199 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1201 comment_button.unset_bg (STATE_NORMAL);
1202 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1207 if (! str.empty()) {
1208 comment_button.modify_bg (STATE_NORMAL, color());
1209 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1211 comment_button.unset_bg (STATE_NORMAL);
1212 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1217 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1218 str.empty() ? _("Click to Add/Edit Comments") : str);
1224 MixerStrip::comment_button_clicked ()
1226 if (comment_window == 0) {
1227 setup_comment_editor ();
1230 int x, y, cw_width, cw_height;
1232 if (comment_window->is_visible()) {
1233 comment_window->hide ();
1237 comment_window->get_size (cw_width, cw_height);
1238 comment_window->get_position(x, y);
1239 comment_window->move(x, y - (cw_height / 2) - 45);
1241 half the dialog height minus the comments button height
1242 with some window decoration fudge thrown in.
1245 comment_window->show();
1246 comment_window->present();
1250 MixerStrip::setup_comment_editor ()
1253 title = _route->name();
1254 title += _(": comment editor");
1256 comment_window = new ArdourDialog (title, false);
1257 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1258 comment_window->set_skip_taskbar_hint (true);
1259 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1261 comment_area = manage (new TextView());
1262 comment_area->set_name ("MixerTrackCommentArea");
1263 comment_area->set_size_request (110, 178);
1264 comment_area->set_wrap_mode (WRAP_WORD);
1265 comment_area->set_editable (true);
1266 comment_area->get_buffer()->set_text (_route->comment());
1267 comment_area->show ();
1269 comment_window->get_vbox()->pack_start (*comment_area);
1270 comment_window->get_action_area()->hide();
1274 MixerStrip::comment_changed (void *src)
1276 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1279 ignore_comment_edit = true;
1281 comment_area->get_buffer()->set_text (_route->comment());
1283 ignore_comment_edit = false;
1288 MixerStrip::set_route_group (RouteGroup *rg)
1290 _route->set_route_group (rg, this);
1294 MixerStrip::select_route_group (GdkEventButton *ev)
1296 using namespace Menu_Helpers;
1298 if (ev->button == 1) {
1300 if (group_menu == 0) {
1302 group_menu = new RouteGroupMenu (
1304 (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo)
1307 group_menu->GroupSelected.connect (mem_fun (*this, &MixerStrip::set_route_group));
1310 group_menu->popup (1, ev->time);
1317 MixerStrip::route_group_changed (void *ignored)
1319 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_group_changed), ignored));
1321 RouteGroup *rg = _route->route_group();
1324 /* XXX: this needs a better algorithm */
1325 string truncated = rg->name ();
1326 if (truncated.length () > 5) {
1327 truncated = truncated.substr (0, 5);
1329 group_label.set_text (truncated);
1333 group_label.set_text (_("Grp"));
1336 group_label.set_text (_("~G"));
1344 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1346 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1348 if (what_changed == "color") {
1349 if (set_color_from_route () == 0) {
1350 show_route_color ();
1356 MixerStrip::show_route_color ()
1358 name_button.modify_bg (STATE_NORMAL, color());
1359 top_event_box.modify_bg (STATE_NORMAL, color());
1360 route_active_changed ();
1364 MixerStrip::show_passthru_color ()
1366 route_active_changed ();
1370 MixerStrip::build_route_ops_menu ()
1372 using namespace Menu_Helpers;
1373 route_ops_menu = new Menu;
1374 route_ops_menu->set_name ("ArdourContextMenu");
1376 MenuList& items = route_ops_menu->items();
1378 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1379 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1380 rename_menu_item = &items.back();
1381 items.push_back (SeparatorElem());
1382 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1383 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1384 route_active_menu_item->set_active (_route->active());
1386 items.push_back (SeparatorElem());
1388 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1390 items.push_back (SeparatorElem());
1391 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1392 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1393 polarity_menu_item->set_active (_route->phase_invert());
1394 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1395 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1396 denormal_menu_item->set_active (_route->denormal_protection());
1398 if (!Profile->get_sae()) {
1399 items.push_back (SeparatorElem());
1400 items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1403 items.push_back (SeparatorElem());
1404 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1408 MixerStrip::name_button_button_press (GdkEventButton* ev)
1410 if (ev->button == 1 || ev->button == 3) {
1411 list_route_operations ();
1413 /* do not allow rename if the track is record-enabled */
1414 rename_menu_item->set_sensitive (!_route->record_enabled());
1415 route_ops_menu->popup (1, ev->time);
1421 MixerStrip::list_route_operations ()
1423 if (route_ops_menu == 0) {
1424 build_route_ops_menu ();
1429 MixerStrip::set_selected (bool yn)
1431 AxisView::set_selected (yn);
1433 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1434 global_frame.set_name ("MixerStripSelectedFrame");
1436 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1437 global_frame.set_name ("MixerStripFrame");
1439 global_frame.queue_draw ();
1443 MixerStrip::name_changed ()
1447 RouteUI::name_changed ();
1450 name_label.set_text (PBD::short_version (_route->name(), 5));
1453 if (_route->phase_invert()) {
1454 name_label.set_text (X_("Ø ") + name_label.get_text());
1459 MixerStrip::width_clicked ()
1463 set_width_enum (Narrow, this);
1466 set_width_enum (Wide, this);
1472 MixerStrip::hide_clicked ()
1474 // LAME fix to reset the button status for when it is redisplayed (part 1)
1475 hide_button.set_sensitive(false);
1478 Hiding(); /* EMIT_SIGNAL */
1480 _mixer.hide_strip (this);
1484 hide_button.set_sensitive(true);
1488 MixerStrip::set_embedded (bool yn)
1494 MixerStrip::map_frozen ()
1496 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1498 boost::shared_ptr<AudioTrack> at = audio_track();
1501 switch (at->freeze_state()) {
1502 case AudioTrack::Frozen:
1503 processor_box.set_sensitive (false);
1506 processor_box.set_sensitive (true);
1507 // XXX need some way, maybe, to retoggle redirect editors
1512 hide_redirect_editors ();
1516 MixerStrip::hide_redirect_editors ()
1518 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1522 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1524 boost::shared_ptr<Processor> processor (p.lock ());
1529 void* gui = processor->get_gui ();
1532 static_cast<Gtk::Widget*>(gui)->hide ();
1537 MixerStrip::route_active_changed ()
1539 RouteUI::route_active_changed ();
1541 if (is_midi_track()) {
1542 if (_route->active()) {
1543 set_name ("MidiTrackStripBase");
1544 gpm.set_meter_strip_name ("MidiTrackStripBase");
1546 set_name ("MidiTrackStripBaseInactive");
1547 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1549 gpm.set_fader_name ("MidiTrackFader");
1550 } else if (is_audio_track()) {
1551 if (_route->active()) {
1552 set_name ("AudioTrackStripBase");
1553 gpm.set_meter_strip_name ("AudioTrackMetrics");
1555 set_name ("AudioTrackStripBaseInactive");
1556 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1558 gpm.set_fader_name ("AudioTrackFader");
1560 if (_route->active()) {
1561 set_name ("AudioBusStripBase");
1562 gpm.set_meter_strip_name ("AudioBusMetrics");
1564 set_name ("AudioBusStripBaseInactive");
1565 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1567 gpm.set_fader_name ("AudioBusFader");
1569 /* (no MIDI busses yet) */
1574 MixerStrip::route_group() const
1576 return _route->route_group();
1580 MixerStrip::engine_stopped ()
1585 MixerStrip::engine_running ()
1590 MixerStrip::meter_changed (void *src)
1592 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1594 switch (_route->meter_point()) {
1596 meter_point_label.set_text (_("input"));
1600 meter_point_label.set_text (_("pre"));
1603 case MeterPostFader:
1604 meter_point_label.set_text (_("post"));
1608 gpm.setup_meters ();
1609 // reset peak when meter point changes
1610 gpm.reset_peak_display();
1611 set_width_enum (_width, this);
1615 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1617 if (_route == target || _route->is_master()) {
1618 /* don't change the display for the target or the master bus */
1620 } else if (!is_track() && show_sends_button) {
1621 /* make sure our show sends button is inactive, and we no longer blink,
1622 since we're not the target.
1624 send_blink_connection.disconnect ();
1625 show_sends_button->set_active (false);
1626 show_sends_button->set_state (STATE_NORMAL);
1630 /* switch back to default */
1631 revert_to_default_display ();
1635 boost::shared_ptr<Send> send;
1637 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1638 send->set_metering (false);
1641 _current_delivery = _route->internal_send_for (target);
1643 cerr << "internal send from " << _route->name() << " to " << target->name() << " = "
1644 << _current_delivery << endl;
1646 if (_current_delivery) {
1647 send = boost::dynamic_pointer_cast<Send>(_current_delivery);
1648 send->set_metering (true);
1649 _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1650 gain_meter().set_controls (_route, send->meter(), send->amp());
1651 panner_ui().set_panner (_current_delivery->panner());
1654 _current_delivery = _route->main_outs ();
1655 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1656 panner_ui().set_panner (_route->main_outs()->panner());
1659 gain_meter().setup_meters ();
1660 panner_ui().setup_pan ();
1665 MixerStrip::revert_to_default_display ()
1667 show_sends_button->set_active (false);
1669 boost::shared_ptr<Send> send;
1671 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1672 send->set_metering (false);
1675 _current_delivery = _route->main_outs();
1677 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1678 gain_meter().setup_meters ();
1679 panner_ui().set_panner (_route->main_outs()->panner());
1680 panner_ui().setup_pan ();
1684 MixerStrip::set_button_names ()
1688 rec_enable_button_label.set_text (_("Rec"));
1689 mute_button_label.set_text (_("Mute"));
1690 if (!Config->get_solo_control_is_listen_control()) {
1691 solo_button_label.set_text (_("Solo"));
1693 switch (Config->get_listen_position()) {
1694 case AfterFaderListen:
1695 solo_button_label.set_text (_("AFL"));
1697 case PreFaderListen:
1698 solo_button_label.set_text (_("PFL"));
1705 rec_enable_button_label.set_text (_("R"));
1706 mute_button_label.set_text (_("M"));
1707 if (!Config->get_solo_control_is_listen_control()) {
1708 solo_button_label.set_text (_("S"));
1710 switch (Config->get_listen_position()) {
1711 case AfterFaderListen:
1712 solo_button_label.set_text (_("A"));
1714 case PreFaderListen:
1715 solo_button_label.set_text (_("P"));
1725 MixerStrip::on_key_press_event (GdkEventKey* ev)
1727 GdkEventButton fake;
1728 fake.type = GDK_BUTTON_PRESS;
1730 fake.state = ev->state;
1732 switch (ev->keyval) {
1744 rec_enable_press (&fake);
1749 show_sends_press (&fake);
1754 if (ev->state & Keyboard::PrimaryModifier) {
1764 _route->set_gain (1.0, this);
1777 MixerStrip::on_key_release_event (GdkEventKey* ev)
1779 GdkEventButton fake;
1780 fake.type = GDK_BUTTON_RELEASE;
1782 fake.state = ev->state;
1784 switch (ev->keyval) {
1786 mute_release (&fake);
1791 solo_release (&fake);
1796 rec_enable_release (&fake);
1801 show_sends_release (&fake);
1817 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1819 Keyboard::magic_widget_grab_focus ();
1825 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1827 switch (ev->detail) {
1828 case GDK_NOTIFY_INFERIOR:
1831 Keyboard::magic_widget_drop_focus ();
1838 MixerStrip::mono_button_clicked ()
1840 panners.set_mono (_mono_button.get_active ());
1844 MixerStrip::plugin_selector()
1846 return _mixer.plugin_selector();