sanitycheck should be looking for SCHED_FIFO
[ardour2.git] / gtk2_ardour / mixer_strip.cc
blob33b012aebb27d9bee17fcef1eb8718d35132a5bc
1 /*
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.
19 #include <cmath>
20 #include <algorithm>
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/doi.h>
32 #include <gtkmm2ext/slider_controller.h>
33 #include <gtkmm2ext/bindable_button.h>
35 #include "ardour/ardour.h"
36 #include "ardour/amp.h"
37 #include "ardour/session.h"
38 #include "ardour/audioengine.h"
39 #include "ardour/internal_send.h"
40 #include "ardour/route.h"
41 #include "ardour/route_group.h"
42 #include "ardour/audio_track.h"
43 #include "ardour/pannable.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"
50 #include "ardour/port.h"
52 #include "ardour_ui.h"
53 #include "ardour_dialog.h"
54 #include "mixer_strip.h"
55 #include "mixer_ui.h"
56 #include "keyboard.h"
57 #include "led.h"
58 #include "public_editor.h"
59 #include "send_ui.h"
60 #include "io_selector.h"
61 #include "utils.h"
62 #include "gui_thread.h"
63 #include "route_group_menu.h"
65 #include "i18n.h"
67 using namespace ARDOUR;
68 using namespace PBD;
69 using namespace Gtk;
70 using namespace Gtkmm2ext;
71 using namespace std;
73 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
75 int MixerStrip::scrollbar_height = 0;
76 PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
78 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
79 : AxisView(sess)
80 , RouteUI (sess)
81 , _mixer(mx)
82 , _mixer_owned (in_mixer)
83 , processor_box (sess, boost::bind (&MixerStrip::plugin_selector, this), mx.selection(), this, in_mixer)
84 , gpm (sess, 250)
85 , panners (sess)
86 , button_table (3, 1)
87 , solo_led_table (2, 2)
88 , middle_button_table (1, 2)
89 , bottom_button_table (1, 2)
90 , meter_point_label (_("pre"))
92 init ();
94 if (!_mixer_owned) {
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)
104 : AxisView(sess)
105 , RouteUI (sess)
106 , _mixer(mx)
107 , _mixer_owned (in_mixer)
108 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
109 , gpm (sess, 250)
110 , panners (sess)
111 , button_table (3, 1)
112 , middle_button_table (1, 2)
113 , bottom_button_table (1, 2)
114 , meter_point_label (_("pre"))
116 init ();
117 set_route (rt);
120 void
121 MixerStrip::init ()
123 input_selector = 0;
124 output_selector = 0;
125 group_menu = 0;
126 _marked_for_display = false;
127 route_ops_menu = 0;
128 ignore_comment_edit = false;
129 ignore_toggle = false;
130 comment_window = 0;
131 comment_area = 0;
132 _width_owner = 0;
133 spacer = 0;
135 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
136 longest_label = "longest label";
138 Gtk::Image* img;
140 img = manage (new Gtk::Image (::get_icon("strip_width")));
141 img->show ();
143 width_button.add (*img);
145 img = manage (new Gtk::Image (::get_icon("hide")));
146 img->show ();
148 hide_button.add (*img);
150 input_label.set_text (_("Input"));
151 ARDOUR_UI::instance()->set_tip (&input_button, _("Button 1 to choose inputs from a port matrix, button 3 to select inputs from a menu"), "");
152 input_button.add (input_label);
153 input_button.set_name ("MixerIOButton");
154 input_label.set_name ("MixerIOButtonLabel");
156 Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 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.c_str(), 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 (sigc::mem_fun (gpm, &GainMeter::meter_press), false);
178 meter_point_button.signal_button_release_event().connect (sigc::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 solo_isolated_led = manage (new LED);
186 solo_isolated_led->show ();
187 solo_isolated_led->set_diameter (6);
188 solo_isolated_led->set_no_show_all (true);
189 solo_isolated_led->set_name (X_("SoloIsolatedLED"));
190 solo_isolated_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
191 solo_isolated_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_isolate_button_release));
192 UI::instance()->set_tip (solo_isolated_led, _("Isolate Solo"), "");
194 solo_safe_led = manage (new LED);
195 solo_safe_led->show ();
196 solo_safe_led->set_diameter (6);
197 solo_safe_led->set_no_show_all (true);
198 solo_safe_led->set_name (X_("SoloSafeLED"));
199 solo_safe_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
200 solo_safe_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_safe_button_release));
201 UI::instance()->set_tip (solo_safe_led, _("Lock Solo Status"), "");
203 _iso_label = manage (new Label (_("iso")));
204 _safe_label = manage (new Label (_("lock")));
206 _iso_label->set_name (X_("SoloLEDLabel"));
207 _safe_label->set_name (X_("SoloLEDLabel"));
209 _iso_label->show ();
210 _safe_label->show ();
212 solo_led_table.set_spacings (0);
213 solo_led_table.set_border_width (1);
214 solo_led_table.attach (*_iso_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
215 solo_led_table.attach (*solo_isolated_led, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
216 solo_led_table.attach (*_safe_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
217 solo_led_table.attach (*solo_safe_led, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL);
219 solo_led_table.show ();
220 below_panner_box.set_border_width (2);
221 below_panner_box.set_spacing (2);
222 below_panner_box.pack_end (solo_led_table, false, false);
223 below_panner_box.show ();
225 button_table.set_homogeneous (true);
226 button_table.set_spacings (0);
228 button_table.attach (name_button, 0, 1, 0, 1);
229 button_table.attach (input_button, 0, 1, 1, 2);
230 button_table.attach (_invert_button_box, 0, 1, 2, 3);
232 middle_button_table.set_homogeneous (true);
233 middle_button_table.set_spacings (0);
234 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
235 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
237 bottom_button_table.set_col_spacings (0);
238 bottom_button_table.set_homogeneous (true);
239 bottom_button_table.attach (group_button, 0, 1, 0, 1);
241 name_button.add (name_label);
242 name_button.set_name ("MixerNameButton");
243 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
245 name_label.set_name ("MixerNameButtonLabel");
246 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
247 group_button.add (group_label);
248 group_button.set_name ("MixerGroupButton");
249 Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Group", 2, 2);
250 group_label.set_name ("MixerGroupButtonLabel");
252 global_vpacker.set_border_width (0);
253 global_vpacker.set_spacing (0);
255 width_button.set_name ("MixerWidthButton");
256 hide_button.set_name ("MixerHideButton");
257 top_event_box.set_name ("MixerTopEventBox");
259 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
260 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
262 width_hide_box.pack_start (width_button, false, true);
263 width_hide_box.pack_start (top_event_box, true, true);
264 width_hide_box.pack_end (hide_button, false, true);
265 gain_meter_alignment.set_padding(0, 4, 0, 0);
266 gain_meter_alignment.add(gpm);
268 whvbox.pack_start (width_hide_box, true, true);
270 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
271 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
272 global_vpacker.pack_start (processor_box, true, true);
273 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
274 global_vpacker.pack_start (below_panner_box, Gtk::PACK_SHRINK);
275 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
276 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
277 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
278 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
280 global_frame.add (global_vpacker);
281 global_frame.set_shadow_type (Gtk::SHADOW_IN);
282 global_frame.set_name ("BaseFrame");
284 add (global_frame);
286 /* force setting of visible selected status */
288 _selected = true;
289 set_selected (false);
291 _packed = false;
292 _embedded = false;
294 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_stopped, this), gui_context());
295 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_running, this), gui_context());
297 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
298 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
300 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
301 hurt (much).
304 rec_enable_button->set_name ("MixerRecordEnableButton");
306 /* ditto for this button and busses */
308 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
309 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
311 _width = (Width) -1;
313 /* start off as a passthru strip. we'll correct this, if necessary,
314 in update_diskstream_display().
317 /* start off as a passthru strip. we'll correct this, if necessary,
318 in update_diskstream_display().
321 if (is_midi_track())
322 set_name ("MidiTrackStripBase");
323 else
324 set_name ("AudioTrackStripBase");
326 add_events (Gdk::BUTTON_RELEASE_MASK|
327 Gdk::ENTER_NOTIFY_MASK|
328 Gdk::LEAVE_NOTIFY_MASK|
329 Gdk::KEY_PRESS_MASK|
330 Gdk::KEY_RELEASE_MASK);
332 set_flags (get_flags() | Gtk::CAN_FOCUS);
334 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
336 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
337 *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context ()
341 MixerStrip::~MixerStrip ()
343 CatchDeletion (this);
345 delete input_selector;
346 delete output_selector;
347 delete comment_window;
350 void
351 MixerStrip::set_route (boost::shared_ptr<Route> rt)
353 if (rec_enable_button->get_parent()) {
354 below_panner_box.remove (*rec_enable_button);
357 if (show_sends_button->get_parent()) {
358 below_panner_box.remove (*show_sends_button);
361 processor_box.set_route (rt);
363 RouteUI::set_route (rt);
365 /* map the current state */
367 mute_changed (0);
368 update_solo_display ();
370 delete input_selector;
371 input_selector = 0;
373 delete output_selector;
374 output_selector = 0;
376 revert_to_default_display ();
378 if (set_color_from_route()) {
379 set_color (unique_random_color());
382 if (route()->is_master()) {
383 solo_button->hide ();
384 below_panner_box.hide ();
385 } else {
386 solo_button->show ();
387 below_panner_box.show ();
390 if (_mixer_owned && (route()->is_master() || route()->is_monitor())) {
392 if (scrollbar_height == 0) {
393 HScrollbar scrollbar;
394 Gtk::Requisition requisition(scrollbar.size_request ());
395 scrollbar_height = requisition.height;
398 spacer = manage (new EventBox);
399 spacer->set_size_request (-1, scrollbar_height);
400 global_vpacker.pack_start (*spacer, false, false);
403 if (is_audio_track()) {
404 boost::shared_ptr<AudioTrack> at = audio_track();
405 at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context());
408 if (has_audio_outputs ()) {
409 panners.show_all ();
410 } else {
411 panners.hide_all ();
414 if (is_track ()) {
416 below_panner_box.pack_start (*rec_enable_button);
417 rec_enable_button->set_sensitive (_session->writable());
418 rec_enable_button->show();
420 } else {
422 /* non-master bus */
424 if (!_route->is_master()) {
425 below_panner_box.pack_start (*show_sends_button);
426 show_sends_button->show();
430 switch (_route->meter_point()) {
431 case MeterInput:
432 meter_point_label.set_text (_("input"));
433 break;
435 case MeterPreFader:
436 meter_point_label.set_text (_("pre"));
437 break;
439 case MeterPostFader:
440 meter_point_label.set_text (_("post"));
441 break;
443 case MeterCustom:
444 meter_point_label.set_text (_("custom"));
445 break;
448 delete route_ops_menu;
449 route_ops_menu = 0;
451 _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context());
452 _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
454 if (_route->panner()) {
455 _route->panner()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
458 if (is_audio_track()) {
459 audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
462 _route->comment_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
463 _route->gui_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
465 set_stuff_from_route ();
467 /* now force an update of all the various elements */
469 mute_changed (0);
470 update_solo_display ();
471 name_changed ();
472 comment_changed (0);
473 route_group_changed ();
475 connect_to_pan ();
477 panners.setup_pan ();
479 update_diskstream_display ();
480 update_input_display ();
481 update_output_display ();
483 add_events (Gdk::BUTTON_RELEASE_MASK);
485 processor_box.show ();
487 if (!route()->is_master() && !route()->is_monitor()) {
488 /* we don't allow master or control routes to be hidden */
489 hide_button.show();
492 width_button.show();
493 width_hide_box.show();
494 whvbox.show ();
495 global_frame.show();
496 global_vpacker.show();
497 button_table.show();
498 middle_button_table.show();
499 bottom_button_table.show();
500 gpm.show_all ();
501 gain_meter_alignment.show ();
502 gain_unit_button.show();
503 gain_unit_label.show();
504 meter_point_button.show();
505 meter_point_label.show();
506 diskstream_button.show();
507 diskstream_label.show();
508 input_button.show();
509 input_label.show();
510 output_button.show();
511 output_label.show();
512 name_label.show();
513 name_button.show();
514 group_button.show();
515 group_label.show();
517 show ();
520 void
521 MixerStrip::set_stuff_from_route ()
523 XMLProperty *prop;
525 ensure_xml_node ();
527 /* if width is not set, it will be set by the MixerUI or editor */
529 if ((prop = xml_node->property ("strip-width")) != 0) {
530 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
533 if ((prop = xml_node->property ("shown-mixer")) != 0) {
534 if (prop->value() == "no") {
535 _marked_for_display = false;
536 } else {
537 _marked_for_display = true;
539 } else {
540 /* backwards compatibility */
541 _marked_for_display = true;
545 void
546 MixerStrip::set_width_enum (Width w, void* owner)
548 /* always set the gpm width again, things may be hidden */
550 gpm.set_width (w);
551 panners.set_width (w);
553 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
555 _width_owner = owner;
557 ensure_xml_node ();
559 _width = w;
561 if (_width_owner == this) {
562 xml_node->add_property ("strip-width", enum_2_string (_width));
565 set_button_names ();
567 switch (w) {
568 case Wide:
569 if (show_sends_button) {
570 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
573 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
574 gpm.astyle_string(gain_automation->automation_style()));
575 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
576 gpm.astate_string(gain_automation->automation_state()));
578 if (_route->panner()) {
579 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
580 panners.astyle_string(_route->panner()->automation_style()));
581 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
582 panners.astate_string(_route->panner()->automation_state()));
585 _iso_label->show ();
586 _safe_label->show ();
588 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
589 set_size_request (-1, -1);
590 break;
592 case Narrow:
593 if (show_sends_button) {
594 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
597 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
598 gpm.short_astyle_string(gain_automation->automation_style()));
599 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
600 gpm.short_astate_string(gain_automation->automation_state()));
602 if (_route->panner()) {
603 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
604 panners.short_astyle_string(_route->panner()->automation_style()));
605 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
606 panners.short_astate_string(_route->panner()->automation_state()));
609 _iso_label->hide ();
610 _safe_label->hide ();
612 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
613 set_size_request (max (50, gpm.get_gm_width()), -1);
614 break;
617 processor_box.set_width (w);
619 update_input_display ();
620 update_output_display ();
621 route_group_changed ();
622 name_changed ();
623 WidthChanged ();
626 void
627 MixerStrip::set_packed (bool yn)
629 _packed = yn;
631 ensure_xml_node ();
633 if (_packed) {
634 xml_node->add_property ("shown-mixer", "yes");
635 } else {
636 xml_node->add_property ("shown-mixer", "no");
641 gint
642 MixerStrip::output_press (GdkEventButton *ev)
644 using namespace Menu_Helpers;
645 if (!_session->engine().connected()) {
646 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
647 msg.run ();
648 return true;
651 MenuList& citems = output_menu.items();
652 switch (ev->button) {
654 case 1:
655 edit_output_configuration ();
656 break;
658 case 3:
660 output_menu.set_name ("ArdourContextMenu");
661 citems.clear ();
662 output_menu_bundles.clear ();
664 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
665 citems.push_back (SeparatorElem());
667 ARDOUR::BundleList current = _route->output()->bundles_connected ();
669 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
671 /* give user bundles first chance at being in the menu */
673 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
674 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
675 maybe_add_bundle_to_output_menu (*i, current);
679 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
680 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
681 maybe_add_bundle_to_output_menu (*i, current);
685 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
686 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
687 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
690 if (citems.size() == 2) {
691 /* no routes added; remove the separator */
692 citems.pop_back ();
695 output_menu.popup (1, ev->time);
696 break;
699 default:
700 break;
702 return TRUE;
705 void
706 MixerStrip::edit_output_configuration ()
708 if (output_selector == 0) {
710 boost::shared_ptr<Send> send;
711 boost::shared_ptr<IO> output;
713 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
714 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
715 output = send->output();
716 } else {
717 output = _route->output ();
719 } else {
720 output = _route->output ();
723 output_selector = new IOSelectorWindow (_session, output);
726 if (output_selector->is_visible()) {
727 output_selector->get_toplevel()->get_window()->raise();
728 } else {
729 output_selector->present ();
733 void
734 MixerStrip::edit_input_configuration ()
736 if (input_selector == 0) {
737 input_selector = new IOSelectorWindow (_session, _route->input());
740 if (input_selector->is_visible()) {
741 input_selector->get_toplevel()->get_window()->raise();
742 } else {
743 input_selector->present ();
747 gint
748 MixerStrip::input_press (GdkEventButton *ev)
750 using namespace Menu_Helpers;
752 MenuList& citems = input_menu.items();
753 input_menu.set_name ("ArdourContextMenu");
754 citems.clear();
756 if (!_session->engine().connected()) {
757 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
758 msg.run ();
759 return true;
762 if (_session->actively_recording() && _route->record_enabled())
763 return true;
765 switch (ev->button) {
767 case 1:
768 edit_input_configuration ();
769 break;
771 case 3:
773 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
774 citems.push_back (SeparatorElem());
775 input_menu_bundles.clear ();
777 ARDOUR::BundleList current = _route->input()->bundles_connected ();
779 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
781 /* give user bundles first chance at being in the menu */
783 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
784 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
785 maybe_add_bundle_to_input_menu (*i, current);
789 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
790 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
791 maybe_add_bundle_to_input_menu (*i, current);
795 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
796 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
797 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
800 if (citems.size() == 2) {
801 /* no routes added; remove the separator */
802 citems.pop_back ();
805 input_menu.popup (1, ev->time);
806 break;
808 default:
809 break;
811 return TRUE;
814 void
815 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
817 if (ignore_toggle) {
818 return;
821 ARDOUR::BundleList current = _route->input()->bundles_connected ();
823 if (std::find (current.begin(), current.end(), c) == current.end()) {
824 _route->input()->connect_ports_to_bundle (c, this);
825 } else {
826 _route->input()->disconnect_ports_from_bundle (c, this);
830 void
831 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
833 if (ignore_toggle) {
834 return;
837 ARDOUR::BundleList current = _route->output()->bundles_connected ();
839 if (std::find (current.begin(), current.end(), c) == current.end()) {
840 _route->output()->connect_ports_to_bundle (c, this);
841 } else {
842 _route->output()->disconnect_ports_from_bundle (c, this);
846 void
847 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
849 using namespace Menu_Helpers;
851 if (b->ports_are_outputs() == false || b->nchannels() != _route->n_inputs()) {
852 return;
855 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
856 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
857 ++i;
860 if (i != input_menu_bundles.end()) {
861 return;
864 input_menu_bundles.push_back (b);
866 MenuList& citems = input_menu.items();
868 std::string n = b->name ();
869 replace_all (n, "_", " ");
871 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
873 if (std::find (current.begin(), current.end(), b) != current.end()) {
874 ignore_toggle = true;
875 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
876 ignore_toggle = false;
880 void
881 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
883 using namespace Menu_Helpers;
885 if (b->ports_are_inputs() == false || b->nchannels() != _route->n_outputs()) {
886 return;
889 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
890 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
891 ++i;
894 if (i != output_menu_bundles.end()) {
895 return;
898 output_menu_bundles.push_back (b);
900 MenuList& citems = output_menu.items();
902 std::string n = b->name ();
903 replace_all (n, "_", " ");
905 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
907 if (std::find (current.begin(), current.end(), b) != current.end()) {
908 ignore_toggle = true;
909 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
910 ignore_toggle = false;
914 void
915 MixerStrip::update_diskstream_display ()
917 if (is_track()) {
919 if (input_selector) {
920 input_selector->hide_all ();
923 show_route_color ();
925 } else {
927 show_passthru_color ();
931 void
932 MixerStrip::connect_to_pan ()
934 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
936 panstate_connection.disconnect ();
937 panstyle_connection.disconnect ();
939 if (!_route->panner()) {
940 return;
943 boost::shared_ptr<Pannable> p = _route->pannable ();
945 p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
946 p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
948 panners.panner_changed (this);
953 * Output port labelling
954 * =====================
956 * Case 1: Each output has one connection, all connections are to system:playback_%i
957 * out 1 -> system:playback_1
958 * out 2 -> system:playback_2
959 * out 3 -> system:playback_3
960 * Display as: 1/2/3
962 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
963 * out 1 -> ardour:track_x/in 1
964 * out 2 -> ardour:track_x/in 2
965 * Display as: track_x
967 * Case 3: Each output has one connection, all connections are to Jack client "program x"
968 * out 1 -> program x:foo
969 * out 2 -> program x:foo
970 * Display as: program x
972 * Case 4: No connections (Disconnected)
973 * Display as: -
975 * Default case (unusual routing):
976 * Display as: *number of connections*
978 * Tooltips
979 * ========
980 * .-----------------------------------------------.
981 * | Mixdown |
982 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
983 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
984 * '-----------------------------------------------'
985 * .-----------------------------------------------.
986 * | Guitar SM58 |
987 * | Disconnected |
988 * '-----------------------------------------------'
991 void
992 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
994 uint32_t io_count;
995 uint32_t io_index;
996 Port *port;
997 vector<string> port_connections;
999 uint32_t total_connection_count = 0;
1000 uint32_t io_connection_count = 0;
1001 uint32_t ardour_connection_count = 0;
1002 uint32_t system_connection_count = 0;
1003 uint32_t other_connection_count = 0;
1005 ostringstream label;
1006 string label_string;
1008 bool have_label = false;
1009 bool each_io_has_one_connection = true;
1011 string connection_name;
1012 string ardour_track_name;
1013 string other_connection_type;
1014 string system_ports;
1015 string system_port;
1017 ostringstream tooltip;
1018 char * tooltip_cstr;
1020 tooltip << route->name();
1022 if (for_input) {
1023 io_count = route->n_inputs().n_total();
1024 } else {
1025 io_count = route->n_outputs().n_total();
1028 for (io_index = 0; io_index < io_count; ++io_index) {
1029 if (for_input) {
1030 port = route->input()->nth (io_index);
1031 } else {
1032 port = route->output()->nth (io_index);
1035 port_connections.clear ();
1036 port->get_connections(port_connections);
1037 io_connection_count = 0;
1039 if (!port_connections.empty()) {
1040 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1041 string& connection_name (*i);
1043 if (io_connection_count == 0) {
1044 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1045 } else {
1046 tooltip << ", " << connection_name;
1049 if (connection_name.find("ardour:") == 0) {
1050 if (ardour_track_name.empty()) {
1051 // "ardour:Master/in 1" -> "ardour:Master/"
1052 string::size_type slash = connection_name.find("/");
1053 if (slash != string::npos) {
1054 ardour_track_name = connection_name.substr(0, slash + 1);
1058 if (connection_name.find(ardour_track_name) == 0) {
1059 ++ardour_connection_count;
1061 } else if (connection_name.find("system:") == 0) {
1062 if (for_input) {
1063 // "system:capture_123" -> "123"
1064 system_port = connection_name.substr(15);
1065 } else {
1066 // "system:playback_123" -> "123"
1067 system_port = connection_name.substr(16);
1070 if (system_ports.empty()) {
1071 system_ports += system_port;
1072 } else {
1073 system_ports += "/" + system_port;
1076 ++system_connection_count;
1077 } else {
1078 if (other_connection_type.empty()) {
1079 // "jamin:in 1" -> "jamin:"
1080 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1083 if (connection_name.find(other_connection_type) == 0) {
1084 ++other_connection_count;
1088 ++total_connection_count;
1089 ++io_connection_count;
1093 if (io_connection_count != 1) {
1094 each_io_has_one_connection = false;
1098 if (total_connection_count == 0) {
1099 tooltip << endl << _("Disconnected");
1102 tooltip_cstr = new char[tooltip.str().size() + 1];
1103 strcpy(tooltip_cstr, tooltip.str().c_str());
1105 if (for_input) {
1106 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1107 } else {
1108 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1111 if (each_io_has_one_connection) {
1112 if ((total_connection_count == ardour_connection_count)) {
1113 // all connections are to the same track in ardour
1114 // "ardour:Master/" -> "Master"
1115 string::size_type slash = ardour_track_name.find("/");
1116 if (slash != string::npos) {
1117 label << ardour_track_name.substr(7, slash - 7);
1118 have_label = true;
1121 else if (total_connection_count == system_connection_count) {
1122 // all connections are to system ports
1123 label << system_ports;
1124 have_label = true;
1126 else if (total_connection_count == other_connection_count) {
1127 // all connections are to the same external program eg jamin
1128 // "jamin:" -> "jamin"
1129 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1130 have_label = true;
1134 if (!have_label) {
1135 if (total_connection_count == 0) {
1136 // Disconnected
1137 label << "-";
1138 } else {
1139 // Odd configuration
1140 label << "*" << total_connection_count << "*";
1144 switch (width) {
1145 case Wide:
1146 label_string = label.str().substr(0, 6);
1147 break;
1148 case Narrow:
1149 label_string = label.str().substr(0, 3);
1150 break;
1153 if (for_input) {
1154 input_label.set_text (label_string);
1155 } else {
1156 output_label.set_text (label_string);
1160 void
1161 MixerStrip::update_input_display ()
1163 update_io_button (_route, _width, true);
1164 panners.setup_pan ();
1167 void
1168 MixerStrip::update_output_display ()
1170 update_io_button (_route, _width, false);
1171 gpm.setup_meters ();
1172 panners.setup_pan ();
1175 void
1176 MixerStrip::fast_update ()
1178 gpm.update_meters ();
1181 void
1182 MixerStrip::diskstream_changed ()
1184 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
1187 void
1188 MixerStrip::port_connected_or_disconnected (Port* a, Port* b)
1190 if (_route->input()->has_port (a) || _route->input()->has_port (b)) {
1191 update_input_display ();
1192 set_width_enum (_width, this);
1195 if (_route->output()->has_port (a) || _route->output()->has_port (b)) {
1196 update_output_display ();
1197 set_width_enum (_width, this);
1201 void
1202 MixerStrip::comment_editor_done_editing ()
1204 ignore_toggle = true;
1205 _comment_menu_item->set_active (false);
1206 ignore_toggle = false;
1208 string const str = comment_area->get_buffer()->get_text();
1209 if (str == _route->comment ()) {
1210 return;
1213 _route->set_comment (str, this);
1216 void
1217 MixerStrip::toggle_comment ()
1219 if (ignore_toggle) {
1220 return;
1223 if (comment_window == 0) {
1224 setup_comment_editor ();
1227 if (comment_window->is_visible ()) {
1228 comment_window->hide ();
1229 return;
1232 comment_window->show();
1233 comment_window->present();
1236 void
1237 MixerStrip::setup_comment_editor ()
1239 string title;
1240 title = _route->name();
1241 title += _(": comment editor");
1243 comment_window = new ArdourDialog (title, false);
1244 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1245 comment_window->set_skip_taskbar_hint (true);
1246 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1248 comment_area = manage (new TextView());
1249 comment_area->set_name ("MixerTrackCommentArea");
1250 comment_area->set_size_request (110, 178);
1251 comment_area->set_wrap_mode (WRAP_WORD);
1252 comment_area->set_editable (true);
1253 comment_area->get_buffer()->set_text (_route->comment());
1254 comment_area->show ();
1256 comment_window->get_vbox()->pack_start (*comment_area);
1257 comment_window->get_action_area()->hide();
1260 void
1261 MixerStrip::comment_changed (void *src)
1263 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1265 if (src != this) {
1266 ignore_comment_edit = true;
1267 if (comment_area) {
1268 comment_area->get_buffer()->set_text (_route->comment());
1270 ignore_comment_edit = false;
1274 /** Set the route group for this strip's route, or remove it from its current group.
1275 * @param rg New RouteGroup, or 0.
1277 void
1278 MixerStrip::set_route_group (RouteGroup *rg)
1280 if (rg) {
1281 rg->add (_route);
1282 } else if (_route->route_group ()) {
1283 _route->route_group()->remove (_route);
1287 bool
1288 MixerStrip::select_route_group (GdkEventButton *ev)
1290 using namespace Menu_Helpers;
1292 if (ev->button == 1) {
1294 if (group_menu == 0) {
1296 PropertyList* plist = new PropertyList();
1298 plist->add (Properties::gain, true);
1299 plist->add (Properties::mute, true);
1300 plist->add (Properties::solo, true);
1302 group_menu = new RouteGroupMenu (_session, plist);
1303 group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
1306 group_menu->popup (1, ev->time);
1309 return true;
1312 void
1313 MixerStrip::route_group_changed ()
1315 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1317 RouteGroup *rg = _route->route_group();
1319 if (rg) {
1320 group_label.set_text (PBD::short_version (rg->name(), 5));
1321 } else {
1322 switch (_width) {
1323 case Wide:
1324 group_label.set_text (_("Grp"));
1325 break;
1326 case Narrow:
1327 group_label.set_text (_("~G"));
1328 break;
1334 void
1335 MixerStrip::route_gui_changed (string what_changed, void*)
1337 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1339 if (what_changed == "color") {
1340 if (set_color_from_route () == 0) {
1341 show_route_color ();
1346 void
1347 MixerStrip::show_route_color ()
1349 name_button.modify_bg (STATE_NORMAL, color());
1350 top_event_box.modify_bg (STATE_NORMAL, color());
1351 route_active_changed ();
1354 void
1355 MixerStrip::show_passthru_color ()
1357 route_active_changed ();
1360 void
1361 MixerStrip::build_route_ops_menu ()
1363 using namespace Menu_Helpers;
1364 route_ops_menu = new Menu;
1365 route_ops_menu->set_name ("ArdourContextMenu");
1367 MenuList& items = route_ops_menu->items();
1369 items.push_back (CheckMenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::toggle_comment)));
1370 _comment_menu_item = dynamic_cast<CheckMenuItem*> (&items.back ());
1371 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1372 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1373 rename_menu_item = &items.back();
1374 items.push_back (SeparatorElem());
1375 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
1376 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1377 route_active_menu_item->set_active (_route->active());
1379 items.push_back (SeparatorElem());
1381 items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1383 items.push_back (SeparatorElem());
1384 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1385 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1386 denormal_menu_item->set_active (_route->denormal_protection());
1388 if (!Profile->get_sae()) {
1389 items.push_back (SeparatorElem());
1390 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1393 items.push_back (SeparatorElem());
1394 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
1397 gboolean
1398 MixerStrip::name_button_button_press (GdkEventButton* ev)
1400 if (ev->button == 3) {
1401 list_route_operations ();
1403 /* do not allow rename if the track is record-enabled */
1404 rename_menu_item->set_sensitive (!_route->record_enabled());
1405 route_ops_menu->popup (1, ev->time);
1407 } else if (ev->button == 1) {
1408 revert_to_default_display ();
1411 return false;
1414 void
1415 MixerStrip::list_route_operations ()
1417 if (route_ops_menu == 0) {
1418 build_route_ops_menu ();
1422 void
1423 MixerStrip::set_selected (bool yn)
1425 AxisView::set_selected (yn);
1426 if (_selected) {
1427 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1428 global_frame.set_name ("MixerStripSelectedFrame");
1429 } else {
1430 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1431 global_frame.set_name ("MixerStripFrame");
1433 global_frame.queue_draw ();
1436 void
1437 MixerStrip::name_changed ()
1439 switch (_width) {
1440 case Wide:
1441 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1442 break;
1443 case Narrow:
1444 name_label.set_text (PBD::short_version (_route->name(), 5));
1445 break;
1449 void
1450 MixerStrip::width_clicked ()
1452 switch (_width) {
1453 case Wide:
1454 set_width_enum (Narrow, this);
1455 break;
1456 case Narrow:
1457 set_width_enum (Wide, this);
1458 break;
1462 void
1463 MixerStrip::hide_clicked ()
1465 // LAME fix to reset the button status for when it is redisplayed (part 1)
1466 hide_button.set_sensitive(false);
1468 if (_embedded) {
1469 Hiding(); /* EMIT_SIGNAL */
1470 } else {
1471 _mixer.hide_strip (this);
1474 // (part 2)
1475 hide_button.set_sensitive(true);
1478 void
1479 MixerStrip::set_embedded (bool yn)
1481 _embedded = yn;
1484 void
1485 MixerStrip::map_frozen ()
1487 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1489 boost::shared_ptr<AudioTrack> at = audio_track();
1491 if (at) {
1492 switch (at->freeze_state()) {
1493 case AudioTrack::Frozen:
1494 processor_box.set_sensitive (false);
1495 hide_redirect_editors ();
1496 break;
1497 default:
1498 processor_box.set_sensitive (true);
1499 // XXX need some way, maybe, to retoggle redirect editors
1500 break;
1505 void
1506 MixerStrip::hide_redirect_editors ()
1508 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1511 void
1512 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1514 boost::shared_ptr<Processor> processor (p.lock ());
1515 if (!processor) {
1516 return;
1519 Gtk::Window* w = processor_box.get_processor_ui (processor);
1521 if (w) {
1522 w->hide ();
1526 void
1527 MixerStrip::route_active_changed ()
1529 RouteUI::route_active_changed ();
1530 reset_strip_style ();
1533 void
1534 MixerStrip::reset_strip_style ()
1536 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1538 gpm.set_fader_name ("SendStripBase");
1540 } else {
1542 if (is_midi_track()) {
1543 if (_route->active()) {
1544 set_name ("MidiTrackStripBase");
1545 gpm.set_meter_strip_name ("MidiTrackMetrics");
1546 } else {
1547 set_name ("MidiTrackStripBaseInactive");
1548 gpm.set_meter_strip_name ("MidiTrackMetricsInactive");
1550 gpm.set_fader_name ("MidiTrackFader");
1551 } else if (is_audio_track()) {
1552 if (_route->active()) {
1553 set_name ("AudioTrackStripBase");
1554 gpm.set_meter_strip_name ("AudioTrackMetrics");
1555 } else {
1556 set_name ("AudioTrackStripBaseInactive");
1557 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1559 gpm.set_fader_name ("AudioTrackFader");
1560 } else {
1561 if (_route->active()) {
1562 set_name ("AudioBusStripBase");
1563 gpm.set_meter_strip_name ("AudioBusMetrics");
1564 } else {
1565 set_name ("AudioBusStripBaseInactive");
1566 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1568 gpm.set_fader_name ("AudioBusFader");
1570 /* (no MIDI busses yet) */
1575 RouteGroup*
1576 MixerStrip::route_group() const
1578 return _route->route_group();
1581 void
1582 MixerStrip::engine_stopped ()
1586 void
1587 MixerStrip::engine_running ()
1591 /** Called when the metering point has changed */
1592 void
1593 MixerStrip::meter_changed ()
1595 ENSURE_GUI_THREAD (*this, &MixerStrip::meter_changed)
1597 switch (_route->meter_point()) {
1598 case MeterInput:
1599 meter_point_label.set_text (_("input"));
1600 break;
1602 case MeterPreFader:
1603 meter_point_label.set_text (_("pre"));
1604 break;
1606 case MeterPostFader:
1607 meter_point_label.set_text (_("post"));
1608 break;
1610 case MeterCustom:
1611 meter_point_label.set_text (_("custom"));
1612 break;
1615 gpm.setup_meters ();
1616 // reset peak when meter point changes
1617 gpm.reset_peak_display();
1620 void
1621 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1623 /* don't respond to switch IO signal outside of the mixer window */
1625 if (!_mixer_owned) {
1626 return;
1629 if (_route == target || _route->is_master()) {
1630 /* don't change the display for the target or the master bus */
1631 return;
1632 } else if (!is_track() && show_sends_button) {
1633 /* make sure our show sends button is inactive, and we no longer blink,
1634 since we're not the target.
1636 send_blink_connection.disconnect ();
1637 show_sends_button->set_active (false);
1638 show_sends_button->set_state (STATE_NORMAL);
1641 if (!target) {
1642 /* switch back to default */
1643 revert_to_default_display ();
1644 return;
1647 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1649 if (send) {
1650 show_send (send);
1651 } else {
1652 revert_to_default_display ();
1656 void
1657 MixerStrip::drop_send ()
1659 boost::shared_ptr<Send> current_send;
1661 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1662 current_send->set_metering (false);
1665 send_gone_connection.disconnect ();
1666 input_button.set_sensitive (true);
1667 output_button.set_sensitive (true);
1668 group_button.set_sensitive (true);
1669 set_invert_sensitive (true);
1670 meter_point_button.set_sensitive (true);
1671 mute_button->set_sensitive (true);
1672 solo_button->set_sensitive (true);
1673 rec_enable_button->set_sensitive (true);
1674 solo_isolated_led->set_sensitive (true);
1675 solo_safe_led->set_sensitive (true);
1678 void
1679 MixerStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1681 _current_delivery = d;
1682 DeliveryChanged (_current_delivery);
1685 void
1686 MixerStrip::show_send (boost::shared_ptr<Send> send)
1688 assert (send != 0);
1690 drop_send ();
1692 set_current_delivery (send);
1694 send->set_metering (true);
1695 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1697 gain_meter().set_controls (_route, send->meter(), send->amp());
1698 gain_meter().setup_meters ();
1700 panner_ui().set_panner (_current_delivery->panner());
1701 panner_ui().setup_pan ();
1703 input_button.set_sensitive (false);
1704 group_button.set_sensitive (false);
1705 set_invert_sensitive (false);
1706 meter_point_button.set_sensitive (false);
1707 mute_button->set_sensitive (false);
1708 solo_button->set_sensitive (false);
1709 rec_enable_button->set_sensitive (false);
1710 solo_isolated_led->set_sensitive (false);
1711 solo_safe_led->set_sensitive (false);
1713 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1714 output_button.set_sensitive (false);
1717 reset_strip_style ();
1720 void
1721 MixerStrip::revert_to_default_display ()
1723 if (show_sends_button) {
1724 show_sends_button->set_active (false);
1727 drop_send ();
1729 set_current_delivery (_route->main_outs ());
1731 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1732 gain_meter().setup_meters ();
1734 panner_ui().set_panner (_route->main_outs()->panner());
1735 panner_ui().setup_pan ();
1737 reset_strip_style ();
1740 void
1741 MixerStrip::set_button_names ()
1743 switch (_width) {
1744 case Wide:
1745 rec_enable_button_label.set_text (_("Rec"));
1746 mute_button_label.set_text (_("Mute"));
1747 if (_route && _route->solo_safe()) {
1748 solo_button_label.set_text (X_("!"));
1749 } else {
1750 if (!Config->get_solo_control_is_listen_control()) {
1751 solo_button_label.set_text (_("Solo"));
1752 } else {
1753 switch (Config->get_listen_position()) {
1754 case AfterFaderListen:
1755 solo_button_label.set_text (_("AFL"));
1756 break;
1757 case PreFaderListen:
1758 solo_button_label.set_text (_("PFL"));
1759 break;
1763 break;
1765 default:
1766 rec_enable_button_label.set_text (_("R"));
1767 mute_button_label.set_text (_("M"));
1768 if (_route && _route->solo_safe()) {
1769 solo_button_label.set_text (X_("!"));
1770 if (!Config->get_solo_control_is_listen_control()) {
1771 solo_button_label.set_text (_("S"));
1772 } else {
1773 switch (Config->get_listen_position()) {
1774 case AfterFaderListen:
1775 solo_button_label.set_text (_("A"));
1776 break;
1777 case PreFaderListen:
1778 solo_button_label.set_text (_("P"));
1779 break;
1783 break;
1788 bool
1789 MixerStrip::on_key_press_event (GdkEventKey* ev)
1791 GdkEventButton fake;
1792 fake.type = GDK_BUTTON_PRESS;
1793 fake.button = 1;
1794 fake.state = ev->state;
1796 switch (ev->keyval) {
1797 case GDK_m:
1798 mute_press (&fake);
1799 return true;
1800 break;
1802 case GDK_s:
1803 solo_press (&fake);
1804 return true;
1805 break;
1807 case GDK_r:
1808 cerr << "Stole that r\n";
1809 rec_enable_press (&fake);
1810 return true;
1811 break;
1813 case GDK_e:
1814 show_sends_press (&fake);
1815 return true;
1816 break;
1818 case GDK_g:
1819 if (ev->state & Keyboard::PrimaryModifier) {
1820 step_gain_down ();
1821 } else {
1822 step_gain_up ();
1824 return true;
1825 break;
1827 case GDK_0:
1828 if (_route) {
1829 _route->set_gain (1.0, this);
1831 return true;
1833 default:
1834 break;
1837 return false;
1841 bool
1842 MixerStrip::on_key_release_event (GdkEventKey* ev)
1844 GdkEventButton fake;
1845 fake.type = GDK_BUTTON_RELEASE;
1846 fake.button = 1;
1847 fake.state = ev->state;
1849 switch (ev->keyval) {
1850 case GDK_m:
1851 mute_release (&fake);
1852 return true;
1853 break;
1855 case GDK_s:
1856 solo_release (&fake);
1857 return true;
1858 break;
1860 case GDK_r:
1861 cerr << "Stole that r\n";
1862 rec_enable_release (&fake);
1863 return true;
1864 break;
1866 case GDK_e:
1867 show_sends_release (&fake);
1868 return true;
1869 break;
1871 case GDK_g:
1872 return true;
1873 break;
1875 default:
1876 break;
1879 return false;
1882 bool
1883 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1885 Keyboard::magic_widget_grab_focus ();
1886 return false;
1889 bool
1890 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1892 switch (ev->detail) {
1893 case GDK_NOTIFY_INFERIOR:
1894 break;
1895 default:
1896 Keyboard::magic_widget_drop_focus ();
1899 return false;
1902 PluginSelector*
1903 MixerStrip::plugin_selector()
1905 return _mixer.plugin_selector();