2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include <sigc++/bind.h>
24 #include "pbd/convert.h"
25 #include "pbd/enumwriter.h"
26 #include "pbd/replace_all.h"
28 #include <gtkmm2ext/gtk_ui.h>
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/choice.h>
31 #include <gtkmm2ext/stop_signal.h>
32 #include <gtkmm2ext/doi.h>
33 #include <gtkmm2ext/slider_controller.h>
34 #include <gtkmm2ext/bindable_button.h>
36 #include "ardour/ardour.h"
37 #include "ardour/amp.h"
38 #include "ardour/session.h"
39 #include "ardour/audioengine.h"
40 #include "ardour/route.h"
41 #include "ardour/route_group.h"
42 #include "ardour/audio_track.h"
43 #include "ardour/audio_diskstream.h"
44 #include "ardour/panner.h"
45 #include "ardour/send.h"
46 #include "ardour/processor.h"
47 #include "ardour/profile.h"
48 #include "ardour/ladspa_plugin.h"
49 #include "ardour/user_bundle.h"
51 #include "ardour_ui.h"
52 #include "ardour_dialog.h"
53 #include "mixer_strip.h"
56 #include "public_editor.h"
58 #include "io_selector.h"
60 #include "gui_thread.h"
61 #include "route_group_menu.h"
66 using namespace ARDOUR;
69 using namespace Gtkmm2ext;
72 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
74 int MixerStrip::scrollbar_height = 0;
76 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, bool in_mixer)
80 , _mixer_owned (in_mixer)
81 , pre_processor_box (PreFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
82 , post_processor_box (PostFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
86 , middle_button_table (1, 2)
87 , bottom_button_table (1, 2)
88 , meter_point_label (_("pre"))
89 , comment_button (_("Comments"))
95 /* the editor mixer strip: don't destroy it every time
96 the underlying route goes away.
99 self_destruct = false;
103 MixerStrip::MixerStrip (Mixer_UI& mx, Session& sess, boost::shared_ptr<Route> rt, bool in_mixer)
107 , _mixer_owned (in_mixer)
108 , pre_processor_box (PreFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
109 , post_processor_box (PostFader, sess, mx.plugin_selector(), mx.selection(), this, in_mixer)
112 , button_table (3, 2)
113 , middle_button_table (1, 2)
114 , bottom_button_table (1, 2)
115 , meter_point_label (_("pre"))
116 , comment_button (_("Comments"))
130 _marked_for_display = false;
132 ignore_comment_edit = false;
133 ignore_toggle = false;
141 img = manage (new Gtk::Image (::get_icon("strip_width")));
144 width_button.add (*img);
146 img = manage (new Gtk::Image (::get_icon("hide")));
149 hide_button.add (*img);
151 input_label.set_text (_("Input"));
152 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
153 input_button.add (input_label);
154 input_button.set_name ("MixerIOButton");
155 input_label.set_name ("MixerIOButtonLabel");
156 Gtkmm2ext::set_size_request_to_display_given_text (input_button, "longest label", 4, 4);
158 output_label.set_text (_("Output"));
159 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
160 output_button.add (output_label);
161 output_button.set_name ("MixerIOButton");
162 output_label.set_name ("MixerIOButtonLabel");
163 Gtkmm2ext::set_size_request_to_display_given_text (output_button, "longest label", 4, 4);
165 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
166 meter_point_button.add (meter_point_label);
167 meter_point_button.set_name ("MixerStripMeterPreButton");
168 meter_point_label.set_name ("MixerStripMeterPreButton");
170 /* TRANSLATORS: this string should be longest of the strings
171 used to describe meter points. In english, it's "input".
173 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
175 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
177 meter_point_button.signal_button_press_event().connect (mem_fun (gpm, &GainMeter::meter_press), false);
178 meter_point_button.signal_button_release_event().connect (mem_fun (gpm, &GainMeter::meter_release), false);
180 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
182 mute_button->set_name ("MixerMuteButton");
183 solo_button->set_name ("MixerSoloButton");
185 button_table.set_homogeneous (true);
186 button_table.set_spacings (0);
188 button_table.attach (name_button, 0, 2, 0, 1);
189 button_table.attach (input_button, 0, 2, 1, 2);
191 middle_button_table.set_homogeneous (true);
192 middle_button_table.set_spacings (0);
193 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
194 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
196 bottom_button_table.set_col_spacings (0);
197 bottom_button_table.set_homogeneous (true);
198 bottom_button_table.attach (group_button, 0, 1, 0, 1);
200 name_button.add (name_label);
201 name_button.set_name ("MixerNameButton");
202 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
204 name_label.set_name ("MixerNameButtonLabel");
205 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
206 group_button.add (group_label);
207 group_button.set_name ("MixerGroupButton");
208 group_label.set_name ("MixerGroupButtonLabel");
210 comment_button.set_name ("MixerCommentButton");
212 comment_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::comment_button_clicked));
214 global_vpacker.set_border_width (0);
215 global_vpacker.set_spacing (0);
217 width_button.set_name ("MixerWidthButton");
218 hide_button.set_name ("MixerHideButton");
219 top_event_box.set_name ("MixerTopEventBox");
221 width_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::width_clicked));
222 hide_button.signal_clicked().connect (mem_fun(*this, &MixerStrip::hide_clicked));
224 width_hide_box.pack_start (width_button, false, true);
225 width_hide_box.pack_start (top_event_box, true, true);
226 width_hide_box.pack_end (hide_button, false, true);
227 gain_meter_alignment.set_padding(0, 4, 0, 0);
228 gain_meter_alignment.add(gpm);
230 whvbox.pack_start (width_hide_box, true, true);
232 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
233 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
234 global_vpacker.pack_start (pre_processor_box, true, true);
235 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
236 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
237 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
238 global_vpacker.pack_start (post_processor_box, true, true);
239 if (!is_midi_track()) {
240 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
242 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
243 global_vpacker.pack_start (comment_button, Gtk::PACK_SHRINK);
245 global_frame.add (global_vpacker);
246 global_frame.set_shadow_type (Gtk::SHADOW_IN);
247 global_frame.set_name ("BaseFrame");
251 /* force setting of visible selected status */
254 set_selected (false);
259 _session.engine().Stopped.connect (mem_fun(*this, &MixerStrip::engine_stopped));
260 _session.engine().Running.connect (mem_fun(*this, &MixerStrip::engine_running));
262 input_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::input_press), false);
263 output_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::output_press), false);
265 solo_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::solo_press), false);
266 solo_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::solo_release), false);
267 mute_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::mute_press), false);
268 mute_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::mute_release), 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");
275 rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false);
276 rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release));
278 /* ditto for this button and busses */
280 show_sends_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::show_sends_press), false);
281 show_sends_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::show_sends_release));
283 name_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::name_button_button_press), false);
284 group_button.signal_button_press_event().connect (mem_fun(*this, &MixerStrip::select_route_group), false);
288 /* start off as a passthru strip. we'll correct this, if necessary,
289 in update_diskstream_display().
292 /* start off as a passthru strip. we'll correct this, if necessary,
293 in update_diskstream_display().
297 set_name ("MidiTrackStripBase");
299 set_name ("AudioTrackStripBase");
301 add_events (Gdk::BUTTON_RELEASE_MASK);
303 SwitchIO.connect (mem_fun (*this, &MixerStrip::switch_io));
307 MixerStrip::~MixerStrip ()
309 GoingAway(); /* EMIT_SIGNAL */
311 delete input_selector;
312 delete output_selector;
316 MixerStrip::set_route (boost::shared_ptr<Route> rt)
318 if (rec_enable_button->get_parent()) {
319 button_table.remove (*rec_enable_button);
322 if (show_sends_button->get_parent()) {
323 button_table.remove (*show_sends_button);
326 RouteUI::set_route (rt);
328 delete input_selector;
331 delete output_selector;
334 boost::shared_ptr<Send> send;
336 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
337 send->set_metering (false);
340 _current_delivery = _route->main_outs ();
342 panners.set_panner (rt->main_outs()->panner());
343 gpm.set_controls (rt, rt->shared_peak_meter(), rt->gain_control(), rt->amp());
344 pre_processor_box.set_route (rt);
345 post_processor_box.set_route (rt);
347 if (set_color_from_route()) {
348 set_color (unique_random_color());
351 if (_mixer_owned && (route()->is_master() || route()->is_control())) {
353 if (scrollbar_height == 0) {
354 HScrollbar scrollbar;
355 Gtk::Requisition requisition(scrollbar.size_request ());
356 scrollbar_height = requisition.height;
359 spacer = manage (new EventBox);
360 spacer->set_size_request (-1, scrollbar_height);
361 global_vpacker.pack_start (*spacer, false, false);
364 if (is_audio_track()) {
366 boost::shared_ptr<AudioTrack> at = audio_track();
368 connections.push_back (at->FreezeChange.connect (mem_fun(*this, &MixerStrip::map_frozen)));
370 button_table.attach (*rec_enable_button, 0, 2, 2, 3);
371 rec_enable_button->show();
373 } else if (!is_track()) {
376 if (!_route->is_master()) {
377 button_table.attach (*show_sends_button, 0, 2, 2, 3);
378 show_sends_button->show();
382 if (_route->phase_invert()) {
383 name_label.set_text (X_("Ø ") + name_label.get_text());
385 name_label.set_text (_route->name());
388 switch (_route->meter_point()) {
390 meter_point_label.set_text (_("input"));
394 meter_point_label.set_text (_("pre"));
398 meter_point_label.set_text (_("post"));
402 delete route_ops_menu;
405 ARDOUR_UI::instance()->tooltips().set_tip (comment_button, _route->comment().empty() ?
406 _("Click to Add/Edit Comments"):
409 connections.push_back (_route->meter_change.connect (
410 mem_fun(*this, &MixerStrip::meter_changed)));
411 connections.push_back (_route->input()->changed.connect (
412 mem_fun(*this, &MixerStrip::input_changed)));
413 connections.push_back (_route->output()->changed.connect (
414 mem_fun(*this, &MixerStrip::output_changed)));
415 connections.push_back (_route->route_group_changed.connect (
416 mem_fun(*this, &MixerStrip::route_group_changed)));
418 if (_route->panner()) {
419 connections.push_back (_route->panner()->Changed.connect (
420 mem_fun(*this, &MixerStrip::connect_to_pan)));
423 if (is_audio_track()) {
424 connections.push_back (audio_track()->DiskstreamChanged.connect (
425 mem_fun(*this, &MixerStrip::diskstream_changed)));
428 connections.push_back (_route->NameChanged.connect (
429 mem_fun(*this, &RouteUI::name_changed)));
430 connections.push_back (_route->comment_changed.connect (
431 mem_fun(*this, &MixerStrip::comment_changed)));
432 connections.push_back (_route->gui_changed.connect (
433 mem_fun(*this, &MixerStrip::route_gui_changed)));
435 set_stuff_from_route ();
437 /* now force an update of all the various elements */
439 pre_processor_box.update();
440 post_processor_box.update();
445 route_group_changed (0);
449 panners.setup_pan ();
451 update_diskstream_display ();
452 update_input_display ();
453 update_output_display ();
455 add_events (Gdk::BUTTON_RELEASE_MASK);
457 pre_processor_box.show();
459 if (!route()->is_master() && !route()->is_control()) {
460 /* we don't allow master or control routes to be hidden */
465 width_hide_box.show();
468 global_vpacker.show();
470 middle_button_table.show();
471 bottom_button_table.show();
472 pre_processor_box.show_all ();
475 gain_meter_alignment.show ();
476 post_processor_box.show_all ();
477 gain_unit_button.show();
478 gain_unit_label.show();
479 meter_point_button.show();
480 meter_point_label.show();
481 diskstream_button.show();
482 diskstream_label.show();
485 output_button.show();
489 comment_button.show();
497 MixerStrip::set_stuff_from_route ()
503 /* if width is not set, it will be set by the MixerUI or editor */
505 if ((prop = xml_node->property ("strip-width")) != 0) {
506 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
509 if ((prop = xml_node->property ("shown-mixer")) != 0) {
510 if (prop->value() == "no") {
511 _marked_for_display = false;
513 _marked_for_display = true;
516 /* backwards compatibility */
517 _marked_for_display = true;
522 MixerStrip::set_width_enum (Width w, void* owner)
524 /* always set the gpm width again, things may be hidden */
527 panners.set_width (w);
528 pre_processor_box.set_width (w);
529 post_processor_box.set_width (w);
531 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
533 _width_owner = owner;
539 if (_width_owner == this) {
540 xml_node->add_property ("strip-width", enum_2_string (_width));
547 if (show_sends_button) {
548 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
551 if (_route->comment() == "") {
552 comment_button.unset_bg (STATE_NORMAL);
553 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
555 comment_button.modify_bg (STATE_NORMAL, color());
556 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
559 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
560 gpm.astyle_string(gain_automation->automation_style()));
561 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
562 gpm.astate_string(gain_automation->automation_state()));
564 if (_route->panner()) {
565 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
566 panners.astyle_string(_route->panner()->automation_style()));
567 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
568 panners.astate_string(_route->panner()->automation_state()));
571 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
572 set_size_request (-1, -1);
576 if (show_sends_button) {
577 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
580 if (_route->comment() == "") {
581 comment_button.unset_bg (STATE_NORMAL);
582 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
584 comment_button.modify_bg (STATE_NORMAL, color());
585 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
588 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
589 gpm.short_astyle_string(gain_automation->automation_style()));
590 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
591 gpm.short_astate_string(gain_automation->automation_state()));
593 if (_route->panner()) {
594 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
595 panners.short_astyle_string(_route->panner()->automation_style()));
596 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
597 panners.short_astate_string(_route->panner()->automation_state()));
600 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "longest label", 2, 2);
601 set_size_request (max (50, gpm.get_gm_width()), -1);
604 update_input_display ();
605 update_output_display ();
606 route_group_changed (0);
612 MixerStrip::set_packed (bool yn)
619 xml_node->add_property ("shown-mixer", "yes");
621 xml_node->add_property ("shown-mixer", "no");
627 MixerStrip::output_press (GdkEventButton *ev)
629 using namespace Menu_Helpers;
630 if (!_session.engine().connected()) {
631 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
636 MenuList& citems = output_menu.items();
637 switch (ev->button) {
640 edit_output_configuration ();
645 output_menu.set_name ("ArdourContextMenu");
648 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
649 citems.push_back (SeparatorElem());
651 ARDOUR::BundleList current = _route->output()->bundles_connected ();
653 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
654 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
655 maybe_add_bundle_to_output_menu (*i, current);
658 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
659 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
660 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
663 if (citems.size() == 2) {
664 /* no routes added; remove the separator */
668 output_menu.popup (1, ev->time);
679 MixerStrip::edit_output_configuration ()
681 if (output_selector == 0) {
682 output_selector = new IOSelectorWindow (_session, _route->output());
685 if (output_selector->is_visible()) {
686 output_selector->get_toplevel()->get_window()->raise();
688 output_selector->present ();
693 MixerStrip::edit_input_configuration ()
695 if (input_selector == 0) {
696 input_selector = new IOSelectorWindow (_session, _route->input());
699 if (input_selector->is_visible()) {
700 input_selector->get_toplevel()->get_window()->raise();
702 input_selector->present ();
707 MixerStrip::input_press (GdkEventButton *ev)
709 using namespace Menu_Helpers;
711 MenuList& citems = input_menu.items();
712 input_menu.set_name ("ArdourContextMenu");
715 if (!_session.engine().connected()) {
716 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
721 switch (ev->button) {
724 edit_input_configuration ();
729 citems.push_back (MenuElem (_("Disconnect"), mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
730 citems.push_back (SeparatorElem());
732 ARDOUR::BundleList current = _route->input()->bundles_connected ();
734 boost::shared_ptr<ARDOUR::BundleList> b = _session.bundles ();
735 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
736 maybe_add_bundle_to_input_menu (*i, current);
739 boost::shared_ptr<ARDOUR::RouteList> routes = _session.get_routes ();
740 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
741 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
744 if (citems.size() == 2) {
745 /* no routes added; remove the separator */
749 input_menu.popup (1, ev->time);
759 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
765 ARDOUR::BundleList current = _route->input()->bundles_connected ();
767 if (std::find (current.begin(), current.end(), c) == current.end()) {
768 _route->input()->connect_ports_to_bundle (c, this);
770 _route->input()->disconnect_ports_from_bundle (c, this);
775 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
781 ARDOUR::BundleList current = _route->output()->bundles_connected ();
783 if (std::find (current.begin(), current.end(), c) == current.end()) {
784 _route->output()->connect_ports_to_bundle (c, this);
786 _route->output()->disconnect_ports_from_bundle (c, this);
791 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
793 using namespace Menu_Helpers;
795 if (b->ports_are_outputs() == false ||
796 route()->input()->default_type() != b->type() ||
797 b->nchannels() != _route->n_inputs().get (b->type ())) {
802 MenuList& citems = input_menu.items();
804 std::string n = b->name ();
805 replace_all (n, "_", " ");
807 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
809 if (std::find (current.begin(), current.end(), b) != current.end()) {
810 ignore_toggle = true;
811 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
812 ignore_toggle = false;
817 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
819 using namespace Menu_Helpers;
821 if (b->ports_are_inputs() == false ||
822 route()->output()->default_type() != b->type() ||
823 b->nchannels() != _route->n_outputs().get (b->type ())) {
828 MenuList& citems = output_menu.items();
830 std::string n = b->name ();
831 replace_all (n, "_", " ");
833 citems.push_back (CheckMenuElem (n, bind (mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
835 if (std::find (current.begin(), current.end(), b) != current.end()) {
836 ignore_toggle = true;
837 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
838 ignore_toggle = false;
843 MixerStrip::update_diskstream_display ()
847 if (input_selector) {
848 input_selector->hide_all ();
855 show_passthru_color ();
860 MixerStrip::connect_to_pan ()
862 ENSURE_GUI_THREAD(mem_fun(*this, &MixerStrip::connect_to_pan));
864 panstate_connection.disconnect ();
865 panstyle_connection.disconnect ();
867 if (!_route->panner()) {
871 boost::shared_ptr<ARDOUR::AutomationControl> pan_control
872 = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
873 _route->panner()->data().control(Evoral::Parameter(PanAutomation)));
876 panstate_connection = pan_control->alist()->automation_state_changed.connect (mem_fun(panners, &PannerUI::pan_automation_state_changed));
877 panstyle_connection = pan_control->alist()->automation_style_changed.connect (mem_fun(panners, &PannerUI::pan_automation_style_changed));
880 panners.pan_changed (this);
884 MixerStrip::update_input_display ()
886 ARDOUR::BundleList const c = _route->input()->bundles_connected();
889 input_label.set_text (_("Inputs"));
890 } else if (c.size() == 1) {
891 input_label.set_text (c[0]->name ());
895 input_label.set_text (_(" Input"));
898 input_label.set_text (_("I"));
902 panners.setup_pan ();
906 MixerStrip::update_output_display ()
908 ARDOUR::BundleList const c = _route->output()->bundles_connected ();
910 /* XXX: how do we represent >1 connected bundle? */
912 output_label.set_text (_("Outputs"));
913 } else if (c.size() == 1) {
914 output_label.set_text (c[0]->name());
918 output_label.set_text (_("Output"));
921 output_label.set_text (_("O"));
927 panners.setup_pan ();
931 MixerStrip::fast_update ()
933 gpm.update_meters ();
937 MixerStrip::diskstream_changed ()
939 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_diskstream_display));
943 MixerStrip::input_changed (IOChange change, void *src)
945 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_input_display));
946 set_width_enum (_width, this);
950 MixerStrip::output_changed (IOChange change, void *src)
952 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &MixerStrip::update_output_display));
953 set_width_enum (_width, this);
958 MixerStrip::comment_editor_done_editing()
960 string str = comment_area->get_buffer()->get_text();
961 if (_route->comment() != str) {
962 _route->set_comment (str, this);
968 comment_button.modify_bg (STATE_NORMAL, color());
969 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Comments*"));
971 comment_button.unset_bg (STATE_NORMAL);
972 ((Gtk::Label*)comment_button.get_child())->set_text (_("Comments"));
978 comment_button.modify_bg (STATE_NORMAL, color());
979 ((Gtk::Label*)comment_button.get_child())->set_text (_("*Cmt*"));
981 comment_button.unset_bg (STATE_NORMAL);
982 ((Gtk::Label*)comment_button.get_child())->set_text (_("Cmt"));
987 ARDOUR_UI::instance()->tooltips().set_tip (comment_button,
988 str.empty() ? _("Click to Add/Edit Comments") : str);
994 MixerStrip::comment_button_clicked ()
996 if (comment_window == 0) {
997 setup_comment_editor ();
1000 int x, y, cw_width, cw_height;
1002 if (comment_window->is_visible()) {
1003 comment_window->hide ();
1007 comment_window->get_size (cw_width, cw_height);
1008 comment_window->get_position(x, y);
1009 comment_window->move(x, y - (cw_height / 2) - 45);
1011 half the dialog height minus the comments button height
1012 with some window decoration fudge thrown in.
1015 comment_window->show();
1016 comment_window->present();
1020 MixerStrip::setup_comment_editor ()
1023 title = _route->name();
1024 title += _(": comment editor");
1026 comment_window = new ArdourDialog (title, false);
1027 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1028 comment_window->set_skip_taskbar_hint (true);
1029 comment_window->signal_hide().connect (mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1031 comment_area = manage (new TextView());
1032 comment_area->set_name ("MixerTrackCommentArea");
1033 comment_area->set_size_request (110, 178);
1034 comment_area->set_wrap_mode (WRAP_WORD);
1035 comment_area->set_editable (true);
1036 comment_area->get_buffer()->set_text (_route->comment());
1037 comment_area->show ();
1039 comment_window->get_vbox()->pack_start (*comment_area);
1040 comment_window->get_action_area()->hide();
1044 MixerStrip::comment_changed (void *src)
1046 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::comment_changed), src));
1049 ignore_comment_edit = true;
1051 comment_area->get_buffer()->set_text (_route->comment());
1053 ignore_comment_edit = false;
1058 MixerStrip::set_route_group (RouteGroup *rg)
1060 _route->set_route_group (rg, this);
1064 MixerStrip::select_route_group (GdkEventButton *ev)
1066 using namespace Menu_Helpers;
1068 if (ev->button == 1) {
1070 if (group_menu == 0) {
1071 group_menu = new RouteGroupMenu (_session);
1072 group_menu->GroupSelected.connect (mem_fun (*this, &MixerStrip::set_route_group));
1075 group_menu->popup (1, ev->time);
1082 MixerStrip::route_group_changed (void *ignored)
1084 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_group_changed), ignored));
1086 RouteGroup *rg = _route->route_group();
1089 /* XXX: this needs a better algorithm */
1090 string truncated = rg->name ();
1091 if (truncated.length () > 5) {
1092 truncated = truncated.substr (0, 5);
1094 group_label.set_text (truncated);
1098 group_label.set_text (_("Grp"));
1101 group_label.set_text (_("~G"));
1109 MixerStrip::route_gui_changed (string what_changed, void* ignored)
1111 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_gui_changed), what_changed, ignored));
1113 if (what_changed == "color") {
1114 if (set_color_from_route () == 0) {
1115 show_route_color ();
1121 MixerStrip::show_route_color ()
1123 name_button.modify_bg (STATE_NORMAL, color());
1124 top_event_box.modify_bg (STATE_NORMAL, color());
1125 route_active_changed ();
1129 MixerStrip::show_passthru_color ()
1131 route_active_changed ();
1135 MixerStrip::build_route_ops_menu ()
1137 using namespace Menu_Helpers;
1138 route_ops_menu = new Menu;
1139 route_ops_menu->set_name ("ArdourContextMenu");
1141 MenuList& items = route_ops_menu->items();
1143 items.push_back (MenuElem (_("Save As Template"), mem_fun(*this, &RouteUI::save_as_template)));
1144 items.push_back (MenuElem (_("Rename"), mem_fun(*this, &RouteUI::route_rename)));
1145 rename_menu_item = &items.back();
1146 items.push_back (SeparatorElem());
1147 items.push_back (CheckMenuElem (_("Active"), mem_fun (*this, &RouteUI::toggle_route_active)));
1148 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1149 route_active_menu_item->set_active (_route->active());
1151 items.push_back (SeparatorElem());
1153 items.push_back (MenuElem (_("Adjust latency"), mem_fun (*this, &RouteUI::adjust_latency)));
1155 items.push_back (SeparatorElem());
1156 items.push_back (CheckMenuElem (_("Invert Polarity"), mem_fun (*this, &RouteUI::toggle_polarity)));
1157 polarity_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1158 polarity_menu_item->set_active (_route->phase_invert());
1159 items.push_back (CheckMenuElem (_("Protect against denormals"), mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1160 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1161 denormal_menu_item->set_active (_route->denormal_protection());
1163 if (!Profile->get_sae()) {
1164 build_remote_control_menu ();
1165 items.push_back (SeparatorElem());
1166 items.push_back (MenuElem (_("Remote Control ID"), *remote_control_menu));
1169 items.push_back (SeparatorElem());
1170 items.push_back (MenuElem (_("Remove"), mem_fun(*this, &RouteUI::remove_this_route)));
1174 MixerStrip::name_button_button_press (GdkEventButton* ev)
1176 if (ev->button == 1 || ev->button == 3) {
1177 list_route_operations ();
1179 /* do not allow rename if the track is record-enabled */
1180 rename_menu_item->set_sensitive (!_route->record_enabled());
1181 route_ops_menu->popup (1, ev->time);
1187 MixerStrip::list_route_operations ()
1189 if (route_ops_menu == 0) {
1190 build_route_ops_menu ();
1193 refresh_remote_control_menu();
1197 MixerStrip::set_selected (bool yn)
1199 AxisView::set_selected (yn);
1201 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1202 global_frame.set_name ("MixerStripSelectedFrame");
1204 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1205 global_frame.set_name ("MixerStripFrame");
1207 global_frame.queue_draw ();
1211 MixerStrip::name_changed ()
1215 RouteUI::name_changed ();
1218 name_label.set_text (PBD::short_version (_route->name(), 5));
1221 if (_route->phase_invert()) {
1222 name_label.set_text (X_("Ø ") + name_label.get_text());
1227 MixerStrip::width_clicked ()
1231 set_width_enum (Narrow, this);
1234 set_width_enum (Wide, this);
1240 MixerStrip::hide_clicked ()
1242 // LAME fix to reset the button status for when it is redisplayed (part 1)
1243 hide_button.set_sensitive(false);
1246 Hiding(); /* EMIT_SIGNAL */
1248 _mixer.hide_strip (this);
1252 hide_button.set_sensitive(true);
1256 MixerStrip::set_embedded (bool yn)
1262 MixerStrip::map_frozen ()
1264 ENSURE_GUI_THREAD (mem_fun(*this, &MixerStrip::map_frozen));
1266 boost::shared_ptr<AudioTrack> at = audio_track();
1269 switch (at->freeze_state()) {
1270 case AudioTrack::Frozen:
1271 pre_processor_box.set_sensitive (false);
1272 post_processor_box.set_sensitive (false);
1275 pre_processor_box.set_sensitive (true);
1276 post_processor_box.set_sensitive (true);
1277 // XXX need some way, maybe, to retoggle redirect editors
1282 hide_redirect_editors ();
1286 MixerStrip::hide_redirect_editors ()
1288 _route->foreach_processor (mem_fun (*this, &MixerStrip::hide_processor_editor));
1292 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1294 boost::shared_ptr<Processor> processor (p.lock ());
1299 void* gui = processor->get_gui ();
1302 static_cast<Gtk::Widget*>(gui)->hide ();
1307 MixerStrip::route_active_changed ()
1309 RouteUI::route_active_changed ();
1311 if (is_midi_track()) {
1312 if (_route->active()) {
1313 set_name ("MidiTrackStripBase");
1314 gpm.set_meter_strip_name ("MidiTrackStripBase");
1316 set_name ("MidiTrackStripBaseInactive");
1317 gpm.set_meter_strip_name ("MidiTrackStripBaseInactive");
1319 gpm.set_fader_name ("MidiTrackFader");
1320 } else if (is_audio_track()) {
1321 if (_route->active()) {
1322 set_name ("AudioTrackStripBase");
1323 gpm.set_meter_strip_name ("AudioTrackMetrics");
1325 set_name ("AudioTrackStripBaseInactive");
1326 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1328 gpm.set_fader_name ("AudioTrackFader");
1330 if (_route->active()) {
1331 set_name ("AudioBusStripBase");
1332 gpm.set_meter_strip_name ("AudioBusMetrics");
1334 set_name ("AudioBusStripBaseInactive");
1335 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1337 gpm.set_fader_name ("AudioBusFader");
1339 /* (no MIDI busses yet) */
1344 MixerStrip::route_group() const
1346 return _route->route_group();
1350 MixerStrip::engine_stopped ()
1355 MixerStrip::engine_running ()
1360 MixerStrip::meter_changed (void *src)
1362 ENSURE_GUI_THREAD (bind (mem_fun(*this, &MixerStrip::meter_changed), src));
1364 switch (_route->meter_point()) {
1366 meter_point_label.set_text (_("input"));
1370 meter_point_label.set_text (_("pre"));
1373 case MeterPostFader:
1374 meter_point_label.set_text (_("post"));
1378 gpm.setup_meters ();
1379 // reset peak when meter point changes
1380 gpm.reset_peak_display();
1381 set_width_enum (_width, this);
1385 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1387 if (_route == target || _route->is_master()) {
1388 /* don't change the display for the target or the master bus */
1390 } else if (!is_track() && show_sends_button) {
1391 /* make sure our show sends button is inactive, and we no longer blink,
1392 since we're not the target.
1394 send_blink_connection.disconnect ();
1395 show_sends_button->set_active (false);
1396 show_sends_button->set_state (STATE_NORMAL);
1400 /* switch back to default */
1401 revert_to_default_display ();
1405 boost::shared_ptr<Send> send;
1407 if (_current_delivery && (send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1408 send->set_metering (false);
1411 _current_delivery = _route->internal_send_for (target);
1413 if (_current_delivery) {
1414 send = boost::dynamic_pointer_cast<Send>(_current_delivery);
1415 send->set_metering (true);
1416 _current_delivery->GoingAway.connect (mem_fun (*this, &MixerStrip::revert_to_default_display));
1417 gain_meter().set_controls (_route, send->meter(), send->amp()->gain_control(), send->amp());
1418 panner_ui().set_panner (_current_delivery->panner());
1421 _current_delivery = _route->main_outs ();
1422 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
1423 panner_ui().set_panner (_route->main_outs()->panner());
1426 gain_meter().setup_meters ();
1427 panner_ui().setup_pan ();
1432 MixerStrip::revert_to_default_display ()
1434 show_sends_button->set_active (false);
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->main_outs();
1444 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->gain_control(), _route->amp());
1445 gain_meter().setup_meters ();
1446 panner_ui().set_panner (_route->main_outs()->panner());
1447 panner_ui().setup_pan ();
1451 MixerStrip::set_button_names ()
1455 rec_enable_button_label.set_text (_("Rec"));
1456 mute_button_label.set_text (_("Mute"));
1457 switch (Config->get_solo_model()) {
1459 solo_button_label.set_text (_("Solo"));
1462 solo_button_label.set_text (_("AFL"));
1465 solo_button_label.set_text (_("PFL"));
1471 rec_enable_button_label.set_text (_("R"));
1472 mute_button_label.set_text (_("M"));
1473 switch (Config->get_solo_model()) {
1475 solo_button_label.set_text (_("S"));
1478 solo_button_label.set_text (_("A"));
1481 solo_button_label.set_text (_("P"));