somewhat illogical and temporary workaround to the problems with consolidate & bounce...
[ardour2.git] / gtk2_ardour / mixer_strip.cc
blob71a3662f91716e4531315007181b269dc359de39
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);
267 whvbox.pack_start (width_hide_box, true, true);
269 global_vpacker.pack_start (whvbox, Gtk::PACK_SHRINK);
270 global_vpacker.pack_start (button_table, Gtk::PACK_SHRINK);
271 global_vpacker.pack_start (processor_box, true, true);
272 global_vpacker.pack_start (panners, Gtk::PACK_SHRINK);
273 global_vpacker.pack_start (below_panner_box, Gtk::PACK_SHRINK);
274 global_vpacker.pack_start (middle_button_table, Gtk::PACK_SHRINK);
275 global_vpacker.pack_start (gpm, Gtk::PACK_SHRINK);
276 global_vpacker.pack_start (bottom_button_table, Gtk::PACK_SHRINK);
277 global_vpacker.pack_start (output_button, Gtk::PACK_SHRINK);
279 global_frame.add (global_vpacker);
280 global_frame.set_shadow_type (Gtk::SHADOW_IN);
281 global_frame.set_name ("BaseFrame");
283 add (global_frame);
285 /* force setting of visible selected status */
287 _selected = true;
288 set_selected (false);
290 _packed = false;
291 _embedded = false;
293 _session->engine().Stopped.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_stopped, this), gui_context());
294 _session->engine().Running.connect (*this, invalidator (*this), boost::bind (&MixerStrip::engine_running, this), gui_context());
296 input_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::input_press), false);
297 output_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::output_press), false);
299 /* we don't need this if its not an audio track, but we don't know that yet and it doesn't
300 hurt (much).
303 rec_enable_button->set_name ("MixerRecordEnableButton");
305 /* ditto for this button and busses */
307 name_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::name_button_button_press), false);
308 group_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MixerStrip::select_route_group), false);
310 _width = (Width) -1;
312 /* start off as a passthru strip. we'll correct this, if necessary,
313 in update_diskstream_display().
316 /* start off as a passthru strip. we'll correct this, if necessary,
317 in update_diskstream_display().
320 if (is_midi_track())
321 set_name ("MidiTrackStripBase");
322 else
323 set_name ("AudioTrackStripBase");
325 add_events (Gdk::BUTTON_RELEASE_MASK|
326 Gdk::ENTER_NOTIFY_MASK|
327 Gdk::LEAVE_NOTIFY_MASK|
328 Gdk::KEY_PRESS_MASK|
329 Gdk::KEY_RELEASE_MASK);
331 set_flags (get_flags() | Gtk::CAN_FOCUS);
333 SwitchIO.connect (sigc::mem_fun (*this, &MixerStrip::switch_io));
335 AudioEngine::instance()->PortConnectedOrDisconnected.connect (
336 *this, invalidator (*this), boost::bind (&MixerStrip::port_connected_or_disconnected, this, _1, _2), gui_context ()
340 MixerStrip::~MixerStrip ()
342 CatchDeletion (this);
344 delete input_selector;
345 delete output_selector;
346 delete comment_window;
349 void
350 MixerStrip::set_route (boost::shared_ptr<Route> rt)
352 if (rec_enable_button->get_parent()) {
353 below_panner_box.remove (*rec_enable_button);
356 if (show_sends_button->get_parent()) {
357 below_panner_box.remove (*show_sends_button);
360 processor_box.set_route (rt);
362 RouteUI::set_route (rt);
364 /* map the current state */
366 mute_changed (0);
367 update_solo_display ();
369 delete input_selector;
370 input_selector = 0;
372 delete output_selector;
373 output_selector = 0;
375 revert_to_default_display ();
377 if (set_color_from_route()) {
378 set_color (unique_random_color());
381 if (route()->is_master()) {
382 solo_button->hide ();
383 below_panner_box.hide ();
384 } else {
385 solo_button->show ();
386 below_panner_box.show ();
389 if (_mixer_owned && (route()->is_master() || route()->is_monitor())) {
391 if (scrollbar_height == 0) {
392 HScrollbar scrollbar;
393 Gtk::Requisition requisition(scrollbar.size_request ());
394 scrollbar_height = requisition.height;
397 spacer = manage (new EventBox);
398 spacer->set_size_request (-1, scrollbar_height);
399 global_vpacker.pack_start (*spacer, false, false);
402 if (is_audio_track()) {
403 boost::shared_ptr<AudioTrack> at = audio_track();
404 at->FreezeChange.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::map_frozen, this), gui_context());
407 if (has_audio_outputs ()) {
408 panners.show_all ();
409 } else {
410 panners.hide_all ();
413 if (is_track ()) {
415 below_panner_box.pack_start (*rec_enable_button);
416 rec_enable_button->set_sensitive (_session->writable());
417 rec_enable_button->show();
419 } else {
421 /* non-master bus */
423 if (!_route->is_master()) {
424 below_panner_box.pack_start (*show_sends_button);
425 show_sends_button->show();
429 meter_point_label.set_text (meter_point_string (_route->meter_point()));
431 delete route_ops_menu;
432 route_ops_menu = 0;
434 _route->meter_change.connect (route_connections, invalidator (*this), bind (&MixerStrip::meter_changed, this), gui_context());
435 _route->route_group_changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::route_group_changed, this), gui_context());
437 if (_route->panner()) {
438 _route->panner_shell()->Changed.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::connect_to_pan, this), gui_context());
441 if (is_audio_track()) {
442 audio_track()->DiskstreamChanged.connect (route_connections, invalidator (*this), boost::bind (&MixerStrip::diskstream_changed, this), gui_context());
445 _route->comment_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::comment_changed, this, _1), gui_context());
446 _route->gui_changed.connect (route_connections, invalidator (*this), ui_bind (&MixerStrip::route_gui_changed, this, _1, _2), gui_context());
448 set_stuff_from_route ();
450 /* now force an update of all the various elements */
452 mute_changed (0);
453 update_solo_display ();
454 name_changed ();
455 comment_changed (0);
456 route_group_changed ();
458 connect_to_pan ();
459 panners.setup_pan ();
461 update_diskstream_display ();
462 update_input_display ();
463 update_output_display ();
465 add_events (Gdk::BUTTON_RELEASE_MASK);
467 processor_box.show ();
469 if (!route()->is_master() && !route()->is_monitor()) {
470 /* we don't allow master or control routes to be hidden */
471 hide_button.show();
474 width_button.show();
475 width_hide_box.show();
476 whvbox.show ();
477 global_frame.show();
478 global_vpacker.show();
479 button_table.show();
480 middle_button_table.show();
481 bottom_button_table.show();
482 gpm.show_all ();
483 gain_unit_button.show();
484 gain_unit_label.show();
485 meter_point_button.show();
486 meter_point_label.show();
487 diskstream_button.show();
488 diskstream_label.show();
489 input_button.show();
490 input_label.show();
491 output_button.show();
492 output_label.show();
493 name_label.show();
494 name_button.show();
495 group_button.show();
496 group_label.show();
498 show ();
501 void
502 MixerStrip::set_stuff_from_route ()
504 XMLProperty *prop;
506 ensure_xml_node ();
508 /* if width is not set, it will be set by the MixerUI or editor */
510 if ((prop = xml_node->property ("strip-width")) != 0) {
511 set_width_enum (Width (string_2_enum (prop->value(), _width)), this);
514 if ((prop = xml_node->property ("shown-mixer")) != 0) {
515 if (prop->value() == "no") {
516 _marked_for_display = false;
517 } else {
518 _marked_for_display = true;
520 } else {
521 /* backwards compatibility */
522 _marked_for_display = true;
526 void
527 MixerStrip::set_width_enum (Width w, void* owner)
529 /* always set the gpm width again, things may be hidden */
531 gpm.set_width (w);
532 panners.set_width (w);
534 boost::shared_ptr<AutomationList> gain_automation = _route->gain_control()->alist();
536 _width_owner = owner;
538 ensure_xml_node ();
540 _width = w;
542 if (_width_owner == this) {
543 xml_node->add_property ("strip-width", enum_2_string (_width));
546 set_button_names ();
548 switch (w) {
549 case Wide:
550 if (show_sends_button) {
551 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Sends"));
554 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
555 gpm.astyle_string(gain_automation->automation_style()));
556 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
557 gpm.astate_string(gain_automation->automation_state()));
559 if (_route->panner()) {
560 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
561 panners.astyle_string(_route->panner()->automation_style()));
562 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
563 panners.astate_string(_route->panner()->automation_state()));
566 _iso_label->show ();
567 _safe_label->show ();
569 Gtkmm2ext::set_size_request_to_display_given_text (name_button, "long", 2, 2);
570 set_size_request (-1, -1);
571 break;
573 case Narrow:
574 if (show_sends_button) {
575 ((Gtk::Label*)show_sends_button->get_child())->set_text (_("Snd"));
578 ((Gtk::Label*)gpm.gain_automation_style_button.get_child())->set_text (
579 gpm.short_astyle_string(gain_automation->automation_style()));
580 ((Gtk::Label*)gpm.gain_automation_state_button.get_child())->set_text (
581 gpm.short_astate_string(gain_automation->automation_state()));
583 if (_route->panner()) {
584 ((Gtk::Label*)panners.pan_automation_style_button.get_child())->set_text (
585 panners.short_astyle_string(_route->panner()->automation_style()));
586 ((Gtk::Label*)panners.pan_automation_state_button.get_child())->set_text (
587 panners.short_astate_string(_route->panner()->automation_state()));
590 _iso_label->hide ();
591 _safe_label->hide ();
593 Gtkmm2ext::set_size_request_to_display_given_text (name_button, longest_label.c_str(), 2, 2);
594 set_size_request (max (50, gpm.get_gm_width()), -1);
595 break;
598 processor_box.set_width (w);
600 update_input_display ();
601 update_output_display ();
602 route_group_changed ();
603 name_changed ();
604 WidthChanged ();
607 void
608 MixerStrip::set_packed (bool yn)
610 _packed = yn;
612 ensure_xml_node ();
614 if (_packed) {
615 xml_node->add_property ("shown-mixer", "yes");
616 } else {
617 xml_node->add_property ("shown-mixer", "no");
622 struct RouteCompareByName {
623 bool operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b) {
624 return a->name().compare (b->name()) < 0;
628 gint
629 MixerStrip::output_press (GdkEventButton *ev)
631 using namespace Menu_Helpers;
632 if (!_session->engine().connected()) {
633 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
634 msg.run ();
635 return true;
638 MenuList& citems = output_menu.items();
639 switch (ev->button) {
641 case 1:
642 edit_output_configuration ();
643 break;
645 case 3:
647 output_menu.set_name ("ArdourContextMenu");
648 citems.clear ();
649 output_menu_bundles.clear ();
651 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_output)));
652 citems.push_back (SeparatorElem());
654 ARDOUR::BundleList current = _route->output()->bundles_connected ();
656 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
658 /* give user bundles first chance at being in the menu */
660 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
661 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
662 maybe_add_bundle_to_output_menu (*i, current);
666 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
667 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
668 maybe_add_bundle_to_output_menu (*i, current);
672 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
673 RouteList copy = *routes;
674 copy.sort (RouteCompareByName ());
675 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
676 maybe_add_bundle_to_output_menu ((*i)->input()->bundle(), current);
679 if (citems.size() == 2) {
680 /* no routes added; remove the separator */
681 citems.pop_back ();
684 output_menu.popup (1, ev->time);
685 break;
688 default:
689 break;
691 return TRUE;
694 void
695 MixerStrip::edit_output_configuration ()
697 if (output_selector == 0) {
699 boost::shared_ptr<Send> send;
700 boost::shared_ptr<IO> output;
702 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
703 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
704 output = send->output();
705 } else {
706 output = _route->output ();
708 } else {
709 output = _route->output ();
712 output_selector = new IOSelectorWindow (_session, output);
715 if (output_selector->is_visible()) {
716 output_selector->get_toplevel()->get_window()->raise();
717 } else {
718 output_selector->present ();
722 void
723 MixerStrip::edit_input_configuration ()
725 if (input_selector == 0) {
726 input_selector = new IOSelectorWindow (_session, _route->input());
729 if (input_selector->is_visible()) {
730 input_selector->get_toplevel()->get_window()->raise();
731 } else {
732 input_selector->present ();
736 gint
737 MixerStrip::input_press (GdkEventButton *ev)
739 using namespace Menu_Helpers;
741 MenuList& citems = input_menu.items();
742 input_menu.set_name ("ArdourContextMenu");
743 citems.clear();
745 if (!_session->engine().connected()) {
746 MessageDialog msg (_("Not connected to JACK - no I/O changes are possible"));
747 msg.run ();
748 return true;
751 if (_session->actively_recording() && _route->record_enabled())
752 return true;
754 switch (ev->button) {
756 case 1:
757 edit_input_configuration ();
758 break;
760 case 3:
762 citems.push_back (MenuElem (_("Disconnect"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::disconnect_input)));
763 citems.push_back (SeparatorElem());
764 input_menu_bundles.clear ();
766 ARDOUR::BundleList current = _route->input()->bundles_connected ();
768 boost::shared_ptr<ARDOUR::BundleList> b = _session->bundles ();
770 /* give user bundles first chance at being in the menu */
772 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
773 if (boost::dynamic_pointer_cast<UserBundle> (*i)) {
774 maybe_add_bundle_to_input_menu (*i, current);
778 for (ARDOUR::BundleList::iterator i = b->begin(); i != b->end(); ++i) {
779 if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0) {
780 maybe_add_bundle_to_input_menu (*i, current);
784 boost::shared_ptr<ARDOUR::RouteList> routes = _session->get_routes ();
785 RouteList copy = *routes;
786 copy.sort (RouteCompareByName ());
787 for (ARDOUR::RouteList::const_iterator i = copy.begin(); i != copy.end(); ++i) {
788 maybe_add_bundle_to_input_menu ((*i)->output()->bundle(), current);
791 if (citems.size() == 2) {
792 /* no routes added; remove the separator */
793 citems.pop_back ();
796 input_menu.popup (1, ev->time);
797 break;
799 default:
800 break;
802 return TRUE;
805 void
806 MixerStrip::bundle_input_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
808 if (ignore_toggle) {
809 return;
812 ARDOUR::BundleList current = _route->input()->bundles_connected ();
814 if (std::find (current.begin(), current.end(), c) == current.end()) {
815 _route->input()->connect_ports_to_bundle (c, this);
816 } else {
817 _route->input()->disconnect_ports_from_bundle (c, this);
821 void
822 MixerStrip::bundle_output_toggled (boost::shared_ptr<ARDOUR::Bundle> c)
824 if (ignore_toggle) {
825 return;
828 ARDOUR::BundleList current = _route->output()->bundles_connected ();
830 if (std::find (current.begin(), current.end(), c) == current.end()) {
831 _route->output()->connect_ports_to_bundle (c, this);
832 } else {
833 _route->output()->disconnect_ports_from_bundle (c, this);
837 void
838 MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
840 using namespace Menu_Helpers;
842 if (b->ports_are_outputs() == false || b->nchannels() != _route->n_inputs()) {
843 return;
846 list<boost::shared_ptr<Bundle> >::iterator i = input_menu_bundles.begin ();
847 while (i != input_menu_bundles.end() && b->has_same_ports (*i) == false) {
848 ++i;
851 if (i != input_menu_bundles.end()) {
852 return;
855 input_menu_bundles.push_back (b);
857 MenuList& citems = input_menu.items();
859 std::string n = b->name ();
860 replace_all (n, "_", " ");
862 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_input_toggled), b)));
864 if (std::find (current.begin(), current.end(), b) != current.end()) {
865 ignore_toggle = true;
866 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
867 ignore_toggle = false;
871 void
872 MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR::BundleList const & current)
874 using namespace Menu_Helpers;
876 if (b->ports_are_inputs() == false || b->nchannels() != _route->n_outputs()) {
877 return;
880 list<boost::shared_ptr<Bundle> >::iterator i = output_menu_bundles.begin ();
881 while (i != output_menu_bundles.end() && b->has_same_ports (*i) == false) {
882 ++i;
885 if (i != output_menu_bundles.end()) {
886 return;
889 output_menu_bundles.push_back (b);
891 MenuList& citems = output_menu.items();
893 std::string n = b->name ();
894 replace_all (n, "_", " ");
896 citems.push_back (CheckMenuElem (n, sigc::bind (sigc::mem_fun(*this, &MixerStrip::bundle_output_toggled), b)));
898 if (std::find (current.begin(), current.end(), b) != current.end()) {
899 ignore_toggle = true;
900 dynamic_cast<CheckMenuItem *> (&citems.back())->set_active (true);
901 ignore_toggle = false;
905 void
906 MixerStrip::update_diskstream_display ()
908 if (is_track()) {
910 if (input_selector) {
911 input_selector->hide_all ();
914 show_route_color ();
916 } else {
918 show_passthru_color ();
922 void
923 MixerStrip::connect_to_pan ()
925 ENSURE_GUI_THREAD (*this, &MixerStrip::connect_to_pan)
927 panstate_connection.disconnect ();
928 panstyle_connection.disconnect ();
930 if (!_route->panner()) {
931 return;
934 boost::shared_ptr<Pannable> p = _route->pannable ();
936 p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
937 p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
939 panners.panshell_changed ();
944 * Output port labelling
945 * =====================
947 * Case 1: Each output has one connection, all connections are to system:playback_%i
948 * out 1 -> system:playback_1
949 * out 2 -> system:playback_2
950 * out 3 -> system:playback_3
951 * Display as: 1/2/3
953 * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
954 * out 1 -> ardour:track_x/in 1
955 * out 2 -> ardour:track_x/in 2
956 * Display as: track_x
958 * Case 3: Each output has one connection, all connections are to Jack client "program x"
959 * out 1 -> program x:foo
960 * out 2 -> program x:foo
961 * Display as: program x
963 * Case 4: No connections (Disconnected)
964 * Display as: -
966 * Default case (unusual routing):
967 * Display as: *number of connections*
969 * Tooltips
970 * ========
971 * .-----------------------------------------------.
972 * | Mixdown |
973 * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
974 * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
975 * '-----------------------------------------------'
976 * .-----------------------------------------------.
977 * | Guitar SM58 |
978 * | Disconnected |
979 * '-----------------------------------------------'
982 void
983 MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
985 uint32_t io_count;
986 uint32_t io_index;
987 Port *port;
988 vector<string> port_connections;
990 uint32_t total_connection_count = 0;
991 uint32_t io_connection_count = 0;
992 uint32_t ardour_connection_count = 0;
993 uint32_t system_connection_count = 0;
994 uint32_t other_connection_count = 0;
996 ostringstream label;
997 string label_string;
999 bool have_label = false;
1000 bool each_io_has_one_connection = true;
1002 string connection_name;
1003 string ardour_track_name;
1004 string other_connection_type;
1005 string system_ports;
1006 string system_port;
1008 ostringstream tooltip;
1009 char * tooltip_cstr;
1011 tooltip << route->name();
1013 if (for_input) {
1014 io_count = route->n_inputs().n_total();
1015 } else {
1016 io_count = route->n_outputs().n_total();
1019 for (io_index = 0; io_index < io_count; ++io_index) {
1020 if (for_input) {
1021 port = route->input()->nth (io_index);
1022 } else {
1023 port = route->output()->nth (io_index);
1026 port_connections.clear ();
1027 port->get_connections(port_connections);
1028 io_connection_count = 0;
1030 if (!port_connections.empty()) {
1031 for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
1032 string& connection_name (*i);
1034 if (io_connection_count == 0) {
1035 tooltip << endl << port->name().substr(port->name().find("/") + 1) << " -> " << connection_name;
1036 } else {
1037 tooltip << ", " << connection_name;
1040 if (connection_name.find("ardour:") == 0) {
1041 if (ardour_track_name.empty()) {
1042 // "ardour:Master/in 1" -> "ardour:Master/"
1043 string::size_type slash = connection_name.find("/");
1044 if (slash != string::npos) {
1045 ardour_track_name = connection_name.substr(0, slash + 1);
1049 if (connection_name.find(ardour_track_name) == 0) {
1050 ++ardour_connection_count;
1052 } else if (connection_name.find("system:") == 0) {
1053 if (for_input) {
1054 // "system:capture_123" -> "123"
1055 system_port = connection_name.substr(15);
1056 } else {
1057 // "system:playback_123" -> "123"
1058 system_port = connection_name.substr(16);
1061 if (system_ports.empty()) {
1062 system_ports += system_port;
1063 } else {
1064 system_ports += "/" + system_port;
1067 ++system_connection_count;
1068 } else {
1069 if (other_connection_type.empty()) {
1070 // "jamin:in 1" -> "jamin:"
1071 other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
1074 if (connection_name.find(other_connection_type) == 0) {
1075 ++other_connection_count;
1079 ++total_connection_count;
1080 ++io_connection_count;
1084 if (io_connection_count != 1) {
1085 each_io_has_one_connection = false;
1089 if (total_connection_count == 0) {
1090 tooltip << endl << _("Disconnected");
1093 tooltip_cstr = new char[tooltip.str().size() + 1];
1094 strcpy(tooltip_cstr, tooltip.str().c_str());
1096 if (for_input) {
1097 ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
1098 } else {
1099 ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
1102 if (each_io_has_one_connection) {
1103 if ((total_connection_count == ardour_connection_count)) {
1104 // all connections are to the same track in ardour
1105 // "ardour:Master/" -> "Master"
1106 string::size_type slash = ardour_track_name.find("/");
1107 if (slash != string::npos) {
1108 label << ardour_track_name.substr(7, slash - 7);
1109 have_label = true;
1112 else if (total_connection_count == system_connection_count) {
1113 // all connections are to system ports
1114 label << system_ports;
1115 have_label = true;
1117 else if (total_connection_count == other_connection_count) {
1118 // all connections are to the same external program eg jamin
1119 // "jamin:" -> "jamin"
1120 label << other_connection_type.substr(0, other_connection_type.size() - 1);
1121 have_label = true;
1125 if (!have_label) {
1126 if (total_connection_count == 0) {
1127 // Disconnected
1128 label << "-";
1129 } else {
1130 // Odd configuration
1131 label << "*" << total_connection_count << "*";
1135 switch (width) {
1136 case Wide:
1137 label_string = label.str().substr(0, 6);
1138 break;
1139 case Narrow:
1140 label_string = label.str().substr(0, 3);
1141 break;
1144 if (for_input) {
1145 input_label.set_text (label_string);
1146 } else {
1147 output_label.set_text (label_string);
1151 void
1152 MixerStrip::update_input_display ()
1154 update_io_button (_route, _width, true);
1155 panners.setup_pan ();
1158 void
1159 MixerStrip::update_output_display ()
1161 update_io_button (_route, _width, false);
1162 gpm.setup_meters ();
1163 panners.setup_pan ();
1166 void
1167 MixerStrip::fast_update ()
1169 gpm.update_meters ();
1172 void
1173 MixerStrip::diskstream_changed ()
1175 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&MixerStrip::update_diskstream_display, this));
1178 void
1179 MixerStrip::port_connected_or_disconnected (Port* a, Port* b)
1181 if (_route->input()->has_port (a) || _route->input()->has_port (b)) {
1182 update_input_display ();
1183 set_width_enum (_width, this);
1186 if (_route->output()->has_port (a) || _route->output()->has_port (b)) {
1187 update_output_display ();
1188 set_width_enum (_width, this);
1192 void
1193 MixerStrip::comment_editor_done_editing ()
1195 ignore_toggle = true;
1196 _comment_menu_item->set_active (false);
1197 ignore_toggle = false;
1199 string const str = comment_area->get_buffer()->get_text();
1200 if (str == _route->comment ()) {
1201 return;
1204 _route->set_comment (str, this);
1207 void
1208 MixerStrip::toggle_comment ()
1210 if (ignore_toggle) {
1211 return;
1214 if (comment_window == 0) {
1215 setup_comment_editor ();
1218 if (comment_window->is_visible ()) {
1219 comment_window->hide ();
1220 return;
1223 string title;
1224 title = _route->name();
1225 title += _(": comment editor");
1227 comment_window->set_title (title);
1228 comment_window->present();
1231 void
1232 MixerStrip::setup_comment_editor ()
1234 comment_window = new ArdourDialog ("", false); // title will be reset to show route
1235 comment_window->set_position (Gtk::WIN_POS_MOUSE);
1236 comment_window->set_skip_taskbar_hint (true);
1237 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1238 comment_window->set_default_size (400, 200);
1240 comment_area = manage (new TextView());
1241 comment_area->set_name ("MixerTrackCommentArea");
1242 comment_area->set_wrap_mode (WRAP_WORD);
1243 comment_area->set_editable (true);
1244 comment_area->get_buffer()->set_text (_route->comment());
1245 comment_area->show ();
1247 comment_window->get_vbox()->pack_start (*comment_area);
1248 comment_window->get_action_area()->hide();
1251 void
1252 MixerStrip::comment_changed (void *src)
1254 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_changed, src)
1256 if (src != this) {
1257 ignore_comment_edit = true;
1258 if (comment_area) {
1259 comment_area->get_buffer()->set_text (_route->comment());
1261 ignore_comment_edit = false;
1265 bool
1266 MixerStrip::select_route_group (GdkEventButton *ev)
1268 using namespace Menu_Helpers;
1270 if (ev->button == 1) {
1272 if (group_menu == 0) {
1274 PropertyList* plist = new PropertyList();
1276 plist->add (Properties::gain, true);
1277 plist->add (Properties::mute, true);
1278 plist->add (Properties::solo, true);
1280 group_menu = new RouteGroupMenu (_session, plist);
1283 WeakRouteList r;
1284 r.push_back (route ());
1285 group_menu->build (r);
1286 group_menu->menu()->popup (1, ev->time);
1289 return true;
1292 void
1293 MixerStrip::route_group_changed ()
1295 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1297 RouteGroup *rg = _route->route_group();
1299 if (rg) {
1300 group_label.set_text (PBD::short_version (rg->name(), 5));
1301 } else {
1302 switch (_width) {
1303 case Wide:
1304 group_label.set_text (_("Grp"));
1305 break;
1306 case Narrow:
1307 group_label.set_text (_("~G"));
1308 break;
1314 void
1315 MixerStrip::route_gui_changed (string what_changed, void*)
1317 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1319 if (what_changed == "color") {
1320 if (set_color_from_route () == 0) {
1321 show_route_color ();
1326 void
1327 MixerStrip::show_route_color ()
1329 name_button.modify_bg (STATE_NORMAL, color());
1330 top_event_box.modify_bg (STATE_NORMAL, color());
1331 reset_strip_style ();
1334 void
1335 MixerStrip::show_passthru_color ()
1337 reset_strip_style ();
1340 void
1341 MixerStrip::build_route_ops_menu ()
1343 using namespace Menu_Helpers;
1344 route_ops_menu = new Menu;
1345 route_ops_menu->set_name ("ArdourContextMenu");
1347 MenuList& items = route_ops_menu->items();
1349 items.push_back (CheckMenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::toggle_comment)));
1350 _comment_menu_item = dynamic_cast<CheckMenuItem*> (&items.back ());
1351 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1352 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1353 rename_menu_item = &items.back();
1354 items.push_back (SeparatorElem());
1355 items.push_back (CheckMenuElem (_("Active")));
1356 CheckMenuItem* i = dynamic_cast<CheckMenuItem *> (&items.back());
1357 i->set_active (_route->active());
1358 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
1360 items.push_back (SeparatorElem());
1362 items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1364 items.push_back (SeparatorElem());
1365 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1366 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1367 denormal_menu_item->set_active (_route->denormal_protection());
1369 if (!Profile->get_sae()) {
1370 items.push_back (SeparatorElem());
1371 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1374 items.push_back (SeparatorElem());
1375 items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), false)));
1378 gboolean
1379 MixerStrip::name_button_button_press (GdkEventButton* ev)
1381 if (ev->button == 3) {
1382 list_route_operations ();
1384 /* do not allow rename if the track is record-enabled */
1385 rename_menu_item->set_sensitive (!_route->record_enabled());
1386 route_ops_menu->popup (1, ev->time);
1388 } else if (ev->button == 1) {
1389 revert_to_default_display ();
1392 return false;
1395 void
1396 MixerStrip::list_route_operations ()
1398 delete route_ops_menu;
1399 build_route_ops_menu ();
1402 void
1403 MixerStrip::set_selected (bool yn)
1405 AxisView::set_selected (yn);
1406 if (_selected) {
1407 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1408 global_frame.set_name ("MixerStripSelectedFrame");
1409 } else {
1410 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1411 global_frame.set_name ("MixerStripFrame");
1413 global_frame.queue_draw ();
1416 void
1417 MixerStrip::name_changed ()
1419 switch (_width) {
1420 case Wide:
1421 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1422 break;
1423 case Narrow:
1424 name_label.set_text (PBD::short_version (_route->name(), 5));
1425 break;
1429 void
1430 MixerStrip::width_clicked ()
1432 switch (_width) {
1433 case Wide:
1434 set_width_enum (Narrow, this);
1435 break;
1436 case Narrow:
1437 set_width_enum (Wide, this);
1438 break;
1442 void
1443 MixerStrip::hide_clicked ()
1445 // LAME fix to reset the button status for when it is redisplayed (part 1)
1446 hide_button.set_sensitive(false);
1448 if (_embedded) {
1449 Hiding(); /* EMIT_SIGNAL */
1450 } else {
1451 _mixer.hide_strip (this);
1454 // (part 2)
1455 hide_button.set_sensitive(true);
1458 void
1459 MixerStrip::set_embedded (bool yn)
1461 _embedded = yn;
1464 void
1465 MixerStrip::map_frozen ()
1467 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1469 boost::shared_ptr<AudioTrack> at = audio_track();
1471 if (at) {
1472 switch (at->freeze_state()) {
1473 case AudioTrack::Frozen:
1474 processor_box.set_sensitive (false);
1475 hide_redirect_editors ();
1476 break;
1477 default:
1478 processor_box.set_sensitive (true);
1479 // XXX need some way, maybe, to retoggle redirect editors
1480 break;
1485 void
1486 MixerStrip::hide_redirect_editors ()
1488 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1491 void
1492 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1494 boost::shared_ptr<Processor> processor (p.lock ());
1495 if (!processor) {
1496 return;
1499 Gtk::Window* w = processor_box.get_processor_ui (processor);
1501 if (w) {
1502 w->hide ();
1506 void
1507 MixerStrip::reset_strip_style ()
1509 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1511 gpm.set_fader_name ("SendStripBase");
1513 } else {
1515 if (is_midi_track()) {
1516 if (_route->active()) {
1517 set_name ("MidiTrackStripBase");
1518 gpm.set_meter_strip_name ("MidiTrackMetrics");
1519 } else {
1520 set_name ("MidiTrackStripBaseInactive");
1521 gpm.set_meter_strip_name ("MidiTrackMetricsInactive");
1523 gpm.set_fader_name ("MidiTrackFader");
1524 } else if (is_audio_track()) {
1525 if (_route->active()) {
1526 set_name ("AudioTrackStripBase");
1527 gpm.set_meter_strip_name ("AudioTrackMetrics");
1528 } else {
1529 set_name ("AudioTrackStripBaseInactive");
1530 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1532 gpm.set_fader_name ("AudioTrackFader");
1533 } else {
1534 if (_route->active()) {
1535 set_name ("AudioBusStripBase");
1536 gpm.set_meter_strip_name ("AudioBusMetrics");
1537 } else {
1538 set_name ("AudioBusStripBaseInactive");
1539 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1541 gpm.set_fader_name ("AudioBusFader");
1543 /* (no MIDI busses yet) */
1548 RouteGroup*
1549 MixerStrip::route_group() const
1551 return _route->route_group();
1554 void
1555 MixerStrip::engine_stopped ()
1559 void
1560 MixerStrip::engine_running ()
1564 string
1565 MixerStrip::meter_point_string (MeterPoint mp)
1567 switch (mp) {
1568 case MeterInput:
1569 return _("in");
1570 break;
1572 case MeterPreFader:
1573 return _("pre");
1574 break;
1576 case MeterPostFader:
1577 return _("post");
1578 break;
1580 case MeterOutput:
1581 return _("out");
1582 break;
1584 case MeterCustom:
1585 default:
1586 return _("custom");
1587 break;
1591 /** Called when the metering point has changed */
1592 void
1593 MixerStrip::meter_changed ()
1595 meter_point_label.set_text (meter_point_string (_route->meter_point()));
1596 gpm.setup_meters ();
1597 // reset peak when meter point changes
1598 gpm.reset_peak_display();
1601 void
1602 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1604 /* don't respond to switch IO signal outside of the mixer window */
1606 if (!_mixer_owned) {
1607 return;
1610 if (_route == target || _route->is_master()) {
1611 /* don't change the display for the target or the master bus */
1612 return;
1613 } else if (!is_track() && show_sends_button) {
1614 /* make sure our show sends button is inactive, and we no longer blink,
1615 since we're not the target.
1617 send_blink_connection.disconnect ();
1618 show_sends_button->set_active (false);
1619 show_sends_button->set_state (STATE_NORMAL);
1622 if (!target) {
1623 /* switch back to default */
1624 revert_to_default_display ();
1625 return;
1628 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1630 if (send) {
1631 show_send (send);
1632 } else {
1633 revert_to_default_display ();
1637 void
1638 MixerStrip::drop_send ()
1640 boost::shared_ptr<Send> current_send;
1642 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1643 current_send->set_metering (false);
1646 send_gone_connection.disconnect ();
1647 input_button.set_sensitive (true);
1648 output_button.set_sensitive (true);
1649 group_button.set_sensitive (true);
1650 set_invert_sensitive (true);
1651 meter_point_button.set_sensitive (true);
1652 mute_button->set_sensitive (true);
1653 solo_button->set_sensitive (true);
1654 rec_enable_button->set_sensitive (true);
1655 solo_isolated_led->set_sensitive (true);
1656 solo_safe_led->set_sensitive (true);
1659 void
1660 MixerStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1662 _current_delivery = d;
1663 DeliveryChanged (_current_delivery);
1666 void
1667 MixerStrip::show_send (boost::shared_ptr<Send> send)
1669 assert (send != 0);
1671 drop_send ();
1673 set_current_delivery (send);
1675 send->set_metering (true);
1676 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1678 gain_meter().set_controls (_route, send->meter(), send->amp());
1679 gain_meter().setup_meters ();
1681 panner_ui().set_panner (_current_delivery->panner_shell(), _current_delivery->panner());
1682 panner_ui().setup_pan ();
1684 input_button.set_sensitive (false);
1685 group_button.set_sensitive (false);
1686 set_invert_sensitive (false);
1687 meter_point_button.set_sensitive (false);
1688 mute_button->set_sensitive (false);
1689 solo_button->set_sensitive (false);
1690 rec_enable_button->set_sensitive (false);
1691 solo_isolated_led->set_sensitive (false);
1692 solo_safe_led->set_sensitive (false);
1694 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1695 output_button.set_sensitive (false);
1698 reset_strip_style ();
1701 void
1702 MixerStrip::revert_to_default_display ()
1704 if (show_sends_button) {
1705 show_sends_button->set_active (false);
1708 drop_send ();
1710 set_current_delivery (_route->main_outs ());
1712 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1713 gain_meter().setup_meters ();
1715 panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
1716 panner_ui().setup_pan ();
1718 reset_strip_style ();
1721 void
1722 MixerStrip::set_button_names ()
1724 switch (_width) {
1725 case Wide:
1726 rec_enable_button_label.set_text (_("Rec"));
1727 mute_button_label.set_text (_("Mute"));
1728 if (_route && _route->solo_safe()) {
1729 solo_button_label.set_text (X_("!"));
1730 } else {
1731 if (!Config->get_solo_control_is_listen_control()) {
1732 solo_button_label.set_text (_("Solo"));
1733 } else {
1734 switch (Config->get_listen_position()) {
1735 case AfterFaderListen:
1736 solo_button_label.set_text (_("AFL"));
1737 break;
1738 case PreFaderListen:
1739 solo_button_label.set_text (_("PFL"));
1740 break;
1744 break;
1746 default:
1747 rec_enable_button_label.set_text (_("R"));
1748 mute_button_label.set_text (_("M"));
1749 if (_route && _route->solo_safe()) {
1750 solo_button_label.set_text (X_("!"));
1751 if (!Config->get_solo_control_is_listen_control()) {
1752 solo_button_label.set_text (_("S"));
1753 } else {
1754 switch (Config->get_listen_position()) {
1755 case AfterFaderListen:
1756 solo_button_label.set_text (_("A"));
1757 break;
1758 case PreFaderListen:
1759 solo_button_label.set_text (_("P"));
1760 break;
1764 break;
1769 bool
1770 MixerStrip::on_key_press_event (GdkEventKey* ev)
1772 GdkEventButton fake;
1773 fake.type = GDK_BUTTON_PRESS;
1774 fake.button = 1;
1775 fake.state = ev->state;
1777 switch (ev->keyval) {
1778 case GDK_m:
1779 mute_press (&fake);
1780 return true;
1781 break;
1783 case GDK_s:
1784 solo_press (&fake);
1785 return true;
1786 break;
1788 case GDK_r:
1789 cerr << "Stole that r\n";
1790 rec_enable_press (&fake);
1791 return true;
1792 break;
1794 case GDK_e:
1795 show_sends_press (&fake);
1796 return true;
1797 break;
1799 case GDK_g:
1800 if (ev->state & Keyboard::PrimaryModifier) {
1801 step_gain_down ();
1802 } else {
1803 step_gain_up ();
1805 return true;
1806 break;
1808 case GDK_0:
1809 if (_route) {
1810 _route->set_gain (1.0, this);
1812 return true;
1814 default:
1815 break;
1818 return false;
1822 bool
1823 MixerStrip::on_key_release_event (GdkEventKey* ev)
1825 GdkEventButton fake;
1826 fake.type = GDK_BUTTON_RELEASE;
1827 fake.button = 1;
1828 fake.state = ev->state;
1830 switch (ev->keyval) {
1831 case GDK_m:
1832 mute_release (&fake);
1833 return true;
1834 break;
1836 case GDK_s:
1837 solo_release (&fake);
1838 return true;
1839 break;
1841 case GDK_r:
1842 cerr << "Stole that r\n";
1843 rec_enable_release (&fake);
1844 return true;
1845 break;
1847 case GDK_e:
1848 show_sends_release (&fake);
1849 return true;
1850 break;
1852 case GDK_g:
1853 return true;
1854 break;
1856 default:
1857 break;
1860 return false;
1863 bool
1864 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1866 Keyboard::magic_widget_grab_focus ();
1867 return false;
1870 bool
1871 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1873 switch (ev->detail) {
1874 case GDK_NOTIFY_INFERIOR:
1875 break;
1876 default:
1877 Keyboard::magic_widget_drop_focus ();
1880 return false;
1883 PluginSelector*
1884 MixerStrip::plugin_selector()
1886 return _mixer.plugin_selector();
1889 void
1890 MixerStrip::hide_things ()
1892 processor_box.hide_things ();