2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <sigc++/bind.h>
24 #include "pbd/convert.h"
25 #include "pbd/enumwriter.h"
26 #include "pbd/replace_all.h"
28 #include <gtkmm2ext/gtk_ui.h>
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/choice.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/doi.h>
33 #include <gtkmm2ext/slider_controller.h>
34 #include <gtkmm2ext/bindable_button.h>
36 #include "ardour/ardour.h"
37 #include "ardour/amp.h"
38 #include "ardour/session.h"
39 #include "ardour/audioengine.h"
40 #include "ardour/route.h"
41 #include "ardour/route_group.h"
42 #include "ardour/audio_track.h"
43 #include "ardour/audio_diskstream.h"
44 #include "ardour/panner.h"
45 #include "ardour/send.h"
46 #include "ardour/processor.h"
47 #include "ardour/profile.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/user_bundle.h"
51 #include "ardour_ui.h"
52 #include "ardour_dialog.h"
53 #include "mixer_strip.h"
56 #include "public_editor.h"
58 #include "io_selector.h"
60 #include "gui_thread.h"
61 #include "route_group_menu.h"
66 using namespace ARDOUR;
69 using namespace Gtkmm2ext;
72 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
74 int MixerStrip::scrollbar_height = 0;
76 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
80 , _mixer_owned (in_mixer)
81 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
84 , _mono_button (_("Mono"))
86 , middle_button_table (1, 2)
87 , bottom_button_table (1, 2)
88 , meter_point_label (_("pre"))
89 , comment_button (_("Comments"))
94 /* the editor mixer strip: don't destroy it every time
95 the underlying route goes away.
98 self_destruct = false;
102 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt, bool in_mixer)
106 , _mixer_owned (in_mixer)
107 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
110 , button_table (3, 2)
111 , middle_button_table (1, 2)
112 , bottom_button_table (1, 2)
113 , meter_point_label (_("pre"))
114 , comment_button (_("Comments"))
127 _marked_for_display = false;
129 ignore_comment_edit = false;
130 ignore_toggle = false;
138 img = manage (new Gtk::Image (::get_icon("strip_width")));
141 width_button.add (*img);
143 img = manage (new Gtk::Image (::get_icon("hide")));
146 hide_button.add (*img);
148 input_label.set_text (_("Input"));
149 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
150 input_button.add (input_label);
151 input_button.set_name ("MixerIOButton");
152 input_label.set_name ("MixerIOButtonLabel");
153 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
155 output_label.set_text (_("Output"));
156 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
157 output_button.add (output_label);
158 output_button.set_name ("MixerIOButton");
159 output_label.set_name ("MixerIOButtonLabel");
160 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
162 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
163 meter_point_button.add (meter_point_label);
164 meter_point_button.set_name ("MixerStripMeterPreButton");
165 meter_point_label.set_name ("MixerStripMeterPreButton");
167 /* TRANSLATORS: this string should be longest of the strings
168 used to describe meter points. In english, it's "input".
170 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
172 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
174 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
175 meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
177 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
179 mute_button->set_name ("MixerMuteButton");
180 solo_button->set_name ("MixerSoloButton");
182 button_table.set_homogeneous (true);
183 button_table.set_spacings (0);
185 button_table.attach (name_button, 0, 2, 0, 1);
186 button_table.attach (input_button, 0, 2, 1, 2);
188 middle_button_table.set_homogeneous (true);
189 middle_button_table.set_spacings (0);
190 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
191 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
193 bottom_button_table.set_col_spacings (0);
194 bottom_button_table.set_homogeneous (true);
195 bottom_button_table.attach (group_button, 0, 1, 0, 1);
197 name_button.add (name_label);
198 name_button.set_name ("MixerNameButton");
199 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
201 name_label.set_name ("MixerNameButtonLabel");
202 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
203 group_button.add (group_label);
204 group_button.set_name ("MixerGroupButton");
205 group_label.set_name ("MixerGroupButtonLabel");
207 comment_button.set_name ("MixerCommentButton");
209 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
211 global_vpacker.set_border_width (0);
212 global_vpacker.set_spacing (0);
214 width_button.set_name ("MixerWidthButton");
215 hide_button.set_name ("MixerHideButton");
216 top_event_box.set_name ("MixerTopEventBox");
218 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
219 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
221 width_hide_box.pack_start (width_button, false, true);
222 width_hide_box.pack_start (top_event_box, true, true);
223 width_hide_box.pack_end (hide_button, false, true);
224 gain_meter_alignment.set_padding(0, 4, 0, 0);
225 gain_meter_alignment.add(gpm);
227 whvbox.pack_start (width_hide_box, true, true);
229 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
230 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
231 global_vpacker.pack_start (processor_box, true, true);
232 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
233 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
234 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
235 if (!is_midi_track()) {
236 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
238 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
239 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
242 global_frame.add (global_vpacker);
243 global_frame.set_shadow_type (Gtk::SHADOW_IN);
244 global_frame.set_name ("BaseFrame");
248 /* force setting of visible selected status */
251 set_selected (false);
256 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
257 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
259 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
260 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
262 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
263 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
264 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
265 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
267 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
271 rec_enable_button->set_name ("MixerRecordEnableButton");
272 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
273 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
275 /* ditto for this button and busses */
277 show_sends_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::show_sends_press), false);
278 show_sends_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::show_sends_release));
280 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
281 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_route_group), false);
285 /* start off as a passthru strip. we'll correct this, if necessary,
286 in update_diskstream_display().
289 /* start off as a passthru strip. we'll correct this, if necessary,
290 in update_diskstream_display().
294 set_name ("MidiTrackStripBase");
296 set_name ("AudioTrackStripBase");
298 add_events (Gdk::BUTTON_RELEASE_MASK|
299 Gdk::ENTER_NOTIFY_MASK|
300 Gdk::LEAVE_NOTIFY_MASK|
302 Gdk::KEY_RELEASE_MASK);
304 set_flags (get_flags() | Gtk::CAN_FOCUS);
306 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
309 MixerStrip::~MixerStrip ()
311 GoingAway(); /* EMIT_SIGNAL */
313 delete input_selector;
314 delete output_selector;
315 delete comment_window;
319 MixerStrip::set_route (boost::shared_ptr<Route> rt)
321 if (rec_enable_button->get_parent()) {
322 button_table.remove (*rec_enable_button);
325 if (show_sends_button->get_parent()) {
326 button_table.remove (*show_sends_button);
329 RouteUI::set_route (rt);
331 delete input_selector;
334 delete output_selector;
337 boost::shared_ptr<Send> send;
339 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
340 send->set_metering (false);
343 _current_delivery = _route->main_outs ();
345 panners.set_panner (rt->main_outs()->panner());
346 gpm.set_controls (rt, rt->shared_peak_meter(), rt->amp());
347 processor_box.set_route (rt);
349 if (set_color_from_route()) {
350 set_color (unique_random_color());
353 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
355 if (scrollbar_height == 0) {
356 HScrollbar scrollbar;
357 Gtk::Requisition requisition(scrollbar.size_request ());
358 scrollbar_height = requisition.height;
361 spacer = manage (new EventBox);
362 spacer->set_size_request (-1, scrollbar_height);
363 global_vpacker.pack_start (*spacer, false, false);
366 if (is_audio_track()) {
368 boost::shared_ptr<AudioTrack> at = audio_track();
370 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
372 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
373 rec_enable_button->set_sensitive (_session.writable());
374 rec_enable_button->show();
376 } else if (!is_track()) {
379 if (!_route->is_master()) {
380 button_table.attach (*show_sends_button, 0, 2, 2, 3);
381 show_sends_button->show();
385 if (_route->phase_invert()) {
386 name_label.set_text (X_("Ø ") + name_label.get_text());
388 name_label.set_text (_route->name());
391 _mono_button.set_name ("MixerMonoButton");
392 _mono_button.signal_clicked().connect (mem_fun (*this, &MixerStrip::mono_button_clicked));
394 switch (_route->meter_point()) {
396 meter_point_label.set_text (_("input"));
400 meter_point_label.set_text (_("pre"));
404 meter_point_label.set_text (_("post"));
408 delete route_ops_menu;
411 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
412 _("Click to Add/Edit Comments"):
415 connections.push_back (_route->meter_change.connect (
416 mem_fun(*this, &MixerStrip::meter_changed)));
417 connections.push_back (_route->input()->changed.connect (
418 mem_fun(*this, &MixerStrip::input_changed)));
419 connections.push_back (_route->output()->changed.connect (
420 mem_fun(*this, &MixerStrip::output_changed)));
421 connections.push_back (_route->route_group_changed.connect (
422 mem_fun(*this, &MixerStrip::route_group_changed)));
424 if (_route->panner()) {
425 connections.push_back (_route->panner()->Changed.connect (
426 mem_fun(*this, &MixerStrip::connect_to_pan)));
429 if (is_audio_track()) {
430 connections.push_back (audio_track()->DiskstreamChanged.connect (
431 mem_fun(*this, &MixerStrip::diskstream_changed)));
434 connections.push_back (_route->NameChanged.connect (
435 mem_fun(*this, &RouteUI::name_changed)));
436 connections.push_back (_route->comment_changed.connect (
437 mem_fun(*this, &MixerStrip::comment_changed)));
438 connections.push_back (_route->gui_changed.connect (
439 mem_fun(*this, &MixerStrip::route_gui_changed)));
441 set_stuff_from_route ();
443 /* now force an update of all the various elements */
445 processor_box.update();
450 route_group_changed (0);
454 panners.setup_pan ();
456 update_diskstream_display ();
457 update_input_display ();
458 update_output_display ();
460 add_events (Gdk::BUTTON_RELEASE_MASK);
462 processor_box.show();
464 if (!route()->is_master() && !route()->is_control()) {
465 /* we don't allow master or control routes to be hidden */
470 width_hide_box.show();
473 global_vpacker.show();
475 middle_button_table.show();
476 bottom_button_table.show();
477 processor_box.show_all ();
480 gain_meter_alignment.show ();
481 gain_unit_button.show();
482 gain_unit_label.show();
483 meter_point_button.show();
484 meter_point_label.show();
485 diskstream_button.show();
486 diskstream_label.show();
489 output_button.show();
493 comment_button.show();
501 MixerStrip::set_stuff_from_route ()
507 /* if width is not set, it will be set by the MixerUI or editor */
509 if ((prop = xml_node->property ("strip-width")) != 0) {
510 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
513 if ((prop = xml_node->property ("shown-mixer")) != 0) {
514 if (prop->value() == "no") {
515 _marked_for_display = false;
517 _marked_for_display = true;
520 /* backwards compatibility */
521 _marked_for_display = true;
526 MixerStrip::set_width_enum (Width w, void* owner)
528 /* always set the gpm width again, things may be hidden */
531 panners.set_width (w);
532 processor_box.set_width (w);
534 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
536 _width_owner = owner;
542 if (_width_owner == this) {
543 xml_node->add_property ("strip-width", enum_2_string (_width));
550 if (show_sends_button) {
551 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
554 if (_route->comment() == "") {
555 comment_button.unset_bg (STATE_NORMAL);
556 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
558 comment_button.modify_bg (STATE_NORMAL, color());
559 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
562 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
563 gpm.astyle_string(gain_automation->automation_style()));
564 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
565 gpm.astate_string(gain_automation->automation_state()));
567 if (_route->panner()) {
568 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
569 panners.astyle_string(_route->panner()->automation_style()));
570 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
571 panners.astate_string(_route->panner()->automation_state()));
574 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
575 set_size_request (-1, -1);
579 if (show_sends_button) {
580 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
583 if (_route->comment() == "") {
584 comment_button.unset_bg (STATE_NORMAL);
585 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
587 comment_button.modify_bg (STATE_NORMAL, color());
588 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
591 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
592 gpm.short_astyle_string(gain_automation->automation_style()));
593 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
594 gpm.short_astate_string(gain_automation->automation_state()));
596 if (_route->panner()) {
597 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
598 panners.short_astyle_string(_route->panner()->automation_style()));
599 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
600 panners.short_astate_string(_route->panner()->automation_state()));
603 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
604 set_size_request (max (50, gpm.get_gm_width()), -1);
607 update_input_display ();
608 update_output_display ();
609 route_group_changed (0);
615 MixerStrip::set_packed (bool yn)
622 xml_node->add_property ("shown-mixer", "yes");
624 xml_node->add_property ("shown-mixer", "no");
630 MixerStrip::output_press (GdkEventButton *ev)
632 using namespace Menu_Helpers;
633 if (!_session.engine().connected()) {
634 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
639 MenuList& citems = output_menu.items();
640 switch (ev->button) {
643 edit_output_configuration ();
648 output_menu.set_name ("ArdourContextMenu");
651 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
652 citems.push_back (SeparatorElem());
654 ARDOUR::BundleList current = _route->output()->bundles_connected ();
656 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
657 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
658 maybe_add_bundle_to_output_menu (*i, current);
661 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
662 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
663 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
666 if (citems.size() == 2) {
667 /* no routes added; remove the separator */
671 output_menu.popup (1, ev->time);
682 MixerStrip::edit_output_configuration ()
684 if (output_selector == 0) {
685 output_selector = new IOSelectorWindow (_session, _route->output());
688 if (output_selector->is_visible()) {
689 output_selector->get_toplevel()->get_window()->raise();
691 output_selector->present ();
696 MixerStrip::edit_input_configuration ()
698 if (input_selector == 0) {
699 input_selector = new IOSelectorWindow (_session, _route->input());
702 if (input_selector->is_visible()) {
703 input_selector->get_toplevel()->get_window()->raise();
705 input_selector->present ();
710 MixerStrip::input_press (GdkEventButton *ev)
712 using namespace Menu_Helpers;
714 MenuList& citems = input_menu.items();
715 input_menu.set_name ("ArdourContextMenu");
718 if (!_session.engine().connected()) {
719 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
724 switch (ev->button) {
727 edit_input_configuration ();
732 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
733 citems.push_back (SeparatorElem());
735 ARDOUR::BundleList current = _route->input()->bundles_connected ();
737 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
738 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
739 maybe_add_bundle_to_input_menu (*i, current);
742 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
743 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
744 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
747 if (citems.size() == 2) {
748 /* no routes added; remove the separator */
752 input_menu.popup (1, ev->time);
762 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
768 ARDOUR::BundleList current = _route->input()->bundles_connected ();
770 if (std::find (current.begin(), current.end(), c) == current.end()) {
771 _route->input()->connect_ports_to_bundle (c, this);
773 _route->input()->disconnect_ports_from_bundle (c, this);
778 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
784 ARDOUR::BundleList current = _route->output()->bundles_connected ();
786 if (std::find (current.begin(), current.end(), c) == current.end()) {
787 _route->output()->connect_ports_to_bundle (c, this);
789 _route->output()->disconnect_ports_from_bundle (c, this);
794 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
796 using namespace Menu_Helpers;
798 if (b->ports_are_outputs() == false ||
799 route()->input()->default_type() != b->type() ||
800 b->nchannels() != _route->n_inputs().get (b->type ())) {
805 MenuList& citems = input_menu.items();
807 std::string n = b->name ();
808 replace_all (n, "_", " ");
810 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
812 if (std::find (current.begin(), current.end(), b) != current.end()) {
813 ignore_toggle = true;
814 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
815 ignore_toggle = false;
820 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
822 using namespace Menu_Helpers;
824 if (b->ports_are_inputs() == false ||
825 route()->output()->default_type() != b->type() ||
826 b->nchannels() != _route->n_outputs().get (b->type ())) {
831 MenuList& citems = output_menu.items();
833 std::string n = b->name ();
834 replace_all (n, "_", " ");
836 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
838 if (std::find (current.begin(), current.end(), b) != current.end()) {
839 ignore_toggle = true;
840 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
841 ignore_toggle = false;
846 MixerStrip::update_diskstream_display ()
850 if (input_selector) {
851 input_selector->hide_all ();
858 show_passthru_color ();
863 MixerStrip::connect_to_pan ()
865 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
867 panstate_connection.disconnect ();
868 panstyle_connection.disconnect ();
870 if (!_route->panner()) {
874 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
875 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
876 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
879 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
880 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
883 panners.pan_changed (this);
888 * Output port labelling
889 * =====================
891 * Case 1: Each output has one connection, all connections are to system:playback_%i
892 * out 1 -> system:playback_1
893 * out 2 -> system:playback_2
894 * out 3 -> system:playback_3
897 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
898 * out 1 -> ardour:track_x/in 1
899 * out 2 -> ardour:track_x/in 2
900 * Display as: track_x
902 * Case 3: Each output has one connection, all connections are to Jack client "program x"
903 * out 1 -> program x:foo
904 * out 2 -> program x:foo
905 * Display as: program x
907 * Case 4: No connections (Disconnected)
910 * Default case (unusual routing):
911 * Display as: *number of connections*
915 * .-----------------------------------------------.
917 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
918 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
919 * '-----------------------------------------------'
920 * .-----------------------------------------------.
923 * '-----------------------------------------------'
927 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
932 vector<string> connections;
934 uint32_t total_connection_count = 0;
935 uint32_t io_connection_count = 0;
936 uint32_t ardour_connection_count = 0;
937 uint32_t system_connection_count = 0;
938 uint32_t other_connection_count = 0;
944 bool have_label = false;
945 bool each_io_has_one_connection = true;
947 string connection_name;
948 string ardour_track_name;
949 string other_connection_type;
953 ostringstream tooltip;
956 tooltip << route->name();
959 io_count = route->n_inputs().n_total();
961 io_count = route->n_outputs().n_total();
964 for (io_index = 0; io_index < io_count; ++io_index) {
966 port = route->input()->nth (io_index);
968 port = route->output()->nth (io_index);
971 connections.clear ();
972 port->get_connections(connections);
973 io_connection_count = 0;
975 if (!connections.empty()) {
976 for (vector<string>::iterator i = connections.begin(); i != connections.end(); ++i) {
977 string& connection_name (*i);
979 if (io_connection_count == 0) {
980 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
982 tooltip << ", " << connection_name;
985 if (connection_name.find("ardour:") == 0) {
986 if (ardour_track_name.empty()) {
987 // "ardour:Master/in 1" -> "ardour:Master/"
988 string::size_type slash = connection_name.find("/");
989 if (slash != string::npos) {
990 ardour_track_name = connection_name.substr(0, slash + 1);
994 if (connection_name.find(ardour_track_name) == 0) {
995 ++ardour_connection_count;
997 } else if (connection_name.find("system:") == 0) {
999 // "system:capture_123" -> "123"
1000 system_port = connection_name.substr(15);
1002 // "system:playback_123" -> "123"
1003 system_port = connection_name.substr(16);
1006 if (system_ports.empty()) {
1007 system_ports += system_port;
1009 system_ports += "/" + system_port;
1012 ++system_connection_count;
1014 if (other_connection_type.empty()) {
1015 // "jamin:in 1" -> "jamin:"
1016 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1019 if (connection_name.find(other_connection_type) == 0) {
1020 ++other_connection_count;
1024 ++total_connection_count;
1025 ++io_connection_count;
1029 if (io_connection_count != 1) {
1030 each_io_has_one_connection = false;
1034 if (total_connection_count == 0) {
1035 tooltip << endl << _("Disconnected");
1038 tooltip_cstr = new char[tooltip.str().size() + 1];
1039 strcpy(tooltip_cstr, tooltip.str().c_str());
1042 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1044 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1047 if (each_io_has_one_connection) {
1048 if ((total_connection_count == ardour_connection_count)) {
1049 // all connections are to the same track in ardour
1050 // "ardour:Master/" -> "Master"
1051 string::size_type slash = ardour_track_name.find("/");
1052 if (slash != string::npos) {
1053 label << ardour_track_name.substr(7, slash - 7);
1057 else if (total_connection_count == system_connection_count) {
1058 // all connections are to system ports
1059 label << system_ports;
1062 else if (total_connection_count == other_connection_count) {
1063 // all connections are to the same external program eg jamin
1064 // "jamin:" -> "jamin"
1065 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1071 if (total_connection_count == 0) {
1075 // Odd configuration
1076 label << "*" << total_connection_count << "*";
1082 label_string = label.str().substr(0, 6);
1085 label_string = label.str().substr(0, 3);
1089 label_cstr = new char[label_string.size() + 1];
1090 strcpy(label_cstr, label_string.c_str());
1093 input_label.set_text (label_cstr);
1095 output_label.set_text (label_cstr);
1100 MixerStrip::update_input_display ()
1102 update_io_button (_route, _width, true);
1103 panners.setup_pan ();
1107 MixerStrip::update_output_display ()
1109 update_io_button (_route, _width, false);
1110 gpm.setup_meters ();
1111 panners.setup_pan ();
1115 MixerStrip::fast_update ()
1117 gpm.update_meters ();
1121 MixerStrip::diskstream_changed ()
1123 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
1127 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1129 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1130 set_width_enum (_width, this);
1134 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1136 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1137 set_width_enum (_width, this);
1142 MixerStrip::comment_editor_done_editing()
1144 string str = comment_area->get_buffer()->get_text();
1145 if (_route->comment() != str) {
1146 _route->set_comment (str, this);
1151 if (! str.empty()) {
1152 comment_button.modify_bg (STATE_NORMAL, color());
1153 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1155 comment_button.unset_bg (STATE_NORMAL);
1156 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1161 if (! str.empty()) {
1162 comment_button.modify_bg (STATE_NORMAL, color());
1163 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1165 comment_button.unset_bg (STATE_NORMAL);
1166 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1171 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1172 str.empty() ? _("Click to Add/Edit Comments") : str);
1178 MixerStrip::comment_button_clicked ()
1180 if (comment_window == 0) {
1181 setup_comment_editor ();
1184 int x, y, cw_width, cw_height;
1186 if (comment_window->is_visible()) {
1187 comment_window->hide ();
1191 comment_window->get_size (cw_width, cw_height);
1192 comment_window->get_position(x, y);
1193 comment_window->move(x, y - (cw_height / 2) - 45);
1195 half the dialog height minus the comments button height
1196 with some window decoration fudge thrown in.
1199 comment_window->show();
1200 comment_window->present();
1204 MixerStrip::setup_comment_editor ()
1207 title = _route->name();
1208 title += _(": comment editor");
1210 comment_window = new ArdourDialog (title, false);
1211 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1212 comment_window->set_skip_taskbar_hint (true);
1213 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1215 comment_area = manage (new TextView());
1216 comment_area->set_name ("MixerTrackCommentArea");
1217 comment_area->set_size_request (110, 178);
1218 comment_area->set_wrap_mode (WRAP_WORD);
1219 comment_area->set_editable (true);
1220 comment_area->get_buffer()->set_text (_route->comment());
1221 comment_area->show ();
1223 comment_window->get_vbox()->pack_start (*comment_area);
1224 comment_window->get_action_area()->hide();
1228 MixerStrip::comment_changed (void *src)
1230 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1233 ignore_comment_edit = true;
1235 comment_area->get_buffer()->set_text (_route->comment());
1237 ignore_comment_edit = false;
1242 MixerStrip::set_route_group (RouteGroup *rg)
1244 _route->set_route_group (rg, this);
1248 MixerStrip::select_route_group (GdkEventButton *ev)
1250 using namespace Menu_Helpers;
1252 if (ev->button == 1) {
1254 if (group_menu == 0) {
1256 group_menu = new RouteGroupMenu (
1258 (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo)
1261 group_menu->GroupSelected.connect (mem_fun (*this, &MixerStrip::set_route_group));
1264 group_menu->popup (1, ev->time);
1271 MixerStrip::route_group_changed (void *ignored)
1273 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_group_changed), ignored));
1275 RouteGroup *rg = _route->route_group();
1278 /* XXX: this needs a better algorithm */
1279 string truncated = rg->name ();
1280 if (truncated.length () > 5) {
1281 truncated = truncated.substr (0, 5);
1283 group_label.set_text (truncated);
1287 group_label.set_text (_("Grp"));
1290 group_label.set_text (_("~G"));
1298 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1300 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1302 if (what_changed == "color") {
1303 if (set_color_from_route () == 0) {
1304 show_route_color ();
1310 MixerStrip::show_route_color ()
1312 name_button.modify_bg (STATE_NORMAL, color());
1313 top_event_box.modify_bg (STATE_NORMAL, color());
1314 route_active_changed ();
1318 MixerStrip::show_passthru_color ()
1320 route_active_changed ();
1324 MixerStrip::build_route_ops_menu ()
1326 using namespace Menu_Helpers;
1327 route_ops_menu = new Menu;
1328 route_ops_menu->set_name ("ArdourContextMenu");
1330 MenuList& items = route_ops_menu->items();
1332 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1333 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1334 rename_menu_item = &items.back();
1335 items.push_back (SeparatorElem());
1336 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1337 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1338 route_active_menu_item->set_active (_route->active());
1340 items.push_back (SeparatorElem());
1342 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1344 items.push_back (SeparatorElem());
1345 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1346 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1347 polarity_menu_item->set_active (_route->phase_invert());
1348 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1349 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1350 denormal_menu_item->set_active (_route->denormal_protection());
1352 if (!Profile->get_sae()) {
1353 items.push_back (SeparatorElem());
1354 items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1357 items.push_back (SeparatorElem());
1358 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1362 MixerStrip::name_button_button_press (GdkEventButton* ev)
1364 if (ev->button == 1 || ev->button == 3) {
1365 list_route_operations ();
1367 /* do not allow rename if the track is record-enabled */
1368 rename_menu_item->set_sensitive (!_route->record_enabled());
1369 route_ops_menu->popup (1, ev->time);
1375 MixerStrip::list_route_operations ()
1377 if (route_ops_menu == 0) {
1378 build_route_ops_menu ();
1383 MixerStrip::set_selected (bool yn)
1385 AxisView::set_selected (yn);
1387 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1388 global_frame.set_name ("MixerStripSelectedFrame");
1390 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1391 global_frame.set_name ("MixerStripFrame");
1393 global_frame.queue_draw ();
1397 MixerStrip::name_changed ()
1401 RouteUI::name_changed ();
1404 name_label.set_text (PBD::short_version (_route->name(), 5));
1407 if (_route->phase_invert()) {
1408 name_label.set_text (X_("Ø ") + name_label.get_text());
1413 MixerStrip::width_clicked ()
1417 set_width_enum (Narrow, this);
1420 set_width_enum (Wide, this);
1426 MixerStrip::hide_clicked ()
1428 // LAME fix to reset the button status for when it is redisplayed (part 1)
1429 hide_button.set_sensitive(false);
1432 Hiding(); /* EMIT_SIGNAL */
1434 _mixer.hide_strip (this);
1438 hide_button.set_sensitive(true);
1442 MixerStrip::set_embedded (bool yn)
1448 MixerStrip::map_frozen ()
1450 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1452 boost::shared_ptr<AudioTrack> at = audio_track();
1455 switch (at->freeze_state()) {
1456 case AudioTrack::Frozen:
1457 processor_box.set_sensitive (false);
1460 processor_box.set_sensitive (true);
1461 // XXX need some way, maybe, to retoggle redirect editors
1466 hide_redirect_editors ();
1470 MixerStrip::hide_redirect_editors ()
1472 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1476 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1478 boost::shared_ptr<Processor> processor (p.lock ());
1483 void* gui = processor->get_gui ();
1486 static_cast<Gtk::Widget*>(gui)->hide ();
1491 MixerStrip::route_active_changed ()
1493 RouteUI::route_active_changed ();
1495 if (is_midi_track()) {
1496 if (_route->active()) {
1497 set_name ("MidiTrackStripBase");
1498 gpm.set_meter_strip_name ("MidiTrackStripBase");
1500 set_name ("MidiTrackStripBaseInactive");
1501 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1503 gpm.set_fader_name ("MidiTrackFader");
1504 } else if (is_audio_track()) {
1505 if (_route->active()) {
1506 set_name ("AudioTrackStripBase");
1507 gpm.set_meter_strip_name ("AudioTrackMetrics");
1509 set_name ("AudioTrackStripBaseInactive");
1510 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1512 gpm.set_fader_name ("AudioTrackFader");
1514 if (_route->active()) {
1515 set_name ("AudioBusStripBase");
1516 gpm.set_meter_strip_name ("AudioBusMetrics");
1518 set_name ("AudioBusStripBaseInactive");
1519 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1521 gpm.set_fader_name ("AudioBusFader");
1523 /* (no MIDI busses yet) */
1528 MixerStrip::route_group() const
1530 return _route->route_group();
1534 MixerStrip::engine_stopped ()
1539 MixerStrip::engine_running ()
1544 MixerStrip::meter_changed (void *src)
1546 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1548 switch (_route->meter_point()) {
1550 meter_point_label.set_text (_("input"));
1554 meter_point_label.set_text (_("pre"));
1557 case MeterPostFader:
1558 meter_point_label.set_text (_("post"));
1562 gpm.setup_meters ();
1563 // reset peak when meter point changes
1564 gpm.reset_peak_display();
1565 set_width_enum (_width, this);
1569 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1571 if (_route == target || _route->is_master()) {
1572 /* don't change the display for the target or the master bus */
1574 } else if (!is_track() && show_sends_button) {
1575 /* make sure our show sends button is inactive, and we no longer blink,
1576 since we're not the target.
1578 send_blink_connection.disconnect ();
1579 show_sends_button->set_active (false);
1580 show_sends_button->set_state (STATE_NORMAL);
1584 /* switch back to default */
1585 revert_to_default_display ();
1589 boost::shared_ptr<Send> send;
1591 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1592 send->set_metering (false);
1595 _current_delivery = _route->internal_send_for (target);
1597 cerr << "internal send from " << _route->name() << " to " << target->name() << " = "
1598 << _current_delivery << endl;
1600 if (_current_delivery) {
1601 send = boost::dynamic_pointer_cast<Send>(_current_delivery);
1602 send->set_metering (true);
1603 _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1604 gain_meter().set_controls (_route, send->meter(), send->amp());
1605 panner_ui().set_panner (_current_delivery->panner());
1608 _current_delivery = _route->main_outs ();
1609 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1610 panner_ui().set_panner (_route->main_outs()->panner());
1613 gain_meter().setup_meters ();
1614 panner_ui().setup_pan ();
1619 MixerStrip::revert_to_default_display ()
1621 show_sends_button->set_active (false);
1623 boost::shared_ptr<Send> send;
1625 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1626 send->set_metering (false);
1629 _current_delivery = _route->main_outs();
1631 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1632 gain_meter().setup_meters ();
1633 panner_ui().set_panner (_route->main_outs()->panner());
1634 panner_ui().setup_pan ();
1638 MixerStrip::set_button_names ()
1642 rec_enable_button_label.set_text (_("Rec"));
1643 mute_button_label.set_text (_("Mute"));
1644 if (!Config->get_solo_control_is_listen_control()) {
1645 solo_button_label.set_text (_("Solo"));
1647 switch (Config->get_listen_position()) {
1648 case AfterFaderListen:
1649 solo_button_label.set_text (_("AFL"));
1651 case PreFaderListen:
1652 solo_button_label.set_text (_("PFL"));
1659 rec_enable_button_label.set_text (_("R"));
1660 mute_button_label.set_text (_("M"));
1661 if (!Config->get_solo_control_is_listen_control()) {
1662 solo_button_label.set_text (_("S"));
1664 switch (Config->get_listen_position()) {
1665 case AfterFaderListen:
1666 solo_button_label.set_text (_("A"));
1668 case PreFaderListen:
1669 solo_button_label.set_text (_("P"));
1679 MixerStrip::on_key_press_event (GdkEventKey* ev)
1681 GdkEventButton fake;
1682 fake.type = GDK_BUTTON_PRESS;
1684 fake.state = ev->state;
1686 switch (ev->keyval) {
1698 rec_enable_press (&fake);
1703 show_sends_press (&fake);
1708 if (ev->state & Keyboard::PrimaryModifier) {
1718 _route->set_gain (1.0, this);
1731 MixerStrip::on_key_release_event (GdkEventKey* ev)
1733 GdkEventButton fake;
1734 fake.type = GDK_BUTTON_RELEASE;
1736 fake.state = ev->state;
1738 switch (ev->keyval) {
1740 mute_release (&fake);
1745 solo_release (&fake);
1750 rec_enable_release (&fake);
1755 show_sends_release (&fake);
1771 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1773 Keyboard::magic_widget_grab_focus ();
1779 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1781 switch (ev->detail) {
1782 case GDK_NOTIFY_INFERIOR:
1785 Keyboard::magic_widget_drop_focus ();
1792 MixerStrip::mono_button_clicked ()
1794 panners.set_mono (_mono_button.get_active ());
1798 MixerStrip::plugin_selector()
1800 return _mixer.plugin_selector();