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;
137 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
138 longest_label = "longest label";
142 img = manage (new Gtk::Image (::get_icon("strip_width")));
145 width_button.add (*img);
147 img = manage (new Gtk::Image (::get_icon("hide")));
150 hide_button.add (*img);
152 input_label.set_text (_("Input"));
153 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
154 input_button.add (input_label);
155 input_button.set_name ("MixerIOButton");
156 input_label.set_name ("MixerIOButtonLabel");
158 Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 4, 4);
160 output_label.set_text (_("Output"));
161 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
162 output_button.add (output_label);
163 output_button.set_name ("MixerIOButton");
164 output_label.set_name ("MixerIOButtonLabel");
165 Gtkmm2ext::set_size_request_to_display_given_text (output_button, longest_label.c_str(), 4, 4);
167 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
168 meter_point_button.add (meter_point_label);
169 meter_point_button.set_name ("MixerStripMeterPreButton");
170 meter_point_label.set_name ("MixerStripMeterPreButton");
172 /* TRANSLATORS: this string should be longest of the strings
173 used to describe meter points. In english, it's "input".
175 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
177 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
179 meter_point_button.signal_button_press_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_press), false);
180 meter_point_button.signal_button_release_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_release), false);
182 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
184 mute_button->set_name ("MixerMuteButton");
185 solo_button->set_name ("MixerSoloButton");
187 button_table.set_homogeneous (true);
188 button_table.set_spacings (0);
190 button_table.attach (name_button, 0, 2, 0, 1);
191 button_table.attach (input_button, 0, 2, 1, 2);
193 middle_button_table.set_homogeneous (true);
194 middle_button_table.set_spacings (0);
195 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
196 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
198 bottom_button_table.set_col_spacings (0);
199 bottom_button_table.set_homogeneous (true);
200 bottom_button_table.attach (group_button, 0, 1, 0, 1);
202 name_button.add (name_label);
203 name_button.set_name ("MixerNameButton");
204 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
206 name_label.set_name ("MixerNameButtonLabel");
207 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
208 group_button.add (group_label);
209 group_button.set_name ("MixerGroupButton");
210 group_label.set_name ("MixerGroupButtonLabel");
212 comment_button.set_name ("MixerCommentButton");
214 comment_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::comment_button_clicked));
216 global_vpacker.set_border_width (0);
217 global_vpacker.set_spacing (0);
219 width_button.set_name ("MixerWidthButton");
220 hide_button.set_name ("MixerHideButton");
221 top_event_box.set_name ("MixerTopEventBox");
223 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
224 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
226 width_hide_box.pack_start (width_button, false, true);
227 width_hide_box.pack_start (top_event_box, true, true);
228 width_hide_box.pack_end (hide_button, false, true);
229 gain_meter_alignment.set_padding(0, 4, 0, 0);
230 gain_meter_alignment.add(gpm);
232 whvbox.pack_start (width_hide_box, true, true);
234 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
235 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
236 global_vpacker.pack_start (processor_box, true, true);
237 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
238 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
239 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
240 if (!is_midi_track()) {
241 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
243 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
244 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
245 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
247 global_frame.add (global_vpacker);
248 global_frame.set_shadow_type (Gtk::SHADOW_IN);
249 global_frame.set_name ("BaseFrame");
253 /* force setting of visible selected status */
256 set_selected (false);
261 _session.engine().Stopped.connect (sigc::mem_fun(*this, &MixerStrip::engine_stopped));
262 _session.engine().Running.connect (sigc::mem_fun(*this, &MixerStrip::engine_running));
264 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
265 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
267 solo_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::solo_press), false);
268 solo_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::solo_release), false);
269 mute_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::mute_press), false);
270 mute_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::mute_release), false);
272 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
276 rec_enable_button->set_name ("MixerRecordEnableButton");
277 rec_enable_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_press), false);
278 rec_enable_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_release));
280 /* ditto for this button and busses */
282 show_sends_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_press), false);
283 show_sends_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_release));
285 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
286 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
290 /* start off as a passthru strip. we'll correct this, if necessary,
291 in update_diskstream_display().
294 /* start off as a passthru strip. we'll correct this, if necessary,
295 in update_diskstream_display().
299 set_name ("MidiTrackStripBase");
301 set_name ("AudioTrackStripBase");
303 add_events (Gdk::BUTTON_RELEASE_MASK|
304 Gdk::ENTER_NOTIFY_MASK|
305 Gdk::LEAVE_NOTIFY_MASK|
307 Gdk::KEY_RELEASE_MASK);
309 set_flags (get_flags() | Gtk::CAN_FOCUS);
311 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
314 MixerStrip::~MixerStrip ()
316 GoingAway(); /* EMIT_SIGNAL */
318 delete input_selector;
319 delete output_selector;
320 delete comment_window;
324 MixerStrip::set_route (boost::shared_ptr<Route> rt)
326 if (rec_enable_button->get_parent()) {
327 button_table.remove (*rec_enable_button);
330 if (show_sends_button->get_parent()) {
331 button_table.remove (*show_sends_button);
334 RouteUI::set_route (rt);
336 delete input_selector;
339 delete output_selector;
342 revert_to_default_display ();
344 processor_box.set_route (rt);
346 if (set_color_from_route()) {
347 set_color (unique_random_color());
350 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
352 if (scrollbar_height == 0) {
353 HScrollbar scrollbar;
354 Gtk::Requisition requisition(scrollbar.size_request ());
355 scrollbar_height = requisition.height;
358 spacer = manage (new EventBox);
359 spacer->set_size_request (-1, scrollbar_height);
360 global_vpacker.pack_start (*spacer, false, false);
363 if (is_audio_track()) {
365 boost::shared_ptr<AudioTrack> at = audio_track();
367 connections.push_back (at->FreezeChange.connect (sigc::mem_fun(*this, &MixerStrip::map_frozen)));
369 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
370 rec_enable_button->set_sensitive (_session.writable());
371 rec_enable_button->show();
373 } else if (!is_track()) {
376 if (!_route->is_master()) {
377 button_table.attach (*show_sends_button, 0, 2, 2, 3);
378 show_sends_button->show();
382 if (_route->phase_invert()) {
383 name_label.set_text (X_("Ø ") + name_label.get_text());
385 name_label.set_text (_route->name());
388 _mono_button.set_name ("MixerMonoButton");
389 _mono_button.signal_clicked().connect (sigc::mem_fun (*this, &MixerStrip::mono_button_clicked));
391 switch (_route->meter_point()) {
393 meter_point_label.set_text (_("input"));
397 meter_point_label.set_text (_("pre"));
401 meter_point_label.set_text (_("post"));
405 meter_point_label.set_text (_("custom"));
409 delete route_ops_menu;
412 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
413 _("Click to Add/Edit Comments"):
416 connections.push_back (_route->meter_change.connect (
417 sigc::mem_fun(*this, &MixerStrip::meter_changed)));
418 connections.push_back (_route->input()->changed.connect (
419 sigc::mem_fun(*this, &MixerStrip::input_changed)));
420 connections.push_back (_route->output()->changed.connect (
421 sigc::mem_fun(*this, &MixerStrip::output_changed)));
422 connections.push_back (_route->route_group_changed.connect (
423 sigc::mem_fun(*this, &MixerStrip::route_group_changed)));
425 if (_route->panner()) {
426 connections.push_back (_route->panner()->Changed.connect (
427 sigc::mem_fun(*this, &MixerStrip::connect_to_pan)));
430 if (is_audio_track()) {
431 connections.push_back (audio_track()->DiskstreamChanged.connect (
432 sigc::mem_fun(*this, &MixerStrip::diskstream_changed)));
435 connections.push_back (_route->NameChanged.connect (
436 sigc::mem_fun(*this, &RouteUI::name_changed)));
437 connections.push_back (_route->comment_changed.connect (
438 sigc::mem_fun(*this, &MixerStrip::comment_changed)));
439 connections.push_back (_route->gui_changed.connect (
440 sigc::mem_fun(*this, &MixerStrip::route_gui_changed)));
442 set_stuff_from_route ();
444 /* now force an update of all the various elements */
450 route_group_changed ();
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);
533 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
535 _width_owner = owner;
541 if (_width_owner == this) {
542 xml_node->add_property ("strip-width", enum_2_string (_width));
549 if (show_sends_button) {
550 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
553 if (_route->comment() == "") {
554 comment_button.unset_bg (STATE_NORMAL);
555 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
557 comment_button.modify_bg (STATE_NORMAL, color());
558 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
561 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
562 gpm.astyle_string(gain_automation->automation_style()));
563 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
564 gpm.astate_string(gain_automation->automation_state()));
566 if (_route->panner()) {
567 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
568 panners.astyle_string(_route->panner()->automation_style()));
569 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
570 panners.astate_string(_route->panner()->automation_state()));
573 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
574 set_size_request (-1, -1);
578 if (show_sends_button) {
579 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
582 if (_route->comment() == "") {
583 comment_button.unset_bg (STATE_NORMAL);
584 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
586 comment_button.modify_bg (STATE_NORMAL, color());
587 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
590 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
591 gpm.short_astyle_string(gain_automation->automation_style()));
592 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
593 gpm.short_astate_string(gain_automation->automation_state()));
595 if (_route->panner()) {
596 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
597 panners.short_astyle_string(_route->panner()->automation_style()));
598 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
599 panners.short_astate_string(_route->panner()->automation_state()));
602 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
603 set_size_request (max (50, gpm.get_gm_width()), -1);
607 processor_box.set_width (w);
609 update_input_display ();
610 update_output_display ();
611 route_group_changed ();
617 MixerStrip::set_packed (bool yn)
624 xml_node->add_property ("shown-mixer", "yes");
626 xml_node->add_property ("shown-mixer", "no");
632 MixerStrip::output_press (GdkEventButton *ev)
634 using namespace Menu_Helpers;
635 if (!_session.engine().connected()) {
636 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
641 MenuList& citems = output_menu.items();
642 switch (ev->button) {
645 edit_output_configuration ();
650 output_menu.set_name ("ArdourContextMenu");
652 output_menu_bundles.clear ();
654 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
655 citems.push_back (SeparatorElem());
657 ARDOUR::BundleList current = _route->output()->bundles_connected ();
659 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
661 /* give user bundles first chance at being in the menu */
663 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
664 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
665 maybe_add_bundle_to_output_menu (*i, current);
669 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
670 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
671 maybe_add_bundle_to_output_menu (*i, current);
675 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
676 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
677 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
680 if (citems.size() == 2) {
681 /* no routes added; remove the separator */
685 output_menu.popup (1, ev->time);
696 MixerStrip::edit_output_configuration ()
698 if (output_selector == 0) {
700 boost::shared_ptr<Send> send;
701 boost::shared_ptr<IO> output;
703 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
704 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
705 output = send->output();
707 output = _route->output ();
710 output = _route->output ();
713 output_selector = new IOSelectorWindow (&_session, output);
716 if (output_selector->is_visible()) {
717 output_selector->get_toplevel()->get_window()->raise();
719 output_selector->present ();
724 MixerStrip::edit_input_configuration ()
726 if (input_selector == 0) {
727 input_selector = new IOSelectorWindow (&_session, _route->input());
730 if (input_selector->is_visible()) {
731 input_selector->get_toplevel()->get_window()->raise();
733 input_selector->present ();
738 MixerStrip::input_press (GdkEventButton *ev)
740 using namespace Menu_Helpers;
742 MenuList& citems = input_menu.items();
743 input_menu.set_name ("ArdourContextMenu");
746 if (!_session.engine().connected()) {
747 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
752 switch (ev->button) {
755 edit_input_configuration ();
760 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
761 citems.push_back (SeparatorElem());
762 input_menu_bundles.clear ();
764 ARDOUR::BundleList current = _route->input()->bundles_connected ();
766 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
768 /* give user bundles first chance at being in the menu */
770 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
771 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
772 maybe_add_bundle_to_input_menu (*i, current);
776 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
777 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
778 maybe_add_bundle_to_input_menu (*i, current);
782 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
783 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
784 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
787 if (citems.size() == 2) {
788 /* no routes added; remove the separator */
792 input_menu.popup (1, ev->time);
802 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
808 ARDOUR::BundleList current = _route->input()->bundles_connected ();
810 if (std::find (current.begin(), current.end(), c) == current.end()) {
811 _route->input()->connect_ports_to_bundle (c, this);
813 _route->input()->disconnect_ports_from_bundle (c, this);
818 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
824 ARDOUR::BundleList current = _route->output()->bundles_connected ();
826 if (std::find (current.begin(), current.end(), c) == current.end()) {
827 _route->output()->connect_ports_to_bundle (c, this);
829 _route->output()->disconnect_ports_from_bundle (c, this);
834 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
836 using namespace Menu_Helpers;
838 if (b->ports_are_outputs() == false ||
839 route()->input()->default_type() != b->type() ||
840 b->nchannels() != _route->n_inputs().get (b->type ())) {
845 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
846 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
850 if (i != input_menu_bundles.end()) {
854 input_menu_bundles.push_back (b);
856 MenuList& citems = input_menu.items();
858 std::string n = b->name ();
859 replace_all (n, "_", " ");
861 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
863 if (std::find (current.begin(), current.end(), b) != current.end()) {
864 ignore_toggle = true;
865 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
866 ignore_toggle = false;
871 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
873 using namespace Menu_Helpers;
875 if (b->ports_are_inputs() == false ||
876 route()->output()->default_type() != b->type() ||
877 b->nchannels() != _route->n_outputs().get (b->type ())) {
882 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
883 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
887 if (i != output_menu_bundles.end()) {
891 output_menu_bundles.push_back (b);
893 MenuList& citems = output_menu.items();
895 std::string n = b->name ();
896 replace_all (n, "_", " ");
898 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
900 if (std::find (current.begin(), current.end(), b) != current.end()) {
901 ignore_toggle = true;
902 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
903 ignore_toggle = false;
908 MixerStrip::update_diskstream_display ()
912 if (input_selector) {
913 input_selector->hide_all ();
920 show_passthru_color ();
925 MixerStrip::connect_to_pan ()
927 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
929 panstate_connection.disconnect ();
930 panstyle_connection.disconnect ();
932 if (!_route->panner()) {
936 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
937 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
938 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
941 panstate_connection = pan_control->alist()->automation_state_changed.connect (sigc::mem_fun(panners, &PannerUI::pan_automation_state_changed));
942 panstyle_connection = pan_control->alist()->automation_style_changed.connect (sigc::mem_fun(panners, &PannerUI::pan_automation_style_changed));
945 panners.pan_changed (this);
950 * Output port labelling
951 * =====================
953 * Case 1: Each output has one connection, all connections are to system:playback_%i
954 * out 1 -> system:playback_1
955 * out 2 -> system:playback_2
956 * out 3 -> system:playback_3
959 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
960 * out 1 -> ardour:track_x/in 1
961 * out 2 -> ardour:track_x/in 2
962 * Display as: track_x
964 * Case 3: Each output has one connection, all connections are to Jack client "program x"
965 * out 1 -> program x:foo
966 * out 2 -> program x:foo
967 * Display as: program x
969 * Case 4: No connections (Disconnected)
972 * Default case (unusual routing):
973 * Display as: *number of connections*
977 * .-----------------------------------------------.
979 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
980 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
981 * '-----------------------------------------------'
982 * .-----------------------------------------------.
985 * '-----------------------------------------------'
989 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
994 vector<string> connections;
996 uint32_t total_connection_count = 0;
997 uint32_t io_connection_count = 0;
998 uint32_t ardour_connection_count = 0;
999 uint32_t system_connection_count = 0;
1000 uint32_t other_connection_count = 0;
1002 ostringstream label;
1003 string label_string;
1006 bool have_label = false;
1007 bool each_io_has_one_connection = true;
1009 string connection_name;
1010 string ardour_track_name;
1011 string other_connection_type;
1012 string system_ports;
1015 ostringstream tooltip;
1016 char * tooltip_cstr;
1018 tooltip << route->name();
1021 io_count = route->n_inputs().n_total();
1023 io_count = route->n_outputs().n_total();
1026 for (io_index = 0; io_index < io_count; ++io_index) {
1028 port = route->input()->nth (io_index);
1030 port = route->output()->nth (io_index);
1033 connections.clear ();
1034 port->get_connections(connections);
1035 io_connection_count = 0;
1037 if (!connections.empty()) {
1038 for (vector<string>::iterator i = connections.begin(); i != connections.end(); ++i) {
1039 string& connection_name (*i);
1041 if (io_connection_count == 0) {
1042 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1044 tooltip << ", " << connection_name;
1047 if (connection_name.find("ardour:") == 0) {
1048 if (ardour_track_name.empty()) {
1049 // "ardour:Master/in 1" -> "ardour:Master/"
1050 string::size_type slash = connection_name.find("/");
1051 if (slash != string::npos) {
1052 ardour_track_name = connection_name.substr(0, slash + 1);
1056 if (connection_name.find(ardour_track_name) == 0) {
1057 ++ardour_connection_count;
1059 } else if (connection_name.find("system:") == 0) {
1061 // "system:capture_123" -> "123"
1062 system_port = connection_name.substr(15);
1064 // "system:playback_123" -> "123"
1065 system_port = connection_name.substr(16);
1068 if (system_ports.empty()) {
1069 system_ports += system_port;
1071 system_ports += "/" + system_port;
1074 ++system_connection_count;
1076 if (other_connection_type.empty()) {
1077 // "jamin:in 1" -> "jamin:"
1078 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1081 if (connection_name.find(other_connection_type) == 0) {
1082 ++other_connection_count;
1086 ++total_connection_count;
1087 ++io_connection_count;
1091 if (io_connection_count != 1) {
1092 each_io_has_one_connection = false;
1096 if (total_connection_count == 0) {
1097 tooltip << endl << _("Disconnected");
1100 tooltip_cstr = new char[tooltip.str().size() + 1];
1101 strcpy(tooltip_cstr, tooltip.str().c_str());
1104 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1106 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1109 if (each_io_has_one_connection) {
1110 if ((total_connection_count == ardour_connection_count)) {
1111 // all connections are to the same track in ardour
1112 // "ardour:Master/" -> "Master"
1113 string::size_type slash = ardour_track_name.find("/");
1114 if (slash != string::npos) {
1115 label << ardour_track_name.substr(7, slash - 7);
1119 else if (total_connection_count == system_connection_count) {
1120 // all connections are to system ports
1121 label << system_ports;
1124 else if (total_connection_count == other_connection_count) {
1125 // all connections are to the same external program eg jamin
1126 // "jamin:" -> "jamin"
1127 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1133 if (total_connection_count == 0) {
1137 // Odd configuration
1138 label << "*" << total_connection_count << "*";
1144 label_string = label.str().substr(0, 6);
1147 label_string = label.str().substr(0, 3);
1151 label_cstr = new char[label_string.size() + 1];
1152 strcpy(label_cstr, label_string.c_str());
1155 input_label.set_text (label_cstr);
1157 output_label.set_text (label_cstr);
1162 MixerStrip::update_input_display ()
1164 update_io_button (_route, _width, true);
1165 panners.setup_pan ();
1169 MixerStrip::update_output_display ()
1171 update_io_button (_route, _width, false);
1172 gpm.setup_meters ();
1173 panners.setup_pan ();
1177 MixerStrip::fast_update ()
1179 gpm.update_meters ();
1183 MixerStrip::diskstream_changed ()
1185 Gtkmm2ext::UI::instance()->call_slot (sigc::mem_fun(*this, &MixerStrip::update_diskstream_display));
1189 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1191 Gtkmm2ext::UI::instance()->call_slot (sigc::mem_fun(*this, &MixerStrip::update_input_display));
1192 set_width_enum (_width, this);
1196 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1198 Gtkmm2ext::UI::instance()->call_slot (sigc::mem_fun(*this, &MixerStrip::update_output_display));
1199 set_width_enum (_width, this);
1204 MixerStrip::comment_editor_done_editing()
1206 string str = comment_area->get_buffer()->get_text();
1207 if (_route->comment() != str) {
1208 _route->set_comment (str, this);
1213 if (! str.empty()) {
1214 comment_button.modify_bg (STATE_NORMAL, color());
1215 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1217 comment_button.unset_bg (STATE_NORMAL);
1218 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1223 if (! str.empty()) {
1224 comment_button.modify_bg (STATE_NORMAL, color());
1225 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1227 comment_button.unset_bg (STATE_NORMAL);
1228 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1233 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1234 str.empty() ? _("Click to Add/Edit Comments") : str);
1240 MixerStrip::comment_button_clicked ()
1242 if (comment_window == 0) {
1243 setup_comment_editor ();
1246 int x, y, cw_width, cw_height;
1248 if (comment_window->is_visible()) {
1249 comment_window->hide ();
1253 comment_window->get_size (cw_width, cw_height);
1254 comment_window->get_position(x, y);
1255 comment_window->move(x, y - (cw_height / 2) - 45);
1257 half the dialog height minus the comments button height
1258 with some window decoration fudge thrown in.
1261 comment_window->show();
1262 comment_window->present();
1266 MixerStrip::setup_comment_editor ()
1269 title = _route->name();
1270 title += _(": comment editor");
1272 comment_window = new ArdourDialog (title, false);
1273 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1274 comment_window->set_skip_taskbar_hint (true);
1275 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1277 comment_area = manage (new TextView());
1278 comment_area->set_name ("MixerTrackCommentArea");
1279 comment_area->set_size_request (110, 178);
1280 comment_area->set_wrap_mode (WRAP_WORD);
1281 comment_area->set_editable (true);
1282 comment_area->get_buffer()->set_text (_route->comment());
1283 comment_area->show ();
1285 comment_window->get_vbox()->pack_start (*comment_area);
1286 comment_window->get_action_area()->hide();
1290 MixerStrip::comment_changed (void *src)
1292 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1295 ignore_comment_edit = true;
1297 comment_area->get_buffer()->set_text (_route->comment());
1299 ignore_comment_edit = false;
1304 MixerStrip::set_route_group (RouteGroup *rg)
1310 MixerStrip::select_route_group (GdkEventButton *ev)
1312 using namespace Menu_Helpers;
1314 if (ev->button == 1) {
1316 if (group_menu == 0) {
1318 group_menu = new RouteGroupMenu (
1320 (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo)
1323 group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
1326 group_menu->popup (1, ev->time);
1333 MixerStrip::route_group_changed ()
1335 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1337 RouteGroup *rg = _route->route_group();
1340 /* XXX: this needs a better algorithm */
1341 string truncated = rg->name ();
1342 if (truncated.length () > 5) {
1343 truncated = truncated.substr (0, 5);
1345 group_label.set_text (truncated);
1349 group_label.set_text (_("Grp"));
1352 group_label.set_text (_("~G"));
1360 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1362 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1364 if (what_changed == "color") {
1365 if (set_color_from_route () == 0) {
1366 show_route_color ();
1372 MixerStrip::show_route_color ()
1374 name_button.modify_bg (STATE_NORMAL, color());
1375 top_event_box.modify_bg (STATE_NORMAL, color());
1376 route_active_changed ();
1380 MixerStrip::show_passthru_color ()
1382 route_active_changed ();
1386 MixerStrip::build_route_ops_menu ()
1388 using namespace Menu_Helpers;
1389 route_ops_menu = new Menu;
1390 route_ops_menu->set_name ("ArdourContextMenu");
1392 MenuList& items = route_ops_menu->items();
1394 items.push_back (MenuElem (_("Save As Template"), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1395 items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteUI::route_rename)));
1396 rename_menu_item = &items.back();
1397 items.push_back (SeparatorElem());
1398 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
1399 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1400 route_active_menu_item->set_active (_route->active());
1402 items.push_back (SeparatorElem());
1404 items.push_back (MenuElem (_("Adjust latency"), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1406 items.push_back (SeparatorElem());
1407 items.push_back (CheckMenuElem (_("Invert Polarity"), sigc::mem_fun (*this, &RouteUI::toggle_polarity)));
1408 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1409 polarity_menu_item->set_active (_route->phase_invert());
1410 items.push_back (CheckMenuElem (_("Protect against denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1411 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1412 denormal_menu_item->set_active (_route->denormal_protection());
1414 if (!Profile->get_sae()) {
1415 items.push_back (SeparatorElem());
1416 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1419 items.push_back (SeparatorElem());
1420 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
1424 MixerStrip::name_button_button_press (GdkEventButton* ev)
1426 if (ev->button == 1 || ev->button == 3) {
1427 list_route_operations ();
1429 /* do not allow rename if the track is record-enabled */
1430 rename_menu_item->set_sensitive (!_route->record_enabled());
1431 route_ops_menu->popup (1, ev->time);
1437 MixerStrip::list_route_operations ()
1439 if (route_ops_menu == 0) {
1440 build_route_ops_menu ();
1445 MixerStrip::set_selected (bool yn)
1447 AxisView::set_selected (yn);
1449 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1450 global_frame.set_name ("MixerStripSelectedFrame");
1452 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1453 global_frame.set_name ("MixerStripFrame");
1455 global_frame.queue_draw ();
1459 MixerStrip::name_changed ()
1463 RouteUI::name_changed ();
1466 name_label.set_text (PBD::short_version (_route->name(), 5));
1469 if (_route->phase_invert()) {
1470 name_label.set_text (X_("Ø ") + name_label.get_text());
1475 MixerStrip::width_clicked ()
1479 set_width_enum (Narrow, this);
1482 set_width_enum (Wide, this);
1488 MixerStrip::hide_clicked ()
1490 // LAME fix to reset the button status for when it is redisplayed (part 1)
1491 hide_button.set_sensitive(false);
1494 Hiding(); /* EMIT_SIGNAL */
1496 _mixer.hide_strip (this);
1500 hide_button.set_sensitive(true);
1504 MixerStrip::set_embedded (bool yn)
1510 MixerStrip::map_frozen ()
1512 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1514 boost::shared_ptr<AudioTrack> at = audio_track();
1517 switch (at->freeze_state()) {
1518 case AudioTrack::Frozen:
1519 processor_box.set_sensitive (false);
1522 processor_box.set_sensitive (true);
1523 // XXX need some way, maybe, to retoggle redirect editors
1528 hide_redirect_editors ();
1532 MixerStrip::hide_redirect_editors ()
1534 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1538 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1540 boost::shared_ptr<Processor> processor (p.lock ());
1545 void* gui = processor->get_gui ();
1548 static_cast<Gtk::Widget*>(gui)->hide ();
1553 MixerStrip::route_active_changed ()
1555 RouteUI::route_active_changed ();
1556 reset_strip_style ();
1560 MixerStrip::reset_strip_style ()
1562 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1564 gpm.set_fader_name ("SendStripBase");
1568 if (is_midi_track()) {
1569 if (_route->active()) {
1570 set_name ("MidiTrackStripBase");
1571 gpm.set_meter_strip_name ("MidiTrackStripBase");
1573 set_name ("MidiTrackStripBaseInactive");
1574 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1576 gpm.set_fader_name ("MidiTrackFader");
1577 } else if (is_audio_track()) {
1578 if (_route->active()) {
1579 set_name ("AudioTrackStripBase");
1580 gpm.set_meter_strip_name ("AudioTrackMetrics");
1582 set_name ("AudioTrackStripBaseInactive");
1583 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1585 gpm.set_fader_name ("AudioTrackFader");
1587 if (_route->active()) {
1588 set_name ("AudioBusStripBase");
1589 gpm.set_meter_strip_name ("AudioBusMetrics");
1591 set_name ("AudioBusStripBaseInactive");
1592 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1594 gpm.set_fader_name ("AudioBusFader");
1596 /* (no MIDI busses yet) */
1602 MixerStrip::route_group() const
1604 return _route->route_group();
1608 MixerStrip::engine_stopped ()
1613 MixerStrip::engine_running ()
1617 /** Called when the metering point has changed */
1619 MixerStrip::meter_changed (void *src)
1621 ENSURE_GUI_THREAD (*this, &MixerStrip::meter_changed, src)
1623 switch (_route->meter_point()) {
1625 meter_point_label.set_text (_("input"));
1629 meter_point_label.set_text (_("pre"));
1632 case MeterPostFader:
1633 meter_point_label.set_text (_("post"));
1637 meter_point_label.set_text (_("custom"));
1641 gpm.setup_meters ();
1642 // reset peak when meter point changes
1643 gpm.reset_peak_display();
1647 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1649 /* don't respond to switch IO signal outside of the mixer window */
1651 if (!_mixer_owned) {
1655 if (_route == target || _route->is_master()) {
1656 /* don't change the display for the target or the master bus */
1658 } else if (!is_track() && show_sends_button) {
1659 /* make sure our show sends button is inactive, and we no longer blink,
1660 since we're not the target.
1662 send_blink_connection.disconnect ();
1663 show_sends_button->set_active (false);
1664 show_sends_button->set_state (STATE_NORMAL);
1668 /* switch back to default */
1669 revert_to_default_display ();
1673 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1678 revert_to_default_display ();
1683 MixerStrip::drop_send ()
1685 boost::shared_ptr<Send> current_send;
1687 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1688 current_send->set_metering (false);
1691 send_gone_connection.disconnect ();
1692 input_button.set_sensitive (true);
1693 output_button.set_sensitive (true);
1697 MixerStrip::show_send (boost::shared_ptr<Send> send)
1703 _current_delivery = send;
1705 send->set_metering (true);
1706 send_gone_connection = _current_delivery->GoingAway.connect (sigc::mem_fun (*this, &MixerStrip::revert_to_default_display));
1708 gain_meter().set_controls (_route, send->meter(), send->amp());
1709 gain_meter().setup_meters ();
1711 panner_ui().set_panner (_current_delivery->panner());
1712 panner_ui().setup_pan ();
1714 input_button.set_sensitive (false);
1716 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1717 output_button.set_sensitive (false);
1720 reset_strip_style ();
1724 MixerStrip::revert_to_default_display ()
1726 if (show_sends_button) {
1727 show_sends_button->set_active (false);
1732 _current_delivery = _route->main_outs();
1734 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1735 gain_meter().setup_meters ();
1737 panner_ui().set_panner (_route->main_outs()->panner());
1738 panner_ui().setup_pan ();
1740 reset_strip_style ();
1744 MixerStrip::set_button_names ()
1748 rec_enable_button_label.set_text (_("Rec"));
1749 mute_button_label.set_text (_("Mute"));
1750 if (!Config->get_solo_control_is_listen_control()) {
1751 solo_button_label.set_text (_("Solo"));
1753 switch (Config->get_listen_position()) {
1754 case AfterFaderListen:
1755 solo_button_label.set_text (_("AFL"));
1757 case PreFaderListen:
1758 solo_button_label.set_text (_("PFL"));
1765 rec_enable_button_label.set_text (_("R"));
1766 mute_button_label.set_text (_("M"));
1767 if (!Config->get_solo_control_is_listen_control()) {
1768 solo_button_label.set_text (_("S"));
1770 switch (Config->get_listen_position()) {
1771 case AfterFaderListen:
1772 solo_button_label.set_text (_("A"));
1774 case PreFaderListen:
1775 solo_button_label.set_text (_("P"));
1785 MixerStrip::on_key_press_event (GdkEventKey* ev)
1787 GdkEventButton fake;
1788 fake.type = GDK_BUTTON_PRESS;
1790 fake.state = ev->state;
1792 switch (ev->keyval) {
1804 rec_enable_press (&fake);
1809 show_sends_press (&fake);
1814 if (ev->state & Keyboard::PrimaryModifier) {
1824 _route->set_gain (1.0, this);
1837 MixerStrip::on_key_release_event (GdkEventKey* ev)
1839 GdkEventButton fake;
1840 fake.type = GDK_BUTTON_RELEASE;
1842 fake.state = ev->state;
1844 switch (ev->keyval) {
1846 mute_release (&fake);
1851 solo_release (&fake);
1856 rec_enable_release (&fake);
1861 show_sends_release (&fake);
1877 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1879 Keyboard::magic_widget_grab_focus ();
1885 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1887 switch (ev->detail) {
1888 case GDK_NOTIFY_INFERIOR:
1891 Keyboard::magic_widget_drop_focus ();
1898 MixerStrip::mono_button_clicked ()
1900 panners.set_mono (_mono_button.get_active ());
1904 MixerStrip::plugin_selector()
1906 return _mixer.plugin_selector();