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/internal_send.h"
41 #include "ardour/route.h"
42 #include "ardour/route_group.h"
43 #include "ardour/audio_track.h"
44 #include "ardour/audio_diskstream.h"
45 #include "ardour/panner.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"
52 #include "ardour_ui.h"
53 #include "ardour_dialog.h"
54 #include "mixer_strip.h"
57 #include "public_editor.h"
59 #include "io_selector.h"
61 #include "gui_thread.h"
62 #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;
77 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
81 , _mixer_owned (in_mixer)
82 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
85 , _mono_button (_("Mono"))
87 , middle_button_table (1, 2)
88 , bottom_button_table (1, 2)
89 , meter_point_label (_("pre"))
90 , comment_button (_("Comments"))
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"))
115 , comment_button (_("Comments"))
128 _marked_for_display = false;
130 ignore_comment_edit = false;
131 ignore_toggle = false;
139 img = manage (new Gtk::Image (::get_icon("strip_width")));
142 width_button.add (*img);
144 img = manage (new Gtk::Image (::get_icon("hide")));
147 hide_button.add (*img);
149 input_label.set_text (_("Input"));
150 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
151 input_button.add (input_label);
152 input_button.set_name ("MixerIOButton");
153 input_label.set_name ("MixerIOButtonLabel");
154 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
156 output_label.set_text (_("Output"));
157 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
158 output_button.add (output_label);
159 output_button.set_name ("MixerIOButton");
160 output_label.set_name ("MixerIOButtonLabel");
161 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
163 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
164 meter_point_button.add (meter_point_label);
165 meter_point_button.set_name ("MixerStripMeterPreButton");
166 meter_point_label.set_name ("MixerStripMeterPreButton");
168 /* TRANSLATORS: this string should be longest of the strings
169 used to describe meter points. In english, it's "input".
171 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
173 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
175 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
176 meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
178 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
180 mute_button->set_name ("MixerMuteButton");
181 solo_button->set_name ("MixerSoloButton");
183 button_table.set_homogeneous (true);
184 button_table.set_spacings (0);
186 button_table.attach (name_button, 0, 2, 0, 1);
187 button_table.attach (input_button, 0, 2, 1, 2);
189 middle_button_table.set_homogeneous (true);
190 middle_button_table.set_spacings (0);
191 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
192 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
194 bottom_button_table.set_col_spacings (0);
195 bottom_button_table.set_homogeneous (true);
196 bottom_button_table.attach (group_button, 0, 1, 0, 1);
198 name_button.add (name_label);
199 name_button.set_name ("MixerNameButton");
200 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
202 name_label.set_name ("MixerNameButtonLabel");
203 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
204 group_button.add (group_label);
205 group_button.set_name ("MixerGroupButton");
206 group_label.set_name ("MixerGroupButtonLabel");
208 comment_button.set_name ("MixerCommentButton");
210 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
212 global_vpacker.set_border_width (0);
213 global_vpacker.set_spacing (0);
215 width_button.set_name ("MixerWidthButton");
216 hide_button.set_name ("MixerHideButton");
217 top_event_box.set_name ("MixerTopEventBox");
219 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
220 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
222 width_hide_box.pack_start (width_button, false, true);
223 width_hide_box.pack_start (top_event_box, true, true);
224 width_hide_box.pack_end (hide_button, false, true);
225 gain_meter_alignment.set_padding(0, 4, 0, 0);
226 gain_meter_alignment.add(gpm);
228 whvbox.pack_start (width_hide_box, true, true);
230 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
231 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
232 global_vpacker.pack_start (processor_box, true, true);
233 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
234 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
235 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
236 if (!is_midi_track()) {
237 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
239 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
241 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
243 global_frame.add (global_vpacker);
244 global_frame.set_shadow_type (Gtk::SHADOW_IN);
245 global_frame.set_name ("BaseFrame");
249 /* force setting of visible selected status */
252 set_selected (false);
257 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
258 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
260 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
261 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
263 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
264 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
265 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
266 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
268 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
272 rec_enable_button->set_name ("MixerRecordEnableButton");
273 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
274 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
276 /* ditto for this button and busses */
278 show_sends_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::show_sends_press), false);
279 show_sends_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::show_sends_release));
281 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
282 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_route_group), false);
286 /* start off as a passthru strip. we'll correct this, if necessary,
287 in update_diskstream_display().
290 /* start off as a passthru strip. we'll correct this, if necessary,
291 in update_diskstream_display().
295 set_name ("MidiTrackStripBase");
297 set_name ("AudioTrackStripBase");
299 add_events (Gdk::BUTTON_RELEASE_MASK|
300 Gdk::ENTER_NOTIFY_MASK|
301 Gdk::LEAVE_NOTIFY_MASK|
303 Gdk::KEY_RELEASE_MASK);
305 set_flags (get_flags() | Gtk::CAN_FOCUS);
307 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
310 MixerStrip::~MixerStrip ()
312 GoingAway(); /* EMIT_SIGNAL */
314 delete input_selector;
315 delete output_selector;
316 delete comment_window;
320 MixerStrip::set_route (boost::shared_ptr<Route> rt)
322 if (rec_enable_button->get_parent()) {
323 button_table.remove (*rec_enable_button);
326 if (show_sends_button->get_parent()) {
327 button_table.remove (*show_sends_button);
330 RouteUI::set_route (rt);
332 delete input_selector;
335 delete output_selector;
338 revert_to_default_display ();
340 processor_box.set_route (rt);
342 if (set_color_from_route()) {
343 set_color (unique_random_color());
346 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
348 if (scrollbar_height == 0) {
349 HScrollbar scrollbar;
350 Gtk::Requisition requisition(scrollbar.size_request ());
351 scrollbar_height = requisition.height;
354 spacer = manage (new EventBox);
355 spacer->set_size_request (-1, scrollbar_height);
356 global_vpacker.pack_start (*spacer, false, false);
359 if (is_audio_track()) {
361 boost::shared_ptr<AudioTrack> at = audio_track();
363 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
365 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
366 rec_enable_button->set_sensitive (_session.writable());
367 rec_enable_button->show();
369 } else if (!is_track()) {
372 if (!_route->is_master()) {
373 button_table.attach (*show_sends_button, 0, 2, 2, 3);
374 show_sends_button->show();
378 if (_route->phase_invert()) {
379 name_label.set_text (X_("Ø ") + name_label.get_text());
381 name_label.set_text (_route->name());
384 _mono_button.set_name ("MixerMonoButton");
385 _mono_button.signal_clicked().connect (mem_fun (*this, &MixerStrip::mono_button_clicked));
387 switch (_route->meter_point()) {
389 meter_point_label.set_text (_("input"));
393 meter_point_label.set_text (_("pre"));
397 meter_point_label.set_text (_("post"));
401 meter_point_label.set_text (_("custom"));
405 delete route_ops_menu;
408 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
409 _("Click to Add/Edit Comments"):
412 connections.push_back (_route->meter_change.connect (
413 mem_fun(*this, &MixerStrip::meter_changed)));
414 connections.push_back (_route->input()->changed.connect (
415 mem_fun(*this, &MixerStrip::input_changed)));
416 connections.push_back (_route->output()->changed.connect (
417 mem_fun(*this, &MixerStrip::output_changed)));
418 connections.push_back (_route->route_group_changed.connect (
419 mem_fun(*this, &MixerStrip::route_group_changed)));
421 if (_route->panner()) {
422 connections.push_back (_route->panner()->Changed.connect (
423 mem_fun(*this, &MixerStrip::connect_to_pan)));
426 if (is_audio_track()) {
427 connections.push_back (audio_track()->DiskstreamChanged.connect (
428 mem_fun(*this, &MixerStrip::diskstream_changed)));
431 connections.push_back (_route->NameChanged.connect (
432 mem_fun(*this, &RouteUI::name_changed)));
433 connections.push_back (_route->comment_changed.connect (
434 mem_fun(*this, &MixerStrip::comment_changed)));
435 connections.push_back (_route->gui_changed.connect (
436 mem_fun(*this, &MixerStrip::route_gui_changed)));
438 set_stuff_from_route ();
440 /* now force an update of all the various elements */
442 processor_box.update();
447 route_group_changed (0);
451 panners.setup_pan ();
453 update_diskstream_display ();
454 update_input_display ();
455 update_output_display ();
457 add_events (Gdk::BUTTON_RELEASE_MASK);
459 processor_box.show();
461 if (!route()->is_master() && !route()->is_control()) {
462 /* we don't allow master or control routes to be hidden */
467 width_hide_box.show();
470 global_vpacker.show();
472 middle_button_table.show();
473 bottom_button_table.show();
474 processor_box.show_all ();
477 gain_meter_alignment.show ();
478 gain_unit_button.show();
479 gain_unit_label.show();
480 meter_point_button.show();
481 meter_point_label.show();
482 diskstream_button.show();
483 diskstream_label.show();
486 output_button.show();
490 comment_button.show();
498 MixerStrip::set_stuff_from_route ()
504 /* if width is not set, it will be set by the MixerUI or editor */
506 if ((prop = xml_node->property ("strip-width")) != 0) {
507 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
510 if ((prop = xml_node->property ("shown-mixer")) != 0) {
511 if (prop->value() == "no") {
512 _marked_for_display = false;
514 _marked_for_display = true;
517 /* backwards compatibility */
518 _marked_for_display = true;
523 MixerStrip::set_width_enum (Width w, void* owner)
525 /* always set the gpm width again, things may be hidden */
528 panners.set_width (w);
529 processor_box.set_width (w);
531 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
533 _width_owner = owner;
539 if (_width_owner == this) {
540 xml_node->add_property ("strip-width", enum_2_string (_width));
547 if (show_sends_button) {
548 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
551 if (_route->comment() == "") {
552 comment_button.unset_bg (STATE_NORMAL);
553 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
555 comment_button.modify_bg (STATE_NORMAL, color());
556 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
559 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
560 gpm.astyle_string(gain_automation->automation_style()));
561 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
562 gpm.astate_string(gain_automation->automation_state()));
564 if (_route->panner()) {
565 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
566 panners.astyle_string(_route->panner()->automation_style()));
567 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
568 panners.astate_string(_route->panner()->automation_state()));
571 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
572 set_size_request (-1, -1);
576 if (show_sends_button) {
577 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
580 if (_route->comment() == "") {
581 comment_button.unset_bg (STATE_NORMAL);
582 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
584 comment_button.modify_bg (STATE_NORMAL, color());
585 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
588 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
589 gpm.short_astyle_string(gain_automation->automation_style()));
590 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
591 gpm.short_astate_string(gain_automation->automation_state()));
593 if (_route->panner()) {
594 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
595 panners.short_astyle_string(_route->panner()->automation_style()));
596 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
597 panners.short_astate_string(_route->panner()->automation_state()));
600 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
601 set_size_request (max (50, gpm.get_gm_width()), -1);
604 update_input_display ();
605 update_output_display ();
606 route_group_changed (0);
612 MixerStrip::set_packed (bool yn)
619 xml_node->add_property ("shown-mixer", "yes");
621 xml_node->add_property ("shown-mixer", "no");
627 MixerStrip::output_press (GdkEventButton *ev)
629 using namespace Menu_Helpers;
630 if (!_session.engine().connected()) {
631 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
636 MenuList& citems = output_menu.items();
637 switch (ev->button) {
640 edit_output_configuration ();
645 output_menu.set_name ("ArdourContextMenu");
647 output_menu_bundles.clear ();
649 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
650 citems.push_back (SeparatorElem());
652 ARDOUR::BundleList current = _route->output()->bundles_connected ();
654 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
656 /* give user bundles first chance at being in the menu */
658 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
659 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
660 maybe_add_bundle_to_output_menu (*i, current);
664 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
665 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
666 maybe_add_bundle_to_output_menu (*i, current);
670 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
671 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
672 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
675 if (citems.size() == 2) {
676 /* no routes added; remove the separator */
680 output_menu.popup (1, ev->time);
691 MixerStrip::edit_output_configuration ()
693 if (output_selector == 0) {
695 boost::shared_ptr<Send> send;
696 boost::shared_ptr<IO> output;
698 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
699 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
700 output = send->output();
702 output = _route->output ();
705 output = _route->output ();
708 output_selector = new IOSelectorWindow (_session, output);
711 if (output_selector->is_visible()) {
712 output_selector->get_toplevel()->get_window()->raise();
714 output_selector->present ();
719 MixerStrip::edit_input_configuration ()
721 if (input_selector == 0) {
722 input_selector = new IOSelectorWindow (_session, _route->input());
725 if (input_selector->is_visible()) {
726 input_selector->get_toplevel()->get_window()->raise();
728 input_selector->present ();
733 MixerStrip::input_press (GdkEventButton *ev)
735 using namespace Menu_Helpers;
737 MenuList& citems = input_menu.items();
738 input_menu.set_name ("ArdourContextMenu");
741 if (!_session.engine().connected()) {
742 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
747 switch (ev->button) {
750 edit_input_configuration ();
755 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
756 citems.push_back (SeparatorElem());
757 input_menu_bundles.clear ();
759 ARDOUR::BundleList current = _route->input()->bundles_connected ();
761 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
763 /* give user bundles first chance at being in the menu */
765 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
766 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
767 maybe_add_bundle_to_input_menu (*i, current);
771 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
772 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
773 maybe_add_bundle_to_input_menu (*i, current);
777 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
778 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
779 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
782 if (citems.size() == 2) {
783 /* no routes added; remove the separator */
787 input_menu.popup (1, ev->time);
797 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
803 ARDOUR::BundleList current = _route->input()->bundles_connected ();
805 if (std::find (current.begin(), current.end(), c) == current.end()) {
806 _route->input()->connect_ports_to_bundle (c, this);
808 _route->input()->disconnect_ports_from_bundle (c, this);
813 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
819 ARDOUR::BundleList current = _route->output()->bundles_connected ();
821 if (std::find (current.begin(), current.end(), c) == current.end()) {
822 _route->output()->connect_ports_to_bundle (c, this);
824 _route->output()->disconnect_ports_from_bundle (c, this);
829 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
831 using namespace Menu_Helpers;
833 if (b->ports_are_outputs() == false ||
834 route()->input()->default_type() != b->type() ||
835 b->nchannels() != _route->n_inputs().get (b->type ())) {
840 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
841 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
845 if (i != input_menu_bundles.end()) {
849 input_menu_bundles.push_back (b);
851 MenuList& citems = input_menu.items();
853 std::string n = b->name ();
854 replace_all (n, "_", " ");
856 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
858 if (std::find (current.begin(), current.end(), b) != current.end()) {
859 ignore_toggle = true;
860 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
861 ignore_toggle = false;
866 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
868 using namespace Menu_Helpers;
870 if (b->ports_are_inputs() == false ||
871 route()->output()->default_type() != b->type() ||
872 b->nchannels() != _route->n_outputs().get (b->type ())) {
877 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
878 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
882 if (i != output_menu_bundles.end()) {
886 output_menu_bundles.push_back (b);
888 MenuList& citems = output_menu.items();
890 std::string n = b->name ();
891 replace_all (n, "_", " ");
893 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
895 if (std::find (current.begin(), current.end(), b) != current.end()) {
896 ignore_toggle = true;
897 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
898 ignore_toggle = false;
903 MixerStrip::update_diskstream_display ()
907 if (input_selector) {
908 input_selector->hide_all ();
915 show_passthru_color ();
920 MixerStrip::connect_to_pan ()
922 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
924 panstate_connection.disconnect ();
925 panstyle_connection.disconnect ();
927 if (!_route->panner()) {
931 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
932 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
933 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
936 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
937 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
940 panners.pan_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> 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;
1001 bool have_label = false;
1002 bool each_io_has_one_connection = true;
1004 string connection_name;
1005 string ardour_track_name;
1006 string other_connection_type;
1007 string system_ports;
1010 ostringstream tooltip;
1011 char * tooltip_cstr;
1013 tooltip << route->name();
1016 io_count = route->n_inputs().n_total();
1018 io_count = route->n_outputs().n_total();
1021 for (io_index = 0; io_index < io_count; ++io_index) {
1023 port = route->input()->nth (io_index);
1025 port = route->output()->nth (io_index);
1028 connections.clear ();
1029 port->get_connections(connections);
1030 io_connection_count = 0;
1032 if (!connections.empty()) {
1033 for (vector<string>::iterator i = connections.begin(); i != connections.end(); ++i) {
1034 string& connection_name (*i);
1036 if (io_connection_count == 0) {
1037 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1039 tooltip << ", " << connection_name;
1042 if (connection_name.find("ardour:") == 0) {
1043 if (ardour_track_name.empty()) {
1044 // "ardour:Master/in 1" -> "ardour:Master/"
1045 string::size_type slash = connection_name.find("/");
1046 if (slash != string::npos) {
1047 ardour_track_name = connection_name.substr(0, slash + 1);
1051 if (connection_name.find(ardour_track_name) == 0) {
1052 ++ardour_connection_count;
1054 } else if (connection_name.find("system:") == 0) {
1056 // "system:capture_123" -> "123"
1057 system_port = connection_name.substr(15);
1059 // "system:playback_123" -> "123"
1060 system_port = connection_name.substr(16);
1063 if (system_ports.empty()) {
1064 system_ports += system_port;
1066 system_ports += "/" + system_port;
1069 ++system_connection_count;
1071 if (other_connection_type.empty()) {
1072 // "jamin:in 1" -> "jamin:"
1073 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1076 if (connection_name.find(other_connection_type) == 0) {
1077 ++other_connection_count;
1081 ++total_connection_count;
1082 ++io_connection_count;
1086 if (io_connection_count != 1) {
1087 each_io_has_one_connection = false;
1091 if (total_connection_count == 0) {
1092 tooltip << endl << _("Disconnected");
1095 tooltip_cstr = new char[tooltip.str().size() + 1];
1096 strcpy(tooltip_cstr, tooltip.str().c_str());
1099 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1101 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1104 if (each_io_has_one_connection) {
1105 if ((total_connection_count == ardour_connection_count)) {
1106 // all connections are to the same track in ardour
1107 // "ardour:Master/" -> "Master"
1108 string::size_type slash = ardour_track_name.find("/");
1109 if (slash != string::npos) {
1110 label << ardour_track_name.substr(7, slash - 7);
1114 else if (total_connection_count == system_connection_count) {
1115 // all connections are to system ports
1116 label << system_ports;
1119 else if (total_connection_count == other_connection_count) {
1120 // all connections are to the same external program eg jamin
1121 // "jamin:" -> "jamin"
1122 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1128 if (total_connection_count == 0) {
1132 // Odd configuration
1133 label << "*" << total_connection_count << "*";
1139 label_string = label.str().substr(0, 6);
1142 label_string = label.str().substr(0, 3);
1146 label_cstr = new char[label_string.size() + 1];
1147 strcpy(label_cstr, label_string.c_str());
1150 input_label.set_text (label_cstr);
1152 output_label.set_text (label_cstr);
1157 MixerStrip::update_input_display ()
1159 update_io_button (_route, _width, true);
1160 panners.setup_pan ();
1164 MixerStrip::update_output_display ()
1166 update_io_button (_route, _width, false);
1167 gpm.setup_meters ();
1168 panners.setup_pan ();
1172 MixerStrip::fast_update ()
1174 gpm.update_meters ();
1178 MixerStrip::diskstream_changed ()
1180 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
1184 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1186 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1187 set_width_enum (_width, this);
1191 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1193 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1194 set_width_enum (_width, this);
1199 MixerStrip::comment_editor_done_editing()
1201 string str = comment_area->get_buffer()->get_text();
1202 if (_route->comment() != str) {
1203 _route->set_comment (str, this);
1208 if (! str.empty()) {
1209 comment_button.modify_bg (STATE_NORMAL, color());
1210 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1212 comment_button.unset_bg (STATE_NORMAL);
1213 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1218 if (! str.empty()) {
1219 comment_button.modify_bg (STATE_NORMAL, color());
1220 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1222 comment_button.unset_bg (STATE_NORMAL);
1223 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1228 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1229 str.empty() ? _("Click to Add/Edit Comments") : str);
1235 MixerStrip::comment_button_clicked ()
1237 if (comment_window == 0) {
1238 setup_comment_editor ();
1241 int x, y, cw_width, cw_height;
1243 if (comment_window->is_visible()) {
1244 comment_window->hide ();
1248 comment_window->get_size (cw_width, cw_height);
1249 comment_window->get_position(x, y);
1250 comment_window->move(x, y - (cw_height / 2) - 45);
1252 half the dialog height minus the comments button height
1253 with some window decoration fudge thrown in.
1256 comment_window->show();
1257 comment_window->present();
1261 MixerStrip::setup_comment_editor ()
1264 title = _route->name();
1265 title += _(": comment editor");
1267 comment_window = new ArdourDialog (title, false);
1268 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1269 comment_window->set_skip_taskbar_hint (true);
1270 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1272 comment_area = manage (new TextView());
1273 comment_area->set_name ("MixerTrackCommentArea");
1274 comment_area->set_size_request (110, 178);
1275 comment_area->set_wrap_mode (WRAP_WORD);
1276 comment_area->set_editable (true);
1277 comment_area->get_buffer()->set_text (_route->comment());
1278 comment_area->show ();
1280 comment_window->get_vbox()->pack_start (*comment_area);
1281 comment_window->get_action_area()->hide();
1285 MixerStrip::comment_changed (void *src)
1287 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1290 ignore_comment_edit = true;
1292 comment_area->get_buffer()->set_text (_route->comment());
1294 ignore_comment_edit = false;
1299 MixerStrip::set_route_group (RouteGroup *rg)
1301 _route->set_route_group (rg, this);
1305 MixerStrip::select_route_group (GdkEventButton *ev)
1307 using namespace Menu_Helpers;
1309 if (ev->button == 1) {
1311 if (group_menu == 0) {
1313 group_menu = new RouteGroupMenu (
1315 (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo)
1318 group_menu->GroupSelected.connect (mem_fun (*this, &MixerStrip::set_route_group));
1321 group_menu->popup (1, ev->time);
1328 MixerStrip::route_group_changed (void *ignored)
1330 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_group_changed), ignored));
1332 RouteGroup *rg = _route->route_group();
1335 /* XXX: this needs a better algorithm */
1336 string truncated = rg->name ();
1337 if (truncated.length () > 5) {
1338 truncated = truncated.substr (0, 5);
1340 group_label.set_text (truncated);
1344 group_label.set_text (_("Grp"));
1347 group_label.set_text (_("~G"));
1355 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1357 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1359 if (what_changed == "color") {
1360 if (set_color_from_route () == 0) {
1361 show_route_color ();
1367 MixerStrip::show_route_color ()
1369 name_button.modify_bg (STATE_NORMAL, color());
1370 top_event_box.modify_bg (STATE_NORMAL, color());
1371 route_active_changed ();
1375 MixerStrip::show_passthru_color ()
1377 route_active_changed ();
1381 MixerStrip::build_route_ops_menu ()
1383 using namespace Menu_Helpers;
1384 route_ops_menu = new Menu;
1385 route_ops_menu->set_name ("ArdourContextMenu");
1387 MenuList& items = route_ops_menu->items();
1389 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1390 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1391 rename_menu_item = &items.back();
1392 items.push_back (SeparatorElem());
1393 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1394 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1395 route_active_menu_item->set_active (_route->active());
1397 items.push_back (SeparatorElem());
1399 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1401 items.push_back (SeparatorElem());
1402 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1403 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1404 polarity_menu_item->set_active (_route->phase_invert());
1405 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1406 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1407 denormal_menu_item->set_active (_route->denormal_protection());
1409 if (!Profile->get_sae()) {
1410 items.push_back (SeparatorElem());
1411 items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1414 items.push_back (SeparatorElem());
1415 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1419 MixerStrip::name_button_button_press (GdkEventButton* ev)
1421 if (ev->button == 1 || ev->button == 3) {
1422 list_route_operations ();
1424 /* do not allow rename if the track is record-enabled */
1425 rename_menu_item->set_sensitive (!_route->record_enabled());
1426 route_ops_menu->popup (1, ev->time);
1432 MixerStrip::list_route_operations ()
1434 if (route_ops_menu == 0) {
1435 build_route_ops_menu ();
1440 MixerStrip::set_selected (bool yn)
1442 AxisView::set_selected (yn);
1444 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1445 global_frame.set_name ("MixerStripSelectedFrame");
1447 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1448 global_frame.set_name ("MixerStripFrame");
1450 global_frame.queue_draw ();
1454 MixerStrip::name_changed ()
1458 RouteUI::name_changed ();
1461 name_label.set_text (PBD::short_version (_route->name(), 5));
1464 if (_route->phase_invert()) {
1465 name_label.set_text (X_("Ø ") + name_label.get_text());
1470 MixerStrip::width_clicked ()
1474 set_width_enum (Narrow, this);
1477 set_width_enum (Wide, this);
1483 MixerStrip::hide_clicked ()
1485 // LAME fix to reset the button status for when it is redisplayed (part 1)
1486 hide_button.set_sensitive(false);
1489 Hiding(); /* EMIT_SIGNAL */
1491 _mixer.hide_strip (this);
1495 hide_button.set_sensitive(true);
1499 MixerStrip::set_embedded (bool yn)
1505 MixerStrip::map_frozen ()
1507 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1509 boost::shared_ptr<AudioTrack> at = audio_track();
1512 switch (at->freeze_state()) {
1513 case AudioTrack::Frozen:
1514 processor_box.set_sensitive (false);
1517 processor_box.set_sensitive (true);
1518 // XXX need some way, maybe, to retoggle redirect editors
1523 hide_redirect_editors ();
1527 MixerStrip::hide_redirect_editors ()
1529 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1533 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1535 boost::shared_ptr<Processor> processor (p.lock ());
1540 void* gui = processor->get_gui ();
1543 static_cast<Gtk::Widget*>(gui)->hide ();
1548 MixerStrip::route_active_changed ()
1550 RouteUI::route_active_changed ();
1551 reset_strip_style ();
1555 MixerStrip::reset_strip_style ()
1557 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1559 gpm.set_fader_name ("SendStripBase");
1563 if (is_midi_track()) {
1564 if (_route->active()) {
1565 set_name ("MidiTrackStripBase");
1566 gpm.set_meter_strip_name ("MidiTrackStripBase");
1568 set_name ("MidiTrackStripBaseInactive");
1569 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1571 gpm.set_fader_name ("MidiTrackFader");
1572 } else if (is_audio_track()) {
1573 if (_route->active()) {
1574 set_name ("AudioTrackStripBase");
1575 gpm.set_meter_strip_name ("AudioTrackMetrics");
1577 set_name ("AudioTrackStripBaseInactive");
1578 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1580 gpm.set_fader_name ("AudioTrackFader");
1582 if (_route->active()) {
1583 set_name ("AudioBusStripBase");
1584 gpm.set_meter_strip_name ("AudioBusMetrics");
1586 set_name ("AudioBusStripBaseInactive");
1587 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1589 gpm.set_fader_name ("AudioBusFader");
1591 /* (no MIDI busses yet) */
1597 MixerStrip::route_group() const
1599 return _route->route_group();
1603 MixerStrip::engine_stopped ()
1608 MixerStrip::engine_running ()
1613 MixerStrip::meter_changed (void *src)
1615 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1617 switch (_route->meter_point()) {
1619 meter_point_label.set_text (_("input"));
1623 meter_point_label.set_text (_("pre"));
1626 case MeterPostFader:
1627 meter_point_label.set_text (_("post"));
1631 meter_point_label.set_text (_("custom"));
1635 gpm.setup_meters ();
1636 // reset peak when meter point changes
1637 gpm.reset_peak_display();
1638 set_width_enum (_width, this);
1642 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1644 /* don't respond to switch IO signal outside of the mixer window */
1646 if (!_mixer_owned) {
1650 if (_route == target || _route->is_master()) {
1651 /* don't change the display for the target or the master bus */
1653 } else if (!is_track() && show_sends_button) {
1654 /* make sure our show sends button is inactive, and we no longer blink,
1655 since we're not the target.
1657 send_blink_connection.disconnect ();
1658 show_sends_button->set_active (false);
1659 show_sends_button->set_state (STATE_NORMAL);
1663 /* switch back to default */
1664 revert_to_default_display ();
1668 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1673 revert_to_default_display ();
1678 MixerStrip::drop_send ()
1680 boost::shared_ptr<Send> current_send;
1682 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1683 current_send->set_metering (false);
1686 send_gone_connection.disconnect ();
1687 input_button.set_sensitive (true);
1688 output_button.set_sensitive (true);
1692 MixerStrip::show_send (boost::shared_ptr<Send> send)
1698 _current_delivery = send;
1700 send->set_metering (true);
1701 send_gone_connection = _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1703 gain_meter().set_controls (_route, send->meter(), send->amp());
1704 gain_meter().setup_meters ();
1706 panner_ui().set_panner (_current_delivery->panner());
1707 panner_ui().setup_pan ();
1709 input_button.set_sensitive (false);
1711 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1712 output_button.set_sensitive (false);
1715 reset_strip_style ();
1719 MixerStrip::revert_to_default_display ()
1721 if (show_sends_button) {
1722 show_sends_button->set_active (false);
1727 _current_delivery = _route->main_outs();
1729 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1730 gain_meter().setup_meters ();
1732 panner_ui().set_panner (_route->main_outs()->panner());
1733 panner_ui().setup_pan ();
1735 reset_strip_style ();
1739 MixerStrip::set_button_names ()
1743 rec_enable_button_label.set_text (_("Rec"));
1744 mute_button_label.set_text (_("Mute"));
1745 if (!Config->get_solo_control_is_listen_control()) {
1746 solo_button_label.set_text (_("Solo"));
1748 switch (Config->get_listen_position()) {
1749 case AfterFaderListen:
1750 solo_button_label.set_text (_("AFL"));
1752 case PreFaderListen:
1753 solo_button_label.set_text (_("PFL"));
1760 rec_enable_button_label.set_text (_("R"));
1761 mute_button_label.set_text (_("M"));
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"));
1780 MixerStrip::on_key_press_event (GdkEventKey* ev)
1782 GdkEventButton fake;
1783 fake.type = GDK_BUTTON_PRESS;
1785 fake.state = ev->state;
1787 switch (ev->keyval) {
1799 rec_enable_press (&fake);
1804 show_sends_press (&fake);
1809 if (ev->state & Keyboard::PrimaryModifier) {
1819 _route->set_gain (1.0, this);
1832 MixerStrip::on_key_release_event (GdkEventKey* ev)
1834 GdkEventButton fake;
1835 fake.type = GDK_BUTTON_RELEASE;
1837 fake.state = ev->state;
1839 switch (ev->keyval) {
1841 mute_release (&fake);
1846 solo_release (&fake);
1851 rec_enable_release (&fake);
1856 show_sends_release (&fake);
1872 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1874 Keyboard::magic_widget_grab_focus ();
1880 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1882 switch (ev->detail) {
1883 case GDK_NOTIFY_INFERIOR:
1886 Keyboard::magic_widget_drop_focus ();
1893 MixerStrip::mono_button_clicked ()
1895 panners.set_mono (_mono_button.get_active ());
1899 MixerStrip::plugin_selector()
1901 return _mixer.plugin_selector();