comment fix
[ardour2.git] / gtk2_ardour / mixer_strip.cc
blobce077377604f72ca9274315025ddbc68079cfe19
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/panner_shell.h"
46 #include "ardour/send.h"
47 #include "ardour/processor.h"
48 #include "ardour/profile.h"
49 #include "ardour/ladspa_plugin.h"
50 #include "ardour/user_bundle.h"
51 #include "ardour/port.h"
53 #include "ardour_ui.h"
54 #include "ardour_dialog.h"
55 #include "mixer_strip.h"
56 #include "mixer_ui.h"
57 #include "keyboard.h"
58 #include "led.h"
59 #include "public_editor.h"
60 #include "send_ui.h"
61 #include "io_selector.h"
62 #include "utils.h"
63 #include "gui_thread.h"
64 #include "route_group_menu.h"
66 #include "i18n.h"
68 using namespace ARDOUR;
69 using namespace PBD;
70 using namespace Gtk;
71 using namespace Gtkmm2ext;
72 using namespace std;
74 sigc::signal<void,boost::shared_ptr<Route> > MixerStrip::SwitchIO;
76 int MixerStrip::scrollbar_height = 0;
77 PBD::Signal1<void,MixerStrip*> MixerStrip::CatchDeletion;
79 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, bool in_mixer)
80 : AxisView(sess)
81 , RouteUI (sess)
82 , _mixer(mx)
83 , _mixer_owned (in_mixer)
84 , processor_box (sess, boost::bind (&MixerStrip::plugin_selector, this), mx.selection(), this, in_mixer)
85 , gpm (sess, 250)
86 , panners (sess)
87 , button_table (3, 1)
88 , solo_led_table (2, 2)
89 , middle_button_table (1, 2)
90 , bottom_button_table (1, 2)
91 , meter_point_label (_("pre"))
93 init ();
95 if (!_mixer_owned) {
96 /* the editor mixer strip: don't destroy it every time
97 the underlying route goes away.
100 self_destruct = false;
104 MixerStrip::MixerStrip (Mixer_UI& mx, Session* sess, boost::shared_ptr<Route> rt, bool in_mixer)
105 : AxisView(sess)
106 , RouteUI (sess)
107 , _mixer(mx)
108 , _mixer_owned (in_mixer)
109 , processor_box (sess, sigc::mem_fun(*this, &MixerStrip::plugin_selector), mx.selection(), this, in_mixer)
110 , gpm (sess, 250)
111 , panners (sess)
112 , button_table (3, 1)
113 , middle_button_table (1, 2)
114 , bottom_button_table (1, 2)
115 , meter_point_label (_("pre"))
117 init ();
118 set_route (rt);
121 void
122 MixerStrip::init ()
124 input_selector = 0;
125 output_selector = 0;
126 group_menu = 0;
127 _marked_for_display = false;
128 route_ops_menu = 0;
129 ignore_comment_edit = false;
130 ignore_toggle = false;
131 comment_window = 0;
132 comment_area = 0;
133 _width_owner = 0;
134 spacer = 0;
136 /* the length of this string determines the width of the mixer strip when it is set to `wide' */
137 longest_label = "longest label";
139 Gtk::Image* img;
141 img = manage (new Gtk::Image (::get_icon("strip_width")));
142 img->show ();
144 width_button.add (*img);
146 img = manage (new Gtk::Image (::get_icon("hide")));
147 img->show ();
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");
157 Gtkmm2ext::set_size_request_to_display_given_text (input_button, longest_label.c_str(), 4, 4);
159 output_label.set_text (_("Output"));
160 ARDOUR_UI::instance()->set_tip (&output_button, _("Button 1 to choose outputs from a port matrix, button 3 to select inputs from a menu"), "");
161 output_button.add (output_label);
162 output_button.set_name ("MixerIOButton");
163 output_label.set_name ("MixerIOButtonLabel");
164 Gtkmm2ext::set_size_request_to_display_given_text (output_button, longest_label.c_str(), 4, 4);
166 ARDOUR_UI::instance()->set_tip (&meter_point_button, _("Select metering point"), "");
167 meter_point_button.add (meter_point_label);
168 meter_point_button.set_name ("MixerStripMeterPreButton");
169 meter_point_label.set_name ("MixerStripMeterPreButton");
171 /* TRANSLATORS: this string should be longest of the strings
172 used to describe meter points. In english, it's "input".
174 set_size_request_to_display_given_text (meter_point_button, _("tupni"), 5, 5);
176 bottom_button_table.attach (meter_point_button, 1, 2, 0, 1);
178 meter_point_button.signal_button_press_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_press), false);
179 meter_point_button.signal_button_release_event().connect (sigc::mem_fun (gpm, &GainMeter::meter_release), false);
181 hide_button.set_events (hide_button.get_events() & ~(Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK));
183 mute_button->set_name ("MixerMuteButton");
184 solo_button->set_name ("MixerSoloButton");
186 solo_isolated_led = manage (new LED);
187 solo_isolated_led->show ();
188 solo_isolated_led->set_diameter (6);
189 solo_isolated_led->set_no_show_all (true);
190 solo_isolated_led->set_name (X_("SoloIsolatedLED"));
191 solo_isolated_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
192 solo_isolated_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_isolate_button_release));
193 UI::instance()->set_tip (solo_isolated_led, _("Isolate Solo"), "");
195 solo_safe_led = manage (new LED);
196 solo_safe_led->show ();
197 solo_safe_led->set_diameter (6);
198 solo_safe_led->set_no_show_all (true);
199 solo_safe_led->set_name (X_("SoloSafeLED"));
200 solo_safe_led->add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
201 solo_safe_led->signal_button_release_event().connect (sigc::mem_fun (*this, &RouteUI::solo_safe_button_release));
202 UI::instance()->set_tip (solo_safe_led, _("Lock Solo Status"), "");
204 _iso_label = manage (new Label (_("iso")));
205 _safe_label = manage (new Label (_("lock")));
207 _iso_label->set_name (X_("SoloLEDLabel"));
208 _safe_label->set_name (X_("SoloLEDLabel"));
210 _iso_label->show ();
211 _safe_label->show ();
213 solo_led_table.set_spacings (0);
214 solo_led_table.set_border_width (1);
215 solo_led_table.attach (*_iso_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL);
216 solo_led_table.attach (*solo_isolated_led, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL);
217 solo_led_table.attach (*_safe_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL);
218 solo_led_table.attach (*solo_safe_led, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL);
220 solo_led_table.show ();
221 below_panner_box.set_border_width (2);
222 below_panner_box.set_spacing (2);
223 below_panner_box.pack_end (solo_led_table, false, false);
224 below_panner_box.show ();
226 button_table.set_homogeneous (true);
227 button_table.set_spacings (0);
229 button_table.attach (name_button, 0, 1, 0, 1);
230 button_table.attach (input_button, 0, 1, 1, 2);
231 button_table.attach (_invert_button_box, 0, 1, 2, 3);
233 middle_button_table.set_homogeneous (true);
234 middle_button_table.set_spacings (0);
235 middle_button_table.attach (*mute_button, 0, 1, 0, 1);
236 middle_button_table.attach (*solo_button, 1, 2, 0, 1);
238 bottom_button_table.set_col_spacings (0);
239 bottom_button_table.set_homogeneous (true);
240 bottom_button_table.attach (group_button, 0, 1, 0, 1);
242 name_button.add (name_label);
243 name_button.set_name ("MixerNameButton");
244 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
246 name_label.set_name ("MixerNameButtonLabel");
247 ARDOUR_UI::instance()->set_tip (&group_button, _("Mix group"), "");
248 group_button.add (group_label);
249 group_button.set_name ("MixerGroupButton");
250 Gtkmm2ext::set_size_request_to_display_given_text (group_button, "Group", 2, 2);
251 group_label.set_name ("MixerGroupButtonLabel");
253 global_vpacker.set_border_width (0);
254 global_vpacker.set_spacing (0);
256 width_button.set_name ("MixerWidthButton");
257 hide_button.set_name ("MixerHideButton");
258 top_event_box.set_name ("MixerTopEventBox");
260 width_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::width_clicked));
261 hide_button.signal_clicked().connect (sigc::mem_fun(*this, &MixerStrip::hide_clicked));
263 width_hide_box.pack_start (width_button, false, true);
264 width_hide_box.pack_start (top_event_box, true, true);
265 width_hide_box.pack_end (hide_button, false, true);
266 gain_meter_alignment.set_padding(0, 4, 0, 0);
267 gain_meter_alignment.add(gpm);
269 whvbox.pack_start (width_hide_box, true, true);
271 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
272 global_vpacker.pack_start (button_table,Gtk::PACK_SHRINK);
273 global_vpacker.pack_start (processor_box, true, true);
274 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
275 global_vpacker.pack_start (below_panner_box, Gtk::PACK_SHRINK);
276 global_vpacker.pack_start (middle_button_table,Gtk::PACK_SHRINK);
277 global_vpacker.pack_start (gain_meter_alignment,Gtk::PACK_SHRINK);
278 global_vpacker.pack_start (bottom_button_table,Gtk::PACK_SHRINK);
279 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
281 global_frame.add (global_vpacker);
282 global_frame.set_shadow_type (Gtk::SHADOW_IN);
283 global_frame.set_name ("BaseFrame");
285 add (global_frame);
287 /* force setting of visible selected status */
289 _selected = true;
290 set_selected (false);
292 _packed = false;
293 _embedded = false;
295 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_stopped, this), gui_context());
296 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_running, this), gui_context());
298 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
299 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
301 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
302 hurt (much).
305 rec_enable_button->set_name ("MixerRecordEnableButton");
307 /* ditto for this button and busses */
309 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
310 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
312 _width = (Width) -1;
314 /* start off as a passthru strip. we'll correct this, if necessary,
315 in update_diskstream_display().
318 /* start off as a passthru strip. we'll correct this, if necessary,
319 in update_diskstream_display().
322 if (is_midi_track())
323 set_name ("MidiTrackStripBase");
324 else
325 set_name ("AudioTrackStripBase");
327 add_events (Gdk::BUTTON_RELEASE_MASK|
328 Gdk::ENTER_NOTIFY_MASK|
329 Gdk::LEAVE_NOTIFY_MASK|
330 Gdk::KEY_PRESS_MASK|
331 Gdk::KEY_RELEASE_MASK);
333 set_flags (get_flags() | Gtk::CAN_FOCUS);
335 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
337 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
338 *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context ()
342 MixerStrip::~MixerStrip ()
344 CatchDeletion (this);
346 delete input_selector;
347 delete output_selector;
348 delete comment_window;
351 void
352 MixerStrip::set_route (boost::shared_ptr<Route> rt)
354 if (rec_enable_button->get_parent()) {
355 below_panner_box.remove (*rec_enable_button);
358 if (show_sends_button->get_parent()) {
359 below_panner_box.remove (*show_sends_button);
362 processor_box.set_route (rt);
364 RouteUI::set_route (rt);
366 /* map the current state */
368 mute_changed (0);
369 update_solo_display ();
371 delete input_selector;
372 input_selector = 0;
374 delete output_selector;
375 output_selector = 0;
377 revert_to_default_display ();
379 if (set_color_from_route()) {
380 set_color (unique_random_color());
383 if (route()->is_master()) {
384 solo_button->hide ();
385 below_panner_box.hide ();
386 } else {
387 solo_button->show ();
388 below_panner_box.show ();
391 if (_mixer_owned && (route()->is_master() || route()->is_monitor())) {
393 if (scrollbar_height == 0) {
394 HScrollbar scrollbar;
395 Gtk::Requisition requisition(scrollbar.size_request ());
396 scrollbar_height = requisition.height;
399 spacer = manage (new EventBox);
400 spacer->set_size_request (-1, scrollbar_height);
401 global_vpacker.pack_start (*spacer, false, false);
404 if (is_audio_track()) {
405 boost::shared_ptr<AudioTrack> at = audio_track();
406 at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context());
409 if (has_audio_outputs ()) {
410 panners.show_all ();
411 } else {
412 panners.hide_all ();
415 if (is_track ()) {
417 below_panner_box.pack_start (*rec_enable_button);
418 rec_enable_button->set_sensitive (_session->writable());
419 rec_enable_button->show();
421 } else {
423 /* non-master bus */
425 if (!_route->is_master()) {
426 below_panner_box.pack_start (*show_sends_button);
427 show_sends_button->show();
431 meter_point_label.set_text (meter_point_string (_route->meter_point()));
433 delete route_ops_menu;
434 route_ops_menu = 0;
436 _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context());
437 _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
439 if (_route->panner()) {
440 _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
443 if (is_audio_track()) {
444 audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
447 _route->comment_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
448 _route->gui_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
450 set_stuff_from_route ();
452 /* now force an update of all the various elements */
454 mute_changed (0);
455 update_solo_display ();
456 name_changed ();
457 comment_changed (0);
458 route_group_changed ();
460 connect_to_pan ();
461 panners.setup_pan ();
463 update_diskstream_display ();
464 update_input_display ();
465 update_output_display ();
467 add_events (Gdk::BUTTON_RELEASE_MASK);
469 processor_box.show ();
471 if (!route()->is_master() && !route()->is_monitor()) {
472 /* we don't allow master or control routes to be hidden */
473 hide_button.show();
476 width_button.show();
477 width_hide_box.show();
478 whvbox.show ();
479 global_frame.show();
480 global_vpacker.show();
481 button_table.show();
482 middle_button_table.show();
483 bottom_button_table.show();
484 gpm.show_all ();
485 gain_meter_alignment.show ();
486 gain_unit_button.show();
487 gain_unit_label.show();
488 meter_point_button.show();
489 meter_point_label.show();
490 diskstream_button.show();
491 diskstream_label.show();
492 input_button.show();
493 input_label.show();
494 output_button.show();
495 output_label.show();
496 name_label.show();
497 name_button.show();
498 group_button.show();
499 group_label.show();
501 show ();
504 void
505 MixerStrip::set_stuff_from_route ()
507 XMLProperty *prop;
509 ensure_xml_node ();
511 /* if width is not set, it will be set by the MixerUI or editor */
513 if ((prop = xml_node->property ("strip-width")) != 0) {
514 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
517 if ((prop = xml_node->property ("shown-mixer")) != 0) {
518 if (prop->value() == "no") {
519 _marked_for_display = false;
520 } else {
521 _marked_for_display = true;
523 } else {
524 /* backwards compatibility */
525 _marked_for_display = true;
529 void
530 MixerStrip::set_width_enum (Width w, void* owner)
532 /* always set the gpm width again, things may be hidden */
534 gpm.set_width (w);
535 panners.set_width (w);
537 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
539 _width_owner = owner;
541 ensure_xml_node ();
543 _width = w;
545 if (_width_owner == this) {
546 xml_node->add_property ("strip-width", enum_2_string (_width));
549 set_button_names ();
551 switch (w) {
552 case Wide:
553 if (show_sends_button) {
554 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
557 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
558 gpm.astyle_string(gain_automation->automation_style()));
559 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
560 gpm.astate_string(gain_automation->automation_state()));
562 if (_route->panner()) {
563 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
564 panners.astyle_string(_route->panner()->automation_style()));
565 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
566 panners.astate_string(_route->panner()->automation_state()));
569 _iso_label->show ();
570 _safe_label->show ();
572 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
573 set_size_request (-1, -1);
574 break;
576 case Narrow:
577 if (show_sends_button) {
578 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
581 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
582 gpm.short_astyle_string(gain_automation->automation_style()));
583 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
584 gpm.short_astate_string(gain_automation->automation_state()));
586 if (_route->panner()) {
587 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
588 panners.short_astyle_string(_route->panner()->automation_style()));
589 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
590 panners.short_astate_string(_route->panner()->automation_state()));
593 _iso_label->hide ();
594 _safe_label->hide ();
596 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
597 set_size_request (max (50, gpm.get_gm_width()), -1);
598 break;
601 processor_box.set_width (w);
603 update_input_display ();
604 update_output_display ();
605 route_group_changed ();
606 name_changed ();
607 WidthChanged ();
610 void
611 MixerStrip::set_packed (bool yn)
613 _packed = yn;
615 ensure_xml_node ();
617 if (_packed) {
618 xml_node->add_property ("shown-mixer", "yes");
619 } else {
620 xml_node->add_property ("shown-mixer", "no");
625 gint
626 MixerStrip::output_press (GdkEventButton *ev)
628 using namespace Menu_Helpers;
629 if (!_session->engine().connected()) {
630 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
631 msg.run ();
632 return true;
635 MenuList& citems = output_menu.items();
636 switch (ev->button) {
638 case 1:
639 edit_output_configuration ();
640 break;
642 case 3:
644 output_menu.set_name ("ArdourContextMenu");
645 citems.clear ();
646 output_menu_bundles.clear ();
648 citems.push_back (MenuElem (_("Disconnect"), sigc::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 ();
655 /* give user bundles first chance at being in the menu */
657 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
658 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
659 maybe_add_bundle_to_output_menu (*i, current);
663 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
664 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
665 maybe_add_bundle_to_output_menu (*i, current);
669 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
670 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
671 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
674 if (citems.size() == 2) {
675 /* no routes added; remove the separator */
676 citems.pop_back ();
679 output_menu.popup (1, ev->time);
680 break;
683 default:
684 break;
686 return TRUE;
689 void
690 MixerStrip::edit_output_configuration ()
692 if (output_selector == 0) {
694 boost::shared_ptr<Send> send;
695 boost::shared_ptr<IO> output;
697 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
698 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
699 output = send->output();
700 } else {
701 output = _route->output ();
703 } else {
704 output = _route->output ();
707 output_selector = new IOSelectorWindow (_session, output);
710 if (output_selector->is_visible()) {
711 output_selector->get_toplevel()->get_window()->raise();
712 } else {
713 output_selector->present ();
717 void
718 MixerStrip::edit_input_configuration ()
720 if (input_selector == 0) {
721 input_selector = new IOSelectorWindow (_session, _route->input());
724 if (input_selector->is_visible()) {
725 input_selector->get_toplevel()->get_window()->raise();
726 } else {
727 input_selector->present ();
731 gint
732 MixerStrip::input_press (GdkEventButton *ev)
734 using namespace Menu_Helpers;
736 MenuList& citems = input_menu.items();
737 input_menu.set_name ("ArdourContextMenu");
738 citems.clear();
740 if (!_session->engine().connected()) {
741 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
742 msg.run ();
743 return true;
746 if (_session->actively_recording() && _route->record_enabled())
747 return true;
749 switch (ev->button) {
751 case 1:
752 edit_input_configuration ();
753 break;
755 case 3:
757 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
758 citems.push_back (SeparatorElem());
759 input_menu_bundles.clear ();
761 ARDOUR::BundleList current = _route->input()->bundles_connected ();
763 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
765 /* give user bundles first chance at being in the menu */
767 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
768 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
769 maybe_add_bundle_to_input_menu (*i, current);
773 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
774 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
775 maybe_add_bundle_to_input_menu (*i, current);
779 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
780 for (ARDOUR::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
781 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
784 if (citems.size() == 2) {
785 /* no routes added; remove the separator */
786 citems.pop_back ();
789 input_menu.popup (1, ev->time);
790 break;
792 default:
793 break;
795 return TRUE;
798 void
799 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
801 if (ignore_toggle) {
802 return;
805 ARDOUR::BundleList current = _route->input()->bundles_connected ();
807 if (std::find (current.begin(), current.end(), c) == current.end()) {
808 _route->input()->connect_ports_to_bundle (c, this);
809 } else {
810 _route->input()->disconnect_ports_from_bundle (c, this);
814 void
815 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
817 if (ignore_toggle) {
818 return;
821 ARDOUR::BundleList current = _route->output()->bundles_connected ();
823 if (std::find (current.begin(), current.end(), c) == current.end()) {
824 _route->output()->connect_ports_to_bundle (c, this);
825 } else {
826 _route->output()->disconnect_ports_from_bundle (c, this);
830 void
831 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
833 using namespace Menu_Helpers;
835 if (b->ports_are_outputs() == false || b->nchannels() != _route->n_inputs()) {
836 return;
839 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
840 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
841 ++i;
844 if (i != input_menu_bundles.end()) {
845 return;
848 input_menu_bundles.push_back (b);
850 MenuList& citems = input_menu.items();
852 std::string n = b->name ();
853 replace_all (n, "_", " ");
855 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
857 if (std::find (current.begin(), current.end(), b) != current.end()) {
858 ignore_toggle = true;
859 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
860 ignore_toggle = false;
864 void
865 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
867 using namespace Menu_Helpers;
869 if (b->ports_are_inputs() == false || b->nchannels() != _route->n_outputs()) {
870 return;
873 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
874 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
875 ++i;
878 if (i != output_menu_bundles.end()) {
879 return;
882 output_menu_bundles.push_back (b);
884 MenuList& citems = output_menu.items();
886 std::string n = b->name ();
887 replace_all (n, "_", " ");
889 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
891 if (std::find (current.begin(), current.end(), b) != current.end()) {
892 ignore_toggle = true;
893 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
894 ignore_toggle = false;
898 void
899 MixerStrip::update_diskstream_display ()
901 if (is_track()) {
903 if (input_selector) {
904 input_selector->hide_all ();
907 show_route_color ();
909 } else {
911 show_passthru_color ();
915 void
916 MixerStrip::connect_to_pan ()
918 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
920 panstate_connection.disconnect ();
921 panstyle_connection.disconnect ();
923 if (!_route->panner()) {
924 return;
927 boost::shared_ptr<Pannable> p = _route->pannable ();
929 p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
930 p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
932 panners.panshell_changed ();
937 * Output port labelling
938 * =====================
940 * Case 1: Each output has one connection, all connections are to system:playback_%i
941 * out 1 -> system:playback_1
942 * out 2 -> system:playback_2
943 * out 3 -> system:playback_3
944 * Display as: 1/2/3
946 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
947 * out 1 -> ardour:track_x/in 1
948 * out 2 -> ardour:track_x/in 2
949 * Display as: track_x
951 * Case 3: Each output has one connection, all connections are to Jack client "program x"
952 * out 1 -> program x:foo
953 * out 2 -> program x:foo
954 * Display as: program x
956 * Case 4: No connections (Disconnected)
957 * Display as: -
959 * Default case (unusual routing):
960 * Display as: *number of connections*
962 * Tooltips
963 * ========
964 * .-----------------------------------------------.
965 * | Mixdown |
966 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
967 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
968 * '-----------------------------------------------'
969 * .-----------------------------------------------.
970 * | Guitar SM58 |
971 * | Disconnected |
972 * '-----------------------------------------------'
975 void
976 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
978 uint32_t io_count;
979 uint32_t io_index;
980 Port *port;
981 vector<string> port_connections;
983 uint32_t total_connection_count = 0;
984 uint32_t io_connection_count = 0;
985 uint32_t ardour_connection_count = 0;
986 uint32_t system_connection_count = 0;
987 uint32_t other_connection_count = 0;
989 ostringstream label;
990 string label_string;
992 bool have_label = false;
993 bool each_io_has_one_connection = true;
995 string connection_name;
996 string ardour_track_name;
997 string other_connection_type;
998 string system_ports;
999 string system_port;
1001 ostringstream tooltip;
1002 char * tooltip_cstr;
1004 tooltip << route->name();
1006 if (for_input) {
1007 io_count = route->n_inputs().n_total();
1008 } else {
1009 io_count = route->n_outputs().n_total();
1012 for (io_index = 0; io_index < io_count; ++io_index) {
1013 if (for_input) {
1014 port = route->input()->nth (io_index);
1015 } else {
1016 port = route->output()->nth (io_index);
1019 port_connections.clear ();
1020 port->get_connections(port_connections);
1021 io_connection_count = 0;
1023 if (!port_connections.empty()) {
1024 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1025 string& connection_name (*i);
1027 if (io_connection_count == 0) {
1028 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1029 } else {
1030 tooltip << ", " << connection_name;
1033 if (connection_name.find("ardour:") == 0) {
1034 if (ardour_track_name.empty()) {
1035 // "ardour:Master/in 1" -> "ardour:Master/"
1036 string::size_type slash = connection_name.find("/");
1037 if (slash != string::npos) {
1038 ardour_track_name = connection_name.substr(0, slash + 1);
1042 if (connection_name.find(ardour_track_name) == 0) {
1043 ++ardour_connection_count;
1045 } else if (connection_name.find("system:") == 0) {
1046 if (for_input) {
1047 // "system:capture_123" -> "123"
1048 system_port = connection_name.substr(15);
1049 } else {
1050 // "system:playback_123" -> "123"
1051 system_port = connection_name.substr(16);
1054 if (system_ports.empty()) {
1055 system_ports += system_port;
1056 } else {
1057 system_ports += "/" + system_port;
1060 ++system_connection_count;
1061 } else {
1062 if (other_connection_type.empty()) {
1063 // "jamin:in 1" -> "jamin:"
1064 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1067 if (connection_name.find(other_connection_type) == 0) {
1068 ++other_connection_count;
1072 ++total_connection_count;
1073 ++io_connection_count;
1077 if (io_connection_count != 1) {
1078 each_io_has_one_connection = false;
1082 if (total_connection_count == 0) {
1083 tooltip << endl << _("Disconnected");
1086 tooltip_cstr = new char[tooltip.str().size() + 1];
1087 strcpy(tooltip_cstr, tooltip.str().c_str());
1089 if (for_input) {
1090 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1091 } else {
1092 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1095 if (each_io_has_one_connection) {
1096 if ((total_connection_count == ardour_connection_count)) {
1097 // all connections are to the same track in ardour
1098 // "ardour:Master/" -> "Master"
1099 string::size_type slash = ardour_track_name.find("/");
1100 if (slash != string::npos) {
1101 label << ardour_track_name.substr(7, slash - 7);
1102 have_label = true;
1105 else if (total_connection_count == system_connection_count) {
1106 // all connections are to system ports
1107 label << system_ports;
1108 have_label = true;
1110 else if (total_connection_count == other_connection_count) {
1111 // all connections are to the same external program eg jamin
1112 // "jamin:" -> "jamin"
1113 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1114 have_label = true;
1118 if (!have_label) {
1119 if (total_connection_count == 0) {
1120 // Disconnected
1121 label << "-";
1122 } else {
1123 // Odd configuration
1124 label << "*" << total_connection_count << "*";
1128 switch (width) {
1129 case Wide:
1130 label_string = label.str().substr(0, 6);
1131 break;
1132 case Narrow:
1133 label_string = label.str().substr(0, 3);
1134 break;
1137 if (for_input) {
1138 input_label.set_text (label_string);
1139 } else {
1140 output_label.set_text (label_string);
1144 void
1145 MixerStrip::update_input_display ()
1147 update_io_button (_route, _width, true);
1148 panners.setup_pan ();
1151 void
1152 MixerStrip::update_output_display ()
1154 update_io_button (_route, _width, false);
1155 gpm.setup_meters ();
1156 panners.setup_pan ();
1159 void
1160 MixerStrip::fast_update ()
1162 gpm.update_meters ();
1165 void
1166 MixerStrip::diskstream_changed ()
1168 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
1171 void
1172 MixerStrip::port_connected_or_disconnected (Port* a, Port* b)
1174 if (_route->input()->has_port (a) || _route->input()->has_port (b)) {
1175 update_input_display ();
1176 set_width_enum (_width, this);
1179 if (_route->output()->has_port (a) || _route->output()->has_port (b)) {
1180 update_output_display ();
1181 set_width_enum (_width, this);
1185 void
1186 MixerStrip::comment_editor_done_editing ()
1188 ignore_toggle = true;
1189 _comment_menu_item->set_active (false);
1190 ignore_toggle = false;
1192 string const str = comment_area->get_buffer()->get_text();
1193 if (str == _route->comment ()) {
1194 return;
1197 _route->set_comment (str, this);
1200 void
1201 MixerStrip::toggle_comment ()
1203 if (ignore_toggle) {
1204 return;
1207 if (comment_window == 0) {
1208 setup_comment_editor ();
1211 if (comment_window->is_visible ()) {
1212 comment_window->hide ();
1213 return;
1216 comment_window->show();
1217 comment_window->present();
1220 void
1221 MixerStrip::setup_comment_editor ()
1223 string title;
1224 title = _route->name();
1225 title += _(": comment editor");
1227 comment_window = new ArdourDialog (title, false);
1228 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1229 comment_window->set_skip_taskbar_hint (true);
1230 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1232 comment_area = manage (new TextView());
1233 comment_area->set_name ("MixerTrackCommentArea");
1234 comment_area->set_size_request (110, 178);
1235 comment_area->set_wrap_mode (WRAP_WORD);
1236 comment_area->set_editable (true);
1237 comment_area->get_buffer()->set_text (_route->comment());
1238 comment_area->show ();
1240 comment_window->get_vbox()->pack_start (*comment_area);
1241 comment_window->get_action_area()->hide();
1244 void
1245 MixerStrip::comment_changed (void *src)
1247 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1249 if (src != this) {
1250 ignore_comment_edit = true;
1251 if (comment_area) {
1252 comment_area->get_buffer()->set_text (_route->comment());
1254 ignore_comment_edit = false;
1258 /** Set the route group for this strip's route, or remove it from its current group.
1259 * @param rg New RouteGroup, or 0.
1261 void
1262 MixerStrip::set_route_group (RouteGroup *rg)
1264 if (rg) {
1265 rg->add (_route);
1266 } else if (_route->route_group ()) {
1267 _route->route_group()->remove (_route);
1271 bool
1272 MixerStrip::select_route_group (GdkEventButton *ev)
1274 using namespace Menu_Helpers;
1276 if (ev->button == 1) {
1278 if (group_menu == 0) {
1280 PropertyList* plist = new PropertyList();
1282 plist->add (Properties::gain, true);
1283 plist->add (Properties::mute, true);
1284 plist->add (Properties::solo, true);
1286 group_menu = new RouteGroupMenu (_session, plist);
1287 group_menu->GroupSelected.connect (sigc::mem_fun (*this, &MixerStrip::set_route_group));
1290 group_menu->build (route_group ());
1291 group_menu->menu()->popup (1, ev->time);
1294 return true;
1297 void
1298 MixerStrip::route_group_changed ()
1300 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1302 RouteGroup *rg = _route->route_group();
1304 if (rg) {
1305 group_label.set_text (PBD::short_version (rg->name(), 5));
1306 } else {
1307 switch (_width) {
1308 case Wide:
1309 group_label.set_text (_("Grp"));
1310 break;
1311 case Narrow:
1312 group_label.set_text (_("~G"));
1313 break;
1319 void
1320 MixerStrip::route_gui_changed (string what_changed, void*)
1322 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1324 if (what_changed == "color") {
1325 if (set_color_from_route () == 0) {
1326 show_route_color ();
1331 void
1332 MixerStrip::show_route_color ()
1334 name_button.modify_bg (STATE_NORMAL, color());
1335 top_event_box.modify_bg (STATE_NORMAL, color());
1336 route_active_changed ();
1339 void
1340 MixerStrip::show_passthru_color ()
1342 route_active_changed ();
1345 void
1346 MixerStrip::build_route_ops_menu ()
1348 using namespace Menu_Helpers;
1349 route_ops_menu = new Menu;
1350 route_ops_menu->set_name ("ArdourContextMenu");
1352 MenuList& items = route_ops_menu->items();
1354 items.push_back (CheckMenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::toggle_comment)));
1355 _comment_menu_item = dynamic_cast<CheckMenuItem*> (&items.back ());
1356 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1357 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1358 rename_menu_item = &items.back();
1359 items.push_back (SeparatorElem());
1360 items.push_back (CheckMenuElem (_("Active"), sigc::mem_fun (*this, &RouteUI::toggle_route_active)));
1361 route_active_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1362 route_active_menu_item->set_active (_route->active());
1364 items.push_back (SeparatorElem());
1366 items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1368 items.push_back (SeparatorElem());
1369 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1370 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1371 denormal_menu_item->set_active (_route->denormal_protection());
1373 if (!Profile->get_sae()) {
1374 items.push_back (SeparatorElem());
1375 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1378 items.push_back (SeparatorElem());
1379 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(*this, &RouteUI::remove_this_route)));
1382 gboolean
1383 MixerStrip::name_button_button_press (GdkEventButton* ev)
1385 if (ev->button == 3) {
1386 list_route_operations ();
1388 /* do not allow rename if the track is record-enabled */
1389 rename_menu_item->set_sensitive (!_route->record_enabled());
1390 route_ops_menu->popup (1, ev->time);
1392 } else if (ev->button == 1) {
1393 revert_to_default_display ();
1396 return false;
1399 void
1400 MixerStrip::list_route_operations ()
1402 if (route_ops_menu == 0) {
1403 build_route_ops_menu ();
1407 void
1408 MixerStrip::set_selected (bool yn)
1410 AxisView::set_selected (yn);
1411 if (_selected) {
1412 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1413 global_frame.set_name ("MixerStripSelectedFrame");
1414 } else {
1415 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1416 global_frame.set_name ("MixerStripFrame");
1418 global_frame.queue_draw ();
1421 void
1422 MixerStrip::name_changed ()
1424 switch (_width) {
1425 case Wide:
1426 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1427 break;
1428 case Narrow:
1429 name_label.set_text (PBD::short_version (_route->name(), 5));
1430 break;
1434 void
1435 MixerStrip::width_clicked ()
1437 switch (_width) {
1438 case Wide:
1439 set_width_enum (Narrow, this);
1440 break;
1441 case Narrow:
1442 set_width_enum (Wide, this);
1443 break;
1447 void
1448 MixerStrip::hide_clicked ()
1450 // LAME fix to reset the button status for when it is redisplayed (part 1)
1451 hide_button.set_sensitive(false);
1453 if (_embedded) {
1454 Hiding(); /* EMIT_SIGNAL */
1455 } else {
1456 _mixer.hide_strip (this);
1459 // (part 2)
1460 hide_button.set_sensitive(true);
1463 void
1464 MixerStrip::set_embedded (bool yn)
1466 _embedded = yn;
1469 void
1470 MixerStrip::map_frozen ()
1472 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1474 boost::shared_ptr<AudioTrack> at = audio_track();
1476 if (at) {
1477 switch (at->freeze_state()) {
1478 case AudioTrack::Frozen:
1479 processor_box.set_sensitive (false);
1480 hide_redirect_editors ();
1481 break;
1482 default:
1483 processor_box.set_sensitive (true);
1484 // XXX need some way, maybe, to retoggle redirect editors
1485 break;
1490 void
1491 MixerStrip::hide_redirect_editors ()
1493 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1496 void
1497 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1499 boost::shared_ptr<Processor> processor (p.lock ());
1500 if (!processor) {
1501 return;
1504 Gtk::Window* w = processor_box.get_processor_ui (processor);
1506 if (w) {
1507 w->hide ();
1511 void
1512 MixerStrip::route_active_changed ()
1514 RouteUI::route_active_changed ();
1515 reset_strip_style ();
1518 void
1519 MixerStrip::reset_strip_style ()
1521 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1523 gpm.set_fader_name ("SendStripBase");
1525 } else {
1527 if (is_midi_track()) {
1528 if (_route->active()) {
1529 set_name ("MidiTrackStripBase");
1530 gpm.set_meter_strip_name ("MidiTrackMetrics");
1531 } else {
1532 set_name ("MidiTrackStripBaseInactive");
1533 gpm.set_meter_strip_name ("MidiTrackMetricsInactive");
1535 gpm.set_fader_name ("MidiTrackFader");
1536 } else if (is_audio_track()) {
1537 if (_route->active()) {
1538 set_name ("AudioTrackStripBase");
1539 gpm.set_meter_strip_name ("AudioTrackMetrics");
1540 } else {
1541 set_name ("AudioTrackStripBaseInactive");
1542 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1544 gpm.set_fader_name ("AudioTrackFader");
1545 } else {
1546 if (_route->active()) {
1547 set_name ("AudioBusStripBase");
1548 gpm.set_meter_strip_name ("AudioBusMetrics");
1549 } else {
1550 set_name ("AudioBusStripBaseInactive");
1551 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1553 gpm.set_fader_name ("AudioBusFader");
1555 /* (no MIDI busses yet) */
1560 RouteGroup*
1561 MixerStrip::route_group() const
1563 return _route->route_group();
1566 void
1567 MixerStrip::engine_stopped ()
1571 void
1572 MixerStrip::engine_running ()
1576 string
1577 MixerStrip::meter_point_string (MeterPoint mp)
1579 switch (mp) {
1580 case MeterInput:
1581 return _("in");
1582 break;
1584 case MeterPreFader:
1585 return _("pre");
1586 break;
1588 case MeterPostFader:
1589 return _("post");
1590 break;
1592 case MeterOutput:
1593 return _("out");
1594 break;
1596 case MeterCustom:
1597 default:
1598 return _("custom");
1599 break;
1603 /** Called when the metering point has changed */
1604 void
1605 MixerStrip::meter_changed ()
1607 meter_point_label.set_text (meter_point_string (_route->meter_point()));
1608 gpm.setup_meters ();
1609 // reset peak when meter point changes
1610 gpm.reset_peak_display();
1613 void
1614 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1616 /* don't respond to switch IO signal outside of the mixer window */
1618 if (!_mixer_owned) {
1619 return;
1622 if (_route == target || _route->is_master()) {
1623 /* don't change the display for the target or the master bus */
1624 return;
1625 } else if (!is_track() && show_sends_button) {
1626 /* make sure our show sends button is inactive, and we no longer blink,
1627 since we're not the target.
1629 send_blink_connection.disconnect ();
1630 show_sends_button->set_active (false);
1631 show_sends_button->set_state (STATE_NORMAL);
1634 if (!target) {
1635 /* switch back to default */
1636 revert_to_default_display ();
1637 return;
1640 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1642 if (send) {
1643 show_send (send);
1644 } else {
1645 revert_to_default_display ();
1649 void
1650 MixerStrip::drop_send ()
1652 boost::shared_ptr<Send> current_send;
1654 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1655 current_send->set_metering (false);
1658 send_gone_connection.disconnect ();
1659 input_button.set_sensitive (true);
1660 output_button.set_sensitive (true);
1661 group_button.set_sensitive (true);
1662 set_invert_sensitive (true);
1663 meter_point_button.set_sensitive (true);
1664 mute_button->set_sensitive (true);
1665 solo_button->set_sensitive (true);
1666 rec_enable_button->set_sensitive (true);
1667 solo_isolated_led->set_sensitive (true);
1668 solo_safe_led->set_sensitive (true);
1671 void
1672 MixerStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1674 _current_delivery = d;
1675 DeliveryChanged (_current_delivery);
1678 void
1679 MixerStrip::show_send (boost::shared_ptr<Send> send)
1681 assert (send != 0);
1683 drop_send ();
1685 set_current_delivery (send);
1687 send->set_metering (true);
1688 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1690 gain_meter().set_controls (_route, send->meter(), send->amp());
1691 gain_meter().setup_meters ();
1693 panner_ui().set_panner (_current_delivery->panner_shell(), _current_delivery->panner());
1694 panner_ui().setup_pan ();
1696 input_button.set_sensitive (false);
1697 group_button.set_sensitive (false);
1698 set_invert_sensitive (false);
1699 meter_point_button.set_sensitive (false);
1700 mute_button->set_sensitive (false);
1701 solo_button->set_sensitive (false);
1702 rec_enable_button->set_sensitive (false);
1703 solo_isolated_led->set_sensitive (false);
1704 solo_safe_led->set_sensitive (false);
1706 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1707 output_button.set_sensitive (false);
1710 reset_strip_style ();
1713 void
1714 MixerStrip::revert_to_default_display ()
1716 if (show_sends_button) {
1717 show_sends_button->set_active (false);
1720 drop_send ();
1722 set_current_delivery (_route->main_outs ());
1724 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1725 gain_meter().setup_meters ();
1727 panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
1728 panner_ui().setup_pan ();
1730 reset_strip_style ();
1733 void
1734 MixerStrip::set_button_names ()
1736 switch (_width) {
1737 case Wide:
1738 rec_enable_button_label.set_text (_("Rec"));
1739 mute_button_label.set_text (_("Mute"));
1740 if (_route && _route->solo_safe()) {
1741 solo_button_label.set_text (X_("!"));
1742 } else {
1743 if (!Config->get_solo_control_is_listen_control()) {
1744 solo_button_label.set_text (_("Solo"));
1745 } else {
1746 switch (Config->get_listen_position()) {
1747 case AfterFaderListen:
1748 solo_button_label.set_text (_("AFL"));
1749 break;
1750 case PreFaderListen:
1751 solo_button_label.set_text (_("PFL"));
1752 break;
1756 break;
1758 default:
1759 rec_enable_button_label.set_text (_("R"));
1760 mute_button_label.set_text (_("M"));
1761 if (_route && _route->solo_safe()) {
1762 solo_button_label.set_text (X_("!"));
1763 if (!Config->get_solo_control_is_listen_control()) {
1764 solo_button_label.set_text (_("S"));
1765 } else {
1766 switch (Config->get_listen_position()) {
1767 case AfterFaderListen:
1768 solo_button_label.set_text (_("A"));
1769 break;
1770 case PreFaderListen:
1771 solo_button_label.set_text (_("P"));
1772 break;
1776 break;
1781 bool
1782 MixerStrip::on_key_press_event (GdkEventKey* ev)
1784 GdkEventButton fake;
1785 fake.type = GDK_BUTTON_PRESS;
1786 fake.button = 1;
1787 fake.state = ev->state;
1789 switch (ev->keyval) {
1790 case GDK_m:
1791 mute_press (&fake);
1792 return true;
1793 break;
1795 case GDK_s:
1796 solo_press (&fake);
1797 return true;
1798 break;
1800 case GDK_r:
1801 cerr << "Stole that r\n";
1802 rec_enable_press (&fake);
1803 return true;
1804 break;
1806 case GDK_e:
1807 show_sends_press (&fake);
1808 return true;
1809 break;
1811 case GDK_g:
1812 if (ev->state & Keyboard::PrimaryModifier) {
1813 step_gain_down ();
1814 } else {
1815 step_gain_up ();
1817 return true;
1818 break;
1820 case GDK_0:
1821 if (_route) {
1822 _route->set_gain (1.0, this);
1824 return true;
1826 default:
1827 break;
1830 return false;
1834 bool
1835 MixerStrip::on_key_release_event (GdkEventKey* ev)
1837 GdkEventButton fake;
1838 fake.type = GDK_BUTTON_RELEASE;
1839 fake.button = 1;
1840 fake.state = ev->state;
1842 switch (ev->keyval) {
1843 case GDK_m:
1844 mute_release (&fake);
1845 return true;
1846 break;
1848 case GDK_s:
1849 solo_release (&fake);
1850 return true;
1851 break;
1853 case GDK_r:
1854 cerr << "Stole that r\n";
1855 rec_enable_release (&fake);
1856 return true;
1857 break;
1859 case GDK_e:
1860 show_sends_release (&fake);
1861 return true;
1862 break;
1864 case GDK_g:
1865 return true;
1866 break;
1868 default:
1869 break;
1872 return false;
1875 bool
1876 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1878 Keyboard::magic_widget_grab_focus ();
1879 return false;
1882 bool
1883 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1885 switch (ev->detail) {
1886 case GDK_NOTIFY_INFERIOR:
1887 break;
1888 default:
1889 Keyboard::magic_widget_drop_focus ();
1892 return false;
1895 PluginSelector*
1896 MixerStrip::plugin_selector()
1898 return _mixer.plugin_selector();
1901 void
1902 MixerStrip::hide_things ()
1904 processor_box.hide_things ();