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, mx.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"))
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, mx.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"))
129 _marked_for_display = false;
131 ignore_comment_edit = false;
132 ignore_toggle = false;
140 img = manage (new Gtk::Image (::get_icon("strip_width")));
143 width_button.add (*img);
145 img = manage (new Gtk::Image (::get_icon("hide")));
148 hide_button.add (*img);
150 input_label.set_text (_("Input"));
151 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
152 input_button.add (input_label);
153 input_button.set_name ("MixerIOButton");
154 input_label.set_name ("MixerIOButtonLabel");
155 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
157 output_label.set_text (_("Output"));
158 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
159 output_button.add (output_label);
160 output_button.set_name ("MixerIOButton");
161 output_label.set_name ("MixerIOButtonLabel");
162 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
164 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
165 meter_point_button.add (meter_point_label);
166 meter_point_button.set_name ("MixerStripMeterPreButton");
167 meter_point_label.set_name ("MixerStripMeterPreButton");
169 /* TRANSLATORS: this string should be longest of the strings
170 used to describe meter points. In english, it's "input".
172 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
174 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
176 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
177 meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
179 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
181 mute_button->set_name ("MixerMuteButton");
182 solo_button->set_name ("MixerSoloButton");
184 button_table.set_homogeneous (true);
185 button_table.set_spacings (0);
187 button_table.attach (name_button, 0, 2, 0, 1);
188 button_table.attach (input_button, 0, 2, 1, 2);
190 middle_button_table.set_homogeneous (true);
191 middle_button_table.set_spacings (0);
192 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
193 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
195 bottom_button_table.set_col_spacings (0);
196 bottom_button_table.set_homogeneous (true);
197 bottom_button_table.attach (group_button, 0, 1, 0, 1);
199 name_button.add (name_label);
200 name_button.set_name ("MixerNameButton");
201 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
203 name_label.set_name ("MixerNameButtonLabel");
204 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
205 group_button.add (group_label);
206 group_button.set_name ("MixerGroupButton");
207 group_label.set_name ("MixerGroupButtonLabel");
209 comment_button.set_name ("MixerCommentButton");
211 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
213 global_vpacker.set_border_width (0);
214 global_vpacker.set_spacing (0);
216 width_button.set_name ("MixerWidthButton");
217 hide_button.set_name ("MixerHideButton");
218 top_event_box.set_name ("MixerTopEventBox");
220 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
221 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
223 width_hide_box.pack_start (width_button, false, true);
224 width_hide_box.pack_start (top_event_box, true, true);
225 width_hide_box.pack_end (hide_button, false, true);
226 gain_meter_alignment.set_padding(0, 4, 0, 0);
227 gain_meter_alignment.add(gpm);
229 whvbox.pack_start (width_hide_box, true, true);
231 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
232 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
233 global_vpacker.pack_start (processor_box, true, true);
234 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
235 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
236 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
237 if (!is_midi_track()) {
238 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
241 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
242 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
244 global_frame.add (global_vpacker);
245 global_frame.set_shadow_type (Gtk::SHADOW_IN);
246 global_frame.set_name ("BaseFrame");
250 /* force setting of visible selected status */
253 set_selected (false);
258 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
259 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
261 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
262 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
264 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
265 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
266 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
267 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
269 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
273 rec_enable_button->set_name ("MixerRecordEnableButton");
274 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
275 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
277 /* ditto for this button and busses */
279 show_sends_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::show_sends_press), false);
280 show_sends_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::show_sends_release));
282 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
283 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_route_group), false);
287 /* start off as a passthru strip. we'll correct this, if necessary,
288 in update_diskstream_display().
291 /* start off as a passthru strip. we'll correct this, if necessary,
292 in update_diskstream_display().
296 set_name ("MidiTrackStripBase");
298 set_name ("AudioTrackStripBase");
300 add_events (Gdk::BUTTON_RELEASE_MASK|
301 Gdk::ENTER_NOTIFY_MASK|
302 Gdk::LEAVE_NOTIFY_MASK|
304 Gdk::KEY_RELEASE_MASK);
306 set_flags (get_flags() | Gtk::CAN_FOCUS);
308 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
311 MixerStrip::~MixerStrip ()
313 GoingAway(); /* EMIT_SIGNAL */
315 delete input_selector;
316 delete output_selector;
317 delete comment_window;
321 MixerStrip::set_route (boost::shared_ptr<Route> rt)
323 if (rec_enable_button->get_parent()) {
324 button_table.remove (*rec_enable_button);
327 if (show_sends_button->get_parent()) {
328 button_table.remove (*show_sends_button);
331 RouteUI::set_route (rt);
333 delete input_selector;
336 delete output_selector;
339 boost::shared_ptr<Send> send;
341 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
342 send->set_metering (false);
345 _current_delivery = _route->main_outs ();
347 panners.set_panner (rt->main_outs()->panner());
348 gpm.set_controls (rt, rt->shared_peak_meter(), rt->amp());
349 processor_box.set_route (rt);
351 if (set_color_from_route()) {
352 set_color (unique_random_color());
355 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
357 if (scrollbar_height == 0) {
358 HScrollbar scrollbar;
359 Gtk::Requisition requisition(scrollbar.size_request ());
360 scrollbar_height = requisition.height;
363 spacer = manage (new EventBox);
364 spacer->set_size_request (-1, scrollbar_height);
365 global_vpacker.pack_start (*spacer, false, false);
368 if (is_audio_track()) {
370 boost::shared_ptr<AudioTrack> at = audio_track();
372 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
374 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
375 rec_enable_button->set_sensitive (_session.writable());
376 rec_enable_button->show();
378 } else if (!is_track()) {
381 if (!_route->is_master()) {
382 button_table.attach (*show_sends_button, 0, 2, 2, 3);
383 show_sends_button->show();
387 if (_route->phase_invert()) {
388 name_label.set_text (X_("Ø ") + name_label.get_text());
390 name_label.set_text (_route->name());
393 _mono_button.set_name ("MixerMonoButton");
394 _mono_button.signal_clicked().connect (mem_fun (*this, &MixerStrip::mono_button_clicked));
396 switch (_route->meter_point()) {
398 meter_point_label.set_text (_("input"));
402 meter_point_label.set_text (_("pre"));
406 meter_point_label.set_text (_("post"));
410 delete route_ops_menu;
413 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
414 _("Click to Add/Edit Comments"):
417 connections.push_back (_route->meter_change.connect (
418 mem_fun(*this, &MixerStrip::meter_changed)));
419 connections.push_back (_route->input()->changed.connect (
420 mem_fun(*this, &MixerStrip::input_changed)));
421 connections.push_back (_route->output()->changed.connect (
422 mem_fun(*this, &MixerStrip::output_changed)));
423 connections.push_back (_route->route_group_changed.connect (
424 mem_fun(*this, &MixerStrip::route_group_changed)));
426 if (_route->panner()) {
427 connections.push_back (_route->panner()->Changed.connect (
428 mem_fun(*this, &MixerStrip::connect_to_pan)));
431 if (is_audio_track()) {
432 connections.push_back (audio_track()->DiskstreamChanged.connect (
433 mem_fun(*this, &MixerStrip::diskstream_changed)));
436 connections.push_back (_route->NameChanged.connect (
437 mem_fun(*this, &RouteUI::name_changed)));
438 connections.push_back (_route->comment_changed.connect (
439 mem_fun(*this, &MixerStrip::comment_changed)));
440 connections.push_back (_route->gui_changed.connect (
441 mem_fun(*this, &MixerStrip::route_gui_changed)));
443 set_stuff_from_route ();
445 /* now force an update of all the various elements */
447 processor_box.update();
452 route_group_changed (0);
456 panners.setup_pan ();
458 update_diskstream_display ();
459 update_input_display ();
460 update_output_display ();
462 add_events (Gdk::BUTTON_RELEASE_MASK);
464 processor_box.show();
466 if (!route()->is_master() && !route()->is_control()) {
467 /* we don't allow master or control routes to be hidden */
472 width_hide_box.show();
475 global_vpacker.show();
477 middle_button_table.show();
478 bottom_button_table.show();
479 processor_box.show_all ();
482 gain_meter_alignment.show ();
483 gain_unit_button.show();
484 gain_unit_label.show();
485 meter_point_button.show();
486 meter_point_label.show();
487 diskstream_button.show();
488 diskstream_label.show();
491 output_button.show();
495 comment_button.show();
503 MixerStrip::set_stuff_from_route ()
509 /* if width is not set, it will be set by the MixerUI or editor */
511 if ((prop = xml_node->property ("strip-width")) != 0) {
512 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
515 if ((prop = xml_node->property ("shown-mixer")) != 0) {
516 if (prop->value() == "no") {
517 _marked_for_display = false;
519 _marked_for_display = true;
522 /* backwards compatibility */
523 _marked_for_display = true;
528 MixerStrip::set_width_enum (Width w, void* owner)
530 /* always set the gpm width again, things may be hidden */
533 panners.set_width (w);
534 processor_box.set_width (w);
536 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
538 _width_owner = owner;
544 if (_width_owner == this) {
545 xml_node->add_property ("strip-width", enum_2_string (_width));
552 if (show_sends_button) {
553 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
556 if (_route->comment() == "") {
557 comment_button.unset_bg (STATE_NORMAL);
558 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
560 comment_button.modify_bg (STATE_NORMAL, color());
561 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
564 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
565 gpm.astyle_string(gain_automation->automation_style()));
566 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
567 gpm.astate_string(gain_automation->automation_state()));
569 if (_route->panner()) {
570 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
571 panners.astyle_string(_route->panner()->automation_style()));
572 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
573 panners.astate_string(_route->panner()->automation_state()));
576 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
577 set_size_request (-1, -1);
581 if (show_sends_button) {
582 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
585 if (_route->comment() == "") {
586 comment_button.unset_bg (STATE_NORMAL);
587 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
589 comment_button.modify_bg (STATE_NORMAL, color());
590 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
593 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
594 gpm.short_astyle_string(gain_automation->automation_style()));
595 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
596 gpm.short_astate_string(gain_automation->automation_state()));
598 if (_route->panner()) {
599 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
600 panners.short_astyle_string(_route->panner()->automation_style()));
601 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
602 panners.short_astate_string(_route->panner()->automation_state()));
605 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
606 set_size_request (max (50, gpm.get_gm_width()), -1);
609 update_input_display ();
610 update_output_display ();
611 route_group_changed (0);
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");
653 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
654 citems.push_back (SeparatorElem());
656 ARDOUR::BundleList current = _route->output()->bundles_connected ();
658 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
659 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
660 maybe_add_bundle_to_output_menu (*i, current);
663 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
664 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
665 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
668 if (citems.size() == 2) {
669 /* no routes added; remove the separator */
673 output_menu.popup (1, ev->time);
684 MixerStrip::edit_output_configuration ()
686 if (output_selector == 0) {
687 output_selector = new IOSelectorWindow (_session, _route->output());
690 if (output_selector->is_visible()) {
691 output_selector->get_toplevel()->get_window()->raise();
693 output_selector->present ();
698 MixerStrip::edit_input_configuration ()
700 if (input_selector == 0) {
701 input_selector = new IOSelectorWindow (_session, _route->input());
704 if (input_selector->is_visible()) {
705 input_selector->get_toplevel()->get_window()->raise();
707 input_selector->present ();
712 MixerStrip::input_press (GdkEventButton *ev)
714 using namespace Menu_Helpers;
716 MenuList& citems = input_menu.items();
717 input_menu.set_name ("ArdourContextMenu");
720 if (!_session.engine().connected()) {
721 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
726 switch (ev->button) {
729 edit_input_configuration ();
734 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
735 citems.push_back (SeparatorElem());
737 ARDOUR::BundleList current = _route->input()->bundles_connected ();
739 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
740 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
741 maybe_add_bundle_to_input_menu (*i, current);
744 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
745 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
746 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
749 if (citems.size() == 2) {
750 /* no routes added; remove the separator */
754 input_menu.popup (1, ev->time);
764 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
770 ARDOUR::BundleList current = _route->input()->bundles_connected ();
772 if (std::find (current.begin(), current.end(), c) == current.end()) {
773 _route->input()->connect_ports_to_bundle (c, this);
775 _route->input()->disconnect_ports_from_bundle (c, this);
780 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
786 ARDOUR::BundleList current = _route->output()->bundles_connected ();
788 if (std::find (current.begin(), current.end(), c) == current.end()) {
789 _route->output()->connect_ports_to_bundle (c, this);
791 _route->output()->disconnect_ports_from_bundle (c, this);
796 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
798 using namespace Menu_Helpers;
800 if (b->ports_are_outputs() == false ||
801 route()->input()->default_type() != b->type() ||
802 b->nchannels() != _route->n_inputs().get (b->type ())) {
807 MenuList& citems = input_menu.items();
809 std::string n = b->name ();
810 replace_all (n, "_", " ");
812 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
814 if (std::find (current.begin(), current.end(), b) != current.end()) {
815 ignore_toggle = true;
816 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
817 ignore_toggle = false;
822 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
824 using namespace Menu_Helpers;
826 if (b->ports_are_inputs() == false ||
827 route()->output()->default_type() != b->type() ||
828 b->nchannels() != _route->n_outputs().get (b->type ())) {
833 MenuList& citems = output_menu.items();
835 std::string n = b->name ();
836 replace_all (n, "_", " ");
838 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
840 if (std::find (current.begin(), current.end(), b) != current.end()) {
841 ignore_toggle = true;
842 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
843 ignore_toggle = false;
848 MixerStrip::update_diskstream_display ()
852 if (input_selector) {
853 input_selector->hide_all ();
860 show_passthru_color ();
865 MixerStrip::connect_to_pan ()
867 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
869 panstate_connection.disconnect ();
870 panstyle_connection.disconnect ();
872 if (!_route->panner()) {
876 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
877 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
878 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
881 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
882 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
885 panners.pan_changed (this);
890 * Output port labelling
891 * =====================
893 * Case 1: Each output has one connection, all connections are to system:playback_%i
894 * out 1 -> system:playback_1
895 * out 2 -> system:playback_2
896 * out 3 -> system:playback_3
899 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
900 * out 1 -> ardour:track_x/in 1
901 * out 2 -> ardour:track_x/in 2
902 * Display as: track_x
904 * Case 3: Each output has one connection, all connections are to Jack client "program x"
905 * out 1 -> program x:foo
906 * out 2 -> program x:foo
907 * Display as: program x
909 * Case 4: No connections (Disconnected)
912 * Default case (unusual routing):
913 * Display as: *number of connections*
917 * .-----------------------------------------------.
919 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
920 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
921 * '-----------------------------------------------'
922 * .-----------------------------------------------.
925 * '-----------------------------------------------'
929 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
934 vector<string> connections;
936 uint32_t total_connection_count = 0;
937 uint32_t io_connection_count = 0;
938 uint32_t ardour_connection_count = 0;
939 uint32_t system_connection_count = 0;
940 uint32_t other_connection_count = 0;
946 bool have_label = false;
947 bool each_io_has_one_connection = true;
949 string connection_name;
950 string ardour_track_name;
951 string other_connection_type;
955 ostringstream tooltip;
958 tooltip << route->name();
961 io_count = route->n_inputs().n_total();
963 io_count = route->n_outputs().n_total();
966 for (io_index = 0; io_index < io_count; ++io_index) {
968 port = route->input()->nth (io_index);
970 port = route->output()->nth (io_index);
973 connections.clear ();
974 port->get_connections(connections);
975 io_connection_count = 0;
977 if (!connections.empty()) {
978 for (vector<string>::iterator i = connections.begin(); i != connections.end(); ++i) {
979 string& connection_name (*i);
981 if (io_connection_count == 0) {
982 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
984 tooltip << ", " << connection_name;
987 if (connection_name.find("ardour:") == 0) {
988 if (ardour_track_name.empty()) {
989 // "ardour:Master/in 1" -> "ardour:Master/"
990 string::size_type slash = connection_name.find("/");
991 if (slash != string::npos) {
992 ardour_track_name = connection_name.substr(0, slash + 1);
996 if (connection_name.find(ardour_track_name) == 0) {
997 ++ardour_connection_count;
999 } else if (connection_name.find("system:") == 0) {
1001 // "system:capture_123" -> "123"
1002 system_port = connection_name.substr(15);
1004 // "system:playback_123" -> "123"
1005 system_port = connection_name.substr(16);
1008 if (system_ports.empty()) {
1009 system_ports += system_port;
1011 system_ports += "/" + system_port;
1014 ++system_connection_count;
1016 if (other_connection_type.empty()) {
1017 // "jamin:in 1" -> "jamin:"
1018 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1021 if (connection_name.find(other_connection_type) == 0) {
1022 ++other_connection_count;
1026 ++total_connection_count;
1027 ++io_connection_count;
1031 if (io_connection_count != 1) {
1032 each_io_has_one_connection = false;
1036 if (total_connection_count == 0) {
1037 tooltip << endl << _("Disconnected");
1040 tooltip_cstr = new char[tooltip.str().size() + 1];
1041 strcpy(tooltip_cstr, tooltip.str().c_str());
1044 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1046 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1049 if (each_io_has_one_connection) {
1050 if ((total_connection_count == ardour_connection_count)) {
1051 // all connections are to the same track in ardour
1052 // "ardour:Master/" -> "Master"
1053 string::size_type slash = ardour_track_name.find("/");
1054 if (slash != string::npos) {
1055 label << ardour_track_name.substr(7, slash - 7);
1059 else if (total_connection_count == system_connection_count) {
1060 // all connections are to system ports
1061 label << system_ports;
1064 else if (total_connection_count == other_connection_count) {
1065 // all connections are to the same external program eg jamin
1066 // "jamin:" -> "jamin"
1067 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1073 if (total_connection_count == 0) {
1077 // Odd configuration
1078 label << "*" << total_connection_count << "*";
1084 label_string = label.str().substr(0, 6);
1087 label_string = label.str().substr(0, 3);
1091 label_cstr = new char[label_string.size() + 1];
1092 strcpy(label_cstr, label_string.c_str());
1095 input_label.set_text (label_cstr);
1097 output_label.set_text (label_cstr);
1102 MixerStrip::update_input_display ()
1104 update_io_button (_route, _width, true);
1105 panners.setup_pan ();
1109 MixerStrip::update_output_display ()
1111 update_io_button (_route, _width, false);
1112 gpm.setup_meters ();
1113 panners.setup_pan ();
1117 MixerStrip::fast_update ()
1119 gpm.update_meters ();
1123 MixerStrip::diskstream_changed ()
1125 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
1129 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1131 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
1132 set_width_enum (_width, this);
1136 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1138 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
1139 set_width_enum (_width, this);
1144 MixerStrip::comment_editor_done_editing()
1146 string str = comment_area->get_buffer()->get_text();
1147 if (_route->comment() != str) {
1148 _route->set_comment (str, this);
1153 if (! str.empty()) {
1154 comment_button.modify_bg (STATE_NORMAL, color());
1155 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1157 comment_button.unset_bg (STATE_NORMAL);
1158 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1163 if (! str.empty()) {
1164 comment_button.modify_bg (STATE_NORMAL, color());
1165 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1167 comment_button.unset_bg (STATE_NORMAL);
1168 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1173 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
1174 str.empty() ? _("Click to Add/Edit Comments") : str);
1180 MixerStrip::comment_button_clicked ()
1182 if (comment_window == 0) {
1183 setup_comment_editor ();
1186 int x, y, cw_width, cw_height;
1188 if (comment_window->is_visible()) {
1189 comment_window->hide ();
1193 comment_window->get_size (cw_width, cw_height);
1194 comment_window->get_position(x, y);
1195 comment_window->move(x, y - (cw_height / 2) - 45);
1197 half the dialog height minus the comments button height
1198 with some window decoration fudge thrown in.
1201 comment_window->show();
1202 comment_window->present();
1206 MixerStrip::setup_comment_editor ()
1209 title = _route->name();
1210 title += _(": comment editor");
1212 comment_window = new ArdourDialog (title, false);
1213 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1214 comment_window->set_skip_taskbar_hint (true);
1215 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1217 comment_area = manage (new TextView());
1218 comment_area->set_name ("MixerTrackCommentArea");
1219 comment_area->set_size_request (110, 178);
1220 comment_area->set_wrap_mode (WRAP_WORD);
1221 comment_area->set_editable (true);
1222 comment_area->get_buffer()->set_text (_route->comment());
1223 comment_area->show ();
1225 comment_window->get_vbox()->pack_start (*comment_area);
1226 comment_window->get_action_area()->hide();
1230 MixerStrip::comment_changed (void *src)
1232 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1235 ignore_comment_edit = true;
1237 comment_area->get_buffer()->set_text (_route->comment());
1239 ignore_comment_edit = false;
1244 MixerStrip::set_route_group (RouteGroup *rg)
1246 _route->set_route_group (rg, this);
1250 MixerStrip::select_route_group (GdkEventButton *ev)
1252 using namespace Menu_Helpers;
1254 if (ev->button == 1) {
1256 if (group_menu == 0) {
1258 group_menu = new RouteGroupMenu (
1260 (RouteGroup::Property) (RouteGroup::Gain | RouteGroup::Mute | RouteGroup::Solo)
1263 group_menu->GroupSelected.connect (mem_fun (*this, &MixerStrip::set_route_group));
1266 group_menu->popup (1, ev->time);
1273 MixerStrip::route_group_changed (void *ignored)
1275 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_group_changed), ignored));
1277 RouteGroup *rg = _route->route_group();
1280 /* XXX: this needs a better algorithm */
1281 string truncated = rg->name ();
1282 if (truncated.length () > 5) {
1283 truncated = truncated.substr (0, 5);
1285 group_label.set_text (truncated);
1289 group_label.set_text (_("Grp"));
1292 group_label.set_text (_("~G"));
1300 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1302 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1304 if (what_changed == "color") {
1305 if (set_color_from_route () == 0) {
1306 show_route_color ();
1312 MixerStrip::show_route_color ()
1314 name_button.modify_bg (STATE_NORMAL, color());
1315 top_event_box.modify_bg (STATE_NORMAL, color());
1316 route_active_changed ();
1320 MixerStrip::show_passthru_color ()
1322 route_active_changed ();
1326 MixerStrip::build_route_ops_menu ()
1328 using namespace Menu_Helpers;
1329 route_ops_menu = new Menu;
1330 route_ops_menu->set_name ("ArdourContextMenu");
1332 MenuList& items = route_ops_menu->items();
1334 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1335 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1336 rename_menu_item = &items.back();
1337 items.push_back (SeparatorElem());
1338 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1339 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1340 route_active_menu_item->set_active (_route->active());
1342 items.push_back (SeparatorElem());
1344 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1346 items.push_back (SeparatorElem());
1347 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1348 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1349 polarity_menu_item->set_active (_route->phase_invert());
1350 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1351 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1352 denormal_menu_item->set_active (_route->denormal_protection());
1354 if (!Profile->get_sae()) {
1355 items.push_back (SeparatorElem());
1356 items.push_back (MenuElem (_("Remote Control ID..."), mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1359 items.push_back (SeparatorElem());
1360 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1364 MixerStrip::name_button_button_press (GdkEventButton* ev)
1366 if (ev->button == 1 || ev->button == 3) {
1367 list_route_operations ();
1369 /* do not allow rename if the track is record-enabled */
1370 rename_menu_item->set_sensitive (!_route->record_enabled());
1371 route_ops_menu->popup (1, ev->time);
1377 MixerStrip::list_route_operations ()
1379 if (route_ops_menu == 0) {
1380 build_route_ops_menu ();
1385 MixerStrip::set_selected (bool yn)
1387 AxisView::set_selected (yn);
1389 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1390 global_frame.set_name ("MixerStripSelectedFrame");
1392 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1393 global_frame.set_name ("MixerStripFrame");
1395 global_frame.queue_draw ();
1399 MixerStrip::name_changed ()
1403 RouteUI::name_changed ();
1406 name_label.set_text (PBD::short_version (_route->name(), 5));
1409 if (_route->phase_invert()) {
1410 name_label.set_text (X_("Ø ") + name_label.get_text());
1415 MixerStrip::width_clicked ()
1419 set_width_enum (Narrow, this);
1422 set_width_enum (Wide, this);
1428 MixerStrip::hide_clicked ()
1430 // LAME fix to reset the button status for when it is redisplayed (part 1)
1431 hide_button.set_sensitive(false);
1434 Hiding(); /* EMIT_SIGNAL */
1436 _mixer.hide_strip (this);
1440 hide_button.set_sensitive(true);
1444 MixerStrip::set_embedded (bool yn)
1450 MixerStrip::map_frozen ()
1452 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1454 boost::shared_ptr<AudioTrack> at = audio_track();
1457 switch (at->freeze_state()) {
1458 case AudioTrack::Frozen:
1459 processor_box.set_sensitive (false);
1462 processor_box.set_sensitive (true);
1463 // XXX need some way, maybe, to retoggle redirect editors
1468 hide_redirect_editors ();
1472 MixerStrip::hide_redirect_editors ()
1474 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1478 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1480 boost::shared_ptr<Processor> processor (p.lock ());
1485 void* gui = processor->get_gui ();
1488 static_cast<Gtk::Widget*>(gui)->hide ();
1493 MixerStrip::route_active_changed ()
1495 RouteUI::route_active_changed ();
1497 if (is_midi_track()) {
1498 if (_route->active()) {
1499 set_name ("MidiTrackStripBase");
1500 gpm.set_meter_strip_name ("MidiTrackStripBase");
1502 set_name ("MidiTrackStripBaseInactive");
1503 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1505 gpm.set_fader_name ("MidiTrackFader");
1506 } else if (is_audio_track()) {
1507 if (_route->active()) {
1508 set_name ("AudioTrackStripBase");
1509 gpm.set_meter_strip_name ("AudioTrackMetrics");
1511 set_name ("AudioTrackStripBaseInactive");
1512 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1514 gpm.set_fader_name ("AudioTrackFader");
1516 if (_route->active()) {
1517 set_name ("AudioBusStripBase");
1518 gpm.set_meter_strip_name ("AudioBusMetrics");
1520 set_name ("AudioBusStripBaseInactive");
1521 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1523 gpm.set_fader_name ("AudioBusFader");
1525 /* (no MIDI busses yet) */
1530 MixerStrip::route_group() const
1532 return _route->route_group();
1536 MixerStrip::engine_stopped ()
1541 MixerStrip::engine_running ()
1546 MixerStrip::meter_changed (void *src)
1548 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1550 switch (_route->meter_point()) {
1552 meter_point_label.set_text (_("input"));
1556 meter_point_label.set_text (_("pre"));
1559 case MeterPostFader:
1560 meter_point_label.set_text (_("post"));
1564 gpm.setup_meters ();
1565 // reset peak when meter point changes
1566 gpm.reset_peak_display();
1567 set_width_enum (_width, this);
1571 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1573 if (_route == target || _route->is_master()) {
1574 /* don't change the display for the target or the master bus */
1576 } else if (!is_track() && show_sends_button) {
1577 /* make sure our show sends button is inactive, and we no longer blink,
1578 since we're not the target.
1580 send_blink_connection.disconnect ();
1581 show_sends_button->set_active (false);
1582 show_sends_button->set_state (STATE_NORMAL);
1586 /* switch back to default */
1587 revert_to_default_display ();
1591 boost::shared_ptr<Send> send;
1593 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1594 send->set_metering (false);
1597 _current_delivery = _route->internal_send_for (target);
1599 cerr << "internal send from " << _route->name() << " to " << target->name() << " = "
1600 << _current_delivery << endl;
1602 if (_current_delivery) {
1603 send = boost::dynamic_pointer_cast<Send>(_current_delivery);
1604 send->set_metering (true);
1605 _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1606 gain_meter().set_controls (_route, send->meter(), send->amp());
1607 panner_ui().set_panner (_current_delivery->panner());
1610 _current_delivery = _route->main_outs ();
1611 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1612 panner_ui().set_panner (_route->main_outs()->panner());
1615 gain_meter().setup_meters ();
1616 panner_ui().setup_pan ();
1621 MixerStrip::revert_to_default_display ()
1623 show_sends_button->set_active (false);
1625 boost::shared_ptr<Send> send;
1627 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1628 send->set_metering (false);
1631 _current_delivery = _route->main_outs();
1633 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1634 gain_meter().setup_meters ();
1635 panner_ui().set_panner (_route->main_outs()->panner());
1636 panner_ui().setup_pan ();
1640 MixerStrip::set_button_names ()
1644 rec_enable_button_label.set_text (_("Rec"));
1645 mute_button_label.set_text (_("Mute"));
1646 if (!Config->get_solo_control_is_listen_control()) {
1647 solo_button_label.set_text (_("Solo"));
1649 switch (Config->get_listen_position()) {
1650 case AfterFaderListen:
1651 solo_button_label.set_text (_("AFL"));
1653 case PreFaderListen:
1654 solo_button_label.set_text (_("PFL"));
1661 rec_enable_button_label.set_text (_("R"));
1662 mute_button_label.set_text (_("M"));
1663 if (!Config->get_solo_control_is_listen_control()) {
1664 solo_button_label.set_text (_("S"));
1666 switch (Config->get_listen_position()) {
1667 case AfterFaderListen:
1668 solo_button_label.set_text (_("A"));
1670 case PreFaderListen:
1671 solo_button_label.set_text (_("P"));
1681 MixerStrip::on_key_press_event (GdkEventKey* ev)
1683 GdkEventButton fake;
1684 fake.type = GDK_BUTTON_PRESS;
1686 fake.state = ev->state;
1688 switch (ev->keyval) {
1700 rec_enable_press (&fake);
1705 show_sends_press (&fake);
1710 if (ev->state & Keyboard::PrimaryModifier) {
1720 _route->set_gain (1.0, this);
1733 MixerStrip::on_key_release_event (GdkEventKey* ev)
1735 GdkEventButton fake;
1736 fake.type = GDK_BUTTON_RELEASE;
1738 fake.state = ev->state;
1740 switch (ev->keyval) {
1742 mute_release (&fake);
1747 solo_release (&fake);
1752 rec_enable_release (&fake);
1757 show_sends_release (&fake);
1773 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1775 Keyboard::magic_widget_grab_focus ();
1781 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1783 switch (ev->detail) {
1784 case GDK_NOTIFY_INFERIOR:
1787 Keyboard::magic_widget_drop_focus ();
1794 MixerStrip::mono_button_clicked ()
1796 panners.set_mono (_mono_button.get_active ());