X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=a22eca4a181e6e384be295d77b3f27f63722b007;hb=ef636d02741bda53c533747f10b88f7ab667768c;hp=c6a1677cc0e0c552b5ca8c97175c929d7b39d8ab;hpb=3e12d4b4a625e7c02b797e806c1de501a33ade2d;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index c6a1677cc0..a22eca4a18 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -1,31 +1,36 @@ /* - Copyright (C) 2002-2006 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ + * Copyright (C) 2005-2006 Taybin Rutkin + * Copyright (C) 2005-2018 Paul Davis + * Copyright (C) 2005 Karsten Wiese + * Copyright (C) 2006-2015 David Robillard + * Copyright (C) 2008-2012 Carl Hetherington + * Copyright (C) 2009 Sampo Savolainen + * Copyright (C) 2012-2015 Tim Mayberry + * Copyright (C) 2013-2015 Nick Mainsbridge + * Copyright (C) 2013-2019 Robin Gareus + * Copyright (C) 2014-2017 Ben Loftis + * Copyright (C) 2015 André Nusser + * Copyright (C) 2017 Johannes Mueller + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include "pbd/memento_command.h" #include "pbd/stacktrace.h" @@ -38,11 +43,13 @@ #include "ardour/vca.h" #include "ardour/vca_manager.h" #include "ardour/audio_track.h" +#include "ardour/audio_port.h" #include "ardour/audioengine.h" #include "ardour/filename_extensions.h" #include "ardour/midi_track.h" #include "ardour/monitor_control.h" #include "ardour/internal_send.h" +#include "ardour/panner_shell.h" #include "ardour/profile.h" #include "ardour/phase_control.h" #include "ardour/send.h" @@ -50,30 +57,42 @@ #include "ardour/session.h" #include "ardour/template_utils.h" +#include "gtkmm2ext/gtk_ui.h" +#include "gtkmm2ext/doi.h" +#include "gtkmm2ext/gtk_ui.h" +#include "gtkmm2ext/utils.h" + +#include "widgets/ardour_button.h" +#include "widgets/binding_proxy.h" +#include "widgets/prompter.h" + +#include "ardour_dialog.h" #include "ardour_ui.h" +#include "automation_time_axis.h" #include "editor.h" -#include "route_ui.h" -#include "ardour_button.h" -#include "keyboard.h" -#include "utils.h" -#include "plugin_pin_dialog.h" -#include "prompter.h" +#include "group_tabs.h" +#include "gui_object.h" #include "gui_thread.h" -#include "ardour_dialog.h" +#include "keyboard.h" #include "latency_gui.h" #include "mixer_strip.h" -#include "automation_time_axis.h" +#include "patch_change_widget.h" +#include "plugin_pin_dialog.h" +#include "rgb_macros.h" #include "route_time_axis.h" -#include "group_tabs.h" +#include "route_ui.h" +#include "save_template_dialog.h" #include "timers.h" #include "ui_config.h" +#include "utils.h" +#include "pbd/i18n.h" -#include "i18n.h" using namespace Gtk; using namespace Gtkmm2ext; using namespace ARDOUR; using namespace ARDOUR_UI_UTILS; +using namespace ArdourWidgets; using namespace PBD; using namespace std; @@ -83,7 +102,9 @@ boost::weak_ptr RouteUI::_showing_sends_to; std::string RouteUI::program_port_prefix; RouteUI::RouteUI (ARDOUR::Session* sess) - : mute_menu(0) + : monitor_input_button (0) + , monitor_disk_button (0) + , mute_menu(0) , solo_menu(0) , sends_menu(0) , record_menu(0) @@ -111,6 +132,8 @@ RouteUI::~RouteUI() ARDOUR_UI::instance()->gui_object_state->remove_node (route_state_id()); } + delete_patch_change_dialog (); + _route.reset (); /* drop reference to route, so that it can be cleaned up */ route_connections.drop_connections (); @@ -121,6 +144,8 @@ RouteUI::~RouteUI() delete comment_window; delete input_selector; delete output_selector; + delete monitor_input_button; + delete monitor_disk_button; delete _invert_menu; send_blink_connection.disconnect (); @@ -152,7 +177,6 @@ RouteUI::init () multiple_mute_change = false; multiple_solo_change = false; _i_am_the_modifier = 0; - vca_button = 0; input_selector = 0; output_selector = 0; @@ -181,13 +205,13 @@ RouteUI::init () show_sends_button->set_name ("send alert button"); UI::instance()->set_tip (show_sends_button, _("make mixer strips show sends to this bus"), ""); - monitor_input_button = manage (new ArdourButton (ArdourButton::default_elements)); + monitor_input_button = new ArdourButton (ArdourButton::default_elements); monitor_input_button->set_name ("monitor button"); monitor_input_button->set_text (_("In")); UI::instance()->set_tip (monitor_input_button, _("Monitor input"), ""); monitor_input_button->set_no_show_all (true); - monitor_disk_button = manage (new ArdourButton (ArdourButton::default_elements)); + monitor_disk_button = new ArdourButton (ArdourButton::default_elements); monitor_disk_button->set_name ("monitor button"); monitor_disk_button->set_text (_("Disk")); UI::instance()->set_tip (monitor_disk_button, _("Monitor playback"), ""); @@ -196,9 +220,11 @@ RouteUI::init () _session->SoloChanged.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::solo_changed_so_update_mute, this), gui_context()); _session->TransportStateChange.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::check_rec_enable_sensitivity, this), gui_context()); _session->RecordStateChanged.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::session_rec_enable_changed, this), gui_context()); + _session->MonitorBusAddedOrRemoved.connect (_session_connections, invalidator (*this), boost::bind (&RouteUI::set_button_names, this), gui_context()); _session->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteUI::parameter_changed, this, _1), gui_context()); Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&RouteUI::parameter_changed, this, _1), gui_context()); + UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (this, &RouteUI::parameter_changed)); rec_enable_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_press), false); rec_enable_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::rec_enable_release), false); @@ -234,6 +260,9 @@ RouteUI::reset () delete mute_menu; mute_menu = 0; + delete_patch_change_dialog (); + _color_picker.reset (); + denormal_menu_item = 0; } @@ -250,6 +279,41 @@ RouteUI::set_route (boost::shared_ptr rp) _route = rp; + if ( !_route->presentation_info().color_set() ) { + /* deal with older 4.x color, which was stored in the GUI object state */ + + string p = ARDOUR_UI::instance()->gui_object_state->get_string (route_state_id(), X_("color")); + + if (!p.empty()) { + + /* old v4.x or earlier session. Use this information */ + + int red, green, blue; + char colon; + + stringstream ss (p); + + /* old color format version was: + + 16bit value for red:16 bit value for green:16 bit value for blue + + decode to rgb .. + */ + + ss >> red; + ss >> colon; + ss >> green; + ss >> colon; + ss >> blue; + + red >>= 2; + green >>= 2; + blue >>= 2; + + _route->presentation_info().set_color (RGBA_TO_UINT (red, green, blue, 255)); + } + } + if (set_color_from_route()) { set_color (gdk_color_to_rgba (AxisView::unique_random_color ())); } @@ -276,10 +340,10 @@ RouteUI::set_route (boost::shared_ptr rp) _route->solo_safe_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); _route->solo_isolate_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); _route->phase_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::polarity_changed, this), gui_context()); + _route->fan_out.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::fan_out, this, false, true), gui_context()); if (is_track()) { track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteUI::map_frozen, this), gui_context()); - track()->TrackModeChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::track_mode_changed, this), gui_context()); track_mode_changed(); } @@ -298,10 +362,10 @@ RouteUI::set_route (boost::shared_ptr rp) rec_enable_button->show(); rec_enable_button->set_controllable (t->rec_enable_control()); - if (is_midi_track()) { - midi_track()->StepEditStatusChange.connect (route_connections, invalidator (*this), - boost::bind (&RouteUI::step_edit_changed, this, _1), gui_context()); - } + if (is_midi_track()) { + midi_track()->StepEditStatusChange.connect (route_connections, invalidator (*this), + boost::bind (&RouteUI::step_edit_changed, this, _1), gui_context()); + } } @@ -345,14 +409,15 @@ RouteUI::set_route (boost::shared_ptr rp) check_rec_enable_sensitivity (); maybe_add_route_print_mgr (); route_color_changed(); + route_gui_changed (PropertyChange (Properties::selected)); } void RouteUI::polarity_changed () { - if (!_route) { - return; - } + if (!_route) { + return; + } set_invert_button_state (); } @@ -365,7 +430,7 @@ RouteUI::mute_press (GdkEventButton* ev) } //if this is a binding action, let the ArdourButton handle it - if ( BindingProxy::is_bind_action(ev) ) + if (BindingProxy::is_bind_action(ev) ) return false; multiple_mute_change = false; @@ -416,7 +481,6 @@ RouteUI::mute_press (GdkEventButton* ev) _mute_release->routes = copy; } - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (copy, &Stripable::mute_control), _route->muted_by_self() ? 0.0 : 1.0, Controllable::UseGroup); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { @@ -445,7 +509,8 @@ RouteUI::mute_press (GdkEventButton* ev) _mute_release->routes = rl; } - DisplaySuspender ds; + boost::shared_ptr mc = _route->mute_control(); + mc->start_touch (_session->audible_sample ()); _session->set_controls (route_list_to_control_list (rl, &Stripable::mute_control), _route->muted_by_self() ? 0.0 : 1.0, Controllable::InverseGroup); } @@ -460,8 +525,9 @@ RouteUI::mute_press (GdkEventButton* ev) _mute_release->routes = rl; } - _session->set_control (_route->mute_control(), _route->muted_by_self() ? 0.0 : 1.0, Controllable::UseGroup); - + boost::shared_ptr mc = _route->mute_control(); + mc->start_touch (_session->audible_sample ()); + mc->set_value (!_route->muted_by_self(), Controllable::UseGroup); } } } @@ -473,12 +539,13 @@ bool RouteUI::mute_release (GdkEventButton* /*ev*/) { if (_mute_release){ - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (_mute_release->routes, &Stripable::mute_control), _mute_release->active, Controllable::UseGroup); delete _mute_release; _mute_release = 0; } + _route->mute_control()->stop_touch (_session->audible_sample ()); + return false; } @@ -538,7 +605,7 @@ RouteUI::solo_press(GdkEventButton* ev) } //if this is a binding action, let the ArdourButton handle it - if ( BindingProxy::is_bind_action(ev) ) + if (BindingProxy::is_bind_action(ev) ) return false; multiple_solo_change = false; @@ -573,19 +640,25 @@ RouteUI::solo_press(GdkEventButton* ev) _solo_release->routes = _session->get_routes (); } - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_control), !_route->solo_control()->get_value(), Controllable::UseGroup); } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) { - // Primary-Secondary-click: exclusively solo this track + /* Primary-Secondary-click: exclusively solo this track */ if (_solo_release) { _solo_release->exclusive = true; - boost::shared_ptr routes = _session->get_routes(); + _solo_release->routes_on.reset (new RouteList); + _solo_release->routes_off.reset (new RouteList); - for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) { + boost::shared_ptr routes = _session->get_routes(); + for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { +#ifdef MIXBUS + if ((0 == _route->mixbus()) != (0 == (*i)->mixbus ())) { + continue; + } +#endif if ((*i)->soloed ()) { _solo_release->routes_on->push_back (*i); } else { @@ -594,13 +667,25 @@ RouteUI::solo_press(GdkEventButton* ev) } } + boost::shared_ptr rl (new RouteList); + boost::shared_ptr routes = _session->get_routes(); + for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) { +#ifdef MIXBUS + if ((0 == _route->mixbus()) != (0 == (*i)->mixbus ())) { + continue; + } +#endif + if ((*i)->soloed ()) { + rl->push_back (*i); + } + } + _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), false, Controllable::UseGroup); + if (Config->get_solo_control_is_listen_control()) { /* ??? we need a just_one_listen() method */ } else { DisplaySuspender ds; - boost::shared_ptr cl (new ControlList); - cl->push_back (_route->solo_control()); - _session->set_controls (cl, 1.0, Controllable::NoGroup); + _route->solo_control()->set_value (1.0, Controllable::NoGroup); } } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { @@ -645,8 +730,6 @@ RouteUI::solo_press(GdkEventButton* ev) _solo_release->routes = rl; } - DisplaySuspender ds; - _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), !_route->self_soloed(), Controllable::InverseGroup); } @@ -664,7 +747,6 @@ RouteUI::solo_press(GdkEventButton* ev) _solo_release->routes = rl; } - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), !_route->self_soloed(), Controllable::UseGroup); } } @@ -677,11 +759,10 @@ bool RouteUI::solo_release (GdkEventButton* /*ev*/) { if (_solo_release) { - if (_solo_release->exclusive) { - + _session->set_controls (route_list_to_control_list (_solo_release->routes_off, &Stripable::solo_control), 0.0, Controllable::NoGroup); + _session->set_controls (route_list_to_control_list (_solo_release->routes_on, &Stripable::solo_control), 1.0, Controllable::NoGroup); } else { - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (_solo_release->routes, &Stripable::solo_control), _solo_release->active ? 1.0 : 0.0, Controllable::UseGroup); } @@ -700,20 +781,18 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } //if this is a binding action, let the ArdourButton handle it - if ( BindingProxy::is_bind_action(ev) ) + if (BindingProxy::is_bind_action(ev) ) return false; - if (!_session->engine().connected()) { - MessageDialog msg (_("Not connected to AudioEngine - cannot engage record")); - msg.run (); + if (!ARDOUR_UI_UTILS::engine_is_running ()) { return false; } if (is_midi_track()) { - /* rec-enable button exits from step editing */ + /* rec-enable button exits from step editing, but not context click */ - if (midi_track()->step_editing()) { + if (!Keyboard::is_context_menu_event (ev) && midi_track()->step_editing()) { midi_track()->set_step_editing (false); return false; } @@ -728,7 +807,6 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::rec_enable_control), !track()->rec_enable_control()->get_value(), Controllable::NoGroup); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { @@ -744,7 +822,6 @@ RouteUI::rec_enable_press(GdkEventButton* ev) rl.reset (new RouteList); rl->push_back (_route); - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !track()->rec_enable_control()->get_value(), Controllable::InverseGroup); } @@ -755,7 +832,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } else { boost::shared_ptr trk = track(); - _session->set_control (trk->rec_enable_control(), !trk->rec_enable_control()->get_value(), Controllable::UseGroup); + trk->rec_enable_control()->set_value (!trk->rec_enable_control()->get_value(), Controllable::UseGroup); } } @@ -838,37 +915,27 @@ RouteUI::monitor_release (GdkEventButton* ev, MonitorChoice monitor_choice) MonitorChoice mc; boost::shared_ptr rl; - /* XXX for now, monitoring choices are orthogonal. cue monitoring - will follow in 3.X but requires mixing the input and playback (disk) - signal together, which requires yet more buffers. - */ - if (t->monitoring_control()->monitoring_choice() & monitor_choice) { mc = MonitorChoice (t->monitoring_control()->monitoring_choice() & ~monitor_choice); } else { - /* this line will change when the options are non-orthogonal */ - // mc = MonitorChoice (t->monitoring_choice() | monitor_choice); - mc = monitor_choice; + mc = MonitorChoice (t->monitoring_control()->monitoring_choice() | monitor_choice); } if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + /* Primary-Tertiary-click applies change to all routes */ rl = _session->get_routes (); - + _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::NoGroup); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - if (_route->route_group() && _route->route_group()->is_monitoring()) { - rl = _route->route_group()->route_list(); - } else { - rl.reset (new RouteList); - rl->push_back (route()); - } + /* Primary-click overrides group */ + rl.reset (new RouteList); + rl->push_back (route()); + _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::InverseGroup); } else { rl.reset (new RouteList); rl->push_back (route()); + _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::UseGroup); } - DisplaySuspender ds; - _session->set_controls (route_list_to_control_list (rl, &Stripable::monitoring_control), (double) mc, Controllable::UseGroup); - return false; } @@ -989,7 +1056,7 @@ RouteUI::build_sends_menu () ); items.push_back ( - MenuElem(_("Assign all tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true)) + MenuElem(_("Assign all tracks and busses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true)) ); items.push_back ( @@ -997,7 +1064,7 @@ RouteUI::build_sends_menu () ); items.push_back ( - MenuElem(_("Assign all tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, true)) + MenuElem(_("Assign all tracks and busses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, true)) ); items.push_back ( @@ -1005,14 +1072,14 @@ RouteUI::build_sends_menu () ); items.push_back ( - MenuElem(_("Assign selected tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, true))); + MenuElem(_("Assign selected tracks and busses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, true))); items.push_back ( MenuElem(_("Assign selected tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, false)) ); items.push_back ( - MenuElem(_("Assign selected tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, true)) + MenuElem(_("Assign selected tracks and busses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader, true)) ); items.push_back (MenuElem(_("Copy track/bus gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track))); @@ -1201,28 +1268,28 @@ RouteUI::update_solo_display () solo_isolated_check->set_active (yn); } - set_button_names (); + set_button_names (); - if (solo_isolated_led) { - if (_route->solo_isolate_control()->solo_isolated()) { + if (solo_isolated_led) { + if (_route->solo_isolate_control()->solo_isolated()) { solo_isolated_led->set_active_state (Gtkmm2ext::ExplicitActive); } else { solo_isolated_led->unset_active_state (); } - } + } - if (solo_safe_led) { - if (_route->solo_safe_control()->solo_safe()) { + if (solo_safe_led) { + if (_route->solo_safe_control()->solo_safe()) { solo_safe_led->set_active_state (Gtkmm2ext::ExplicitActive); } else { solo_safe_led->unset_active_state (); } - } + } solo_button->set_active_state (solo_active_state (_route)); - /* some changes to solo status can affect mute display, so catch up - */ + /* some changes to solo status can affect mute display, so catch up + */ update_mute_display (); } @@ -1279,54 +1346,24 @@ RouteUI::mute_active_state (Session*, boost::shared_ptr s) void RouteUI::update_mute_display () { - if (!_route) { - return; - } - - mute_button->set_active_state (mute_active_state (_session, _route)); -} - -void -RouteUI::update_vca_display () -{ - if (!vca_button) { + if (!_route) { return; } - VCAList vcas (_session->vca_manager().vcas()); - string label; - - for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { - if (_route->slaved_to (*v)) { - if (!label.empty()) { - label += ' '; - } - label += PBD::to_string ((*v)->number(), std::dec); - } - } - - if (label.empty()) { - label = _("-vca-"); - vca_button->set_active_state (Gtkmm2ext::Off); - } else { - vca_button->set_active_state (Gtkmm2ext::ExplicitActive); - } - - vca_button->set_text (label); + mute_button->set_active_state (mute_active_state (_session, _route)); } + void RouteUI::route_rec_enable_changed () { - blink_rec_display(true); //this lets the button change "immediately" rather than wait for the next blink - update_monitoring_display (); + blink_rec_display (true); //this lets the button change "immediately" rather than wait for the next blink } void RouteUI::session_rec_enable_changed () { - blink_rec_display(true); //this lets the button change "immediately" rather than wait for the next blink - update_monitoring_display (); + blink_rec_display (true); //this lets the button change "immediately" rather than wait for the next blink } void @@ -1345,31 +1382,31 @@ RouteUI::blink_rec_display (bool blinkOn) } if (track()->rec_enable_control()->get_value()) { - switch (_session->record_status ()) { - case Session::Recording: - rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); - break; - - case Session::Disabled: - case Session::Enabled: - if (UIConfiguration::instance().get_blink_rec_arm()) { - rec_enable_button->set_active_state ( blinkOn ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off ); - } else { - rec_enable_button->set_active_state ( ImplicitActive ); - } - break; - } - - if (step_edit_item) { - step_edit_item->set_sensitive (false); - } + switch (_session->record_status ()) { + case Session::Recording: + rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); + break; + + case Session::Disabled: + case Session::Enabled: + if (UIConfiguration::instance().get_blink_rec_arm()) { + rec_enable_button->set_active_state ( blinkOn ? Gtkmm2ext::ExplicitActive : Gtkmm2ext::Off ); + } else { + rec_enable_button->set_active_state ( ImplicitActive ); + } + break; + } + + if (step_edit_item) { + step_edit_item->set_sensitive (false); + } } else { rec_enable_button->unset_active_state (); - if (step_edit_item) { - step_edit_item->set_sensitive (true); - } + if (step_edit_item) { + step_edit_item->set_sensitive (true); + } } check_rec_enable_sensitivity (); @@ -1389,19 +1426,15 @@ RouteUI::build_solo_menu (void) check->set_active (_route->solo_isolate_control()->solo_isolated()); check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_isolated), check)); items.push_back (CheckMenuElem(*check)); - solo_isolated_check = dynamic_cast(&items.back()); + solo_isolated_check = dynamic_cast(&items.back()); check->show_all(); check = new Gtk::CheckMenuItem(_("Solo Safe")); check->set_active (_route->solo_safe_control()->solo_safe()); check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_safe), check)); items.push_back (CheckMenuElem(*check)); - solo_safe_check = dynamic_cast(&items.back()); + solo_safe_check = dynamic_cast(&items.back()); check->show_all(); - - //items.push_back (SeparatorElem()); - // items.push_back (MenuElem (_("MIDI Bind"), sigc::mem_fun (*mute_button, &BindableToggleButton::midi_learn))); - } void @@ -1438,9 +1471,6 @@ RouteUI::build_mute_menu(void) items.push_back (CheckMenuElem(*main_mute_check)); main_mute_check->show_all(); - //items.push_back (SeparatorElem()); - // items.push_back (MenuElem (_("MIDI Bind"), sigc::mem_fun (*mute_button, &BindableToggleButton::midi_learn))); - _route->mute_points_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::muting_change, this), gui_context()); } @@ -1510,11 +1540,9 @@ RouteUI::solo_isolate_button_release (GdkEventButton* ev) if (model) { /* disable isolate for all routes */ - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_isolate_control), 0.0, Controllable::NoGroup); } else { /* enable isolate for all routes */ - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_isolate_control), 1.0, Controllable::NoGroup); } @@ -1526,7 +1554,6 @@ RouteUI::solo_isolate_button_release (GdkEventButton* ev) boost::shared_ptr rl (new RouteList); rl->push_back (_route); - DisplaySuspender ds; _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_isolate_control), view ? 0.0 : 1.0, Controllable::NoGroup); } } @@ -1576,14 +1603,14 @@ RouteUI::solo_safe_button_release (GdkEventButton* ev) void RouteUI::toggle_solo_isolated (Gtk::CheckMenuItem* check) { - bool view = check->get_active(); - bool model = _route->solo_isolate_control()->solo_isolated(); + bool view = check->get_active(); + bool model = _route->solo_isolate_control()->solo_isolated(); - /* called AFTER the view has changed */ + /* called AFTER the view has changed */ - if (model != view) { - _route->solo_isolate_control()->set_value (view ? 1.0 : 0.0, Controllable::UseGroup); - } + if (model != view) { + _route->solo_isolate_control()->set_value (view ? 1.0 : 0.0, Controllable::UseGroup); + } } void @@ -1592,18 +1619,44 @@ RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check) _route->solo_safe_control()->set_value (check->get_active() ? 1.0 : 0.0, Controllable::UseGroup); } -/** Ask the user to choose a colour, and then apply that color to my route - */ void -RouteUI::choose_color () +RouteUI::delete_patch_change_dialog () +{ + if (!_route) { + return; + } + delete _route->patch_selector_dialog (); + _route->set_patch_selector_dialog (0); +} + +PatchChangeGridDialog* +RouteUI::patch_change_dialog () const { - bool picked; - Gdk::Color c (gdk_color_from_rgb (_route->presentation_info().color())); - Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &c); + return _route->patch_selector_dialog (); +} - if (picked) { - set_color (gdk_color_to_rgba (color)); +void +RouteUI::select_midi_patch () +{ + if (patch_change_dialog ()) { + patch_change_dialog()->present (); + return; } + + /* note: RouteTimeAxisView is resoponsible to updating + * the Dialog (PatchChangeGridDialog::refresh()) + * when the midnam model changes. + */ + PatchChangeGridDialog* d = new PatchChangeGridDialog (_route); + _route->set_patch_selector_dialog (d); + d->present (); +} + +/** Ask the user to choose a colour, and then apply that color to my route */ +void +RouteUI::choose_color () +{ + _color_picker.popup (_route); } /** Set the route's own color. This may not be used for display if @@ -1612,7 +1665,6 @@ RouteUI::choose_color () void RouteUI::set_color (uint32_t c) { - cerr << "setting route color\n"; _route->presentation_info().set_color (c); } @@ -1626,7 +1678,11 @@ RouteUI::route_state_id () const int RouteUI::set_color_from_route () { - return 0; + if (_route->presentation_info().color_set()) { + return 0; /* nothing to do */ + } + + return 1; /* pick a color */ } /** @return true if this name should be used for the route, otherwise false */ @@ -1651,7 +1707,7 @@ RouteUI::verify_new_route_name (const std::string& name) void RouteUI::route_rename () { - ArdourPrompter name_prompter (true); + ArdourWidgets::Prompter name_prompter (true); string result; bool done = false; @@ -1871,69 +1927,42 @@ RouteUI::map_frozen () } void -RouteUI::adjust_latency () -{ - LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle()); -} - -bool -RouteUI::process_save_template_prompter (ArdourPrompter& prompter, const std::string& dir) +RouteUI::save_as_template_dialog_response (int response, SaveTemplateDialog* d) { - std::string path; - std::string safe_name; - std::string name; + if (response == RESPONSE_ACCEPT) { + const string name = d->get_template_name (); + const string desc = d->get_description (); + const string path = Glib::build_filename(ARDOUR::user_route_template_directory (), name + ARDOUR::template_suffix); - prompter.get_result (name, true); + if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { /* file already exists. */ + bool overwrite = overwrite_file_dialog (*d, + _("Confirm Template Overwrite"), + _("A template already exists with that name. Do you want to overwrite it?")); - safe_name = legalize_for_path (name); - safe_name += template_suffix; - - path = Glib::build_filename (dir, safe_name); - - if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { - bool overwrite = overwrite_file_dialog (prompter, - _("Confirm Template Overwrite"), - _("A template already exists with that name. Do you want to overwrite it?")); - - if (!overwrite) { - return false; + if (!overwrite) { + d->show (); + return; + } } + _route->save_as_template (path, name, desc); } - _route->save_as_template (path, name); - - return true; + delete d; } void RouteUI::save_as_template () { - std::string dir; - - dir = ARDOUR::user_route_template_directory (); + const std::string dir = ARDOUR::user_route_template_directory (); if (g_mkdir_with_parents (dir.c_str(), 0755)) { error << string_compose (_("Cannot create route template directory %1"), dir) << endmsg; return; } - ArdourPrompter prompter (true); // modal - - prompter.set_title (_("Save As Template")); - prompter.set_prompt (_("Template name:")); - prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); - - bool finished = false; - while (!finished) { - switch (prompter.run()) { - case RESPONSE_ACCEPT: - finished = process_save_template_prompter (prompter, dir); - break; - default: - finished = true; - break; - } - } + SaveTemplateDialog* d = new SaveTemplateDialog (_route->name(), _route->comment()); + d->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::save_as_template_dialog_response), d)); + d->show (); } void @@ -1970,8 +1999,10 @@ RouteUI::parameter_changed (string const & p) if (p == "disable-disarm-during-roll") { check_rec_enable_sensitivity (); - } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { + } else if (p == "solo-control-is-listen-control" || p == "listen-position") { set_button_names (); + } else if (p == "session-monitoring") { + update_monitoring_display (); } else if (p == "auto-input") { update_monitoring_display (); } else if (p == "blink-rec-arm") { @@ -1985,30 +2016,6 @@ RouteUI::parameter_changed (string const & p) } } -void -RouteUI::step_gain_up () -{ - _route->gain_control()->set_value (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.1), Controllable::UseGroup); -} - -void -RouteUI::page_gain_up () -{ - _route->gain_control()->set_value (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.5), Controllable::UseGroup); -} - -void -RouteUI::step_gain_down () -{ - _route->gain_control()->set_value (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.1), Controllable::UseGroup); -} - -void -RouteUI::page_gain_down () -{ - _route->gain_control()->set_value (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), Controllable::UseGroup); -} - void RouteUI::setup_invert_buttons () { @@ -2044,9 +2051,9 @@ RouteUI::setup_invert_buttons () } if (N <= _max_invert_buttons) { - UI::instance()->set_tip (*b, string_compose (_("Left-click to invert (phase reverse) channel %1 of this track. Right-click to show menu."), i + 1)); + 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)); } else { - UI::instance()->set_tip (*b, _("Click to show a menu of channels for inversion (phase reverse)")); + UI::instance()->set_tip (*b, _("Click to show a menu of channels to invert polarity")); } _invert_buttons.push_back (b); @@ -2150,16 +2157,8 @@ RouteUI::invert_menu_toggled (uint32_t c) void RouteUI::set_invert_sensitive (bool yn) { - for (vector::iterator b = _invert_buttons.begin(); b != _invert_buttons.end(); ++b) { - (*b)->set_sensitive (yn); - } -} - -void -RouteUI::request_redraw () -{ - if (_route) { - _route->gui_changed ("track_height", (void *) 0); /* EMIT_SIGNAL */ + for (vector::iterator b = _invert_buttons.begin(); b != _invert_buttons.end(); ++b) { + (*b)->set_sensitive (yn); } } @@ -2191,14 +2190,14 @@ RouteUI::track_mode_changed (void) } /** @return the color that this route should use; it maybe its own, - or it maybe that of its route group. -*/ - + * or it maybe that of its route group. + */ Gdk::Color RouteUI::route_color () const { Gdk::Color c; RouteGroup* g = _route->route_group (); + string p; if (g && g->is_color()) { set_color_from_rgba (c, GroupTabs::group_color (g)); @@ -2284,6 +2283,7 @@ RoutePinWindowProxy::route_going_away () _window = 0; WM::Manager::instance().remove (this); going_away_connection.disconnect(); + delete this; } void @@ -2323,9 +2323,112 @@ RouteUI::manage_pins () } void -RouteUI::set_selected (bool yn) +RouteUI::fan_out (bool to_busses, bool group) { - _route->presentation_info().set_selected (yn); + if (!ARDOUR_UI_UTILS::engine_is_running ()) { + return; + } + + DisplaySuspender ds; + boost::shared_ptr route = _route; + boost::shared_ptr pi = boost::dynamic_pointer_cast (route->the_instrument ()); + assert (pi); + + const uint32_t n_outputs = pi->output_streams ().n_audio (); + if (route->n_outputs ().n_audio () != n_outputs) { + MessageDialog msg (string_compose ( + _("The Plugin's number of audio outputs ports (%1) does not match the Tracks's number of audio outputs (%2). Cannot fan out."), + n_outputs, route->n_outputs ().n_audio ())); + msg.run (); + return; + } + +#define BUSNAME pd.group_name + "(" + route->name () + ")" + + /* count busses and channels/bus */ + boost::shared_ptr plugin = pi->plugin (); + std::map busnames; + for (uint32_t p = 0; p < n_outputs; ++p) { + const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p)); + std::string bn = BUSNAME; + busnames[bn]++; + } + + if (busnames.size () < 2) { + MessageDialog msg (_("Instrument has only 1 output bus. Nothing to fan out.")); + msg.run (); + return; + } + + uint32_t outputs = 2; + if (_session->master_out ()) { + outputs = std::max (outputs, _session->master_out ()->n_inputs ().n_audio ()); + } + + route->output ()->disconnect (this); + route->panner_shell ()->set_bypassed (true); + + boost::shared_ptr msac = route->master_send_enable_controllable (); + if (msac) { + msac->start_touch (msac->session().transport_sample()); + msac->set_value (0, PBD::Controllable::NoGroup); + } + + RouteList to_group; + for (uint32_t p = 0; p < n_outputs; ++p) { + const Plugin::IOPortDescription& pd (plugin->describe_io_port (DataType::AUDIO, false, p)); + std::string bn = BUSNAME; + boost::shared_ptr r = _session->route_by_name (bn); + if (!r) { + try { + if (to_busses) { + RouteList rl = _session->new_audio_route (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::AudioBus, PresentationInfo::max_order); + r = rl.front (); + assert (r); + } else { + list > tl = + _session->new_audio_track (busnames[bn], outputs, NULL, 1, bn, PresentationInfo::max_order, Normal); + r = tl.front (); + assert (r); + + boost::shared_ptr cl (new ControlList); + cl->push_back (r->monitoring_control ()); + _session->set_controls (cl, (double) MonitorInput, Controllable::NoGroup); + } + } catch (...) { + if (!to_group.empty()) { + boost::shared_ptr rl (&to_group); + _session->remove_routes (rl); + } + return; + } + r->input ()->disconnect (this); + } + to_group.push_back (r); + route->output ()->audio (p)->connect (r->input ()->audio (pd.group_channel).get()); + } +#undef BUSNAME + + if (group) { + RouteGroup* rg = NULL; + const std::list& rgs (_session->route_groups ()); + for (std::list::const_iterator i = rgs.begin (); i != rgs.end (); ++i) { + if ((*i)->name () == pi->name ()) { + rg = *i; + break; + } + } + if (!rg) { + rg = new RouteGroup (*_session, pi->name ()); + _session->add_route_group (rg); + rg->set_gain (false); + } + + GroupTabs::set_group_color (rg, route->presentation_info().color()); + for (RouteList::const_iterator i = to_group.begin(); i != to_group.end(); ++i) { + rg->add (*i); + } + } } bool @@ -2337,3 +2440,17 @@ RouteUI::mark_hidden (bool yn) } return false; } + +boost::shared_ptr +RouteUI::stripable () const +{ + return _route; +} + +void +RouteUI::set_disk_io_point (DiskIOPoint diop) +{ + if (_route && is_track()) { + track()->set_disk_io_point (diop); + } +}