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 /* XXX what is this meant to do? */
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 (pre_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 global_vpacker.pack_start (post_processor_box, true, true);
238 if (!is_midi_track()) {
239 global_vpacker.pack_start (panners, 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_mix_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);
302 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
306 MixerStrip::~MixerStrip ()
308 GoingAway(); /* EMIT_SIGNAL */
310 delete input_selector;
311 delete output_selector;
315 MixerStrip::set_route (boost::shared_ptr<Route> rt)
317 if (rec_enable_button->get_parent()) {
318 button_table.remove (*rec_enable_button);
321 if (show_sends_button->get_parent()) {
322 button_table.remove (*show_sends_button);
325 RouteUI::set_route (rt);
327 delete input_selector;
330 delete output_selector;
333 boost::shared_ptr<Send> send;
335 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
336 send->set_metering (false);
339 _current_delivery = _route->main_outs ();
341 panners.set_panner (rt->main_outs()->panner());
342 gpm.set_controls (rt, rt->shared_peak_meter(), rt->gain_control(), rt->amp());
343 pre_processor_box.set_route (rt);
344 post_processor_box.set_route (rt);
346 if (set_color_from_route()) {
347 set_color (unique_random_color());
350 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
352 if (scrollbar_height == 0) {
353 HScrollbar scrollbar;
354 Gtk::Requisition requisition(scrollbar.size_request ());
355 scrollbar_height = requisition.height;
358 spacer = manage (new EventBox);
359 spacer->set_size_request (-1, scrollbar_height);
360 global_vpacker.pack_start (*spacer, false, false);
363 if (is_audio_track()) {
365 boost::shared_ptr<AudioTrack> at = audio_track();
367 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
369 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
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 if (_route->phase_invert()) {
382 name_label.set_text (X_("Ø ") + name_label.get_text());
384 name_label.set_text (_route->name());
387 switch (_route->meter_point()) {
389 meter_point_label.set_text (_("input"));
393 meter_point_label.set_text (_("pre"));
397 meter_point_label.set_text (_("post"));
401 delete route_ops_menu;
404 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
405 _("Click to Add/Edit Comments"):
408 connections.push_back (_route->meter_change.connect (
409 mem_fun(*this, &MixerStrip::meter_changed)));
410 connections.push_back (_route->input()->changed.connect (
411 mem_fun(*this, &MixerStrip::input_changed)));
412 connections.push_back (_route->output()->changed.connect (
413 mem_fun(*this, &MixerStrip::output_changed)));
414 connections.push_back (_route->mix_group_changed.connect (
415 mem_fun(*this, &MixerStrip::mix_group_changed)));
417 if (_route->panner()) {
418 connections.push_back (_route->panner()->Changed.connect (
419 mem_fun(*this, &MixerStrip::connect_to_pan)));
422 if (is_audio_track()) {
423 connections.push_back (audio_track()->DiskstreamChanged.connect (
424 mem_fun(*this, &MixerStrip::diskstream_changed)));
427 connections.push_back (_route->NameChanged.connect (
428 mem_fun(*this, &RouteUI::name_changed)));
429 connections.push_back (_route->comment_changed.connect (
430 mem_fun(*this, &MixerStrip::comment_changed)));
431 connections.push_back (_route->gui_changed.connect (
432 mem_fun(*this, &MixerStrip::route_gui_changed)));
434 set_stuff_from_route ();
436 /* now force an update of all the various elements */
438 pre_processor_box.update();
439 post_processor_box.update();
444 mix_group_changed (0);
448 panners.setup_pan ();
450 update_diskstream_display ();
451 update_input_display ();
452 update_output_display ();
454 add_events (Gdk::BUTTON_RELEASE_MASK);
456 pre_processor_box.show();
458 if (!route()->is_master() && !route()->is_control()) {
459 /* we don't allow master or control routes to be hidden */
464 width_hide_box.show();
467 global_vpacker.show();
469 middle_button_table.show();
470 bottom_button_table.show();
471 pre_processor_box.show_all ();
474 gain_meter_alignment.show ();
475 post_processor_box.show_all ();
476 gain_unit_button.show();
477 gain_unit_label.show();
478 meter_point_button.show();
479 meter_point_label.show();
480 diskstream_button.show();
481 diskstream_label.show();
484 output_button.show();
488 comment_button.show();
496 MixerStrip::set_stuff_from_route ()
502 /* if width is not set, it will be set by the MixerUI or editor */
504 if ((prop = xml_node->property ("strip-width")) != 0) {
505 set_width (Width (string_2_enum (prop->value(), _width)), this);
508 if ((prop = xml_node->property ("shown-mixer")) != 0) {
509 if (prop->value() == "no") {
510 _marked_for_display = false;
512 _marked_for_display = true;
515 /* backwards compatibility */
516 _marked_for_display = true;
521 MixerStrip::set_width (Width w, void* owner)
523 /* always set the gpm width again, things may be hidden */
526 panners.set_width (w);
527 pre_processor_box.set_width (w);
528 post_processor_box.set_width (w);
530 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
532 _width_owner = owner;
538 if (_width_owner == this) {
539 xml_node->add_property ("strip-width", enum_2_string (_width));
545 if (rec_enable_button) {
546 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Record"));
548 if (show_sends_button) {
549 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
551 ((Gtk::Label*)mute_button->get_child())->set_text (_("Mute"));
552 ((Gtk::Label*)solo_button->get_child())->set_text (_("Solo"));
554 if (_route->comment() == "") {
555 comment_button.unset_bg (STATE_NORMAL);
556 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
558 comment_button.modify_bg (STATE_NORMAL, color());
559 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
562 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
563 gpm.astyle_string(gain_automation->automation_style()));
564 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
565 gpm.astate_string(gain_automation->automation_state()));
567 if (_route->panner()) {
568 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
569 panners.astyle_string(_route->panner()->automation_style()));
570 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
571 panners.astate_string(_route->panner()->automation_state()));
574 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
575 set_size_request (-1, -1);
579 if (rec_enable_button) {
580 ((Gtk::Label*)rec_enable_button->get_child())->set_text (_("Rec"));
582 if (show_sends_button) {
583 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
585 ((Gtk::Label*)mute_button->get_child())->set_text (_("M"));
586 ((Gtk::Label*)solo_button->get_child())->set_text (_("S"));
588 if (_route->comment() == "") {
589 comment_button.unset_bg (STATE_NORMAL);
590 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
592 comment_button.modify_bg (STATE_NORMAL, color());
593 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
596 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
597 gpm.short_astyle_string(gain_automation->automation_style()));
598 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
599 gpm.short_astate_string(gain_automation->automation_state()));
601 if (_route->panner()) {
602 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
603 panners.short_astyle_string(_route->panner()->automation_style()));
604 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
605 panners.short_astate_string(_route->panner()->automation_state()));
608 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
609 set_size_request (max (50, gpm.get_gm_width()), -1);
612 update_input_display ();
613 update_output_display ();
614 mix_group_changed (0);
622 MixerStrip::set_packed (bool yn)
629 xml_node->add_property ("shown-mixer", "yes");
631 xml_node->add_property ("shown-mixer", "no");
637 MixerStrip::output_press (GdkEventButton *ev)
639 using namespace Menu_Helpers;
640 if (!_session.engine().connected()) {
641 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
646 MenuList& citems = output_menu.items();
647 switch (ev->button) {
650 edit_output_configuration ();
655 output_menu.set_name ("ArdourContextMenu");
658 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
659 citems.push_back (SeparatorElem());
661 ARDOUR::BundleList current = _route->output()->bundles_connected ();
663 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
664 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
665 maybe_add_bundle_to_output_menu (*i, current);
668 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
669 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
670 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
673 if (citems.size() == 2) {
674 /* no routes added; remove the separator */
678 output_menu.popup (1, ev->time);
689 MixerStrip::edit_output_configuration ()
691 if (output_selector == 0) {
692 output_selector = new IOSelectorWindow (_session, _route->output());
695 if (output_selector->is_visible()) {
696 output_selector->get_toplevel()->get_window()->raise();
698 output_selector->present ();
703 MixerStrip::edit_input_configuration ()
705 if (input_selector == 0) {
706 input_selector = new IOSelectorWindow (_session, _route->input());
709 if (input_selector->is_visible()) {
710 input_selector->get_toplevel()->get_window()->raise();
712 input_selector->present ();
717 MixerStrip::input_press (GdkEventButton *ev)
719 using namespace Menu_Helpers;
721 MenuList& citems = input_menu.items();
722 input_menu.set_name ("ArdourContextMenu");
725 if (!_session.engine().connected()) {
726 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
731 switch (ev->button) {
734 edit_input_configuration ();
739 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
740 citems.push_back (SeparatorElem());
742 ARDOUR::BundleList current = _route->input()->bundles_connected ();
744 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
745 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
746 maybe_add_bundle_to_input_menu (*i, current);
749 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
750 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
751 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
754 if (citems.size() == 2) {
755 /* no routes added; remove the separator */
759 input_menu.popup (1, ev->time);
769 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
775 ARDOUR::BundleList current = _route->input()->bundles_connected ();
777 if (std::find (current.begin(), current.end(), c) == current.end()) {
778 _route->input()->connect_ports_to_bundle (c, this);
780 _route->input()->disconnect_ports_from_bundle (c, this);
785 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
791 ARDOUR::BundleList current = _route->output()->bundles_connected ();
793 if (std::find (current.begin(), current.end(), c) == current.end()) {
794 _route->output()->connect_ports_to_bundle (c, this);
796 _route->output()->disconnect_ports_from_bundle (c, this);
801 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
803 using namespace Menu_Helpers;
805 if (b->ports_are_outputs() == false ||
806 route()->input()->default_type() != b->type() ||
807 b->nchannels() != _route->n_inputs().get (b->type ())) {
812 MenuList& citems = input_menu.items();
814 std::string n = b->name ();
815 replace_all (n, "_", " ");
817 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
819 if (std::find (current.begin(), current.end(), b) != current.end()) {
820 ignore_toggle = true;
821 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
822 ignore_toggle = false;
827 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
829 using namespace Menu_Helpers;
831 if (b->ports_are_inputs() == false ||
832 route()->output()->default_type() != b->type() ||
833 b->nchannels() != _route->n_outputs().get (b->type ())) {
838 MenuList& citems = output_menu.items();
840 std::string n = b->name ();
841 replace_all (n, "_", " ");
843 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
845 if (std::find (current.begin(), current.end(), b) != current.end()) {
846 ignore_toggle = true;
847 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
848 ignore_toggle = false;
853 MixerStrip::update_diskstream_display ()
857 if (input_selector) {
858 input_selector->hide_all ();
865 show_passthru_color ();
870 MixerStrip::connect_to_pan ()
872 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
874 panstate_connection.disconnect ();
875 panstyle_connection.disconnect ();
877 if (!_route->panner()) {
881 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
882 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
883 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
886 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
887 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
890 panners.pan_changed (this);
894 MixerStrip::update_input_display ()
896 ARDOUR::BundleList const c = _route->input()->bundles_connected();
899 input_label.set_text (_("Inputs"));
900 } else if (c.size() == 1) {
901 input_label.set_text (c[0]->name ());
905 input_label.set_text (_(" Input"));
908 input_label.set_text (_("I"));
912 panners.setup_pan ();
916 MixerStrip::update_output_display ()
918 ARDOUR::BundleList const c = _route->output()->bundles_connected ();
920 /* XXX: how do we represent >1 connected bundle? */
922 output_label.set_text (_("Outputs"));
923 } else if (c.size() == 1) {
924 output_label.set_text (c[0]->name());
928 output_label.set_text (_("Output"));
931 output_label.set_text (_("O"));
937 panners.setup_pan ();
941 MixerStrip::fast_update ()
943 gpm.update_meters ();
947 MixerStrip::diskstream_changed ()
949 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
953 MixerStrip::input_changed (IOChange change, void *src)
955 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
956 set_width(_width, this);
960 MixerStrip::output_changed (IOChange change, void *src)
962 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
963 set_width(_width, this);
968 MixerStrip::comment_editor_done_editing()
970 string str = comment_area->get_buffer()->get_text();
971 if (_route->comment() != str) {
972 _route->set_comment (str, this);
978 comment_button.modify_bg (STATE_NORMAL, color());
979 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
981 comment_button.unset_bg (STATE_NORMAL);
982 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
988 comment_button.modify_bg (STATE_NORMAL, color());
989 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
991 comment_button.unset_bg (STATE_NORMAL);
992 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
997 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
998 str.empty() ? _("Click to Add/Edit Comments") : str);
1004 MixerStrip::comment_button_clicked ()
1006 if (comment_window == 0) {
1007 setup_comment_editor ();
1010 int x, y, cw_width, cw_height;
1012 if (comment_window->is_visible()) {
1013 comment_window->hide ();
1017 comment_window->get_size (cw_width, cw_height);
1018 comment_window->get_position(x, y);
1019 comment_window->move(x, y - (cw_height / 2) - 45);
1021 half the dialog height minus the comments button height
1022 with some window decoration fudge thrown in.
1025 comment_window->show();
1026 comment_window->present();
1030 MixerStrip::setup_comment_editor ()
1033 title = _route->name();
1034 title += _(": comment editor");
1036 comment_window = new ArdourDialog (title, false);
1037 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1038 comment_window->set_skip_taskbar_hint (true);
1039 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1041 comment_area = manage (new TextView());
1042 comment_area->set_name ("MixerTrackCommentArea");
1043 comment_area->set_size_request (110, 178);
1044 comment_area->set_wrap_mode (WRAP_WORD);
1045 comment_area->set_editable (true);
1046 comment_area->get_buffer()->set_text (_route->comment());
1047 comment_area->show ();
1049 comment_window->get_vbox()->pack_start (*comment_area);
1050 comment_window->get_action_area()->hide();
1054 MixerStrip::comment_changed (void *src)
1056 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1059 ignore_comment_edit = true;
1061 comment_area->get_buffer()->set_text (_route->comment());
1063 ignore_comment_edit = false;
1068 MixerStrip::set_mix_group (RouteGroup *rg)
1070 _route->set_mix_group (rg, this);
1074 MixerStrip::add_mix_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
1076 using namespace Menu_Helpers;
1078 MenuList& items = group_menu->items();
1080 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_mix_group), rg)));
1082 if (_route->mix_group() == rg) {
1083 static_cast<RadioMenuItem*>(&items.back())->set_active ();
1088 MixerStrip::select_mix_group (GdkEventButton *ev)
1090 using namespace Menu_Helpers;
1092 if (group_menu == 0) {
1093 group_menu = new Menu;
1095 group_menu->set_name ("ArdourContextMenu");
1096 MenuList& items = group_menu->items();
1097 RadioMenuItem::Group group;
1099 switch (ev->button) {
1103 items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &MixerStrip::set_mix_group), (RouteGroup *) 0)));
1105 _session.foreach_mix_group (bind (mem_fun (*this, &MixerStrip::add_mix_group_to_menu), &group));
1107 group_menu->popup (1, ev->time);
1118 MixerStrip::mix_group_changed (void *ignored)
1120 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::mix_group_changed), ignored));
1122 RouteGroup *rg = _route->mix_group();
1125 group_label.set_text (rg->name());
1129 group_label.set_text (_("Grp"));
1132 group_label.set_text (_("~G"));
1140 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1142 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1144 if (what_changed == "color") {
1145 if (set_color_from_route () == 0) {
1146 show_route_color ();
1152 MixerStrip::show_route_color ()
1154 name_button.modify_bg (STATE_NORMAL, color());
1155 top_event_box.modify_bg (STATE_NORMAL, color());
1156 route_active_changed ();
1160 MixerStrip::show_passthru_color ()
1162 route_active_changed ();
1166 MixerStrip::build_route_ops_menu ()
1168 using namespace Menu_Helpers;
1169 route_ops_menu = new Menu;
1170 route_ops_menu->set_name ("ArdourContextMenu");
1172 MenuList& items = route_ops_menu->items();
1174 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1175 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1176 rename_menu_item = &items.back();
1177 items.push_back (SeparatorElem());
1178 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1179 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1180 route_active_menu_item->set_active (_route->active());
1182 items.push_back (SeparatorElem());
1184 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1186 items.push_back (SeparatorElem());
1187 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1188 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1189 polarity_menu_item->set_active (_route->phase_invert());
1190 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1191 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1192 denormal_menu_item->set_active (_route->denormal_protection());
1194 if (!Profile->get_sae()) {
1195 build_remote_control_menu ();
1196 items.push_back (SeparatorElem());
1197 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1200 items.push_back (SeparatorElem());
1201 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1205 MixerStrip::name_button_button_press (GdkEventButton* ev)
1207 if (ev->button == 1 || ev->button == 3) {
1208 list_route_operations ();
1210 /* do not allow rename if the track is record-enabled */
1211 rename_menu_item->set_sensitive (!_route->record_enabled());
1212 route_ops_menu->popup (1, ev->time);
1218 MixerStrip::list_route_operations ()
1220 if (route_ops_menu == 0) {
1221 build_route_ops_menu ();
1224 refresh_remote_control_menu();
1228 MixerStrip::set_selected (bool yn)
1230 AxisView::set_selected (yn);
1232 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1233 global_frame.set_name ("MixerStripSelectedFrame");
1235 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1236 global_frame.set_name ("MixerStripFrame");
1238 global_frame.queue_draw ();
1242 MixerStrip::name_changed ()
1246 RouteUI::name_changed ();
1249 name_label.set_text (PBD::short_version (_route->name(), 5));
1252 if (_route->phase_invert()) {
1253 name_label.set_text (X_("Ø ") + name_label.get_text());
1258 MixerStrip::width_clicked ()
1262 set_width (Narrow, this);
1265 set_width (Wide, this);
1271 MixerStrip::hide_clicked ()
1273 // LAME fix to reset the button status for when it is redisplayed (part 1)
1274 hide_button.set_sensitive(false);
1277 Hiding(); /* EMIT_SIGNAL */
1279 _mixer.hide_strip (this);
1283 hide_button.set_sensitive(true);
1287 MixerStrip::set_embedded (bool yn)
1293 MixerStrip::map_frozen ()
1295 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1297 boost::shared_ptr<AudioTrack> at = audio_track();
1300 switch (at->freeze_state()) {
1301 case AudioTrack::Frozen:
1302 pre_processor_box.set_sensitive (false);
1303 post_processor_box.set_sensitive (false);
1306 pre_processor_box.set_sensitive (true);
1307 post_processor_box.set_sensitive (true);
1308 // XXX need some way, maybe, to retoggle redirect editors
1313 hide_redirect_editors ();
1317 MixerStrip::hide_redirect_editors ()
1319 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1323 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1325 boost::shared_ptr<Processor> processor (p.lock ());
1330 void* gui = processor->get_gui ();
1333 static_cast<Gtk::Widget*>(gui)->hide ();
1338 MixerStrip::route_active_changed ()
1340 RouteUI::route_active_changed ();
1342 if (is_midi_track()) {
1343 if (_route->active()) {
1344 set_name ("MidiTrackStripBase");
1345 gpm.set_meter_strip_name ("MidiTrackStripBase");
1347 set_name ("MidiTrackStripBaseInactive");
1348 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1350 gpm.set_fader_name ("MidiTrackFader");
1351 } else if (is_audio_track()) {
1352 if (_route->active()) {
1353 set_name ("AudioTrackStripBase");
1354 gpm.set_meter_strip_name ("AudioTrackMetrics");
1356 set_name ("AudioTrackStripBaseInactive");
1357 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1359 gpm.set_fader_name ("AudioTrackFader");
1361 if (_route->active()) {
1362 set_name ("AudioBusStripBase");
1363 gpm.set_meter_strip_name ("AudioBusMetrics");
1365 set_name ("AudioBusStripBaseInactive");
1366 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1368 gpm.set_fader_name ("AudioBusFader");
1370 /* (no MIDI busses yet) */
1375 MixerStrip::mix_group() const
1377 return _route->mix_group();
1381 MixerStrip::engine_stopped ()
1386 MixerStrip::engine_running ()
1391 MixerStrip::meter_changed (void *src)
1393 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1395 switch (_route->meter_point()) {
1397 meter_point_label.set_text (_("input"));
1401 meter_point_label.set_text (_("pre"));
1404 case MeterPostFader:
1405 meter_point_label.set_text (_("post"));
1409 gpm.setup_meters ();
1410 // reset peak when meter point changes
1411 gpm.reset_peak_display();
1412 set_width(_width, this);
1416 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1418 if (_route == target || _route->is_master()) {
1419 /* don't change the display for the target or the master bus */
1421 } else if (!is_track() && show_sends_button) {
1422 /* make sure our show sends button is inactive, and we no longer blink,
1423 since we're not the target.
1425 send_blink_connection.disconnect ();
1426 show_sends_button->set_active (false);
1427 show_sends_button->set_state (STATE_NORMAL);
1431 /* switch back to default */
1432 revert_to_default_display ();
1436 boost::shared_ptr<Send> send;
1438 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1439 send->set_metering (false);
1442 _current_delivery = _route->send_for (target->input());
1444 if (_current_delivery) {
1445 send = boost::dynamic_pointer_cast<Send>(_current_delivery);
1446 send->set_metering (true);
1447 _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1448 gain_meter().set_controls (_route, send->meter(), send->amp()->gain_control(), send->amp());
1449 panner_ui().set_panner (_current_delivery->panner());
1452 _current_delivery = _route->main_outs ();
1453 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
1454 panner_ui().set_panner (_route->main_outs()->panner());
1457 gain_meter().setup_meters ();
1458 panner_ui().setup_pan ();
1463 MixerStrip::revert_to_default_display ()
1465 show_sends_button->set_active (false);
1467 boost::shared_ptr<Send> send;
1469 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1470 send->set_metering (false);
1473 _current_delivery = _route->main_outs();
1475 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
1476 gain_meter().setup_meters ();
1477 panner_ui().set_panner (_route->main_outs()->panner());
1478 panner_ui().setup_pan ();