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");
186 invert_button->set_name ("MixerInvertButton");
188 button_table.set_homogeneous (true);
189 button_table.set_spacings (0);
191 button_table.attach (name_button, 0, 2, 0, 1);
192 button_table.attach (input_button, 0, 2, 1, 2);
193 button_table.attach (*invert_button, 0, 2, 3, 4);
195 middle_button_table.set_homogeneous (true);
196 middle_button_table.set_spacings (0);
197 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
198 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
200 bottom_button_table.set_col_spacings (0);
201 bottom_button_table.set_homogeneous (true);
202 bottom_button_table.attach (group_button, 0, 1, 0, 1);
204 name_button.add (name_label);
205 name_button.set_name ("MixerNameButton");
206 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
208 name_label.set_name ("MixerNameButtonLabel");
209 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
210 group_button.add (group_label);
211 group_button.set_name ("MixerGroupButton");
212 Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Group", 2, 2);
213 group_label.set_name ("MixerGroupButtonLabel");
215 comment_button.set_name ("MixerCommentButton");
217 comment_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::comment_button_clicked));
219 global_vpacker.set_border_width (0);
220 global_vpacker.set_spacing (0);
222 width_button.set_name ("MixerWidthButton");
223 hide_button.set_name ("MixerHideButton");
224 top_event_box.set_name ("MixerTopEventBox");
226 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
227 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
229 width_hide_box.pack_start (width_button, false, true);
230 width_hide_box.pack_start (top_event_box, true, true);
231 width_hide_box.pack_end (hide_button, false, true);
232 gain_meter_alignment.set_padding(0, 4, 0, 0);
233 gain_meter_alignment.add(gpm);
235 whvbox.pack_start (width_hide_box, true, true);
237 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
238 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
239 global_vpacker.pack_start (processor_box, true, true);
240 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
241 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
242 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
243 if (!is_midi_track()) {
244 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
246 global_vpacker.pack_start (_mono_button, Gtk::PACK_SHRINK);
247 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
248 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
250 global_frame.add (global_vpacker);
251 global_frame.set_shadow_type (Gtk::SHADOW_IN);
252 global_frame.set_name ("BaseFrame");
256 /* force setting of visible selected status */
259 set_selected (false);
264 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_stopped, this), gui_context());
265 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_running, this), gui_context());
267 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
268 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
270 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
274 rec_enable_button->set_name ("MixerRecordEnableButton");
276 /* ditto for this button and busses */
278 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
279 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
283 /* start off as a passthru strip. we'll correct this, if necessary,
284 in update_diskstream_display().
287 /* start off as a passthru strip. we'll correct this, if necessary,
288 in update_diskstream_display().
292 set_name ("MidiTrackStripBase");
294 set_name ("AudioTrackStripBase");
296 add_events (Gdk::BUTTON_RELEASE_MASK|
297 Gdk::ENTER_NOTIFY_MASK|
298 Gdk::LEAVE_NOTIFY_MASK|
300 Gdk::KEY_RELEASE_MASK);
302 set_flags (get_flags() | Gtk::CAN_FOCUS);
304 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
307 MixerStrip::~MixerStrip ()
309 CatchDeletion (this);
311 delete input_selector;
312 delete output_selector;
313 delete comment_window;
317 MixerStrip::set_route (boost::shared_ptr<Route> rt)
319 if (rec_enable_button->get_parent()) {
320 button_table.remove (*rec_enable_button);
323 if (show_sends_button->get_parent()) {
324 button_table.remove (*show_sends_button);
327 RouteUI::set_route (rt);
329 delete input_selector;
332 delete output_selector;
335 revert_to_default_display ();
337 processor_box.set_route (rt);
339 if (set_color_from_route()) {
340 set_color (unique_random_color());
343 if (route()->is_master()) {
344 solo_button->hide ();
346 solo_button->show ();
349 if (_mixer_owned && (route()->is_master() || route()->is_monitor())) {
351 if (scrollbar_height == 0) {
352 HScrollbar scrollbar;
353 Gtk::Requisition requisition(scrollbar.size_request ());
354 scrollbar_height = requisition.height;
357 spacer = manage (new EventBox);
358 spacer->set_size_request (-1, scrollbar_height);
359 global_vpacker.pack_start (*spacer, false, false);
362 if (is_audio_track()) {
364 boost::shared_ptr<AudioTrack> at = audio_track();
366 at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context());
368 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
369 rec_enable_button->set_sensitive (_session->writable());
370 rec_enable_button->show();
372 } else if (!is_track()) {
375 if (!_route->is_master()) {
376 button_table.attach (*show_sends_button, 0, 2, 2, 3);
377 show_sends_button->show();
381 invert_button->set_active (_route->phase_invert ());
383 _mono_button.set_name ("MixerMonoButton");
384 _mono_button.signal_clicked().connect (sigc::mem_fun (*this, &MixerStrip::mono_button_clicked));
386 switch (_route->meter_point()) {
388 meter_point_label.set_text (_("input"));
392 meter_point_label.set_text (_("pre"));
396 meter_point_label.set_text (_("post"));
400 meter_point_label.set_text (_("custom"));
404 delete route_ops_menu;
407 ARDOUR_UI::instance()->set_tip (comment_button, _route->comment().empty() ?
408 _("Click to Add/Edit Comments"):
411 _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context());
412 _route->input()->changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::input_changed, this, _1, _2), gui_context());
413 _route->output()->changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::output_changed, this, _1, _2), gui_context());
414 _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
416 if (_route->panner()) {
417 _route->panner()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
420 if (is_audio_track()) {
421 audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
424 _route->comment_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
425 _route->gui_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
427 set_stuff_from_route ();
429 /* now force an update of all the various elements */
435 route_group_changed ();
439 panners.setup_pan ();
441 update_diskstream_display ();
442 update_input_display ();
443 update_output_display ();
445 add_events (Gdk::BUTTON_RELEASE_MASK);
447 processor_box.show();
449 if (!route()->is_master() && !route()->is_monitor()) {
450 /* we don't allow master or control routes to be hidden */
455 width_hide_box.show();
458 global_vpacker.show();
460 middle_button_table.show();
461 bottom_button_table.show();
462 processor_box.show_all ();
465 gain_meter_alignment.show ();
466 gain_unit_button.show();
467 gain_unit_label.show();
468 meter_point_button.show();
469 meter_point_label.show();
470 diskstream_button.show();
471 diskstream_label.show();
474 output_button.show();
478 comment_button.show();
486 MixerStrip::set_stuff_from_route ()
492 /* if width is not set, it will be set by the MixerUI or editor */
494 if ((prop = xml_node->property ("strip-width")) != 0) {
495 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
498 if ((prop = xml_node->property ("shown-mixer")) != 0) {
499 if (prop->value() == "no") {
500 _marked_for_display = false;
502 _marked_for_display = true;
505 /* backwards compatibility */
506 _marked_for_display = true;
511 MixerStrip::set_width_enum (Width w, void* owner)
513 /* always set the gpm width again, things may be hidden */
516 panners.set_width (w);
518 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
520 _width_owner = owner;
526 if (_width_owner == this) {
527 xml_node->add_property ("strip-width", enum_2_string (_width));
534 if (show_sends_button) {
535 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
538 if (_route->comment() == "") {
539 comment_button.unset_bg (STATE_NORMAL);
540 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
542 comment_button.modify_bg (STATE_NORMAL, color());
543 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
546 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
547 gpm.astyle_string(gain_automation->automation_style()));
548 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
549 gpm.astate_string(gain_automation->automation_state()));
551 if (_route->panner()) {
552 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
553 panners.astyle_string(_route->panner()->automation_style()));
554 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
555 panners.astate_string(_route->panner()->automation_state()));
558 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
559 set_size_request (-1, -1);
563 if (show_sends_button) {
564 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
567 if (_route->comment() == "") {
568 comment_button.unset_bg (STATE_NORMAL);
569 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
571 comment_button.modify_bg (STATE_NORMAL, color());
572 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
575 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
576 gpm.short_astyle_string(gain_automation->automation_style()));
577 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
578 gpm.short_astate_string(gain_automation->automation_state()));
580 if (_route->panner()) {
581 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
582 panners.short_astyle_string(_route->panner()->automation_style()));
583 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
584 panners.short_astate_string(_route->panner()->automation_state()));
587 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
588 set_size_request (max (50, gpm.get_gm_width()), -1);
592 processor_box.set_width (w);
594 update_input_display ();
595 update_output_display ();
596 route_group_changed ();
602 MixerStrip::set_packed (bool yn)
609 xml_node->add_property ("shown-mixer", "yes");
611 xml_node->add_property ("shown-mixer", "no");
617 MixerStrip::output_press (GdkEventButton *ev)
619 using namespace Menu_Helpers;
620 if (!_session->engine().connected()) {
621 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
626 MenuList& citems = output_menu.items();
627 switch (ev->button) {
630 edit_output_configuration ();
635 output_menu.set_name ("ArdourContextMenu");
637 output_menu_bundles.clear ();
639 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
640 citems.push_back (SeparatorElem());
642 ARDOUR::BundleList current = _route->output()->bundles_connected ();
644 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
646 /* give user bundles first chance at being in the menu */
648 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
649 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
650 maybe_add_bundle_to_output_menu (*i, current);
654 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
655 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
656 maybe_add_bundle_to_output_menu (*i, current);
660 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
661 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
662 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
665 if (citems.size() == 2) {
666 /* no routes added; remove the separator */
670 output_menu.popup (1, ev->time);
681 MixerStrip::edit_output_configuration ()
683 if (output_selector == 0) {
685 boost::shared_ptr<Send> send;
686 boost::shared_ptr<IO> output;
688 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
689 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
690 output = send->output();
692 output = _route->output ();
695 output = _route->output ();
698 output_selector = new IOSelectorWindow (_session, output);
701 if (output_selector->is_visible()) {
702 output_selector->get_toplevel()->get_window()->raise();
704 output_selector->present ();
709 MixerStrip::edit_input_configuration ()
711 if (input_selector == 0) {
712 input_selector = new IOSelectorWindow (_session, _route->input());
715 if (input_selector->is_visible()) {
716 input_selector->get_toplevel()->get_window()->raise();
718 input_selector->present ();
723 MixerStrip::input_press (GdkEventButton *ev)
725 using namespace Menu_Helpers;
727 MenuList& citems = input_menu.items();
728 input_menu.set_name ("ArdourContextMenu");
731 if (!_session->engine().connected()) {
732 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
737 switch (ev->button) {
740 edit_input_configuration ();
745 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
746 citems.push_back (SeparatorElem());
747 input_menu_bundles.clear ();
749 ARDOUR::BundleList current = _route->input()->bundles_connected ();
751 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
753 /* give user bundles first chance at being in the menu */
755 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
756 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
757 maybe_add_bundle_to_input_menu (*i, current);
761 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
762 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
763 maybe_add_bundle_to_input_menu (*i, current);
767 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
768 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
769 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
772 if (citems.size() == 2) {
773 /* no routes added; remove the separator */
777 input_menu.popup (1, ev->time);
787 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
793 ARDOUR::BundleList current = _route->input()->bundles_connected ();
795 if (std::find (current.begin(), current.end(), c) == current.end()) {
796 _route->input()->connect_ports_to_bundle (c, this);
798 _route->input()->disconnect_ports_from_bundle (c, this);
803 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
809 ARDOUR::BundleList current = _route->output()->bundles_connected ();
811 if (std::find (current.begin(), current.end(), c) == current.end()) {
812 _route->output()->connect_ports_to_bundle (c, this);
814 _route->output()->disconnect_ports_from_bundle (c, this);
819 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
821 using namespace Menu_Helpers;
823 if (b->ports_are_outputs() == false ||
824 route()->input()->default_type() != b->type() ||
825 b->nchannels() != _route->n_inputs().get (b->type ())) {
830 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
831 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
835 if (i != input_menu_bundles.end()) {
839 input_menu_bundles.push_back (b);
841 MenuList& citems = input_menu.items();
843 std::string n = b->name ();
844 replace_all (n, "_", " ");
846 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
848 if (std::find (current.begin(), current.end(), b) != current.end()) {
849 ignore_toggle = true;
850 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
851 ignore_toggle = false;
856 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
858 using namespace Menu_Helpers;
860 if (b->ports_are_inputs() == false ||
861 route()->output()->default_type() != b->type() ||
862 b->nchannels() != _route->n_outputs().get (b->type ())) {
867 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
868 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
872 if (i != output_menu_bundles.end()) {
876 output_menu_bundles.push_back (b);
878 MenuList& citems = output_menu.items();
880 std::string n = b->name ();
881 replace_all (n, "_", " ");
883 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
885 if (std::find (current.begin(), current.end(), b) != current.end()) {
886 ignore_toggle = true;
887 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
888 ignore_toggle = false;
893 MixerStrip::update_diskstream_display ()
897 if (input_selector) {
898 input_selector->hide_all ();
905 show_passthru_color ();
910 MixerStrip::connect_to_pan ()
912 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
914 panstate_connection.disconnect ();
915 panstyle_connection.disconnect ();
917 if (!_route->panner()) {
921 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
922 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
923 _route->panner()->control(Evoral::Parameter(PanAutomation)));
926 pan_control->alist()->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
927 pan_control->alist()->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
930 panners.pan_changed (this);
935 * Output port labelling
936 * =====================
938 * Case 1: Each output has one connection, all connections are to system:playback_%i
939 * out 1 -> system:playback_1
940 * out 2 -> system:playback_2
941 * out 3 -> system:playback_3
944 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
945 * out 1 -> ardour:track_x/in 1
946 * out 2 -> ardour:track_x/in 2
947 * Display as: track_x
949 * Case 3: Each output has one connection, all connections are to Jack client "program x"
950 * out 1 -> program x:foo
951 * out 2 -> program x:foo
952 * Display as: program x
954 * Case 4: No connections (Disconnected)
957 * Default case (unusual routing):
958 * Display as: *number of connections*
962 * .-----------------------------------------------.
964 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
965 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
966 * '-----------------------------------------------'
967 * .-----------------------------------------------.
970 * '-----------------------------------------------'
974 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
979 vector<string> port_connections;
981 uint32_t total_connection_count = 0;
982 uint32_t io_connection_count = 0;
983 uint32_t ardour_connection_count = 0;
984 uint32_t system_connection_count = 0;
985 uint32_t other_connection_count = 0;
991 bool have_label = false;
992 bool each_io_has_one_connection = true;
994 string connection_name;
995 string ardour_track_name;
996 string other_connection_type;
1000 ostringstream tooltip;
1001 char * tooltip_cstr;
1003 tooltip << route->name();
1006 io_count = route->n_inputs().n_total();
1008 io_count = route->n_outputs().n_total();
1011 for (io_index = 0; io_index < io_count; ++io_index) {
1013 port = route->input()->nth (io_index);
1015 port = route->output()->nth (io_index);
1018 port_connections.clear ();
1019 port->get_connections(port_connections);
1020 io_connection_count = 0;
1022 if (!port_connections.empty()) {
1023 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1024 string& connection_name (*i);
1026 if (io_connection_count == 0) {
1027 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1029 tooltip << ", " << connection_name;
1032 if (connection_name.find("ardour:") == 0) {
1033 if (ardour_track_name.empty()) {
1034 // "ardour:Master/in 1" -> "ardour:Master/"
1035 string::size_type slash = connection_name.find("/");
1036 if (slash != string::npos) {
1037 ardour_track_name = connection_name.substr(0, slash + 1);
1041 if (connection_name.find(ardour_track_name) == 0) {
1042 ++ardour_connection_count;
1044 } else if (connection_name.find("system:") == 0) {
1046 // "system:capture_123" -> "123"
1047 system_port = connection_name.substr(15);
1049 // "system:playback_123" -> "123"
1050 system_port = connection_name.substr(16);
1053 if (system_ports.empty()) {
1054 system_ports += system_port;
1056 system_ports += "/" + system_port;
1059 ++system_connection_count;
1061 if (other_connection_type.empty()) {
1062 // "jamin:in 1" -> "jamin:"
1063 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1066 if (connection_name.find(other_connection_type) == 0) {
1067 ++other_connection_count;
1071 ++total_connection_count;
1072 ++io_connection_count;
1076 if (io_connection_count != 1) {
1077 each_io_has_one_connection = false;
1081 if (total_connection_count == 0) {
1082 tooltip << endl << _("Disconnected");
1085 tooltip_cstr = new char[tooltip.str().size() + 1];
1086 strcpy(tooltip_cstr, tooltip.str().c_str());
1089 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1091 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1094 if (each_io_has_one_connection) {
1095 if ((total_connection_count == ardour_connection_count)) {
1096 // all connections are to the same track in ardour
1097 // "ardour:Master/" -> "Master"
1098 string::size_type slash = ardour_track_name.find("/");
1099 if (slash != string::npos) {
1100 label << ardour_track_name.substr(7, slash - 7);
1104 else if (total_connection_count == system_connection_count) {
1105 // all connections are to system ports
1106 label << system_ports;
1109 else if (total_connection_count == other_connection_count) {
1110 // all connections are to the same external program eg jamin
1111 // "jamin:" -> "jamin"
1112 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1118 if (total_connection_count == 0) {
1122 // Odd configuration
1123 label << "*" << total_connection_count << "*";
1129 label_string = label.str().substr(0, 6);
1132 label_string = label.str().substr(0, 3);
1136 label_cstr = new char[label_string.size() + 1];
1137 strcpy(label_cstr, label_string.c_str());
1140 input_label.set_text (label_cstr);
1142 output_label.set_text (label_cstr);
1147 MixerStrip::update_input_display ()
1149 update_io_button (_route, _width, true);
1150 panners.setup_pan ();
1154 MixerStrip::update_output_display ()
1156 update_io_button (_route, _width, false);
1157 gpm.setup_meters ();
1158 panners.setup_pan ();
1162 MixerStrip::fast_update ()
1164 gpm.update_meters ();
1168 MixerStrip::diskstream_changed ()
1170 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
1174 MixerStrip::input_changed (IOChange /*change*/, void */*src*/)
1176 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_input_display, this));
1177 set_width_enum (_width, this);
1181 MixerStrip::output_changed (IOChange /*change*/, void */*src*/)
1183 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_output_display, this));
1184 set_width_enum (_width, this);
1189 MixerStrip::comment_editor_done_editing()
1191 string str = comment_area->get_buffer()->get_text();
1192 if (_route->comment() != str) {
1193 _route->set_comment (str, this);
1198 if (! str.empty()) {
1199 comment_button.modify_bg (STATE_NORMAL, color());
1200 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
1202 comment_button.unset_bg (STATE_NORMAL);
1203 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
1208 if (! str.empty()) {
1209 comment_button.modify_bg (STATE_NORMAL, color());
1210 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
1212 comment_button.unset_bg (STATE_NORMAL);
1213 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
1218 ARDOUR_UI::instance()->set_tip (comment_button,
1219 str.empty() ? _("Click to Add/Edit Comments") : str);
1225 MixerStrip::comment_button_clicked ()
1227 if (comment_window == 0) {
1228 setup_comment_editor ();
1231 int x, y, cw_width, cw_height;
1233 if (comment_window->is_visible()) {
1234 comment_window->hide ();
1238 comment_window->get_size (cw_width, cw_height);
1239 comment_window->get_position(x, y);
1240 comment_window->move(x, y - (cw_height / 2) - 45);
1242 half the dialog height minus the comments button height
1243 with some window decoration fudge thrown in.
1246 comment_window->show();
1247 comment_window->present();
1251 MixerStrip::setup_comment_editor ()
1254 title = _route->name();
1255 title += _(": comment editor");
1257 comment_window = new ArdourDialog (title, false);
1258 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1259 comment_window->set_skip_taskbar_hint (true);
1260 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1262 comment_area = manage (new TextView());
1263 comment_area->set_name ("MixerTrackCommentArea");
1264 comment_area->set_size_request (110, 178);
1265 comment_area->set_wrap_mode (WRAP_WORD);
1266 comment_area->set_editable (true);
1267 comment_area->get_buffer()->set_text (_route->comment());
1268 comment_area->show ();
1270 comment_window->get_vbox()->pack_start (*comment_area);
1271 comment_window->get_action_area()->hide();
1275 MixerStrip::comment_changed (void *src)
1277 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1280 ignore_comment_edit = true;
1282 comment_area->get_buffer()->set_text (_route->comment());
1284 ignore_comment_edit = false;
1289 MixerStrip::set_route_group (RouteGroup *rg)
1295 MixerStrip::select_route_group (GdkEventButton *ev)
1297 using namespace Menu_Helpers;
1299 if (ev->button == 1) {
1301 if (group_menu == 0) {
1303 PropertyList* plist = new PropertyList();
1305 plist->add (Properties::gain, true);
1306 plist->add (Properties::mute, true);
1307 plist->add (Properties::solo, true);
1309 group_menu = new RouteGroupMenu (_session, plist);
1310 group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
1313 group_menu->popup (1, ev->time);
1320 MixerStrip::route_group_changed ()
1322 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1324 RouteGroup *rg = _route->route_group();
1327 group_label.set_text (PBD::short_version (rg->name(), 5));
1331 group_label.set_text (_("Grp"));
1334 group_label.set_text (_("~G"));
1342 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1344 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1346 if (what_changed == "color") {
1347 if (set_color_from_route () == 0) {
1348 show_route_color ();
1354 MixerStrip::show_route_color ()
1356 name_button.modify_bg (STATE_NORMAL, color());
1357 top_event_box.modify_bg (STATE_NORMAL, color());
1358 route_active_changed ();
1362 MixerStrip::show_passthru_color ()
1364 route_active_changed ();
1368 MixerStrip::build_route_ops_menu ()
1370 using namespace Menu_Helpers;
1371 route_ops_menu = new Menu;
1372 route_ops_menu->set_name ("ArdourContextMenu");
1374 MenuList& items = route_ops_menu->items();
1376 items.push_back (MenuElem (_("Save As Template"), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1377 items.push_back (MenuElem (_("Rename"), sigc::mem_fun(*this, &RouteUI::route_rename)));
1378 rename_menu_item = &items.back();
1379 items.push_back (SeparatorElem());
1380 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
1381 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1382 route_active_menu_item->set_active (_route->active());
1384 items.push_back (SeparatorElem());
1386 items.push_back (MenuElem (_("Adjust latency"), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1388 items.push_back (SeparatorElem());
1389 items.push_back (CheckMenuElem (_("Protect against denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1390 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1391 denormal_menu_item->set_active (_route->denormal_protection());
1393 if (!Profile->get_sae()) {
1394 items.push_back (SeparatorElem());
1395 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1398 items.push_back (SeparatorElem());
1399 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
1403 MixerStrip::name_button_button_press (GdkEventButton* ev)
1405 if (ev->button == 1 || ev->button == 3) {
1406 list_route_operations ();
1408 /* do not allow rename if the track is record-enabled */
1409 rename_menu_item->set_sensitive (!_route->record_enabled());
1410 route_ops_menu->popup (1, ev->time);
1416 MixerStrip::list_route_operations ()
1418 if (route_ops_menu == 0) {
1419 build_route_ops_menu ();
1424 MixerStrip::set_selected (bool yn)
1426 AxisView::set_selected (yn);
1428 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1429 global_frame.set_name ("MixerStripSelectedFrame");
1431 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1432 global_frame.set_name ("MixerStripFrame");
1434 global_frame.queue_draw ();
1438 MixerStrip::name_changed ()
1442 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1445 name_label.set_text (PBD::short_version (_route->name(), 5));
1451 MixerStrip::width_clicked ()
1455 set_width_enum (Narrow, this);
1458 set_width_enum (Wide, this);
1464 MixerStrip::hide_clicked ()
1466 // LAME fix to reset the button status for when it is redisplayed (part 1)
1467 hide_button.set_sensitive(false);
1470 Hiding(); /* EMIT_SIGNAL */
1472 _mixer.hide_strip (this);
1476 hide_button.set_sensitive(true);
1480 MixerStrip::set_embedded (bool yn)
1486 MixerStrip::map_frozen ()
1488 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1490 boost::shared_ptr<AudioTrack> at = audio_track();
1493 switch (at->freeze_state()) {
1494 case AudioTrack::Frozen:
1495 processor_box.set_sensitive (false);
1498 processor_box.set_sensitive (true);
1499 // XXX need some way, maybe, to retoggle redirect editors
1504 hide_redirect_editors ();
1508 MixerStrip::hide_redirect_editors ()
1510 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1514 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1516 boost::shared_ptr<Processor> processor (p.lock ());
1521 void* gui = processor->get_gui ();
1524 static_cast<Gtk::Widget*>(gui)->hide ();
1529 MixerStrip::route_active_changed ()
1531 RouteUI::route_active_changed ();
1532 reset_strip_style ();
1536 MixerStrip::reset_strip_style ()
1538 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1540 gpm.set_fader_name ("SendStripBase");
1544 if (is_midi_track()) {
1545 if (_route->active()) {
1546 set_name ("MidiTrackStripBase");
1547 gpm.set_meter_strip_name ("MidiTrackStripBase");
1549 set_name ("MidiTrackStripBaseInactive");
1550 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1552 gpm.set_fader_name ("MidiTrackFader");
1553 } else if (is_audio_track()) {
1554 if (_route->active()) {
1555 set_name ("AudioTrackStripBase");
1556 gpm.set_meter_strip_name ("AudioTrackMetrics");
1558 set_name ("AudioTrackStripBaseInactive");
1559 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1561 gpm.set_fader_name ("AudioTrackFader");
1563 if (_route->active()) {
1564 set_name ("AudioBusStripBase");
1565 gpm.set_meter_strip_name ("AudioBusMetrics");
1567 set_name ("AudioBusStripBaseInactive");
1568 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1570 gpm.set_fader_name ("AudioBusFader");
1572 /* (no MIDI busses yet) */
1578 MixerStrip::route_group() const
1580 return _route->route_group();
1584 MixerStrip::engine_stopped ()
1589 MixerStrip::engine_running ()
1593 /** Called when the metering point has changed */
1595 MixerStrip::meter_changed ()
1597 ENSURE_GUI_THREAD (*this, &MixerStrip::meter_changed)
1599 switch (_route->meter_point()) {
1601 meter_point_label.set_text (_("input"));
1605 meter_point_label.set_text (_("pre"));
1608 case MeterPostFader:
1609 meter_point_label.set_text (_("post"));
1613 meter_point_label.set_text (_("custom"));
1617 gpm.setup_meters ();
1618 // reset peak when meter point changes
1619 gpm.reset_peak_display();
1623 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1625 /* don't respond to switch IO signal outside of the mixer window */
1627 if (!_mixer_owned) {
1631 if (_route == target || _route->is_master()) {
1632 /* don't change the display for the target or the master bus */
1634 } else if (!is_track() && show_sends_button) {
1635 /* make sure our show sends button is inactive, and we no longer blink,
1636 since we're not the target.
1638 send_blink_connection.disconnect ();
1639 show_sends_button->set_active (false);
1640 show_sends_button->set_state (STATE_NORMAL);
1644 /* switch back to default */
1645 revert_to_default_display ();
1649 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1654 revert_to_default_display ();
1659 MixerStrip::drop_send ()
1661 boost::shared_ptr<Send> current_send;
1663 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1664 current_send->set_metering (false);
1667 send_gone_connection.disconnect ();
1668 input_button.set_sensitive (true);
1669 output_button.set_sensitive (true);
1673 MixerStrip::show_send (boost::shared_ptr<Send> send)
1679 _current_delivery = send;
1681 send->set_metering (true);
1682 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1684 gain_meter().set_controls (_route, send->meter(), send->amp());
1685 gain_meter().setup_meters ();
1687 panner_ui().set_panner (_current_delivery->panner());
1688 panner_ui().setup_pan ();
1690 input_button.set_sensitive (false);
1692 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1693 output_button.set_sensitive (false);
1696 reset_strip_style ();
1700 MixerStrip::revert_to_default_display ()
1702 if (show_sends_button) {
1703 show_sends_button->set_active (false);
1708 _current_delivery = _route->main_outs();
1710 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1711 gain_meter().setup_meters ();
1713 panner_ui().set_panner (_route->main_outs()->panner());
1714 panner_ui().setup_pan ();
1716 reset_strip_style ();
1720 MixerStrip::set_button_names ()
1722 invert_button_label.set_text (X_("Ø"));
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();