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"
65 using namespace ARDOUR;
68 using namespace Gtkmm2ext;
71 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
73 int MixerStrip::scrollbar_height = 0;
75 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
77 , RouteUI (sess, _("Mute"), _("Solo"), _("Record"))
79 , _mixer_owned (in_mixer)
80 , pre_processor_box (PreFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
81 , post_processor_box (PostFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
85 , middle_button_table (1, 2)
86 , bottom_button_table (1, 2)
87 , meter_point_label (_("pre"))
88 , 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)
104 , RouteUI (sess, _("Mute"), _("Solo"), _("Record"))
106 , _mixer_owned (in_mixer)
107 , pre_processor_box (PreFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
108 , post_processor_box (PostFader, 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"))
128 _marked_for_display = false;
130 ignore_comment_edit = false;
131 ignore_toggle = false;
139 img = manage (new Gtk::Image (::get_icon("strip_width")));
142 width_button.add (*img);
144 img = manage (new Gtk::Image (::get_icon("hide")));
147 hide_button.add (*img);
149 input_label.set_text (_("Input"));
150 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
151 input_button.add (input_label);
152 input_button.set_name ("MixerIOButton");
153 input_label.set_name ("MixerIOButtonLabel");
154 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
156 output_label.set_text (_("Output"));
157 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
158 output_button.add (output_label);
159 output_button.set_name ("MixerIOButton");
160 output_label.set_name ("MixerIOButtonLabel");
161 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
163 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
164 meter_point_button.add (meter_point_label);
165 meter_point_button.set_name ("MixerStripMeterPreButton");
166 meter_point_label.set_name ("MixerStripMeterPreButton");
168 /* TRANSLATORS: this string should be longest of the strings
169 used to describe meter points. In english, it's "input".
171 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
173 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
175 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
176 meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
178 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
180 mute_button->set_name ("MixerMuteButton");
181 solo_button->set_name ("MixerSoloButton");
183 button_table.set_homogeneous (true);
184 button_table.set_spacings (0);
186 button_table.attach (name_button, 0, 2, 0, 1);
187 button_table.attach (input_button, 0, 2, 1, 2);
189 middle_button_table.set_homogeneous (true);
190 middle_button_table.set_spacings (0);
191 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
192 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
194 bottom_button_table.set_col_spacings (0);
195 bottom_button_table.set_homogeneous (true);
196 bottom_button_table.attach (group_button, 0, 1, 0, 1);
198 name_button.add (name_label);
199 name_button.set_name ("MixerNameButton");
200 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
202 name_label.set_name ("MixerNameButtonLabel");
203 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
204 group_button.add (group_label);
205 group_button.set_name ("MixerGroupButton");
206 group_label.set_name ("MixerGroupButtonLabel");
208 comment_button.set_name ("MixerCommentButton");
210 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
212 global_vpacker.set_border_width (0);
213 global_vpacker.set_spacing (0);
215 width_button.set_name ("MixerWidthButton");
216 hide_button.set_name ("MixerHideButton");
217 top_event_box.set_name ("MixerTopEventBox");
219 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
220 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
222 width_hide_box.pack_start (width_button, false, true);
223 width_hide_box.pack_start (top_event_box, true, true);
224 width_hide_box.pack_end (hide_button, false, true);
225 gain_meter_alignment.set_padding(0, 4, 0, 0);
226 gain_meter_alignment.add(gpm);
228 whvbox.pack_start (width_hide_box, true, true);
230 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
231 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
232 global_vpacker.pack_start (pre_processor_box, true, true);
233 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
234 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
235 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
236 global_vpacker.pack_start (post_processor_box, true, true);
237 if (!is_midi_track()) {
238 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
240 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
241 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
243 global_frame.add (global_vpacker);
244 global_frame.set_shadow_type (Gtk::SHADOW_IN);
245 global_frame.set_name ("BaseFrame");
249 /* force setting of visible selected status */
252 set_selected (false);
257 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
258 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
260 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
261 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
263 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
264 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
265 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
266 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), false);
268 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
272 rec_enable_button->set_name ("MixerRecordEnableButton");
273 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
274 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
276 /* ditto for this button and busses */
278 show_sends_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::show_sends_press), false);
279 show_sends_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::show_sends_release));
281 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
282 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_mix_group), false);
286 /* start off as a passthru strip. we'll correct this, if necessary,
287 in update_diskstream_display().
290 /* start off as a passthru strip. we'll correct this, if necessary,
291 in update_diskstream_display().
295 set_name ("MidiTrackStripBase");
297 set_name ("AudioTrackStripBase");
299 add_events (Gdk::BUTTON_RELEASE_MASK);
301 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
305 MixerStrip::~MixerStrip ()
307 GoingAway(); /* EMIT_SIGNAL */
309 delete input_selector;
310 delete output_selector;
314 MixerStrip::set_route (boost::shared_ptr<Route> rt)
316 if (rec_enable_button->get_parent()) {
317 button_table.remove (*rec_enable_button);
320 if (show_sends_button->get_parent()) {
321 button_table.remove (*show_sends_button);
324 RouteUI::set_route (rt);
326 delete input_selector;
329 delete output_selector;
332 boost::shared_ptr<Send> send;
334 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
335 send->set_metering (false);
338 _current_delivery = _route->main_outs ();
340 panners.set_panner (rt->main_outs()->panner());
341 gpm.set_controls (rt, rt->shared_peak_meter(), rt->gain_control(), rt->amp());
342 pre_processor_box.set_route (rt);
343 post_processor_box.set_route (rt);
345 if (set_color_from_route()) {
346 set_color (unique_random_color());
349 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
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 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
368 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
369 rec_enable_button->show();
371 } else if (!is_track()) {
374 if (!_route->is_master()) {
375 button_table.attach (*show_sends_button, 0, 2, 2, 3);
376 show_sends_button->show();
380 if (_route->phase_invert()) {
381 name_label.set_text (X_("Ø ") + name_label.get_text());
383 name_label.set_text (_route->name());
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 delete route_ops_menu;
403 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
404 _("Click to Add/Edit Comments"):
407 connections.push_back (_route->meter_change.connect (
408 mem_fun(*this, &MixerStrip::meter_changed)));
409 connections.push_back (_route->input()->changed.connect (
410 mem_fun(*this, &MixerStrip::input_changed)));
411 connections.push_back (_route->output()->changed.connect (
412 mem_fun(*this, &MixerStrip::output_changed)));
413 connections.push_back (_route->mix_group_changed.connect (
414 mem_fun(*this, &MixerStrip::mix_group_changed)));
416 if (_route->panner()) {
417 connections.push_back (_route->panner()->Changed.connect (
418 mem_fun(*this, &MixerStrip::connect_to_pan)));
421 if (is_audio_track()) {
422 connections.push_back (audio_track()->DiskstreamChanged.connect (
423 mem_fun(*this, &MixerStrip::diskstream_changed)));
426 connections.push_back (_route->NameChanged.connect (
427 mem_fun(*this, &RouteUI::name_changed)));
428 connections.push_back (_route->comment_changed.connect (
429 mem_fun(*this, &MixerStrip::comment_changed)));
430 connections.push_back (_route->gui_changed.connect (
431 mem_fun(*this, &MixerStrip::route_gui_changed)));
433 set_stuff_from_route ();
435 /* now force an update of all the various elements */
437 pre_processor_box.update();
438 post_processor_box.update();
443 mix_group_changed (0);
447 panners.setup_pan ();
449 update_diskstream_display ();
450 update_input_display ();
451 update_output_display ();
453 add_events (Gdk::BUTTON_RELEASE_MASK);
455 pre_processor_box.show();
457 if (!route()->is_master() && !route()->is_control()) {
458 /* we don't allow master or control routes to be hidden */
463 width_hide_box.show();
466 global_vpacker.show();
468 middle_button_table.show();
469 bottom_button_table.show();
470 pre_processor_box.show_all ();
473 gain_meter_alignment.show ();
474 post_processor_box.show_all ();
475 gain_unit_button.show();
476 gain_unit_label.show();
477 meter_point_button.show();
478 meter_point_label.show();
479 diskstream_button.show();
480 diskstream_label.show();
483 output_button.show();
487 comment_button.show();
495 MixerStrip::set_stuff_from_route ()
501 /* if width is not set, it will be set by the MixerUI or editor */
503 if ((prop = xml_node->property ("strip-width")) != 0) {
504 set_width (Width (string_2_enum (prop->value(), _width)), this);
507 if ((prop = xml_node->property ("shown-mixer")) != 0) {
508 if (prop->value() == "no") {
509 _marked_for_display = false;
511 _marked_for_display = true;
514 /* backwards compatibility */
515 _marked_for_display = true;
520 MixerStrip::set_width (Width w, void* owner)
522 /* always set the gpm width again, things may be hidden */
525 panners.set_width (w);
526 pre_processor_box.set_width (w);
527 post_processor_box.set_width (w);
529 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
531 _width_owner = owner;
537 if (_width_owner == this) {
538 xml_node->add_property ("strip-width", enum_2_string (_width));
544 if (rec_enable_button) {
545 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Record"));
547 if (show_sends_button) {
548 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
550 ((Gtk::Label*)mute_button->get_child())->set_text (_("Mute"));
551 ((Gtk::Label*)solo_button->get_child())->set_text (_("Solo"));
553 if (_route->comment() == "") {
554 comment_button.unset_bg (STATE_NORMAL);
555 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
557 comment_button.modify_bg (STATE_NORMAL, color());
558 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
561 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
562 gpm.astyle_string(gain_automation->automation_style()));
563 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
564 gpm.astate_string(gain_automation->automation_state()));
566 if (_route->panner()) {
567 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
568 panners.astyle_string(_route->panner()->automation_style()));
569 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
570 panners.astate_string(_route->panner()->automation_state()));
573 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
574 set_size_request (-1, -1);
578 if (rec_enable_button) {
579 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Rec"));
581 if (show_sends_button) {
582 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
584 ((Gtk::Label*)mute_button->get_child())->set_text (_("M"));
585 ((Gtk::Label*)solo_button->get_child())->set_text (_("S"));
587 if (_route->comment() == "") {
588 comment_button.unset_bg (STATE_NORMAL);
589 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
591 comment_button.modify_bg (STATE_NORMAL, color());
592 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
595 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
596 gpm.short_astyle_string(gain_automation->automation_style()));
597 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
598 gpm.short_astate_string(gain_automation->automation_state()));
600 if (_route->panner()) {
601 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
602 panners.short_astyle_string(_route->panner()->automation_style()));
603 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
604 panners.short_astate_string(_route->panner()->automation_state()));
607 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
608 set_size_request (max (50, gpm.get_gm_width()), -1);
611 update_input_display ();
612 update_output_display ();
613 mix_group_changed (0);
621 MixerStrip::set_packed (bool yn)
628 xml_node->add_property ("shown-mixer", "yes");
630 xml_node->add_property ("shown-mixer", "no");
636 MixerStrip::output_press (GdkEventButton *ev)
638 using namespace Menu_Helpers;
639 if (!_session.engine().connected()) {
640 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
645 MenuList& citems = output_menu.items();
646 switch (ev->button) {
649 edit_output_configuration ();
654 output_menu.set_name ("ArdourContextMenu");
657 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
658 citems.push_back (SeparatorElem());
660 ARDOUR::BundleList current = _route->output()->bundles_connected ();
662 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
663 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
664 maybe_add_bundle_to_output_menu (*i, current);
667 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
668 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
669 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
672 if (citems.size() == 2) {
673 /* no routes added; remove the separator */
677 output_menu.popup (1, ev->time);
688 MixerStrip::edit_output_configuration ()
690 if (output_selector == 0) {
691 output_selector = new IOSelectorWindow (_session, _route->output());
694 if (output_selector->is_visible()) {
695 output_selector->get_toplevel()->get_window()->raise();
697 output_selector->present ();
702 MixerStrip::edit_input_configuration ()
704 if (input_selector == 0) {
705 input_selector = new IOSelectorWindow (_session, _route->input());
708 if (input_selector->is_visible()) {
709 input_selector->get_toplevel()->get_window()->raise();
711 input_selector->present ();
716 MixerStrip::input_press (GdkEventButton *ev)
718 using namespace Menu_Helpers;
720 MenuList& citems = input_menu.items();
721 input_menu.set_name ("ArdourContextMenu");
724 if (!_session.engine().connected()) {
725 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
730 switch (ev->button) {
733 edit_input_configuration ();
738 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
739 citems.push_back (SeparatorElem());
741 ARDOUR::BundleList current = _route->input()->bundles_connected ();
743 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
744 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
745 maybe_add_bundle_to_input_menu (*i, current);
748 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
749 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
750 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
753 if (citems.size() == 2) {
754 /* no routes added; remove the separator */
758 input_menu.popup (1, ev->time);
768 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
774 ARDOUR::BundleList current = _route->input()->bundles_connected ();
776 if (std::find (current.begin(), current.end(), c) == current.end()) {
777 _route->input()->connect_ports_to_bundle (c, this);
779 _route->input()->disconnect_ports_from_bundle (c, this);
784 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
790 ARDOUR::BundleList current = _route->output()->bundles_connected ();
792 if (std::find (current.begin(), current.end(), c) == current.end()) {
793 _route->output()->connect_ports_to_bundle (c, this);
795 _route->output()->disconnect_ports_from_bundle (c, this);
800 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
802 using namespace Menu_Helpers;
804 if (b->ports_are_outputs() == false ||
805 route()->input()->default_type() != b->type() ||
806 b->nchannels() != _route->n_inputs().get (b->type ())) {
811 MenuList& citems = input_menu.items();
813 std::string n = b->name ();
814 replace_all (n, "_", " ");
816 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
818 if (std::find (current.begin(), current.end(), b) != current.end()) {
819 ignore_toggle = true;
820 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
821 ignore_toggle = false;
826 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
828 using namespace Menu_Helpers;
830 if (b->ports_are_inputs() == false ||
831 route()->output()->default_type() != b->type() ||
832 b->nchannels() != _route->n_outputs().get (b->type ())) {
837 MenuList& citems = output_menu.items();
839 std::string n = b->name ();
840 replace_all (n, "_", " ");
842 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
844 if (std::find (current.begin(), current.end(), b) != current.end()) {
845 ignore_toggle = true;
846 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
847 ignore_toggle = false;
852 MixerStrip::update_diskstream_display ()
856 if (input_selector) {
857 input_selector->hide_all ();
864 show_passthru_color ();
869 MixerStrip::connect_to_pan ()
871 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
873 panstate_connection.disconnect ();
874 panstyle_connection.disconnect ();
876 if (!_route->panner()) {
880 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
881 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
882 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
885 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
886 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
889 panners.pan_changed (this);
893 MixerStrip::update_input_display ()
895 ARDOUR::BundleList const c = _route->input()->bundles_connected();
898 input_label.set_text (_("Inputs"));
899 } else if (c.size() == 1) {
900 input_label.set_text (c[0]->name ());
904 input_label.set_text (_(" Input"));
907 input_label.set_text (_("I"));
911 panners.setup_pan ();
915 MixerStrip::update_output_display ()
917 ARDOUR::BundleList const c = _route->output()->bundles_connected ();
919 /* XXX: how do we represent >1 connected bundle? */
921 output_label.set_text (_("Outputs"));
922 } else if (c.size() == 1) {
923 output_label.set_text (c[0]->name());
927 output_label.set_text (_("Output"));
930 output_label.set_text (_("O"));
936 panners.setup_pan ();
940 MixerStrip::fast_update ()
942 gpm.update_meters ();
946 MixerStrip::diskstream_changed ()
948 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
952 MixerStrip::input_changed (IOChange change, void *src)
954 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
955 set_width(_width, this);
959 MixerStrip::output_changed (IOChange change, void *src)
961 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
962 set_width(_width, this);
967 MixerStrip::comment_editor_done_editing()
969 string str = comment_area->get_buffer()->get_text();
970 if (_route->comment() != str) {
971 _route->set_comment (str, this);
977 comment_button.modify_bg (STATE_NORMAL, color());
978 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
980 comment_button.unset_bg (STATE_NORMAL);
981 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
987 comment_button.modify_bg (STATE_NORMAL, color());
988 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
990 comment_button.unset_bg (STATE_NORMAL);
991 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
996 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
997 str.empty() ? _("Click to Add/Edit Comments") : str);
1003 MixerStrip::comment_button_clicked ()
1005 if (comment_window == 0) {
1006 setup_comment_editor ();
1009 int x, y, cw_width, cw_height;
1011 if (comment_window->is_visible()) {
1012 comment_window->hide ();
1016 comment_window->get_size (cw_width, cw_height);
1017 comment_window->get_position(x, y);
1018 comment_window->move(x, y - (cw_height / 2) - 45);
1020 half the dialog height minus the comments button height
1021 with some window decoration fudge thrown in.
1024 comment_window->show();
1025 comment_window->present();
1029 MixerStrip::setup_comment_editor ()
1032 title = _route->name();
1033 title += _(": comment editor");
1035 comment_window = new ArdourDialog (title, false);
1036 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1037 comment_window->set_skip_taskbar_hint (true);
1038 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1040 comment_area = manage (new TextView());
1041 comment_area->set_name ("MixerTrackCommentArea");
1042 comment_area->set_size_request (110, 178);
1043 comment_area->set_wrap_mode (WRAP_WORD);
1044 comment_area->set_editable (true);
1045 comment_area->get_buffer()->set_text (_route->comment());
1046 comment_area->show ();
1048 comment_window->get_vbox()->pack_start (*comment_area);
1049 comment_window->get_action_area()->hide();
1053 MixerStrip::comment_changed (void *src)
1055 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1058 ignore_comment_edit = true;
1060 comment_area->get_buffer()->set_text (_route->comment());
1062 ignore_comment_edit = false;
1067 MixerStrip::set_mix_group (RouteGroup *rg)
1069 _route->set_mix_group (rg, this);
1073 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
1075 using namespace Menu_Helpers;
1077 MenuList& items = group_menu->items();
1079 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1081 if (_route->mix_group() == rg) {
1082 static_cast<RadioMenuItem*>(&items.back())->set_active ();
1087 MixerStrip::select_mix_group (GdkEventButton *ev)
1089 using namespace Menu_Helpers;
1091 if (group_menu == 0) {
1092 group_menu = new Menu;
1094 group_menu->set_name ("ArdourContextMenu");
1095 MenuList& items = group_menu->items();
1096 RadioMenuItem::Group group;
1098 switch (ev->button) {
1102 items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1104 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
1106 group_menu->popup (1, ev->time);
1117 MixerStrip::mix_group_changed (void *ignored)
1119 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1121 RouteGroup *rg = _route->mix_group();
1124 group_label.set_text (rg->name());
1128 group_label.set_text (_("Grp"));
1131 group_label.set_text (_("~G"));
1139 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1141 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1143 if (what_changed == "color") {
1144 if (set_color_from_route () == 0) {
1145 show_route_color ();
1151 MixerStrip::show_route_color ()
1153 name_button.modify_bg (STATE_NORMAL, color());
1154 top_event_box.modify_bg (STATE_NORMAL, color());
1155 route_active_changed ();
1159 MixerStrip::show_passthru_color ()
1161 route_active_changed ();
1165 MixerStrip::build_route_ops_menu ()
1167 using namespace Menu_Helpers;
1168 route_ops_menu = new Menu;
1169 route_ops_menu->set_name ("ArdourContextMenu");
1171 MenuList& items = route_ops_menu->items();
1173 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1174 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1175 rename_menu_item = &items.back();
1176 items.push_back (SeparatorElem());
1177 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1178 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1179 route_active_menu_item->set_active (_route->active());
1181 items.push_back (SeparatorElem());
1183 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1185 items.push_back (SeparatorElem());
1186 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1187 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1188 polarity_menu_item->set_active (_route->phase_invert());
1189 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1190 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1191 denormal_menu_item->set_active (_route->denormal_protection());
1193 if (!Profile->get_sae()) {
1194 build_remote_control_menu ();
1195 items.push_back (SeparatorElem());
1196 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1199 items.push_back (SeparatorElem());
1200 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1204 MixerStrip::name_button_button_press (GdkEventButton* ev)
1206 if (ev->button == 1 || ev->button == 3) {
1207 list_route_operations ();
1209 /* do not allow rename if the track is record-enabled */
1210 rename_menu_item->set_sensitive (!_route->record_enabled());
1211 route_ops_menu->popup (1, ev->time);
1217 MixerStrip::list_route_operations ()
1219 if (route_ops_menu == 0) {
1220 build_route_ops_menu ();
1223 refresh_remote_control_menu();
1227 MixerStrip::set_selected (bool yn)
1229 AxisView::set_selected (yn);
1231 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1232 global_frame.set_name ("MixerStripSelectedFrame");
1234 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1235 global_frame.set_name ("MixerStripFrame");
1237 global_frame.queue_draw ();
1241 MixerStrip::name_changed ()
1245 RouteUI::name_changed ();
1248 name_label.set_text (PBD::short_version (_route->name(), 5));
1251 if (_route->phase_invert()) {
1252 name_label.set_text (X_("Ø ") + name_label.get_text());
1257 MixerStrip::width_clicked ()
1261 set_width (Narrow, this);
1264 set_width (Wide, this);
1270 MixerStrip::hide_clicked ()
1272 // LAME fix to reset the button status for when it is redisplayed (part 1)
1273 hide_button.set_sensitive(false);
1276 Hiding(); /* EMIT_SIGNAL */
1278 _mixer.hide_strip (this);
1282 hide_button.set_sensitive(true);
1286 MixerStrip::set_embedded (bool yn)
1292 MixerStrip::map_frozen ()
1294 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1296 boost::shared_ptr<AudioTrack> at = audio_track();
1299 switch (at->freeze_state()) {
1300 case AudioTrack::Frozen:
1301 pre_processor_box.set_sensitive (false);
1302 post_processor_box.set_sensitive (false);
1305 pre_processor_box.set_sensitive (true);
1306 post_processor_box.set_sensitive (true);
1307 // XXX need some way, maybe, to retoggle redirect editors
1312 hide_redirect_editors ();
1316 MixerStrip::hide_redirect_editors ()
1318 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1322 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1324 boost::shared_ptr<Processor> processor (p.lock ());
1329 void* gui = processor->get_gui ();
1332 static_cast<Gtk::Widget*>(gui)->hide ();
1337 MixerStrip::route_active_changed ()
1339 RouteUI::route_active_changed ();
1341 if (is_midi_track()) {
1342 if (_route->active()) {
1343 set_name ("MidiTrackStripBase");
1344 gpm.set_meter_strip_name ("MidiTrackStripBase");
1346 set_name ("MidiTrackStripBaseInactive");
1347 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1349 gpm.set_fader_name ("MidiTrackFader");
1350 } else if (is_audio_track()) {
1351 if (_route->active()) {
1352 set_name ("AudioTrackStripBase");
1353 gpm.set_meter_strip_name ("AudioTrackMetrics");
1355 set_name ("AudioTrackStripBaseInactive");
1356 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1358 gpm.set_fader_name ("AudioTrackFader");
1360 if (_route->active()) {
1361 set_name ("AudioBusStripBase");
1362 gpm.set_meter_strip_name ("AudioBusMetrics");
1364 set_name ("AudioBusStripBaseInactive");
1365 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1367 gpm.set_fader_name ("AudioBusFader");
1369 /* (no MIDI busses yet) */
1374 MixerStrip::mix_group() const
1376 return _route->mix_group();
1380 MixerStrip::engine_stopped ()
1385 MixerStrip::engine_running ()
1390 MixerStrip::meter_changed (void *src)
1392 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1394 switch (_route->meter_point()) {
1396 meter_point_label.set_text (_("input"));
1400 meter_point_label.set_text (_("pre"));
1403 case MeterPostFader:
1404 meter_point_label.set_text (_("post"));
1408 gpm.setup_meters ();
1409 // reset peak when meter point changes
1410 gpm.reset_peak_display();
1411 set_width(_width, this);
1415 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1417 if (_route == target || _route->is_master()) {
1418 /* don't change the display for the target or the master bus */
1420 } else if (!is_track() && show_sends_button) {
1421 /* make sure our show sends button is inactive, and we no longer blink,
1422 since we're not the target.
1424 send_blink_connection.disconnect ();
1425 show_sends_button->set_active (false);
1426 show_sends_button->set_state (STATE_NORMAL);
1430 /* switch back to default */
1431 revert_to_default_display ();
1435 boost::shared_ptr<Send> send;
1437 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1438 send->set_metering (false);
1441 _current_delivery = _route->internal_send_for (target);
1443 if (_current_delivery) {
1444 send = boost::dynamic_pointer_cast<Send>(_current_delivery);
1445 send->set_metering (true);
1446 _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1447 gain_meter().set_controls (_route, send->meter(), send->amp()->gain_control(), send->amp());
1448 panner_ui().set_panner (_current_delivery->panner());
1451 _current_delivery = _route->main_outs ();
1452 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
1453 panner_ui().set_panner (_route->main_outs()->panner());
1456 gain_meter().setup_meters ();
1457 panner_ui().setup_pan ();
1462 MixerStrip::revert_to_default_display ()
1464 show_sends_button->set_active (false);
1466 boost::shared_ptr<Send> send;
1468 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1469 send->set_metering (false);
1472 _current_delivery = _route->main_outs();
1474 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
1475 gain_meter().setup_meters ();
1476 panner_ui().set_panner (_route->main_outs()->panner());
1477 panner_ui().setup_pan ();