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"
66 using namespace ARDOUR;
69 using namespace Gtkmm2ext;
72 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
74 int MixerStrip::scrollbar_height = 0;
75 PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
77 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
81 , _mixer_owned (in_mixer)
82 , processor_box (sess, boost::bind (&MixerStrip::plugin_selector, this), 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 Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Group", 2, 2);
211 group_label.set_name ("MixerGroupButtonLabel");
213 comment_button.set_name ("MixerCommentButton");
215 comment_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::comment_button_clicked));
217 global_vpacker.set_border_width (0);
218 global_vpacker.set_spacing (0);
220 width_button.set_name ("MixerWidthButton");
221 hide_button.set_name ("MixerHideButton");
222 top_event_box.set_name ("MixerTopEventBox");
224 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
225 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
227 width_hide_box.pack_start (width_button, false, true);
228 width_hide_box.pack_start (top_event_box, true, true);
229 width_hide_box.pack_end (hide_button, false, true);
230 gain_meter_alignment.set_padding(0, 4, 0, 0);
231 gain_meter_alignment.add(gpm);
233 whvbox.pack_start (width_hide_box, true, true);
235 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
236 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
237 global_vpacker.pack_start (processor_box, true, true);
238 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
239 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
241 if (!is_midi_track()) {
242 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
244 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
245 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
246 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
248 global_frame.add (global_vpacker);
249 global_frame.set_shadow_type (Gtk::SHADOW_IN);
250 global_frame.set_name ("BaseFrame");
254 /* force setting of visible selected status */
257 set_selected (false);
262 _session->engine().Stopped.connect (*this, boost::bind (&MixerStrip::engine_stopped, this), gui_context());
263 _session->engine().Running.connect (*this, boost::bind (&MixerStrip::engine_running, this), gui_context());
265 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
266 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), 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");
274 /* ditto for this button and busses */
276 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
277 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
281 /* start off as a passthru strip. we'll correct this, if necessary,
282 in update_diskstream_display().
285 /* start off as a passthru strip. we'll correct this, if necessary,
286 in update_diskstream_display().
290 set_name ("MidiTrackStripBase");
292 set_name ("AudioTrackStripBase");
294 add_events (Gdk::BUTTON_RELEASE_MASK|
295 Gdk::ENTER_NOTIFY_MASK|
296 Gdk::LEAVE_NOTIFY_MASK|
298 Gdk::KEY_RELEASE_MASK);
300 set_flags (get_flags() | Gtk::CAN_FOCUS);
302 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
305 MixerStrip::~MixerStrip ()
307 CatchDeletion (this);
309 delete input_selector;
310 delete output_selector;
311 delete comment_window;
315 MixerStrip::set_route (boost::shared_ptr<Route> rt)
317 if (rec_enable_button->get_parent()) {
318 button_table.remove (*rec_enable_button);
321 if (show_sends_button->get_parent()) {
322 button_table.remove (*show_sends_button);
325 RouteUI::set_route (rt);
327 delete input_selector;
330 delete output_selector;
333 revert_to_default_display ();
335 processor_box.set_route (rt);
337 if (set_color_from_route()) {
338 set_color (unique_random_color());
341 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
343 if (scrollbar_height == 0) {
344 HScrollbar scrollbar;
345 Gtk::Requisition requisition(scrollbar.size_request ());
346 scrollbar_height = requisition.height;
349 spacer = manage (new EventBox);
350 spacer->set_size_request (-1, scrollbar_height);
351 global_vpacker.pack_start (*spacer, false, false);
354 if (is_audio_track()) {
356 boost::shared_ptr<AudioTrack> at = audio_track();
358 at->FreezeChange.connect (route_connections, boost::bind (&MixerStrip::map_frozen, this), gui_context());
360 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
361 rec_enable_button->set_sensitive (_session->writable());
362 rec_enable_button->show();
364 } else if (!is_track()) {
367 if (!_route->is_master()) {
368 button_table.attach (*show_sends_button, 0, 2, 2, 3);
369 show_sends_button->show();
373 if (_route->phase_invert()) {
374 name_label.set_text (X_("Ø ") + name_label.get_text());
376 name_label.set_text (_route->name());
379 _mono_button.set_name ("MixerMonoButton");
380 _mono_button.signal_clicked().connect (sigc::mem_fun (*this, &MixerStrip::mono_button_clicked));
382 switch (_route->meter_point()) {
384 meter_point_label.set_text (_("input"));
388 meter_point_label.set_text (_("pre"));
392 meter_point_label.set_text (_("post"));
396 meter_point_label.set_text (_("custom"));
400 delete route_ops_menu;
403 ARDOUR_UI::instance()->set_tip (comment_button, _route->comment().empty() ?
404 _("Click to Add/Edit Comments"):
407 _route->meter_change.connect (route_connections, ui_bind (&MixerStrip::meter_changed, this, _1), gui_context());
408 _route->input()->changed.connect (route_connections, ui_bind (&MixerStrip::input_changed, this, _1, _2), gui_context());
409 _route->output()->changed.connect (route_connections, ui_bind (&MixerStrip::output_changed, this, _1, _2), gui_context());
410 _route->route_group_changed.connect (route_connections, boost::bind (&MixerStrip::route_group_changed, this), gui_context());
412 if (_route->panner()) {
413 _route->panner()->Changed.connect (route_connections, boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
416 if (is_audio_track()) {
417 audio_track()->DiskstreamChanged.connect (route_connections, boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
420 _route->comment_changed.connect (route_connections, ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
421 _route->gui_changed.connect (route_connections, ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
423 set_stuff_from_route ();
425 /* now force an update of all the various elements */
431 route_group_changed ();
435 panners.setup_pan ();
437 update_diskstream_display ();
438 update_input_display ();
439 update_output_display ();
441 add_events (Gdk::BUTTON_RELEASE_MASK);
443 processor_box.show();
445 if (!route()->is_master() && !route()->is_control()) {
446 /* we don't allow master or control routes to be hidden */
451 width_hide_box.show();
454 global_vpacker.show();
456 middle_button_table.show();
457 bottom_button_table.show();
458 processor_box.show_all ();
461 gain_meter_alignment.show ();
462 gain_unit_button.show();
463 gain_unit_label.show();
464 meter_point_button.show();
465 meter_point_label.show();
466 diskstream_button.show();
467 diskstream_label.show();
470 output_button.show();
474 comment_button.show();
482 MixerStrip::set_stuff_from_route ()
488 /* if width is not set, it will be set by the MixerUI or editor */
490 if ((prop = xml_node->property ("strip-width")) != 0) {
491 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
494 if ((prop = xml_node->property ("shown-mixer")) != 0) {
495 if (prop->value() == "no") {
496 _marked_for_display = false;
498 _marked_for_display = true;
501 /* backwards compatibility */
502 _marked_for_display = true;
507 MixerStrip::set_width_enum (Width w, void* owner)
509 /* always set the gpm width again, things may be hidden */
512 panners.set_width (w);
514 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
516 _width_owner = owner;
522 if (_width_owner == this) {
523 xml_node->add_property ("strip-width", enum_2_string (_width));
530 if (show_sends_button) {
531 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
534 if (_route->comment() == "") {
535 comment_button.unset_bg (STATE_NORMAL);
536 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
538 comment_button.modify_bg (STATE_NORMAL, color());
539 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
542 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
543 gpm.astyle_string(gain_automation->automation_style()));
544 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
545 gpm.astate_string(gain_automation->automation_state()));
547 if (_route->panner()) {
548 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
549 panners.astyle_string(_route->panner()->automation_style()));
550 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
551 panners.astate_string(_route->panner()->automation_state()));
554 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
555 set_size_request (-1, -1);
559 if (show_sends_button) {
560 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
563 if (_route->comment() == "") {
564 comment_button.unset_bg (STATE_NORMAL);
565 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
567 comment_button.modify_bg (STATE_NORMAL, color());
568 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
571 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
572 gpm.short_astyle_string(gain_automation->automation_style()));
573 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
574 gpm.short_astate_string(gain_automation->automation_state()));
576 if (_route->panner()) {
577 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
578 panners.short_astyle_string(_route->panner()->automation_style()));
579 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
580 panners.short_astate_string(_route->panner()->automation_state()));
583 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
584 set_size_request (max (50, gpm.get_gm_width()), -1);
588 processor_box.set_width (w);
590 update_input_display ();
591 update_output_display ();
592 route_group_changed ();
598 MixerStrip::set_packed (bool yn)
605 xml_node->add_property ("shown-mixer", "yes");
607 xml_node->add_property ("shown-mixer", "no");
613 MixerStrip::output_press (GdkEventButton *ev)
615 using namespace Menu_Helpers;
616 if (!_session->engine().connected()) {
617 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
622 MenuList& citems = output_menu.items();
623 switch (ev->button) {
626 edit_output_configuration ();
631 output_menu.set_name ("ArdourContextMenu");
633 output_menu_bundles.clear ();
635 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
636 citems.push_back (SeparatorElem());
638 ARDOUR::BundleList current = _route->output()->bundles_connected ();
640 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
642 /* give user bundles first chance at being in the menu */
644 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
645 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
646 maybe_add_bundle_to_output_menu (*i, current);
650 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
651 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
652 maybe_add_bundle_to_output_menu (*i, current);
656 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
657 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
658 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
661 if (citems.size() == 2) {
662 /* no routes added; remove the separator */
666 output_menu.popup (1, ev->time);
677 MixerStrip::edit_output_configuration ()
679 if (output_selector == 0) {
681 boost::shared_ptr<Send> send;
682 boost::shared_ptr<IO> output;
684 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
685 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
686 output = send->output();
688 output = _route->output ();
691 output = _route->output ();
694 output_selector = new IOSelectorWindow (_session, output);
697 if (output_selector->is_visible()) {
698 output_selector->get_toplevel()->get_window()->raise();
700 output_selector->present ();
705 MixerStrip::edit_input_configuration ()
707 if (input_selector == 0) {
708 input_selector = new IOSelectorWindow (_session, _route->input());
711 if (input_selector->is_visible()) {
712 input_selector->get_toplevel()->get_window()->raise();
714 input_selector->present ();
719 MixerStrip::input_press (GdkEventButton *ev)
721 using namespace Menu_Helpers;
723 MenuList& citems = input_menu.items();
724 input_menu.set_name ("ArdourContextMenu");
727 if (!_session->engine().connected()) {
728 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
733 switch (ev->button) {
736 edit_input_configuration ();
741 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
742 citems.push_back (SeparatorElem());
743 input_menu_bundles.clear ();
745 ARDOUR::BundleList current = _route->input()->bundles_connected ();
747 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
749 /* give user bundles first chance at being in the menu */
751 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
752 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
753 maybe_add_bundle_to_input_menu (*i, current);
757 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
758 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
759 maybe_add_bundle_to_input_menu (*i, current);
763 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
764 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
765 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
768 if (citems.size() == 2) {
769 /* no routes added; remove the separator */
773 input_menu.popup (1, ev->time);
783 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
789 ARDOUR::BundleList current = _route->input()->bundles_connected ();
791 if (std::find (current.begin(), current.end(), c) == current.end()) {
792 _route->input()->connect_ports_to_bundle (c, this);
794 _route->input()->disconnect_ports_from_bundle (c, this);
799 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
805 ARDOUR::BundleList current = _route->output()->bundles_connected ();
807 if (std::find (current.begin(), current.end(), c) == current.end()) {
808 _route->output()->connect_ports_to_bundle (c, this);
810 _route->output()->disconnect_ports_from_bundle (c, this);
815 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
817 using namespace Menu_Helpers;
819 if (b->ports_are_outputs() == false ||
820 route()->input()->default_type() != b->type() ||
821 b->nchannels() != _route->n_inputs().get (b->type ())) {
826 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
827 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
831 if (i != input_menu_bundles.end()) {
835 input_menu_bundles.push_back (b);
837 MenuList& citems = input_menu.items();
839 std::string n = b->name ();
840 replace_all (n, "_", " ");
842 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
844 if (std::find (current.begin(), current.end(), b) != current.end()) {
845 ignore_toggle = true;
846 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
847 ignore_toggle = false;
852 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
854 using namespace Menu_Helpers;
856 if (b->ports_are_inputs() == false ||
857 route()->output()->default_type() != b->type() ||
858 b->nchannels() != _route->n_outputs().get (b->type ())) {
863 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
864 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
868 if (i != output_menu_bundles.end()) {
872 output_menu_bundles.push_back (b);
874 MenuList& citems = output_menu.items();
876 std::string n = b->name ();
877 replace_all (n, "_", " ");
879 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
881 if (std::find (current.begin(), current.end(), b) != current.end()) {
882 ignore_toggle = true;
883 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
884 ignore_toggle = false;
889 MixerStrip::update_diskstream_display ()
893 if (input_selector) {
894 input_selector->hide_all ();
901 show_passthru_color ();
906 MixerStrip::connect_to_pan ()
908 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
910 panstate_connection.disconnect ();
911 panstyle_connection.disconnect ();
913 if (!_route->panner()) {
917 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
918 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
919 _route->panner()->control(Evoral::Parameter(PanAutomation)));
922 pan_control->alist()->automation_state_changed.connect (panstate_connection, boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
923 pan_control->alist()->automation_style_changed.connect (panstyle_connection, boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
926 panners.pan_changed (this);
931 * Output port labelling
932 * =====================
934 * Case 1: Each output has one connection, all connections are to system:playback_%i
935 * out 1 -> system:playback_1
936 * out 2 -> system:playback_2
937 * out 3 -> system:playback_3
940 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
941 * out 1 -> ardour:track_x/in 1
942 * out 2 -> ardour:track_x/in 2
943 * Display as: track_x
945 * Case 3: Each output has one connection, all connections are to Jack client "program x"
946 * out 1 -> program x:foo
947 * out 2 -> program x:foo
948 * Display as: program x
950 * Case 4: No connections (Disconnected)
953 * Default case (unusual routing):
954 * Display as: *number of connections*
958 * .-----------------------------------------------.
960 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
961 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
962 * '-----------------------------------------------'
963 * .-----------------------------------------------.
966 * '-----------------------------------------------'
970 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
975 vector<string> port_connections;
977 uint32_t total_connection_count = 0;
978 uint32_t io_connection_count = 0;
979 uint32_t ardour_connection_count = 0;
980 uint32_t system_connection_count = 0;
981 uint32_t other_connection_count = 0;
987 bool have_label = false;
988 bool each_io_has_one_connection = true;
990 string connection_name;
991 string ardour_track_name;
992 string other_connection_type;
996 ostringstream tooltip;
999 tooltip << route->name();
1002 io_count = route->n_inputs().n_total();
1004 io_count = route->n_outputs().n_total();
1007 for (io_index = 0; io_index < io_count; ++io_index) {
1009 port = route->input()->nth (io_index);
1011 port = route->output()->nth (io_index);
1014 port_connections.clear ();
1015 port->get_connections(port_connections);
1016 io_connection_count = 0;
1018 if (!port_connections.empty()) {
1019 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1020 string& connection_name (*i);
1022 if (io_connection_count == 0) {
1023 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1025 tooltip << ", " << connection_name;
1028 if (connection_name.find("ardour:") == 0) {
1029 if (ardour_track_name.empty()) {
1030 // "ardour:Master/in 1" -> "ardour:Master/"
1031 string::size_type slash = connection_name.find("/");
1032 if (slash != string::npos) {
1033 ardour_track_name = connection_name.substr(0, slash + 1);
1037 if (connection_name.find(ardour_track_name) == 0) {
1038 ++ardour_connection_count;
1040 } else if (connection_name.find("system:") == 0) {
1042 // "system:capture_123" -> "123"
1043 system_port = connection_name.substr(15);
1045 // "system:playback_123" -> "123"
1046 system_port = connection_name.substr(16);
1049 if (system_ports.empty()) {
1050 system_ports += system_port;
1052 system_ports += "/" + system_port;
1055 ++system_connection_count;
1057 if (other_connection_type.empty()) {
1058 // "jamin:in 1" -> "jamin:"
1059 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1062 if (connection_name.find(other_connection_type) == 0) {
1063 ++other_connection_count;
1067 ++total_connection_count;
1068 ++io_connection_count;
1072 if (io_connection_count != 1) {
1073 each_io_has_one_connection = false;
1077 if (total_connection_count == 0) {
1078 tooltip << endl << _("Disconnected");
1081 tooltip_cstr = new char[tooltip.str().size() + 1];
1082 strcpy(tooltip_cstr, tooltip.str().c_str());
1085 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1087 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1090 if (each_io_has_one_connection) {
1091 if ((total_connection_count == ardour_connection_count)) {
1092 // all connections are to the same track in ardour
1093 // "ardour:Master/" -> "Master"
1094 string::size_type slash = ardour_track_name.find("/");
1095 if (slash != string::npos) {
1096 label << ardour_track_name.substr(7, slash - 7);
1100 else if (total_connection_count == system_connection_count) {
1101 // all connections are to system ports
1102 label << system_ports;
1105 else if (total_connection_count == other_connection_count) {
1106 // all connections are to the same external program eg jamin
1107 // "jamin:" -> "jamin"
1108 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1114 if (total_connection_count == 0) {
1118 // Odd configuration
1119 label << "*" << total_connection_count << "*";
1125 label_string = label.str().substr(0, 6);
1128 label_string = label.str().substr(0, 3);
1132 label_cstr = new char[label_string.size() + 1];
1133 strcpy(label_cstr, label_string.c_str());
1136 input_label.set_text (label_cstr);
1138 output_label.set_text (label_cstr);
1143 MixerStrip::update_input_display ()
1145 update_io_button (_route, _width, true);
1146 panners.setup_pan ();
1150 MixerStrip::update_output_display ()
1152 update_io_button (_route, _width, false);
1153 gpm.setup_meters ();
1154 panners.setup_pan ();
1158 MixerStrip::fast_update ()
1160 gpm.update_meters ();
1164 MixerStrip::diskstream_changed ()
1166 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&MixerStrip::update_diskstream_display, this));
1170 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1172 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&MixerStrip::update_input_display, this));
1173 set_width_enum (_width, this);
1177 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1179 Gtkmm2ext::UI::instance()->call_slot (boost::bind (&MixerStrip::update_output_display, this));
1180 set_width_enum (_width, this);
1185 MixerStrip::comment_editor_done_editing()
1187 string str = comment_area->get_buffer()->get_text();
1188 if (_route->comment() != str) {
1189 _route->set_comment (str, this);
1194 if (! str.empty()) {
1195 comment_button.modify_bg (STATE_NORMAL, color());
1196 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1198 comment_button.unset_bg (STATE_NORMAL);
1199 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1204 if (! str.empty()) {
1205 comment_button.modify_bg (STATE_NORMAL, color());
1206 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1208 comment_button.unset_bg (STATE_NORMAL);
1209 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1214 ARDOUR_UI::instance()->set_tip (comment_button,
1215 str.empty() ? _("Click to Add/Edit Comments") : str);
1221 MixerStrip::comment_button_clicked ()
1223 if (comment_window == 0) {
1224 setup_comment_editor ();
1227 int x, y, cw_width, cw_height;
1229 if (comment_window->is_visible()) {
1230 comment_window->hide ();
1234 comment_window->get_size (cw_width, cw_height);
1235 comment_window->get_position(x, y);
1236 comment_window->move(x, y - (cw_height / 2) - 45);
1238 half the dialog height minus the comments button height
1239 with some window decoration fudge thrown in.
1242 comment_window->show();
1243 comment_window->present();
1247 MixerStrip::setup_comment_editor ()
1250 title = _route->name();
1251 title += _(": comment editor");
1253 comment_window = new ArdourDialog (title, false);
1254 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1255 comment_window->set_skip_taskbar_hint (true);
1256 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1258 comment_area = manage (new TextView());
1259 comment_area->set_name ("MixerTrackCommentArea");
1260 comment_area->set_size_request (110, 178);
1261 comment_area->set_wrap_mode (WRAP_WORD);
1262 comment_area->set_editable (true);
1263 comment_area->get_buffer()->set_text (_route->comment());
1264 comment_area->show ();
1266 comment_window->get_vbox()->pack_start (*comment_area);
1267 comment_window->get_action_area()->hide();
1271 MixerStrip::comment_changed (void *src)
1273 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1276 ignore_comment_edit = true;
1278 comment_area->get_buffer()->set_text (_route->comment());
1280 ignore_comment_edit = false;
1285 MixerStrip::set_route_group (RouteGroup *rg)
1291 MixerStrip::select_route_group (GdkEventButton *ev)
1293 using namespace Menu_Helpers;
1295 if (ev->button == 1) {
1297 if (group_menu == 0) {
1299 PropertyList* plist = new PropertyList();
1301 plist->add (Properties::gain, true);
1302 plist->add (Properties::mute, true);
1303 plist->add (Properties::solo, true);
1305 group_menu = new RouteGroupMenu (_session, plist);
1306 group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
1309 group_menu->popup (1, ev->time);
1316 MixerStrip::route_group_changed ()
1318 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1320 RouteGroup *rg = _route->route_group();
1323 group_label.set_text (PBD::short_version (rg->name(), 5));
1327 group_label.set_text (_("Grp"));
1330 group_label.set_text (_("~G"));
1338 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1340 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1342 if (what_changed == "color") {
1343 if (set_color_from_route () == 0) {
1344 show_route_color ();
1350 MixerStrip::show_route_color ()
1352 name_button.modify_bg (STATE_NORMAL, color());
1353 top_event_box.modify_bg (STATE_NORMAL, color());
1354 route_active_changed ();
1358 MixerStrip::show_passthru_color ()
1360 route_active_changed ();
1364 MixerStrip::build_route_ops_menu ()
1366 using namespace Menu_Helpers;
1367 route_ops_menu = new Menu;
1368 route_ops_menu->set_name ("ArdourContextMenu");
1370 MenuList& items = route_ops_menu->items();
1372 items.push_back (MenuElem (_("Save As Template"), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1373 items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteUI::route_rename)));
1374 rename_menu_item = &items.back();
1375 items.push_back (SeparatorElem());
1376 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
1377 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1378 route_active_menu_item->set_active (_route->active());
1380 items.push_back (SeparatorElem());
1382 items.push_back (MenuElem (_("Adjust latency"), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1384 items.push_back (SeparatorElem());
1385 items.push_back (CheckMenuElem (_("Invert Polarity"), sigc::mem_fun (*this, &RouteUI::toggle_polarity)));
1386 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1387 polarity_menu_item->set_active (_route->phase_invert());
1388 items.push_back (CheckMenuElem (_("Protect against denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1389 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1390 denormal_menu_item->set_active (_route->denormal_protection());
1392 if (!Profile->get_sae()) {
1393 items.push_back (SeparatorElem());
1394 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1397 items.push_back (SeparatorElem());
1398 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
1402 MixerStrip::name_button_button_press (GdkEventButton* ev)
1404 if (ev->button == 1 || ev->button == 3) {
1405 list_route_operations ();
1407 /* do not allow rename if the track is record-enabled */
1408 rename_menu_item->set_sensitive (!_route->record_enabled());
1409 route_ops_menu->popup (1, ev->time);
1415 MixerStrip::list_route_operations ()
1417 if (route_ops_menu == 0) {
1418 build_route_ops_menu ();
1423 MixerStrip::set_selected (bool yn)
1425 AxisView::set_selected (yn);
1427 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1428 global_frame.set_name ("MixerStripSelectedFrame");
1430 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1431 global_frame.set_name ("MixerStripFrame");
1433 global_frame.queue_draw ();
1437 MixerStrip::name_changed ()
1441 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1444 name_label.set_text (PBD::short_version (_route->name(), 5));
1447 if (_route->phase_invert()) {
1448 name_label.set_text (X_("Ø ") + name_label.get_text());
1453 MixerStrip::width_clicked ()
1457 set_width_enum (Narrow, this);
1460 set_width_enum (Wide, this);
1466 MixerStrip::hide_clicked ()
1468 // LAME fix to reset the button status for when it is redisplayed (part 1)
1469 hide_button.set_sensitive(false);
1472 Hiding(); /* EMIT_SIGNAL */
1474 _mixer.hide_strip (this);
1478 hide_button.set_sensitive(true);
1482 MixerStrip::set_embedded (bool yn)
1488 MixerStrip::map_frozen ()
1490 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1492 boost::shared_ptr<AudioTrack> at = audio_track();
1495 switch (at->freeze_state()) {
1496 case AudioTrack::Frozen:
1497 processor_box.set_sensitive (false);
1500 processor_box.set_sensitive (true);
1501 // XXX need some way, maybe, to retoggle redirect editors
1506 hide_redirect_editors ();
1510 MixerStrip::hide_redirect_editors ()
1512 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1516 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1518 boost::shared_ptr<Processor> processor (p.lock ());
1523 void* gui = processor->get_gui ();
1526 static_cast<Gtk::Widget*>(gui)->hide ();
1531 MixerStrip::route_active_changed ()
1533 RouteUI::route_active_changed ();
1534 reset_strip_style ();
1538 MixerStrip::reset_strip_style ()
1540 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1542 gpm.set_fader_name ("SendStripBase");
1546 if (is_midi_track()) {
1547 if (_route->active()) {
1548 set_name ("MidiTrackStripBase");
1549 gpm.set_meter_strip_name ("MidiTrackStripBase");
1551 set_name ("MidiTrackStripBaseInactive");
1552 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1554 gpm.set_fader_name ("MidiTrackFader");
1555 } else if (is_audio_track()) {
1556 if (_route->active()) {
1557 set_name ("AudioTrackStripBase");
1558 gpm.set_meter_strip_name ("AudioTrackMetrics");
1560 set_name ("AudioTrackStripBaseInactive");
1561 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1563 gpm.set_fader_name ("AudioTrackFader");
1565 if (_route->active()) {
1566 set_name ("AudioBusStripBase");
1567 gpm.set_meter_strip_name ("AudioBusMetrics");
1569 set_name ("AudioBusStripBaseInactive");
1570 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1572 gpm.set_fader_name ("AudioBusFader");
1574 /* (no MIDI busses yet) */
1580 MixerStrip::route_group() const
1582 return _route->route_group();
1586 MixerStrip::engine_stopped ()
1591 MixerStrip::engine_running ()
1595 /** Called when the metering point has changed */
1597 MixerStrip::meter_changed (void *src)
1599 ENSURE_GUI_THREAD (*this, &MixerStrip::meter_changed, src)
1601 switch (_route->meter_point()) {
1603 meter_point_label.set_text (_("input"));
1607 meter_point_label.set_text (_("pre"));
1610 case MeterPostFader:
1611 meter_point_label.set_text (_("post"));
1615 meter_point_label.set_text (_("custom"));
1619 gpm.setup_meters ();
1620 // reset peak when meter point changes
1621 gpm.reset_peak_display();
1625 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1627 /* don't respond to switch IO signal outside of the mixer window */
1629 if (!_mixer_owned) {
1633 if (_route == target || _route->is_master()) {
1634 /* don't change the display for the target or the master bus */
1636 } else if (!is_track() && show_sends_button) {
1637 /* make sure our show sends button is inactive, and we no longer blink,
1638 since we're not the target.
1640 send_blink_connection.disconnect ();
1641 show_sends_button->set_active (false);
1642 show_sends_button->set_state (STATE_NORMAL);
1646 /* switch back to default */
1647 revert_to_default_display ();
1651 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1656 revert_to_default_display ();
1661 MixerStrip::drop_send ()
1663 boost::shared_ptr<Send> current_send;
1665 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1666 current_send->set_metering (false);
1669 send_gone_connection.disconnect ();
1670 input_button.set_sensitive (true);
1671 output_button.set_sensitive (true);
1675 MixerStrip::show_send (boost::shared_ptr<Send> send)
1681 _current_delivery = send;
1683 send->set_metering (true);
1684 _current_delivery->DropReferences.connect (send_gone_connection, boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1686 gain_meter().set_controls (_route, send->meter(), send->amp());
1687 gain_meter().setup_meters ();
1689 panner_ui().set_panner (_current_delivery->panner());
1690 panner_ui().setup_pan ();
1692 input_button.set_sensitive (false);
1694 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1695 output_button.set_sensitive (false);
1698 reset_strip_style ();
1702 MixerStrip::revert_to_default_display ()
1704 if (show_sends_button) {
1705 show_sends_button->set_active (false);
1710 _current_delivery = _route->main_outs();
1712 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1713 gain_meter().setup_meters ();
1715 panner_ui().set_panner (_route->main_outs()->panner());
1716 panner_ui().setup_pan ();
1718 reset_strip_style ();
1722 MixerStrip::set_button_names ()
1726 rec_enable_button_label.set_text (_("Rec"));
1727 mute_button_label.set_text (_("Mute"));
1728 if (!Config->get_solo_control_is_listen_control()) {
1729 solo_button_label.set_text (_("Solo"));
1731 switch (Config->get_listen_position()) {
1732 case AfterFaderListen:
1733 solo_button_label.set_text (_("AFL"));
1735 case PreFaderListen:
1736 solo_button_label.set_text (_("PFL"));
1743 rec_enable_button_label.set_text (_("R"));
1744 mute_button_label.set_text (_("M"));
1745 if (!Config->get_solo_control_is_listen_control()) {
1746 solo_button_label.set_text (_("S"));
1748 switch (Config->get_listen_position()) {
1749 case AfterFaderListen:
1750 solo_button_label.set_text (_("A"));
1752 case PreFaderListen:
1753 solo_button_label.set_text (_("P"));
1763 MixerStrip::on_key_press_event (GdkEventKey* ev)
1765 GdkEventButton fake;
1766 fake.type = GDK_BUTTON_PRESS;
1768 fake.state = ev->state;
1770 switch (ev->keyval) {
1782 rec_enable_press (&fake);
1787 show_sends_press (&fake);
1792 if (ev->state & Keyboard::PrimaryModifier) {
1802 _route->set_gain (1.0, this);
1815 MixerStrip::on_key_release_event (GdkEventKey* ev)
1817 GdkEventButton fake;
1818 fake.type = GDK_BUTTON_RELEASE;
1820 fake.state = ev->state;
1822 switch (ev->keyval) {
1824 mute_release (&fake);
1829 solo_release (&fake);
1834 rec_enable_release (&fake);
1839 show_sends_release (&fake);
1855 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1857 Keyboard::magic_widget_grab_focus ();
1863 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1865 switch (ev->detail) {
1866 case GDK_NOTIFY_INFERIOR:
1869 Keyboard::magic_widget_drop_focus ();
1876 MixerStrip::mono_button_clicked ()
1878 panners.set_mono (_mono_button.get_active ());
1882 MixerStrip::plugin_selector()
1884 return _mixer.plugin_selector();