2 Copyright (C) 2002-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.
21 #include <boost/algorithm/string.hpp>
23 #include <gtkmm/stock.h>
25 #include "pbd/memento_command.h"
26 #include "pbd/stacktrace.h"
27 #include "pbd/controllable.h"
28 #include "pbd/enumwriter.h"
30 #include "ardour/dB.h"
31 #include "ardour/route_group.h"
32 #include "ardour/solo_isolate_control.h"
33 #include "ardour/vca.h"
34 #include "ardour/vca_manager.h"
35 #include "ardour/audio_track.h"
36 #include "ardour/audio_port.h"
37 #include "ardour/audioengine.h"
38 #include "ardour/filename_extensions.h"
39 #include "ardour/midi_track.h"
40 #include "ardour/monitor_control.h"
41 #include "ardour/internal_send.h"
42 #include "ardour/panner_shell.h"
43 #include "ardour/profile.h"
44 #include "ardour/phase_control.h"
45 #include "ardour/send.h"
46 #include "ardour/route.h"
47 #include "ardour/session.h"
48 #include "ardour/template_utils.h"
50 #include "gtkmm2ext/gtk_ui.h"
51 #include "gtkmm2ext/doi.h"
52 #include "gtkmm2ext/gtk_ui.h"
53 #include "gtkmm2ext/utils.h"
55 #include "widgets/ardour_button.h"
56 #include "widgets/binding_proxy.h"
57 #include "widgets/prompter.h"
59 #include "ardour_dialog.h"
60 #include "ardour_ui.h"
61 #include "automation_time_axis.h"
63 #include "group_tabs.h"
64 #include "gui_object.h"
65 #include "gui_thread.h"
67 #include "latency_gui.h"
68 #include "mixer_strip.h"
69 #include "plugin_pin_dialog.h"
70 #include "rgb_macros.h"
71 #include "route_time_axis.h"
73 #include "save_template_dialog.h"
75 #include "ui_config.h"
81 using namespace Gtkmm2ext;
82 using namespace ARDOUR;
83 using namespace ARDOUR_UI_UTILS;
84 using namespace ArdourWidgets;
88 uint32_t RouteUI::_max_invert_buttons = 3;
89 PBD::Signal1<void, boost::shared_ptr<Route> > RouteUI::BusSendDisplayChanged;
90 boost::weak_ptr<Route> RouteUI::_showing_sends_to;
91 std::string RouteUI::program_port_prefix;
93 RouteUI::RouteUI (ARDOUR::Session* sess)
94 : monitor_input_button (0)
95 , monitor_disk_button (0)
103 , output_selector (0)
106 if (program_port_prefix.empty()) {
107 // compare to gtk2_ardour/port_group.cc
108 string lpn (PROGRAM_NAME);
109 boost::to_lower (lpn);
110 program_port_prefix = lpn + ":"; // e.g. "ardour:"
121 ARDOUR_UI::instance()->gui_object_state->remove_node (route_state_id());
124 _route.reset (); /* drop reference to route, so that it can be cleaned up */
125 route_connections.drop_connections ();
131 delete comment_window;
132 delete input_selector;
133 delete output_selector;
134 delete monitor_input_button;
135 delete monitor_disk_button;
138 send_blink_connection.disconnect ();
139 rec_blink_connection.disconnect ();
145 self_destruct = true;
151 pre_fader_mute_check = 0;
152 post_fader_mute_check = 0;
153 listen_mute_check = 0;
156 solo_isolated_check = 0;
157 solo_isolated_led = 0;
161 denormal_menu_item = 0;
164 multiple_mute_change = false;
165 multiple_solo_change = false;
166 _i_am_the_modifier = 0;
171 setup_invert_buttons ();
173 mute_button = manage (new ArdourButton);
174 mute_button->set_name ("mute button");
175 UI::instance()->set_tip (mute_button, _("Mute this track"), "");
177 solo_button = manage (new ArdourButton);
178 solo_button->set_name ("solo button");
179 UI::instance()->set_tip (solo_button, _("Mute other (non-soloed) tracks"), "");
180 solo_button->set_no_show_all (true);
182 rec_enable_button = manage (new ArdourButton);
183 rec_enable_button->set_name ("record enable button");
184 rec_enable_button->set_icon (ArdourIcon::RecButton);
185 UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), "");
187 if (UIConfiguration::instance().get_blink_rec_arm()) {
188 rec_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display));
191 show_sends_button = manage (new ArdourButton);
192 show_sends_button->set_name ("send alert button");
193 UI::instance()->set_tip (show_sends_button, _("make mixer strips show sends to this bus"), "");
195 monitor_input_button = new ArdourButton (ArdourButton::default_elements);
196 monitor_input_button->set_name ("monitor button");
197 monitor_input_button->set_text (_("In"));
198 UI::instance()->set_tip (monitor_input_button, _("Monitor input"), "");
199 monitor_input_button->set_no_show_all (true);
201 monitor_disk_button = new ArdourButton (ArdourButton::default_elements);
202 monitor_disk_button->set_name ("monitor button");
203 monitor_disk_button->set_text (_("Disk"));
204 UI::instance()->set_tip (monitor_disk_button, _("Monitor playback"), "");
205 monitor_disk_button->set_no_show_all (true);
207 _session->SoloChanged.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::solo_changed_so_update_mute, this), gui_context());
208 _session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::check_rec_enable_sensitivity, this), gui_context());
209 _session->RecordStateChanged.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::session_rec_enable_changed, this), gui_context());
211 _session->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteUI::parameter_changed, this, _1), gui_context());
212 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteUI::parameter_changed, this, _1), gui_context());
213 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (this, &RouteUI::parameter_changed));
215 rec_enable_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_press), false);
216 rec_enable_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_release), false);
218 show_sends_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_press), false);
219 show_sends_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_release), false);
221 solo_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::solo_press), false);
222 solo_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::solo_release), false);
223 mute_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::mute_press), false);
224 mute_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::mute_release), false);
226 monitor_input_button->set_distinct_led_click (false);
227 monitor_disk_button->set_distinct_led_click (false);
229 monitor_input_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_input_press), false);
230 monitor_input_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_input_release), false);
232 monitor_disk_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_disk_press), false);
233 monitor_disk_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_disk_release), false);
235 BusSendDisplayChanged.connect_same_thread (*this, boost::bind(&RouteUI::bus_send_display_changed, this, _1));
241 route_connections.drop_connections ();
249 _color_picker.reset ();
251 denormal_menu_item = 0;
255 RouteUI::self_delete ()
261 RouteUI::set_route (boost::shared_ptr<Route> rp)
267 if ( !_route->presentation_info().color_set() ) {
268 /* deal with older 4.x color, which was stored in the GUI object state */
270 string p = ARDOUR_UI::instance()->gui_object_state->get_string (route_state_id(), X_("color"));
274 /* old v4.x or earlier session. Use this information */
276 int red, green, blue;
281 /* old color format version was:
283 16bit value for red:16 bit value for green:16 bit value for blue
298 _route->presentation_info().set_color (RGBA_TO_UINT (red, green, blue, 255));
302 if (set_color_from_route()) {
303 set_color (gdk_color_to_rgba (AxisView::unique_random_color ()));
307 rp->DropReferences.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::self_delete, this), gui_context());
310 delete input_selector;
313 delete output_selector;
316 mute_button->set_controllable (_route->mute_control());
317 solo_button->set_controllable (_route->solo_control());
319 _route->active_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_active_changed, this), gui_context());
321 _route->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::comment_changed, this), gui_context());
323 _route->mute_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_mute_display, this), gui_context());
324 _route->solo_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context());
325 _route->solo_safe_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context());
326 _route->solo_isolate_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context());
327 _route->phase_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::polarity_changed, this), gui_context());
328 _route->fan_out.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::fan_out, this, true, true), gui_context());
331 track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteUI::map_frozen, this), gui_context());
332 track_mode_changed();
336 _route->PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_property_changed, this, _1), gui_context());
337 _route->presentation_info().PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_gui_changed, this, _1), gui_context ());
339 _route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::setup_invert_buttons, this), gui_context ());
341 if (_session->writable() && is_track()) {
342 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_route);
344 t->rec_enable_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context());
345 t->rec_safe_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context());
347 rec_enable_button->show();
348 rec_enable_button->set_controllable (t->rec_enable_control());
350 if (is_midi_track()) {
351 midi_track()->StepEditStatusChange.connect (route_connections, invalidator (*this),
352 boost::bind (&RouteUI::step_edit_changed, this, _1), gui_context());
357 /* this will work for busses and tracks, and needs to be called to
358 set up the name entry/name label display.
362 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_route);
363 t->monitoring_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_monitoring_display, this), gui_context());
365 update_monitoring_display ();
368 mute_button->unset_flags (Gtk::CAN_FOCUS);
369 solo_button->unset_flags (Gtk::CAN_FOCUS);
373 if (_route->is_monitor() || _route->is_master()) {
374 solo_button->hide ();
381 setup_invert_buttons ();
382 set_invert_button_state ();
384 boost::shared_ptr<Route> s = _showing_sends_to.lock ();
385 bus_send_display_changed (s);
387 update_mute_display ();
388 update_solo_display ();
390 if (!UIConfiguration::instance().get_blink_rec_arm()) {
391 blink_rec_display(true); // set initial rec-en button state
394 check_rec_enable_sensitivity ();
395 maybe_add_route_print_mgr ();
396 route_color_changed();
397 route_gui_changed (PropertyChange (Properties::selected));
401 RouteUI::polarity_changed ()
407 set_invert_button_state ();
411 RouteUI::mute_press (GdkEventButton* ev)
413 if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) {
417 //if this is a binding action, let the ArdourButton handle it
418 if (BindingProxy::is_bind_action(ev) )
421 multiple_mute_change = false;
423 if (Keyboard::is_context_menu_event (ev)) {
429 mute_menu->popup(0,ev->time);
435 if (Keyboard::is_button2_event (ev)) {
436 // button2-click is "momentary"
438 _mute_release = new SoloMuteRelease (_route->mute_control()->muted ());
441 if (ev->button == 1 || Keyboard::is_button2_event (ev)) {
443 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
445 /* toggle mute on everything (but
446 * exclude the master and monitor)
448 * because we are going to erase
449 * elements of the list we need to work
453 boost::shared_ptr<RouteList> copy (new RouteList);
455 *copy = *_session->get_routes ();
457 for (RouteList::iterator i = copy->begin(); i != copy->end(); ) {
458 if ((*i)->is_master() || (*i)->is_monitor()) {
466 _mute_release->routes = copy;
469 _session->set_controls (route_list_to_control_list (copy, &Stripable::mute_control), _route->muted_by_self() ? 0.0 : 1.0, Controllable::UseGroup);
471 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
473 /* Primary-button1 inverts the implication of
474 the group being active. If the group is
475 active (for mute), then this modifier means
476 "do not apply to mute". If the group is
477 inactive (for mute), then this modifier
478 means "apply to route". This is all
479 accomplished by passing just the actual
480 route, along with the InverseGroup group
483 NOTE: Primary-button2 is MIDI learn.
486 boost::shared_ptr<RouteList> rl;
488 if (ev->button == 1) {
490 rl.reset (new RouteList);
491 rl->push_back (_route);
494 _mute_release->routes = rl;
497 boost::shared_ptr<MuteControl> mc = _route->mute_control();
498 mc->start_touch (_session->audible_frame ());
499 _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), _route->muted_by_self() ? 0.0 : 1.0, Controllable::InverseGroup);
504 /* plain click applies change to this route */
506 boost::shared_ptr<RouteList> rl (new RouteList);
507 rl->push_back (_route);
510 _mute_release->routes = rl;
513 boost::shared_ptr<MuteControl> mc = _route->mute_control();
514 mc->start_touch (_session->audible_frame ());
515 mc->set_value (!_route->muted_by_self(), Controllable::UseGroup);
524 RouteUI::mute_release (GdkEventButton* /*ev*/)
527 _session->set_controls (route_list_to_control_list (_mute_release->routes, &Stripable::mute_control), _mute_release->active, Controllable::UseGroup);
528 delete _mute_release;
532 _route->mute_control()->stop_touch (_session->audible_frame ());
538 RouteUI::edit_output_configuration ()
540 if (output_selector == 0) {
542 boost::shared_ptr<Send> send;
543 boost::shared_ptr<IO> output;
545 if ((send = boost::dynamic_pointer_cast<Send>(_current_delivery)) != 0) {
546 if (!boost::dynamic_pointer_cast<InternalSend>(send)) {
547 output = send->output();
549 output = _route->output ();
552 output = _route->output ();
555 output_selector = new IOSelectorWindow (_session, output);
558 if (output_selector->is_visible()) {
559 output_selector->get_toplevel()->get_window()->raise();
561 output_selector->present ();
564 //output_selector->set_keep_above (true);
568 RouteUI::edit_input_configuration ()
570 if (input_selector == 0) {
571 input_selector = new IOSelectorWindow (_session, _route->input());
574 if (input_selector->is_visible()) {
575 input_selector->get_toplevel()->get_window()->raise();
577 input_selector->present ();
580 //input_selector->set_keep_above (true);
584 RouteUI::solo_press(GdkEventButton* ev)
586 /* ignore double/triple clicks */
588 if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) {
592 //if this is a binding action, let the ArdourButton handle it
593 if (BindingProxy::is_bind_action(ev) )
596 multiple_solo_change = false;
598 if (Keyboard::is_context_menu_event (ev)) {
600 if (! (solo_isolated_led && solo_isolated_led->is_visible()) ||
601 ! (solo_safe_led && solo_safe_led->is_visible())) {
603 if (solo_menu == 0) {
607 solo_menu->popup (1, ev->time);
612 if (Keyboard::is_button2_event (ev)) {
614 // button2-click is "momentary"
615 _solo_release = new SoloMuteRelease (_route->self_soloed());
618 if (ev->button == 1 || Keyboard::is_button2_event (ev)) {
620 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
622 /* Primary-Tertiary-click applies change to all routes */
625 _solo_release->routes = _session->get_routes ();
628 _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_control), !_route->solo_control()->get_value(), Controllable::UseGroup);
630 } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) {
632 /* Primary-Secondary-click: exclusively solo this track */
635 _solo_release->exclusive = true;
637 _solo_release->routes_on.reset (new RouteList);
638 _solo_release->routes_off.reset (new RouteList);
640 boost::shared_ptr<RouteList> routes = _session->get_routes();
641 for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
643 if ((0 == _route->mixbus()) != (0 == (*i)->mixbus ())) {
647 if ((*i)->soloed ()) {
648 _solo_release->routes_on->push_back (*i);
650 _solo_release->routes_off->push_back (*i);
655 boost::shared_ptr<RouteList> rl (new RouteList);
656 boost::shared_ptr<RouteList> routes = _session->get_routes();
657 for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
659 if ((0 == _route->mixbus()) != (0 == (*i)->mixbus ())) {
663 if ((*i)->soloed ()) {
667 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), false, Controllable::UseGroup);
669 if (Config->get_solo_control_is_listen_control()) {
670 /* ??? we need a just_one_listen() method */
673 _route->solo_control()->set_value (1.0, Controllable::NoGroup);
676 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
678 // shift-click: toggle solo isolated status
680 _route->solo_isolate_control()->set_value (_route->solo_isolate_control()->get_value() ? 0.0 : 1.0, Controllable::UseGroup);
681 delete _solo_release;
684 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
686 /* Primary-button1: solo mix group.
687 NOTE: Primary-button2 is MIDI learn.
690 /* Primary-button1 applies change to the mix group even if it is not active
691 NOTE: Primary-button2 is MIDI learn.
694 boost::shared_ptr<RouteList> rl;
696 if (ev->button == 1) {
698 /* Primary-button1 inverts the implication of
699 the group being active. If the group is
700 active (for solo), then this modifier means
701 "do not apply to solo". If the group is
702 inactive (for mute), then this modifier
703 means "apply to route". This is all
704 accomplished by passing just the actual
705 route, along with the InverseGroup group
708 NOTE: Primary-button2 is MIDI learn.
711 rl.reset (new RouteList);
712 rl->push_back (_route);
715 _solo_release->routes = rl;
718 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), !_route->self_soloed(), Controllable::InverseGroup);
721 delete _solo_release;
726 /* click: solo this route */
728 boost::shared_ptr<RouteList> rl (new RouteList);
729 rl->push_back (route());
732 _solo_release->routes = rl;
735 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), !_route->self_soloed(), Controllable::UseGroup);
744 RouteUI::solo_release (GdkEventButton* /*ev*/)
747 if (_solo_release->exclusive) {
748 _session->set_controls (route_list_to_control_list (_solo_release->routes_off, &Stripable::solo_control), 0.0, Controllable::NoGroup);
749 _session->set_controls (route_list_to_control_list (_solo_release->routes_on, &Stripable::solo_control), 1.0, Controllable::NoGroup);
751 _session->set_controls (route_list_to_control_list (_solo_release->routes, &Stripable::solo_control), _solo_release->active ? 1.0 : 0.0, Controllable::UseGroup);
754 delete _solo_release;
762 RouteUI::rec_enable_press(GdkEventButton* ev)
764 if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) {
768 //if this is a binding action, let the ArdourButton handle it
769 if (BindingProxy::is_bind_action(ev) )
772 if (!_session->engine().connected()) {
773 MessageDialog msg (_("Not connected to AudioEngine - cannot engage record"));
778 if (is_midi_track()) {
780 /* rec-enable button exits from step editing */
782 if (midi_track()->step_editing()) {
783 midi_track()->set_step_editing (false);
788 if (is_track() && rec_enable_button) {
790 if (Keyboard::is_button2_event (ev)) {
792 //rec arm does not have a momentary mode
795 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
797 _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::rec_enable_control), !track()->rec_enable_control()->get_value(), Controllable::NoGroup);
799 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
801 /* Primary-button1 applies change to the route group (even if it is not active)
802 NOTE: Primary-button2 is MIDI learn.
805 if (ev->button == 1) {
807 boost::shared_ptr<RouteList> rl;
809 rl.reset (new RouteList);
810 rl->push_back (_route);
812 _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !track()->rec_enable_control()->get_value(), Controllable::InverseGroup);
815 } else if (Keyboard::is_context_menu_event (ev)) {
817 /* do this on release */
821 boost::shared_ptr<Track> trk = track();
822 trk->rec_enable_control()->set_value (!trk->rec_enable_control()->get_value(), Controllable::UseGroup);
830 RouteUI::update_monitoring_display ()
836 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_route);
842 MonitorState ms = t->monitoring_state();
844 if (t->monitoring_control()->monitoring_choice() & MonitorInput) {
845 monitor_input_button->set_active_state (Gtkmm2ext::ExplicitActive);
847 if (ms & MonitoringInput) {
848 monitor_input_button->set_active_state (Gtkmm2ext::ImplicitActive);
850 monitor_input_button->unset_active_state ();
854 if (t->monitoring_control()->monitoring_choice() & MonitorDisk) {
855 monitor_disk_button->set_active_state (Gtkmm2ext::ExplicitActive);
857 if (ms & MonitoringDisk) {
858 monitor_disk_button->set_active_state (Gtkmm2ext::ImplicitActive);
860 monitor_disk_button->unset_active_state ();
866 RouteUI::monitor_input_press(GdkEventButton*)
872 RouteUI::monitor_input_release(GdkEventButton* ev)
874 return monitor_release (ev, MonitorInput);
878 RouteUI::monitor_disk_press (GdkEventButton*)
884 RouteUI::monitor_disk_release (GdkEventButton* ev)
886 return monitor_release (ev, MonitorDisk);
890 RouteUI::monitor_release (GdkEventButton* ev, MonitorChoice monitor_choice)
892 if (ev->button != 1) {
896 boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(_route);
903 boost::shared_ptr<RouteList> rl;
905 /* XXX for now, monitoring choices are orthogonal. cue monitoring
906 will follow in 3.X but requires mixing the input and playback (disk)
907 signal together, which requires yet more buffers.
910 if (t->monitoring_control()->monitoring_choice() & monitor_choice) {
911 mc = MonitorChoice (t->monitoring_control()->monitoring_choice() & ~monitor_choice);
913 /* this line will change when the options are non-orthogonal */
914 // mc = MonitorChoice (t->monitoring_choice() | monitor_choice);
918 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
919 /* Primary-Tertiary-click applies change to all routes */
920 rl = _session->get_routes ();
921 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::NoGroup);
922 } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
923 /* Primary-click overrides group */
924 rl.reset (new RouteList);
925 rl->push_back (route());
926 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::InverseGroup);
928 rl.reset (new RouteList);
929 rl->push_back (route());
930 _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::UseGroup);
937 RouteUI::build_record_menu ()
940 record_menu = new Menu;
941 record_menu->set_name ("ArdourContextMenu");
942 using namespace Menu_Helpers;
943 MenuList& items = record_menu->items();
945 items.push_back (CheckMenuElem (_("Rec-Safe"), sigc::mem_fun (*this, &RouteUI::toggle_rec_safe)));
946 rec_safe_item = dynamic_cast<Gtk::CheckMenuItem*> (&items.back());
948 if (is_midi_track()) {
949 items.push_back (SeparatorElem());
950 items.push_back (CheckMenuElem (_("Step Entry"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit)));
951 step_edit_item = dynamic_cast<Gtk::CheckMenuItem*> (&items.back());
955 if (step_edit_item) {
956 if (track()->rec_enable_control()->get_value()) {
957 step_edit_item->set_sensitive (false);
959 step_edit_item->set_active (midi_track()->step_editing());
962 rec_safe_item->set_sensitive (!_route->rec_enable_control()->get_value());
963 rec_safe_item->set_active (_route->rec_safe_control()->get_value());
968 RouteUI::toggle_step_edit ()
970 if (!is_midi_track() || track()->rec_enable_control()->get_value()) {
974 midi_track()->set_step_editing (step_edit_item->get_active());
978 RouteUI::toggle_rec_safe ()
980 boost::shared_ptr<AutomationControl> rs = _route->rec_safe_control();
986 /* This check is made inside the control too, but dong it here can't
990 if (_route->rec_enable_control()->get_value()) {
994 rs->set_value (rec_safe_item->get_active (), Controllable::UseGroup);
998 RouteUI::step_edit_changed (bool yn)
1001 if (rec_enable_button) {
1002 rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive);
1005 start_step_editing ();
1007 if (step_edit_item) {
1008 step_edit_item->set_active (true);
1013 if (rec_enable_button) {
1014 rec_enable_button->unset_active_state ();
1017 stop_step_editing ();
1019 if (step_edit_item) {
1020 step_edit_item->set_active (false);
1026 RouteUI::rec_enable_release (GdkEventButton* ev)
1028 if (Keyboard::is_context_menu_event (ev)) {
1029 build_record_menu ();
1031 record_menu->popup (1, ev->time);
1040 RouteUI::build_sends_menu ()
1042 using namespace Menu_Helpers;
1044 sends_menu = new Menu;
1045 sends_menu->set_name ("ArdourContextMenu");
1046 MenuList& items = sends_menu->items();
1049 MenuElem(_("Assign all tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, false))
1053 MenuElem(_("Assign all tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true))
1057 MenuElem(_("Assign all tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, false))
1061 MenuElem(_("Assign all tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, true))
1065 MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, false))
1069 MenuElem(_("Assign selected tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, true)));
1072 MenuElem(_("Assign selected tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, false))
1076 MenuElem(_("Assign selected tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, true))
1079 items.push_back (MenuElem(_("Copy track/bus gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track)));
1080 items.push_back (MenuElem(_("Set sends gain to -inf"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_zero)));
1081 items.push_back (MenuElem(_("Set sends gain to 0dB"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_unity)));
1086 RouteUI::create_sends (Placement p, bool include_buses)
1088 _session->globally_add_internal_sends (_route, p, include_buses);
1092 RouteUI::create_selected_sends (Placement p, bool include_buses)
1094 boost::shared_ptr<RouteList> rlist (new RouteList);
1095 TrackSelection& selected_tracks (ARDOUR_UI::instance()->the_editor().get_selection().tracks);
1097 for (TrackSelection::iterator i = selected_tracks.begin(); i != selected_tracks.end(); ++i) {
1098 RouteTimeAxisView* rtv;
1100 if ((rtv = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
1101 if ((rui = dynamic_cast<RouteUI*>(rtv)) != 0) {
1102 if (include_buses || boost::dynamic_pointer_cast<AudioTrack>(rui->route())) {
1103 rlist->push_back (rui->route());
1109 _session->add_internal_sends (_route, p, rlist);
1113 RouteUI::set_sends_gain_from_track ()
1115 _session->globally_set_send_gains_from_track (_route);
1119 RouteUI::set_sends_gain_to_zero ()
1121 _session->globally_set_send_gains_to_zero (_route);
1125 RouteUI::set_sends_gain_to_unity ()
1127 _session->globally_set_send_gains_to_unity (_route);
1131 RouteUI::show_sends_press(GdkEventButton* ev)
1133 if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) {
1137 if (!is_track() && show_sends_button) {
1139 if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) {
1141 // do nothing on midi sigc::bind event
1144 } else if (Keyboard::is_context_menu_event (ev)) {
1146 if (sends_menu == 0) {
1147 build_sends_menu ();
1150 sends_menu->popup (0, ev->time);
1154 boost::shared_ptr<Route> s = _showing_sends_to.lock ();
1157 set_showing_sends_to (boost::shared_ptr<Route> ());
1159 set_showing_sends_to (_route);
1168 RouteUI::show_sends_release (GdkEventButton*)
1174 RouteUI::send_blink (bool onoff)
1176 if (!show_sends_button) {
1181 show_sends_button->set_active_state (Gtkmm2ext::ExplicitActive);
1183 show_sends_button->unset_active_state ();
1187 Gtkmm2ext::ActiveState
1188 RouteUI::solo_active_state (boost::shared_ptr<Stripable> s)
1190 boost::shared_ptr<SoloControl> sc = s->solo_control();
1193 return Gtkmm2ext::Off;
1196 if (!sc->can_solo()) {
1197 return Gtkmm2ext::Off;
1201 if (sc->self_soloed()) {
1202 return Gtkmm2ext::ExplicitActive;
1203 } else if (sc->soloed_by_others()) {
1204 return Gtkmm2ext::ImplicitActive;
1206 return Gtkmm2ext::Off;
1210 Gtkmm2ext::ActiveState
1211 RouteUI::solo_isolate_active_state (boost::shared_ptr<Stripable> s)
1213 boost::shared_ptr<SoloIsolateControl> sc = s->solo_isolate_control();
1216 return Gtkmm2ext::Off;
1219 if (s->is_master() || s->is_monitor()) {
1220 return Gtkmm2ext::Off;
1223 if (sc->solo_isolated()) {
1224 return Gtkmm2ext::ExplicitActive;
1226 return Gtkmm2ext::Off;
1230 Gtkmm2ext::ActiveState
1231 RouteUI::solo_safe_active_state (boost::shared_ptr<Stripable> s)
1233 boost::shared_ptr<SoloSafeControl> sc = s->solo_safe_control();
1236 return Gtkmm2ext::Off;
1239 if (s->is_master() || s->is_monitor()) {
1240 return Gtkmm2ext::Off;
1243 if (sc->solo_safe()) {
1244 return Gtkmm2ext::ExplicitActive;
1246 return Gtkmm2ext::Off;
1251 RouteUI::update_solo_display ()
1253 bool yn = _route->solo_safe_control()->solo_safe ();
1255 if (solo_safe_check && solo_safe_check->get_active() != yn) {
1256 solo_safe_check->set_active (yn);
1259 yn = _route->solo_isolate_control()->solo_isolated ();
1261 if (solo_isolated_check && solo_isolated_check->get_active() != yn) {
1262 solo_isolated_check->set_active (yn);
1265 set_button_names ();
1267 if (solo_isolated_led) {
1268 if (_route->solo_isolate_control()->solo_isolated()) {
1269 solo_isolated_led->set_active_state (Gtkmm2ext::ExplicitActive);
1271 solo_isolated_led->unset_active_state ();
1275 if (solo_safe_led) {
1276 if (_route->solo_safe_control()->solo_safe()) {
1277 solo_safe_led->set_active_state (Gtkmm2ext::ExplicitActive);
1279 solo_safe_led->unset_active_state ();
1283 solo_button->set_active_state (solo_active_state (_route));
1285 /* some changes to solo status can affect mute display, so catch up
1288 update_mute_display ();
1292 RouteUI::solo_changed_so_update_mute ()
1294 update_mute_display ();
1298 RouteUI::mute_active_state (Session*, boost::shared_ptr<Stripable> s)
1300 boost::shared_ptr<MuteControl> mc = s->mute_control();
1302 if (s->is_monitor()) {
1303 return Gtkmm2ext::Off;
1307 return Gtkmm2ext::Off;
1310 if (Config->get_show_solo_mutes() && !Config->get_solo_control_is_listen_control ()) {
1312 if (mc->muted_by_self ()) {
1314 return Gtkmm2ext::ExplicitActive;
1315 } else if (mc->muted_by_others_soloing () || mc->muted_by_masters ()) {
1316 /* this will reflect both solo mutes AND master mutes */
1317 return Gtkmm2ext::ImplicitActive;
1319 /* no mute at all */
1320 return Gtkmm2ext::Off;
1325 if (mc->muted_by_self()) {
1327 return Gtkmm2ext::ExplicitActive;
1328 } else if (mc->muted_by_masters ()) {
1329 /* this shows only master mutes, not mute-by-others-soloing */
1330 return Gtkmm2ext::ImplicitActive;
1332 /* no mute at all */
1333 return Gtkmm2ext::Off;
1337 return ActiveState(0);
1341 RouteUI::update_mute_display ()
1347 mute_button->set_active_state (mute_active_state (_session, _route));
1352 RouteUI::route_rec_enable_changed ()
1354 blink_rec_display (true); //this lets the button change "immediately" rather than wait for the next blink
1358 RouteUI::session_rec_enable_changed ()
1360 blink_rec_display (true); //this lets the button change "immediately" rather than wait for the next blink
1364 RouteUI::blink_rec_display (bool blinkOn)
1366 if (!rec_enable_button || !_route) {
1370 if (boost::dynamic_pointer_cast<Send>(_current_delivery)) {
1378 if (track()->rec_enable_control()->get_value()) {
1379 switch (_session->record_status ()) {
1380 case Session::Recording:
1381 rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive);
1384 case Session::Disabled:
1385 case Session::Enabled:
1386 if (UIConfiguration::instance().get_blink_rec_arm()) {
1387 rec_enable_button->set_active_state ( blinkOn ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off );
1389 rec_enable_button->set_active_state ( ImplicitActive );
1394 if (step_edit_item) {
1395 step_edit_item->set_sensitive (false);
1399 rec_enable_button->unset_active_state ();
1401 if (step_edit_item) {
1402 step_edit_item->set_sensitive (true);
1406 check_rec_enable_sensitivity ();
1410 RouteUI::build_solo_menu (void)
1412 using namespace Menu_Helpers;
1414 solo_menu = new Menu;
1415 solo_menu->set_name ("ArdourContextMenu");
1416 MenuList& items = solo_menu->items();
1417 Gtk::CheckMenuItem* check;
1419 check = new Gtk::CheckMenuItem(_("Solo Isolate"));
1420 check->set_active (_route->solo_isolate_control()->solo_isolated());
1421 check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_isolated), check));
1422 items.push_back (CheckMenuElem(*check));
1423 solo_isolated_check = dynamic_cast<Gtk::CheckMenuItem*>(&items.back());
1426 check = new Gtk::CheckMenuItem(_("Solo Safe"));
1427 check->set_active (_route->solo_safe_control()->solo_safe());
1428 check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_safe), check));
1429 items.push_back (CheckMenuElem(*check));
1430 solo_safe_check = dynamic_cast<Gtk::CheckMenuItem*>(&items.back());
1435 RouteUI::build_mute_menu(void)
1437 using namespace Menu_Helpers;
1439 mute_menu = new Menu;
1440 mute_menu->set_name ("ArdourContextMenu");
1442 MenuList& items = mute_menu->items();
1444 pre_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Pre Fader Sends")));
1445 init_mute_menu(MuteMaster::PreFader, pre_fader_mute_check);
1446 pre_fader_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::PreFader, pre_fader_mute_check));
1447 items.push_back (CheckMenuElem(*pre_fader_mute_check));
1448 pre_fader_mute_check->show_all();
1450 post_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Post Fader Sends")));
1451 init_mute_menu(MuteMaster::PostFader, post_fader_mute_check);
1452 post_fader_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::PostFader, post_fader_mute_check));
1453 items.push_back (CheckMenuElem(*post_fader_mute_check));
1454 post_fader_mute_check->show_all();
1456 listen_mute_check = manage (new Gtk::CheckMenuItem(_("Control Outs")));
1457 init_mute_menu(MuteMaster::Listen, listen_mute_check);
1458 listen_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::Listen, listen_mute_check));
1459 items.push_back (CheckMenuElem(*listen_mute_check));
1460 listen_mute_check->show_all();
1462 main_mute_check = manage (new Gtk::CheckMenuItem(_("Main Outs")));
1463 init_mute_menu(MuteMaster::Main, main_mute_check);
1464 main_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::Main, main_mute_check));
1465 items.push_back (CheckMenuElem(*main_mute_check));
1466 main_mute_check->show_all();
1468 _route->mute_points_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::muting_change, this), gui_context());
1472 RouteUI::init_mute_menu(MuteMaster::MutePoint mp, Gtk::CheckMenuItem* check)
1474 check->set_active (_route->mute_control()->mute_points() & mp);
1478 RouteUI::toggle_mute_menu(MuteMaster::MutePoint mp, Gtk::CheckMenuItem* check)
1480 if (check->get_active()) {
1481 _route->mute_control()->set_mute_points (MuteMaster::MutePoint (_route->mute_control()->mute_points() | mp));
1483 _route->mute_control()->set_mute_points (MuteMaster::MutePoint (_route->mute_control()->mute_points() & ~mp));
1488 RouteUI::muting_change ()
1490 ENSURE_GUI_THREAD (*this, &RouteUI::muting_change)
1493 MuteMaster::MutePoint current = _route->mute_control()->mute_points ();
1495 yn = (current & MuteMaster::PreFader);
1497 if (pre_fader_mute_check->get_active() != yn) {
1498 pre_fader_mute_check->set_active (yn);
1501 yn = (current & MuteMaster::PostFader);
1503 if (post_fader_mute_check->get_active() != yn) {
1504 post_fader_mute_check->set_active (yn);
1507 yn = (current & MuteMaster::Listen);
1509 if (listen_mute_check->get_active() != yn) {
1510 listen_mute_check->set_active (yn);
1513 yn = (current & MuteMaster::Main);
1515 if (main_mute_check->get_active() != yn) {
1516 main_mute_check->set_active (yn);
1521 RouteUI::solo_isolate_button_release (GdkEventButton* ev)
1523 if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) {
1527 bool view = solo_isolated_led->active_state();
1528 bool model = _route->solo_isolate_control()->solo_isolated();
1530 /* called BEFORE the view has changed */
1532 if (ev->button == 1) {
1533 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
1536 /* disable isolate for all routes */
1537 _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_isolate_control), 0.0, Controllable::NoGroup);
1539 /* enable isolate for all routes */
1540 _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_isolate_control), 1.0, Controllable::NoGroup);
1545 if (model == view) {
1547 /* flip just this route */
1549 boost::shared_ptr<RouteList> rl (new RouteList);
1550 rl->push_back (_route);
1551 _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_isolate_control), view ? 0.0 : 1.0, Controllable::NoGroup);
1560 RouteUI::solo_safe_button_release (GdkEventButton* ev)
1562 if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) {
1566 bool view = solo_safe_led->active_state();
1567 bool model = _route->solo_safe_control()->solo_safe();
1569 if (ev->button == 1) {
1570 if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) {
1571 boost::shared_ptr<RouteList> rl (_session->get_routes());
1573 /* disable solo safe for all routes */
1574 DisplaySuspender ds;
1575 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
1576 (*i)->solo_safe_control()->set_value (0.0, Controllable::NoGroup);
1579 /* enable solo safe for all routes */
1580 DisplaySuspender ds;
1581 for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
1582 (*i)->solo_safe_control()->set_value (1.0, Controllable::NoGroup);
1587 if (model == view) {
1588 /* flip just this route */
1589 _route->solo_safe_control()->set_value (view ? 0.0 : 1.0, Controllable::NoGroup);
1598 RouteUI::toggle_solo_isolated (Gtk::CheckMenuItem* check)
1600 bool view = check->get_active();
1601 bool model = _route->solo_isolate_control()->solo_isolated();
1603 /* called AFTER the view has changed */
1605 if (model != view) {
1606 _route->solo_isolate_control()->set_value (view ? 1.0 : 0.0, Controllable::UseGroup);
1611 RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check)
1613 _route->solo_safe_control()->set_value (check->get_active() ? 1.0 : 0.0, Controllable::UseGroup);
1616 /** Ask the user to choose a colour, and then apply that color to my route */
1618 RouteUI::choose_color ()
1620 _color_picker.popup (_route);
1623 /** Set the route's own color. This may not be used for display if
1624 * the route is in a group which shares its color with its routes.
1627 RouteUI::set_color (uint32_t c)
1629 _route->presentation_info().set_color (c);
1632 /** @return GUI state ID for things that are common to the route in all its representations */
1634 RouteUI::route_state_id () const
1636 return string_compose (X_("route %1"), _route->id().to_s());
1640 RouteUI::set_color_from_route ()
1642 if (_route->presentation_info().color_set()) {
1643 return 0; /* nothing to do */
1646 return 1; /* pick a color */
1649 /** @return true if this name should be used for the route, otherwise false */
1651 RouteUI::verify_new_route_name (const std::string& name)
1653 if (name.find (':') == string::npos) {
1657 MessageDialog colon_msg (
1658 _("The use of colons (':') is discouraged in track and bus names.\nDo you want to use this new name?"),
1659 false, MESSAGE_QUESTION, BUTTONS_NONE
1662 colon_msg.add_button (_("Use the new name"), Gtk::RESPONSE_ACCEPT);
1663 colon_msg.add_button (_("Re-edit the name"), Gtk::RESPONSE_CANCEL);
1665 return (colon_msg.run () == Gtk::RESPONSE_ACCEPT);
1669 RouteUI::route_rename ()
1671 ArdourWidgets::Prompter name_prompter (true);
1676 name_prompter.set_title (_("Rename Track"));
1678 name_prompter.set_title (_("Rename Bus"));
1680 name_prompter.set_prompt (_("New name:"));
1681 name_prompter.set_initial_text (_route->name());
1682 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
1683 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
1684 name_prompter.show_all ();
1687 switch (name_prompter.run ()) {
1688 case Gtk::RESPONSE_ACCEPT:
1689 name_prompter.get_result (result);
1690 name_prompter.hide ();
1691 if (result.length()) {
1692 if (verify_new_route_name (result)) {
1693 _route->set_name (result);
1696 /* back to name prompter */
1700 /* nothing entered, just get out of here */
1715 RouteUI::toggle_comment_editor ()
1717 // if (ignore_toggle) {
1721 if (comment_window && comment_window->is_visible ()) {
1722 comment_window->hide ();
1724 open_comment_editor ();
1730 RouteUI::open_comment_editor ()
1732 if (comment_window == 0) {
1733 setup_comment_editor ();
1737 title = _route->name();
1738 title += _(": comment editor");
1740 comment_window->set_title (title);
1741 comment_window->present();
1745 RouteUI::setup_comment_editor ()
1747 comment_window = new ArdourWindow (""); // title will be reset to show route
1748 comment_window->set_skip_taskbar_hint (true);
1749 comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing));
1750 comment_window->set_default_size (400, 200);
1752 comment_area = manage (new TextView());
1753 comment_area->set_name ("MixerTrackCommentArea");
1754 comment_area->set_wrap_mode (WRAP_WORD);
1755 comment_area->set_editable (true);
1756 comment_area->get_buffer()->set_text (_route->comment());
1757 comment_area->show ();
1759 comment_window->add (*comment_area);
1763 RouteUI::comment_changed ()
1765 ignore_comment_edit = true;
1767 comment_area->get_buffer()->set_text (_route->comment());
1769 ignore_comment_edit = false;
1773 RouteUI::comment_editor_done_editing ()
1775 ENSURE_GUI_THREAD (*this, &MixerStrip::comment_editor_done_editing, src)
1777 string const str = comment_area->get_buffer()->get_text();
1778 if (str == _route->comment ()) {
1782 _route->set_comment (str, this);
1786 RouteUI::set_route_active (bool a, bool apply_to_selection)
1788 if (apply_to_selection) {
1789 ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteTimeAxisView::set_route_active, _1, a, false));
1791 _route->set_active (a, this);
1796 RouteUI::duplicate_selected_routes ()
1798 ARDOUR_UI::instance()->start_duplicate_routes();
1802 RouteUI::toggle_denormal_protection ()
1804 if (denormal_menu_item) {
1808 ENSURE_GUI_THREAD (*this, &RouteUI::toggle_denormal_protection)
1810 if ((x = denormal_menu_item->get_active()) != _route->denormal_protection()) {
1811 _route->set_denormal_protection (x);
1817 RouteUI::denormal_protection_changed ()
1819 if (denormal_menu_item) {
1820 denormal_menu_item->set_active (_route->denormal_protection());
1825 RouteUI::disconnect_input ()
1827 _route->input()->disconnect (this);
1831 RouteUI::disconnect_output ()
1833 _route->output()->disconnect (this);
1837 RouteUI::is_track () const
1839 return boost::dynamic_pointer_cast<Track>(_route) != 0;
1842 boost::shared_ptr<Track>
1843 RouteUI::track() const
1845 return boost::dynamic_pointer_cast<Track>(_route);
1849 RouteUI::is_audio_track () const
1851 return boost::dynamic_pointer_cast<AudioTrack>(_route) != 0;
1854 boost::shared_ptr<AudioTrack>
1855 RouteUI::audio_track() const
1857 return boost::dynamic_pointer_cast<AudioTrack>(_route);
1861 RouteUI::is_midi_track () const
1863 return boost::dynamic_pointer_cast<MidiTrack>(_route) != 0;
1866 boost::shared_ptr<MidiTrack>
1867 RouteUI::midi_track() const
1869 return boost::dynamic_pointer_cast<MidiTrack>(_route);
1873 RouteUI::has_audio_outputs () const
1875 return (_route->n_outputs().n_audio() > 0);
1879 RouteUI::map_frozen ()
1881 ENSURE_GUI_THREAD (*this, &RouteUI::map_frozen)
1883 AudioTrack* at = dynamic_cast<AudioTrack*>(_route.get());
1886 check_rec_enable_sensitivity ();
1891 RouteUI::adjust_latency ()
1893 LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle());
1898 RouteUI::save_as_template_dialog_response (int response, SaveTemplateDialog* d)
1900 if (response == RESPONSE_ACCEPT) {
1901 const string name = d->get_template_name ();
1902 const string desc = d->get_description ();
1903 const string path = Glib::build_filename(ARDOUR::user_route_template_directory (), name + ARDOUR::template_suffix);
1905 if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { /* file already exists. */
1906 bool overwrite = overwrite_file_dialog (*d,
1907 _("Confirm Template Overwrite"),
1908 _("A template already exists with that name. Do you want to overwrite it?"));
1915 _route->save_as_template (path, name, desc);
1922 RouteUI::save_as_template ()
1924 const std::string dir = ARDOUR::user_route_template_directory ();
1926 if (g_mkdir_with_parents (dir.c_str(), 0755)) {
1927 error << string_compose (_("Cannot create route template directory %1"), dir) << endmsg;
1931 SaveTemplateDialog* d = new SaveTemplateDialog (_route->name(), _route->comment());
1932 d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::save_as_template_dialog_response), d));
1937 RouteUI::check_rec_enable_sensitivity ()
1939 if (!rec_enable_button) {
1940 assert (0); // This should not happen
1943 if (!_session->writable()) {
1944 rec_enable_button->set_sensitive (false);
1948 if (_session->transport_rolling() && rec_enable_button->active_state() && Config->get_disable_disarm_during_roll()) {
1949 rec_enable_button->set_sensitive (false);
1950 } else if (is_audio_track () && track()->freeze_state() == AudioTrack::Frozen) {
1951 rec_enable_button->set_sensitive (false);
1953 rec_enable_button->set_sensitive (true);
1955 if (_route && _route->rec_safe_control () && _route->rec_safe_control()->get_value()) {
1956 rec_enable_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() | Gtkmm2ext::Insensitive));
1958 rec_enable_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() & ~Gtkmm2ext::Insensitive));
1960 update_monitoring_display ();
1964 RouteUI::parameter_changed (string const & p)
1966 /* this handles RC and per-session parameter changes */
1968 if (p == "disable-disarm-during-roll") {
1969 check_rec_enable_sensitivity ();
1970 } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
1971 set_button_names ();
1972 } else if (p == "session-monitoring") {
1973 update_monitoring_display ();
1974 } else if (p == "auto-input") {
1975 update_monitoring_display ();
1976 } else if (p == "blink-rec-arm") {
1977 if (UIConfiguration::instance().get_blink_rec_arm()) {
1978 rec_blink_connection.disconnect ();
1979 rec_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display));
1981 rec_blink_connection.disconnect ();
1982 RouteUI::blink_rec_display(false);
1988 RouteUI::setup_invert_buttons ()
1990 /* remove old invert buttons */
1991 for (vector<ArdourButton*>::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i) {
1992 _invert_button_box.remove (**i);
1995 _invert_buttons.clear ();
1997 if (!_route || !_route->input()) {
2001 uint32_t const N = _route->input()->n_ports().n_audio ();
2003 uint32_t const to_add = (N <= _max_invert_buttons) ? N : 1;
2005 for (uint32_t i = 0; i < to_add; ++i) {
2006 ArdourButton* b = manage (new ArdourButton);
2007 b->signal_button_press_event().connect (sigc::mem_fun (*this, &RouteUI::invert_press), false);
2008 b->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_release), i), false);
2010 b->set_name (X_("invert button"));
2013 b->set_text (string_compose (X_("Ø (%1)"), N));
2015 b->set_text (X_("Ø"));
2018 b->set_text (string_compose (X_("Ø%1"), i + 1));
2021 if (N <= _max_invert_buttons) {
2022 UI::instance()->set_tip (*b, string_compose (_("Left-click to invert polarity of channel %1 of this track. Right-click to show menu."), i + 1));
2024 UI::instance()->set_tip (*b, _("Click to show a menu of channels to invert polarity"));
2027 _invert_buttons.push_back (b);
2028 _invert_button_box.pack_start (*b);
2031 _invert_button_box.set_spacing (1);
2032 _invert_button_box.show_all ();
2036 RouteUI::set_invert_button_state ()
2038 uint32_t const N = _route->input()->n_ports().n_audio();
2039 if (N > _max_invert_buttons) {
2041 /* One button for many channels; explicit active if all channels are inverted,
2042 implicit active if some are, off if none are.
2045 ArdourButton* b = _invert_buttons.front ();
2047 if (_route->phase_control()->count() == _route->phase_control()->size()) {
2048 b->set_active_state (Gtkmm2ext::ExplicitActive);
2049 } else if (_route->phase_control()->any()) {
2050 b->set_active_state (Gtkmm2ext::ImplicitActive);
2052 b->set_active_state (Gtkmm2ext::Off);
2057 /* One button per channel; just set active */
2060 for (vector<ArdourButton*>::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i, ++j) {
2061 (*i)->set_active (_route->phase_control()->inverted (j));
2068 RouteUI::invert_release (GdkEventButton* ev, uint32_t i)
2070 if (ev->button == 1 && i < _invert_buttons.size()) {
2071 uint32_t const N = _route->input()->n_ports().n_audio ();
2072 if (N <= _max_invert_buttons) {
2073 /* left-click inverts phase so long as we have a button per channel */
2074 _route->phase_control()->set_phase_invert (i, !_invert_buttons[i]->get_active());
2083 RouteUI::invert_press (GdkEventButton* ev)
2085 using namespace Menu_Helpers;
2087 uint32_t const N = _route->input()->n_ports().n_audio();
2088 if (N <= _max_invert_buttons && ev->button != 3) {
2089 /* If we have an invert button per channel, we only pop
2090 up a menu on right-click; left click is handled
2096 delete _invert_menu;
2097 _invert_menu = new Menu;
2098 _invert_menu->set_name ("ArdourContextMenu");
2099 MenuList& items = _invert_menu->items ();
2101 for (uint32_t i = 0; i < N; ++i) {
2102 items.push_back (CheckMenuElem (string_compose (X_("Ø%1"), i + 1), sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_menu_toggled), i)));
2103 Gtk::CheckMenuItem* e = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
2104 ++_i_am_the_modifier;
2105 e->set_active (_route->phase_control()->inverted (i));
2106 --_i_am_the_modifier;
2109 _invert_menu->popup (0, ev->time);
2115 RouteUI::invert_menu_toggled (uint32_t c)
2117 if (_i_am_the_modifier) {
2122 _route->phase_control()->set_phase_invert (c, !_route->phase_control()->inverted (c));
2126 RouteUI::set_invert_sensitive (bool yn)
2128 for (vector<ArdourButton*>::iterator b = _invert_buttons.begin(); b != _invert_buttons.end(); ++b) {
2129 (*b)->set_sensitive (yn);
2133 /** The Route's gui_changed signal has been emitted */
2135 RouteUI::route_gui_changed (PropertyChange const& what_changed)
2137 if (what_changed.contains (Properties::color)) {
2138 if (set_color_from_route () == 0) {
2139 route_color_changed ();
2145 RouteUI::track_mode_changed (void)
2148 switch (track()->mode()) {
2149 case ARDOUR::NonLayered:
2150 case ARDOUR::Normal:
2151 rec_enable_button->set_icon (ArdourIcon::RecButton);
2153 case ARDOUR::Destructive:
2154 rec_enable_button->set_icon (ArdourIcon::RecTapeMode);
2157 rec_enable_button->queue_draw();
2160 /** @return the color that this route should use; it maybe its own,
2161 * or it maybe that of its route group.
2164 RouteUI::route_color () const
2167 RouteGroup* g = _route->route_group ();
2170 if (g && g->is_color()) {
2171 set_color_from_rgba (c, GroupTabs::group_color (g));
2173 set_color_from_rgba (c, _route->presentation_info().color());
2180 RouteUI::set_showing_sends_to (boost::shared_ptr<Route> send_to)
2182 _showing_sends_to = send_to;
2183 BusSendDisplayChanged (send_to); /* EMIT SIGNAL */
2187 RouteUI::bus_send_display_changed (boost::shared_ptr<Route> send_to)
2189 if (_route == send_to) {
2190 show_sends_button->set_active (true);
2191 send_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::send_blink));
2193 show_sends_button->set_active (false);
2194 send_blink_connection.disconnect ();
2199 RouteUI::route_group() const
2201 return _route->route_group();
2205 RoutePinWindowProxy::RoutePinWindowProxy(std::string const &name, boost::shared_ptr<ARDOUR::Route> route)
2206 : WM::ProxyBase (name, string())
2207 , _route (boost::weak_ptr<Route> (route))
2209 route->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&RoutePinWindowProxy::route_going_away, this), gui_context());
2212 RoutePinWindowProxy::~RoutePinWindowProxy()
2217 ARDOUR::SessionHandlePtr*
2218 RoutePinWindowProxy::session_handle ()
2220 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
2221 if (aw) { return aw; }
2226 RoutePinWindowProxy::get (bool create)
2228 boost::shared_ptr<Route> r = _route.lock ();
2237 _window = new PluginPinDialog (r);
2238 ArdourWindow* aw = dynamic_cast<ArdourWindow*> (_window);
2240 aw->set_session (_session);
2242 _window->show_all ();
2248 RoutePinWindowProxy::route_going_away ()
2252 WM::Manager::instance().remove (this);
2253 going_away_connection.disconnect();
2258 RouteUI::maybe_add_route_print_mgr ()
2260 if (_route->pinmgr_proxy ()) {
2263 RoutePinWindowProxy* wp = new RoutePinWindowProxy (
2264 string_compose ("RPM-%1", _route->id()), _route);
2265 wp->set_session (_session);
2267 const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
2269 wp->set_state (*ui_xml, 0);
2273 void* existing_ui = _route->pinmgr_proxy ();
2275 wp->use_window (*(reinterpret_cast<Gtk::Window*>(existing_ui)));
2278 _route->set_pingmgr_proxy (wp);
2280 WM::Manager::instance().register_window (wp);
2284 RouteUI::manage_pins ()
2286 RoutePinWindowProxy* proxy = _route->pinmgr_proxy ();
2294 RouteUI::fan_out (bool to_busses, bool group)
2296 DisplaySuspender ds;
2297 boost::shared_ptr<ARDOUR::Route> route = _route;
2298 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (route->the_instrument ());
2301 const uint32_t n_outputs = pi->output_streams ().n_audio ();
2302 if (route->n_outputs ().n_audio () != n_outputs) {
2303 MessageDialog msg (string_compose (
2304 _("The Plugin's number of audio outputs ports (%1) does not match the Tracks's number of audio outputs (%2). Cannot fan out."),
2305 n_outputs, route->n_outputs ().n_audio ()));
2310 #define BUSNAME pd.group_name + "(" + route->name () + ")"
2312 /* count busses and channels/bus */
2313 boost::shared_ptr<Plugin> plugin = pi->plugin ();
2314 std::map<std::string, uint32_t> busnames;
2315 for (uint32_t p = 0; p < n_outputs; ++p) {
2316 const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p));
2317 std::string bn = BUSNAME;
2321 if (busnames.size () < 2) {
2322 MessageDialog msg (_("Instrument has only 1 output bus. Nothing to fan out."));
2327 uint32_t outputs = 2;
2328 if (_session->master_out ()) {
2329 outputs = std::max (outputs, _session->master_out ()->n_inputs ().n_audio ());
2332 route->output ()->disconnect (this);
2333 route->panner_shell ()->set_bypassed (true);
2336 for (uint32_t p = 0; p < n_outputs; ++p) {
2337 const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p));
2338 std::string bn = BUSNAME;
2339 boost::shared_ptr<Route> r = _session->route_by_name (bn);
2342 RouteList rl = _session->new_audio_route (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::AudioBus, PresentationInfo::max_order);
2346 list<boost::shared_ptr<AudioTrack> > tl =
2347 _session->new_audio_track (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::max_order, Normal);
2351 boost::shared_ptr<ControlList> cl (new ControlList);
2352 cl->push_back (r->monitoring_control ());
2353 _session->set_controls (cl, (double) MonitorInput, Controllable::NoGroup);
2355 r->input ()->disconnect (this);
2357 to_group.push_back (r);
2358 route->output ()->audio (p)->connect (r->input ()->audio (pd.group_channel).get());
2363 RouteGroup* rg = NULL;
2364 const std::list<RouteGroup*>& rgs (_session->route_groups ());
2365 for (std::list<RouteGroup*>::const_iterator i = rgs.begin (); i != rgs.end (); ++i) {
2366 if ((*i)->name () == pi->name ()) {
2372 rg = new RouteGroup (*_session, pi->name ());
2373 _session->add_route_group (rg);
2374 rg->set_gain (false);
2377 GroupTabs::set_group_color (rg, route->presentation_info().color());
2378 for (RouteList::const_iterator i = to_group.begin(); i != to_group.end(); ++i) {
2385 RouteUI::mark_hidden (bool yn)
2387 if (yn != _route->presentation_info().hidden()) {
2388 _route->presentation_info().set_hidden (yn);
2389 return true; // things changed
2394 boost::shared_ptr<Stripable>
2395 RouteUI::stripable () const