spell check
[ardour2.git] / gtk2_ardour / mixer_strip.cc
blob5181878fb5a03099149daa066131347047350df0
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 bool
1259 MixerStrip::select_route_group (GdkEventButton *ev)
1261 using namespace Menu_Helpers;
1263 if (ev->button == 1) {
1265 if (group_menu == 0) {
1267 PropertyList* plist = new PropertyList();
1269 plist->add (Properties::gain, true);
1270 plist->add (Properties::mute, true);
1271 plist->add (Properties::solo, true);
1273 group_menu = new RouteGroupMenu (_session, plist);
1276 WeakRouteList r;
1277 r.push_back (route ());
1278 group_menu->build (r);
1279 group_menu->menu()->popup (1, ev->time);
1282 return true;
1285 void
1286 MixerStrip::route_group_changed ()
1288 ENSURE_GUI_THREAD (*this, &MixerStrip::route_group_changed)
1290 RouteGroup *rg = _route->route_group();
1292 if (rg) {
1293 group_label.set_text (PBD::short_version (rg->name(), 5));
1294 } else {
1295 switch (_width) {
1296 case Wide:
1297 group_label.set_text (_("Grp"));
1298 break;
1299 case Narrow:
1300 group_label.set_text (_("~G"));
1301 break;
1307 void
1308 MixerStrip::route_gui_changed (string what_changed, void*)
1310 ENSURE_GUI_THREAD (*this, &MixerStrip::route_gui_changed, what_changed, ignored)
1312 if (what_changed == "color") {
1313 if (set_color_from_route () == 0) {
1314 show_route_color ();
1319 void
1320 MixerStrip::show_route_color ()
1322 name_button.modify_bg (STATE_NORMAL, color());
1323 top_event_box.modify_bg (STATE_NORMAL, color());
1324 reset_strip_style ();
1327 void
1328 MixerStrip::show_passthru_color ()
1330 reset_strip_style ();
1333 void
1334 MixerStrip::build_route_ops_menu ()
1336 using namespace Menu_Helpers;
1337 route_ops_menu = new Menu;
1338 route_ops_menu->set_name ("ArdourContextMenu");
1340 MenuList& items = route_ops_menu->items();
1342 items.push_back (CheckMenuElem (_("Comments..."), sigc::mem_fun (*this, &MixerStrip::toggle_comment)));
1343 _comment_menu_item = dynamic_cast<CheckMenuItem*> (&items.back ());
1344 items.push_back (MenuElem (_("Save As Template..."), sigc::mem_fun(*this, &RouteUI::save_as_template)));
1345 items.push_back (MenuElem (_("Rename..."), sigc::mem_fun(*this, &RouteUI::route_rename)));
1346 rename_menu_item = &items.back();
1347 items.push_back (SeparatorElem());
1348 items.push_back (CheckMenuElem (_("Active")));
1349 CheckMenuItem* i = dynamic_cast<CheckMenuItem *> (&items.back());
1350 i->set_active (_route->active());
1351 i->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::set_route_active), !_route->active(), false));
1353 items.push_back (SeparatorElem());
1355 items.push_back (MenuElem (_("Adjust Latency..."), sigc::mem_fun (*this, &RouteUI::adjust_latency)));
1357 items.push_back (SeparatorElem());
1358 items.push_back (CheckMenuElem (_("Protect Against Denormals"), sigc::mem_fun (*this, &RouteUI::toggle_denormal_protection)));
1359 denormal_menu_item = dynamic_cast<CheckMenuItem *> (&items.back());
1360 denormal_menu_item->set_active (_route->denormal_protection());
1362 if (!Profile->get_sae()) {
1363 items.push_back (SeparatorElem());
1364 items.push_back (MenuElem (_("Remote Control ID..."), sigc::mem_fun (*this, &RouteUI::open_remote_control_id_dialog)));
1367 items.push_back (SeparatorElem());
1368 items.push_back (MenuElem (_("Remove"), sigc::bind (sigc::mem_fun(*this, &RouteUI::remove_this_route), false)));
1371 gboolean
1372 MixerStrip::name_button_button_press (GdkEventButton* ev)
1374 if (ev->button == 3) {
1375 list_route_operations ();
1377 /* do not allow rename if the track is record-enabled */
1378 rename_menu_item->set_sensitive (!_route->record_enabled());
1379 route_ops_menu->popup (1, ev->time);
1381 } else if (ev->button == 1) {
1382 revert_to_default_display ();
1385 return false;
1388 void
1389 MixerStrip::list_route_operations ()
1391 delete route_ops_menu;
1392 build_route_ops_menu ();
1395 void
1396 MixerStrip::set_selected (bool yn)
1398 AxisView::set_selected (yn);
1399 if (_selected) {
1400 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
1401 global_frame.set_name ("MixerStripSelectedFrame");
1402 } else {
1403 global_frame.set_shadow_type (Gtk::SHADOW_IN);
1404 global_frame.set_name ("MixerStripFrame");
1406 global_frame.queue_draw ();
1409 void
1410 MixerStrip::name_changed ()
1412 switch (_width) {
1413 case Wide:
1414 RouteUI::property_changed (PropertyChange (ARDOUR::Properties::name));
1415 break;
1416 case Narrow:
1417 name_label.set_text (PBD::short_version (_route->name(), 5));
1418 break;
1422 void
1423 MixerStrip::width_clicked ()
1425 switch (_width) {
1426 case Wide:
1427 set_width_enum (Narrow, this);
1428 break;
1429 case Narrow:
1430 set_width_enum (Wide, this);
1431 break;
1435 void
1436 MixerStrip::hide_clicked ()
1438 // LAME fix to reset the button status for when it is redisplayed (part 1)
1439 hide_button.set_sensitive(false);
1441 if (_embedded) {
1442 Hiding(); /* EMIT_SIGNAL */
1443 } else {
1444 _mixer.hide_strip (this);
1447 // (part 2)
1448 hide_button.set_sensitive(true);
1451 void
1452 MixerStrip::set_embedded (bool yn)
1454 _embedded = yn;
1457 void
1458 MixerStrip::map_frozen ()
1460 ENSURE_GUI_THREAD (*this, &MixerStrip::map_frozen)
1462 boost::shared_ptr<AudioTrack> at = audio_track();
1464 if (at) {
1465 switch (at->freeze_state()) {
1466 case AudioTrack::Frozen:
1467 processor_box.set_sensitive (false);
1468 hide_redirect_editors ();
1469 break;
1470 default:
1471 processor_box.set_sensitive (true);
1472 // XXX need some way, maybe, to retoggle redirect editors
1473 break;
1478 void
1479 MixerStrip::hide_redirect_editors ()
1481 _route->foreach_processor (sigc::mem_fun (*this, &MixerStrip::hide_processor_editor));
1484 void
1485 MixerStrip::hide_processor_editor (boost::weak_ptr<Processor> p)
1487 boost::shared_ptr<Processor> processor (p.lock ());
1488 if (!processor) {
1489 return;
1492 Gtk::Window* w = processor_box.get_processor_ui (processor);
1494 if (w) {
1495 w->hide ();
1499 void
1500 MixerStrip::reset_strip_style ()
1502 if (_current_delivery && boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1504 gpm.set_fader_name ("SendStripBase");
1506 } else {
1508 if (is_midi_track()) {
1509 if (_route->active()) {
1510 set_name ("MidiTrackStripBase");
1511 gpm.set_meter_strip_name ("MidiTrackMetrics");
1512 } else {
1513 set_name ("MidiTrackStripBaseInactive");
1514 gpm.set_meter_strip_name ("MidiTrackMetricsInactive");
1516 gpm.set_fader_name ("MidiTrackFader");
1517 } else if (is_audio_track()) {
1518 if (_route->active()) {
1519 set_name ("AudioTrackStripBase");
1520 gpm.set_meter_strip_name ("AudioTrackMetrics");
1521 } else {
1522 set_name ("AudioTrackStripBaseInactive");
1523 gpm.set_meter_strip_name ("AudioTrackMetricsInactive");
1525 gpm.set_fader_name ("AudioTrackFader");
1526 } else {
1527 if (_route->active()) {
1528 set_name ("AudioBusStripBase");
1529 gpm.set_meter_strip_name ("AudioBusMetrics");
1530 } else {
1531 set_name ("AudioBusStripBaseInactive");
1532 gpm.set_meter_strip_name ("AudioBusMetricsInactive");
1534 gpm.set_fader_name ("AudioBusFader");
1536 /* (no MIDI busses yet) */
1541 RouteGroup*
1542 MixerStrip::route_group() const
1544 return _route->route_group();
1547 void
1548 MixerStrip::engine_stopped ()
1552 void
1553 MixerStrip::engine_running ()
1557 string
1558 MixerStrip::meter_point_string (MeterPoint mp)
1560 switch (mp) {
1561 case MeterInput:
1562 return _("in");
1563 break;
1565 case MeterPreFader:
1566 return _("pre");
1567 break;
1569 case MeterPostFader:
1570 return _("post");
1571 break;
1573 case MeterOutput:
1574 return _("out");
1575 break;
1577 case MeterCustom:
1578 default:
1579 return _("custom");
1580 break;
1584 /** Called when the metering point has changed */
1585 void
1586 MixerStrip::meter_changed ()
1588 meter_point_label.set_text (meter_point_string (_route->meter_point()));
1589 gpm.setup_meters ();
1590 // reset peak when meter point changes
1591 gpm.reset_peak_display();
1594 void
1595 MixerStrip::switch_io (boost::shared_ptr<Route> target)
1597 /* don't respond to switch IO signal outside of the mixer window */
1599 if (!_mixer_owned) {
1600 return;
1603 if (_route == target || _route->is_master()) {
1604 /* don't change the display for the target or the master bus */
1605 return;
1606 } else if (!is_track() && show_sends_button) {
1607 /* make sure our show sends button is inactive, and we no longer blink,
1608 since we're not the target.
1610 send_blink_connection.disconnect ();
1611 show_sends_button->set_active (false);
1612 show_sends_button->set_state (STATE_NORMAL);
1615 if (!target) {
1616 /* switch back to default */
1617 revert_to_default_display ();
1618 return;
1621 boost::shared_ptr<Send> send = _route->internal_send_for (target);
1623 if (send) {
1624 show_send (send);
1625 } else {
1626 revert_to_default_display ();
1630 void
1631 MixerStrip::drop_send ()
1633 boost::shared_ptr<Send> current_send;
1635 if (_current_delivery && (current_send = boost::dynamic_pointer_cast<Send>(_current_delivery))) {
1636 current_send->set_metering (false);
1639 send_gone_connection.disconnect ();
1640 input_button.set_sensitive (true);
1641 output_button.set_sensitive (true);
1642 group_button.set_sensitive (true);
1643 set_invert_sensitive (true);
1644 meter_point_button.set_sensitive (true);
1645 mute_button->set_sensitive (true);
1646 solo_button->set_sensitive (true);
1647 rec_enable_button->set_sensitive (true);
1648 solo_isolated_led->set_sensitive (true);
1649 solo_safe_led->set_sensitive (true);
1652 void
1653 MixerStrip::set_current_delivery (boost::shared_ptr<Delivery> d)
1655 _current_delivery = d;
1656 DeliveryChanged (_current_delivery);
1659 void
1660 MixerStrip::show_send (boost::shared_ptr<Send> send)
1662 assert (send != 0);
1664 drop_send ();
1666 set_current_delivery (send);
1668 send->set_metering (true);
1669 _current_delivery->DropReferences.connect (send_gone_connection, invalidator (*this), boost::bind (&MixerStrip::revert_to_default_display, this), gui_context());
1671 gain_meter().set_controls (_route, send->meter(), send->amp());
1672 gain_meter().setup_meters ();
1674 panner_ui().set_panner (_current_delivery->panner_shell(), _current_delivery->panner());
1675 panner_ui().setup_pan ();
1677 input_button.set_sensitive (false);
1678 group_button.set_sensitive (false);
1679 set_invert_sensitive (false);
1680 meter_point_button.set_sensitive (false);
1681 mute_button->set_sensitive (false);
1682 solo_button->set_sensitive (false);
1683 rec_enable_button->set_sensitive (false);
1684 solo_isolated_led->set_sensitive (false);
1685 solo_safe_led->set_sensitive (false);
1687 if (boost::dynamic_pointer_cast<InternalSend>(send)) {
1688 output_button.set_sensitive (false);
1691 reset_strip_style ();
1694 void
1695 MixerStrip::revert_to_default_display ()
1697 if (show_sends_button) {
1698 show_sends_button->set_active (false);
1701 drop_send ();
1703 set_current_delivery (_route->main_outs ());
1705 gain_meter().set_controls (_route, _route->shared_peak_meter(), _route->amp());
1706 gain_meter().setup_meters ();
1708 panner_ui().set_panner (_route->main_outs()->panner_shell(), _route->main_outs()->panner());
1709 panner_ui().setup_pan ();
1711 reset_strip_style ();
1714 void
1715 MixerStrip::set_button_names ()
1717 switch (_width) {
1718 case Wide:
1719 rec_enable_button_label.set_text (_("Rec"));
1720 mute_button_label.set_text (_("Mute"));
1721 if (_route && _route->solo_safe()) {
1722 solo_button_label.set_text (X_("!"));
1723 } else {
1724 if (!Config->get_solo_control_is_listen_control()) {
1725 solo_button_label.set_text (_("Solo"));
1726 } else {
1727 switch (Config->get_listen_position()) {
1728 case AfterFaderListen:
1729 solo_button_label.set_text (_("AFL"));
1730 break;
1731 case PreFaderListen:
1732 solo_button_label.set_text (_("PFL"));
1733 break;
1737 break;
1739 default:
1740 rec_enable_button_label.set_text (_("R"));
1741 mute_button_label.set_text (_("M"));
1742 if (_route && _route->solo_safe()) {
1743 solo_button_label.set_text (X_("!"));
1744 if (!Config->get_solo_control_is_listen_control()) {
1745 solo_button_label.set_text (_("S"));
1746 } else {
1747 switch (Config->get_listen_position()) {
1748 case AfterFaderListen:
1749 solo_button_label.set_text (_("A"));
1750 break;
1751 case PreFaderListen:
1752 solo_button_label.set_text (_("P"));
1753 break;
1757 break;
1762 bool
1763 MixerStrip::on_key_press_event (GdkEventKey* ev)
1765 GdkEventButton fake;
1766 fake.type = GDK_BUTTON_PRESS;
1767 fake.button = 1;
1768 fake.state = ev->state;
1770 switch (ev->keyval) {
1771 case GDK_m:
1772 mute_press (&fake);
1773 return true;
1774 break;
1776 case GDK_s:
1777 solo_press (&fake);
1778 return true;
1779 break;
1781 case GDK_r:
1782 cerr << "Stole that r\n";
1783 rec_enable_press (&fake);
1784 return true;
1785 break;
1787 case GDK_e:
1788 show_sends_press (&fake);
1789 return true;
1790 break;
1792 case GDK_g:
1793 if (ev->state & Keyboard::PrimaryModifier) {
1794 step_gain_down ();
1795 } else {
1796 step_gain_up ();
1798 return true;
1799 break;
1801 case GDK_0:
1802 if (_route) {
1803 _route->set_gain (1.0, this);
1805 return true;
1807 default:
1808 break;
1811 return false;
1815 bool
1816 MixerStrip::on_key_release_event (GdkEventKey* ev)
1818 GdkEventButton fake;
1819 fake.type = GDK_BUTTON_RELEASE;
1820 fake.button = 1;
1821 fake.state = ev->state;
1823 switch (ev->keyval) {
1824 case GDK_m:
1825 mute_release (&fake);
1826 return true;
1827 break;
1829 case GDK_s:
1830 solo_release (&fake);
1831 return true;
1832 break;
1834 case GDK_r:
1835 cerr << "Stole that r\n";
1836 rec_enable_release (&fake);
1837 return true;
1838 break;
1840 case GDK_e:
1841 show_sends_release (&fake);
1842 return true;
1843 break;
1845 case GDK_g:
1846 return true;
1847 break;
1849 default:
1850 break;
1853 return false;
1856 bool
1857 MixerStrip::on_enter_notify_event (GdkEventCrossing*)
1859 Keyboard::magic_widget_grab_focus ();
1860 return false;
1863 bool
1864 MixerStrip::on_leave_notify_event (GdkEventCrossing* ev)
1866 switch (ev->detail) {
1867 case GDK_NOTIFY_INFERIOR:
1868 break;
1869 default:
1870 Keyboard::magic_widget_drop_focus ();
1873 return false;
1876 PluginSelector*
1877 MixerStrip::plugin_selector()
1879 return _mixer.plugin_selector();
1882 void
1883 MixerStrip::hide_things ()
1885 processor_box.hide_things ();