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_dialog.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::add_route_group_to_menu (RouteGroup *rg, RadioMenuItem::Group* group)
1066 using namespace Menu_Helpers;
1068 MenuList& items = group_menu->items();
1070 items.push_back (RadioMenuElem (*group, rg->name(), bind (mem_fun(*this, &MixerStrip::set_route_group), rg)));
1072 if (_route->route_group() == rg) {
1073 static_cast<RadioMenuItem*>(&items.back())->set_active ();
1078 MixerStrip::select_route_group (GdkEventButton *ev)
1080 using namespace Menu_Helpers;
1082 if (group_menu == 0) {
1083 group_menu = new Menu;
1085 group_menu->set_name ("ArdourContextMenu");
1086 MenuList& items = group_menu->items();
1087 RadioMenuItem::Group group;
1089 switch (ev->button) {
1094 items.push_back (MenuElem (_("New group..."), mem_fun (*this, &MixerStrip::set_route_group_to_new)));
1096 items.push_back (SeparatorElem ());
1098 items.push_back (RadioMenuElem (group, _("No group"), bind (mem_fun(*this, &MixerStrip::set_route_group), (RouteGroup *) 0)));
1100 _session.foreach_route_group (bind (mem_fun (*this, &MixerStrip::add_route_group_to_menu), &group));
1102 group_menu->popup (1, ev->time);
1113 MixerStrip::route_group_changed (void *ignored)
1115 ENSURE_GUI_THREAD(bind (mem_fun(*this, &MixerStrip::route_group_changed), ignored));
1117 RouteGroup *rg = _route->route_group();
1120 /* XXX: this needs a better algorithm */
1121 string truncated = rg->name ();
1122 if (truncated.length () > 5) {
1123 truncated = truncated.substr (0, 5);
1125 group_label.set_text (truncated);
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_enum (Narrow, this);
1265 set_width_enum (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::route_group() const
1377 return _route->route_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_enum (_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->internal_send_for (target);
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 ();
1482 MixerStrip::set_button_names ()
1486 rec_enable_button_label.set_text (_("Rec"));
1487 mute_button_label.set_text (_("Mute"));
1488 switch (Config->get_solo_model()) {
1490 solo_button_label.set_text (_("Solo"));
1493 solo_button_label.set_text (_("AFL"));
1496 solo_button_label.set_text (_("PFL"));
1502 rec_enable_button_label.set_text (_("R"));
1503 mute_button_label.set_text (_("M"));
1504 switch (Config->get_solo_model()) {
1506 solo_button_label.set_text (_("S"));
1509 solo_button_label.set_text (_("A"));
1512 solo_button_label.set_text (_("P"));
1521 MixerStrip::set_route_group_to_new ()
1523 RouteGroup* g = new RouteGroup (_session, "", RouteGroup::Active);
1524 g->set_active (true, this);
1526 RouteGroupDialog d (g, Gtk::Stock::NEW);
1527 int const r = d.do_run ();
1529 if (r == Gtk::RESPONSE_OK) {
1530 _session.add_route_group (g);
1531 _route->set_route_group (g, this);