X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=gtk2_ardour%2Froute_ui.cc;h=c1dde89c39fea793d30d6a9a15c68ff656faeee0;hb=9b091a52cb77bfe9cce36668ebce714a1ec1eaae;hp=4222b40a93c9bb6bdf82da37a943dd3bad5d722d;hpb=136b8ed74721957e9617885fe156e6b8657116bd;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 4222b40a93..c1dde89c39 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -34,7 +34,7 @@ #include "ardour_ui.h" #include "editor.h" #include "route_ui.h" -#include "led.h" +#include "ardour_button.h" #include "keyboard.h" #include "utils.h" #include "prompter.h" @@ -44,17 +44,15 @@ #include "mixer_strip.h" #include "automation_time_axis.h" #include "route_time_axis.h" +#include "group_tabs.h" -#include "ardour/route.h" -#include "ardour/event_type_map.h" -#include "ardour/session.h" -#include "ardour/audioengine.h" #include "ardour/audio_track.h" +#include "ardour/audioengine.h" +#include "ardour/filename_extensions.h" #include "ardour/midi_track.h" +#include "ardour/route.h" +#include "ardour/session.h" #include "ardour/template_utils.h" -#include "ardour/filename_extensions.h" -#include "ardour/directory_names.h" -#include "ardour/profile.h" #include "i18n.h" using namespace Gtk; @@ -62,19 +60,19 @@ using namespace Gtkmm2ext; using namespace ARDOUR; using namespace PBD; -uint32_t RouteUI::_max_invert_buttons = 4; +uint32_t RouteUI::_max_invert_buttons = 3; +PBD::Signal1 > RouteUI::BusSendDisplayChanged; +boost::weak_ptr RouteUI::_showing_sends_to; RouteUI::RouteUI (ARDOUR::Session* sess) : AxisView(sess) + , mute_menu(0) + , solo_menu(0) + , sends_menu(0) + , record_menu(0) + , _invert_menu(0) { - init (); -} - -RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session* sess) - : AxisView(sess) -{ - init (); - set_route (rt); + if (sess) init (); } RouteUI::~RouteUI() @@ -93,7 +91,6 @@ void RouteUI::init () { self_destruct = true; - xml_node = 0; mute_menu = 0; solo_menu = 0; sends_menu = 0; @@ -109,7 +106,6 @@ RouteUI::init () solo_safe_led = 0; _solo_release = 0; _mute_release = 0; - route_active_menu_item = 0; denormal_menu_item = 0; step_edit_item = 0; multiple_mute_change = false; @@ -118,38 +114,42 @@ RouteUI::init () setup_invert_buttons (); - mute_button = manage (new BindableToggleButton ()); - // mute_button->set_self_managed (true); - mute_button->set_name ("MuteButton"); - mute_button->add (mute_button_label); - mute_button_label.show (); + mute_button = manage (new ArdourButton); + mute_button->set_name ("mute button"); UI::instance()->set_tip (mute_button, _("Mute this track"), ""); - solo_button = manage (new BindableToggleButton ()); - // solo_button->set_self_managed (true); - solo_button->set_name ("SoloButton"); - solo_button->add (solo_button_label); - solo_button_label.show (); + solo_button = manage (new ArdourButton); + solo_button->set_name ("solo button"); UI::instance()->set_tip (solo_button, _("Mute other (non-soloed) tracks"), ""); solo_button->set_no_show_all (true); - rec_enable_button = manage (new BindableToggleButton ()); - rec_enable_button->set_name ("RecordEnableButton"); - // rec_enable_button->set_self_managed (true); - rec_enable_button->add (rec_enable_button_label); - rec_enable_button_label.show (); + rec_enable_button = manage (new ArdourButton); + rec_enable_button->set_name ("record enable button"); + rec_enable_button->set_tweaks (ArdourButton::ImplicitUsesSolidColor); UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), ""); - show_sends_button = manage (new BindableToggleButton ("")); - show_sends_button->set_name ("SendAlert"); - // show_sends_button->set_self_managed (true); + show_sends_button = manage (new ArdourButton); + 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->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->set_name ("monitor button"); + monitor_disk_button->set_text (_("Disk")); + UI::instance()->set_tip (monitor_disk_button, _("Monitor playback"), ""); + monitor_disk_button->set_no_show_all (true); + _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()); - Config->ParameterChanged.connect (*this, invalidator (*this), ui_bind (&RouteUI::parameter_changed, this, _1), 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()); 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); @@ -161,6 +161,17 @@ RouteUI::init () solo_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::solo_release), false); mute_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::mute_press), false); mute_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::mute_release), false); + + monitor_input_button->set_distinct_led_click (false); + monitor_disk_button->set_distinct_led_click (false); + + monitor_input_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_input_press)); + monitor_input_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_input_release)); + + monitor_disk_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_disk_press)); + monitor_disk_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_disk_release)); + + BusSendDisplayChanged.connect_same_thread (*this, boost::bind(&RouteUI::bus_send_display_changed, this, _1)); } void @@ -174,21 +185,13 @@ RouteUI::reset () delete mute_menu; mute_menu = 0; - if (xml_node) { - /* do not delete the node - its owned by the route */ - xml_node = 0; - } - - route_active_menu_item = 0; denormal_menu_item = 0; } void RouteUI::self_delete () { - /* This may be called from a non-GUI thread. Keep it safe */ - - delete_when_idle (this); + delete this; } void @@ -205,12 +208,12 @@ RouteUI::set_route (boost::shared_ptr rp) if (self_destruct) { rp->DropReferences.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::self_delete, this), gui_context()); } - + mute_button->set_controllable (_route->mute_control()); solo_button->set_controllable (_route->solo_control()); _route->active_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_active_changed, this), gui_context()); - _route->mute_changed.connect (route_connections, invalidator (*this), ui_bind (&RouteUI::mute_changed, this, _1), gui_context()); + _route->mute_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::mute_changed, this, _1), gui_context()); _route->solo_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); _route->solo_safe_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); @@ -218,25 +221,37 @@ RouteUI::set_route (boost::shared_ptr rp) _route->solo_isolated_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); _route->phase_invert_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::polarity_changed, this), gui_context()); - _route->PropertyChanged.connect (route_connections, invalidator (*this), ui_bind (&RouteUI::property_changed, this, _1), gui_context()); + _route->PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::property_changed, this, _1), gui_context()); - _route->io_changed.connect (route_connections, invalidator (*this), ui_bind (&RouteUI::setup_invert_buttons, this), gui_context ()); + _route->io_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::setup_invert_buttons, this), gui_context ()); + _route->gui_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_gui_changed, this, _1), gui_context ()); if (_session->writable() && is_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast(_route); t->RecordEnableChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context()); - + rec_enable_button->show(); rec_enable_button->set_controllable (t->rec_enable_control()); - update_rec_display (); - if (is_midi_track()) { midi_track()->StepEditStatusChange.connect (route_connections, invalidator (*this), - ui_bind (&RouteUI::step_edit_changed, this, _1), gui_context()); + boost::bind (&RouteUI::step_edit_changed, this, _1), gui_context()); } + } + + /* this will work for busses and tracks, and needs to be called to + set up the name entry/name label display. + */ + + update_rec_display (); + + if (is_track()) { + boost::shared_ptr t = boost::dynamic_pointer_cast(_route); + t->MonitoringChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::monitoring_changed, this), gui_context()); + + update_monitoring_display (); } mute_button->unset_flags (Gtk::CAN_FOCUS); @@ -244,7 +259,7 @@ RouteUI::set_route (boost::shared_ptr rp) mute_button->show(); - if (_route->is_monitor()) { + if (_route->is_monitor() || _route->is_master()) { solo_button->hide (); } else { solo_button->show(); @@ -254,6 +269,12 @@ RouteUI::set_route (boost::shared_ptr rp) setup_invert_buttons (); set_invert_button_state (); + + boost::shared_ptr s = _showing_sends_to.lock (); + bus_send_display_changed (s); + + update_mute_display (); + update_solo_display (); } void @@ -303,11 +324,31 @@ RouteUI::mute_press (GdkEventButton* ev) if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + /* toggle mute on everything (but + * exclude the master and monitor) + * + * because we are going to erase + * elements of the list we need to work + * on a copy. + */ + + boost::shared_ptr copy (new RouteList); + + *copy = *_session->get_routes (); + + for (RouteList::iterator i = copy->begin(); i != copy->end(); ) { + if ((*i)->is_master() || (*i)->is_monitor()) { + i = copy->erase (i); + } else { + ++i; + } + } + if (_mute_release) { - _mute_release->routes = _session->get_routes (); + _mute_release->routes = copy; } - _session->set_mute (_session->get_routes(), !_route->muted()); + _session->set_mute (copy, !_route->muted()); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { @@ -315,21 +356,32 @@ RouteUI::mute_press (GdkEventButton* ev) NOTE: Primary-button2 is MIDI learn. */ - if (ev->button == 1 && _route->route_group()) { - if (_mute_release) { - _mute_release->routes = _session->get_routes (); + boost::shared_ptr rl; + + if (ev->button == 1) { + + if (_route->route_group()) { + + rl = _route->route_group()->route_list(); + + if (_mute_release) { + _mute_release->routes = rl; + } + } else { + rl.reset (new RouteList); + rl->push_back (_route); } - - _session->set_mute (_session->get_routes(), !_route->muted(), Session::rt_cleanup, true); + + _session->set_mute (rl, !_route->muted(), Session::rt_cleanup, true); } } else { /* plain click applies change to this route */ - + boost::shared_ptr rl (new RouteList); rl->push_back (_route); - + if (_mute_release) { _mute_release->routes = rl; } @@ -367,54 +419,55 @@ RouteUI::solo_press(GdkEventButton* ev) if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) { return true; } - + multiple_solo_change = false; if (!_i_am_the_modifier) { - + if (Keyboard::is_context_menu_event (ev)) { - - if (!solo_isolated_led) { + + if (! (solo_isolated_led && solo_isolated_led->is_visible()) || + ! (solo_safe_led && solo_safe_led->is_visible())) { if (solo_menu == 0) { build_solo_menu (); } - + solo_menu->popup (1, ev->time); } - + } else { - + if (Keyboard::is_button2_event (ev)) { - + // Primary-button2 click is the midi binding click // button2-click is "momentary" - + if (solo_button->on_button_press_event (ev)) { return true; } _solo_release = new SoloMuteRelease (_route->self_soloed()); } - + if (ev->button == 1 || Keyboard::is_button2_event (ev)) { - + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - + /* Primary-Tertiary-click applies change to all routes */ if (_solo_release) { _solo_release->routes = _session->get_routes (); } - + if (Config->get_solo_control_is_listen_control()) { - _session->set_listen (_session->get_routes(), !_route->listening(), Session::rt_cleanup, true); + _session->set_listen (_session->get_routes(), !_route->listening_via_monitor(), Session::rt_cleanup, true); } else { _session->set_solo (_session->get_routes(), !_route->self_soloed(), Session::rt_cleanup, true); } - + } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) { - + // Primary-Secondary-click: exclusively solo this track if (_solo_release) { @@ -430,7 +483,7 @@ RouteUI::solo_press(GdkEventButton* ev) } } } - + if (Config->get_solo_control_is_listen_control()) { /* ??? we need a just_one_listen() method */ } else { @@ -438,36 +491,50 @@ RouteUI::solo_press(GdkEventButton* ev) } } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { - + // shift-click: toggle solo isolated status - + _route->set_solo_isolated (!_route->solo_isolated(), this); delete _solo_release; _solo_release = 0; - + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - + /* Primary-button1: solo mix group. NOTE: Primary-button2 is MIDI learn. */ - - if (ev->button == 1 && _route->route_group()) { - if (_solo_release) { - _solo_release->routes = _route->route_group()->route_list(); + /* Primary-button1 applies change to the mix group even if it is not active + NOTE: Primary-button2 is MIDI learn. + */ + + boost::shared_ptr rl; + + if (ev->button == 1) { + + if (_route->route_group()) { + + rl = _route->route_group()->route_list(); + + if (_solo_release) { + _solo_release->routes = rl; + } + } else { + rl.reset (new RouteList); + rl->push_back (_route); } - + if (Config->get_solo_control_is_listen_control()) { - _session->set_listen (_route->route_group()->route_list(), !_route->listening(), Session::rt_cleanup, true); + _session->set_listen (rl, !_route->listening_via_monitor(), Session::rt_cleanup, true); } else { - _session->set_solo (_route->route_group()->route_list(), !_route->self_soloed(), Session::rt_cleanup, true); + _session->set_solo (rl, !_route->self_soloed(), Session::rt_cleanup, true); } } - + } else { - + /* click: solo this route */ - + boost::shared_ptr rl (new RouteList); rl->push_back (route()); @@ -476,7 +543,7 @@ RouteUI::solo_press(GdkEventButton* ev) } if (Config->get_solo_control_is_listen_control()) { - _session->set_listen (rl, !_route->listening()); + _session->set_listen (rl, !_route->listening_via_monitor()); } else { _session->set_solo (rl, !_route->self_soloed()); } @@ -492,7 +559,7 @@ bool RouteUI::solo_release (GdkEventButton*) { if (!_i_am_the_modifier) { - + if (_solo_release) { if (_solo_release->exclusive) { @@ -528,11 +595,12 @@ RouteUI::rec_enable_press(GdkEventButton* ev) if (is_midi_track()) { - /* cannot rec-enable while step-editing */ + /* rec-enable button exits from step editing */ if (midi_track()->step_editing()) { - return true; - } + midi_track()->set_step_editing (false); + return true; + } } if (!_i_am_the_modifier && is_track() && rec_enable_button) { @@ -544,15 +612,28 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - _session->set_record_enabled (_session->get_routes(), !rec_enable_button->get_active()); + _session->set_record_enabled (_session->get_routes(), !rec_enable_button->active_state()); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { /* Primary-button1 applies change to the route group (even if it is not active) NOTE: Primary-button2 is MIDI learn. */ - if (ev->button == 1 && _route->route_group()) { - _session->set_record_enabled (_route->route_group()->route_list(), !rec_enable_button->get_active(), Session::rt_cleanup, true); + + if (ev->button == 1) { + + boost::shared_ptr rl; + + if (_route->route_group()) { + + rl = _route->route_group()->route_list(); + + } else { + rl.reset (new RouteList); + rl->push_back (_route); + } + + _session->set_record_enabled (rl, !rec_enable_button->active_state(), Session::rt_cleanup, true); } } else if (Keyboard::is_context_menu_event (ev)) { @@ -563,10 +644,125 @@ RouteUI::rec_enable_press(GdkEventButton* ev) boost::shared_ptr rl (new RouteList); rl->push_back (route()); - _session->set_record_enabled (rl, !rec_enable_button->get_active()); + _session->set_record_enabled (rl, !rec_enable_button->active_state()); + } + } + + return true; +} + +void +RouteUI::monitoring_changed () +{ + update_monitoring_display (); +} + +void +RouteUI::update_monitoring_display () +{ + if (!_route) { + return; + } + + boost::shared_ptr t = boost::dynamic_pointer_cast(_route); + + if (!t) { + return; + } + + MonitorState ms = t->monitoring_state(); + + if (t->monitoring_choice() & MonitorInput) { + monitor_input_button->set_active_state (Gtkmm2ext::ExplicitActive); + } else { + if (ms & MonitoringInput) { + monitor_input_button->set_active_state (Gtkmm2ext::ImplicitActive); + } else { + monitor_input_button->unset_active_state (); + } + } + + if (t->monitoring_choice() & MonitorDisk) { + monitor_disk_button->set_active_state (Gtkmm2ext::ExplicitActive); + } else { + if (ms & MonitoringDisk) { + monitor_disk_button->set_active_state (Gtkmm2ext::ImplicitActive); + } else { + monitor_disk_button->unset_active_state (); + } + } +} + +bool +RouteUI::monitor_input_press(GdkEventButton*) +{ + return true; +} + +bool +RouteUI::monitor_input_release(GdkEventButton* ev) +{ + return monitor_release (ev, MonitorInput); +} + +bool +RouteUI::monitor_disk_press (GdkEventButton*) +{ + return true; +} + +bool +RouteUI::monitor_disk_release (GdkEventButton* ev) +{ + return monitor_release (ev, MonitorDisk); +} + +bool +RouteUI::monitor_release (GdkEventButton* ev, MonitorChoice monitor_choice) +{ + if (ev->button != 1) { + return false; + } + + boost::shared_ptr t = boost::dynamic_pointer_cast(_route); + + if (!t) { + return true; + } + + 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_choice() & monitor_choice) { + mc = MonitorChoice (t->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; + } + + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + rl = _session->get_routes (); + + } 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()); } + } else { + rl.reset (new RouteList); + rl->push_back (route()); } + _session->set_monitoring (rl, mc, Session::rt_cleanup, true); + return true; } @@ -577,17 +773,17 @@ RouteUI::build_record_menu () return; } - /* no rec-button context menu for non-MIDI tracks + /* no rec-button context menu for non-MIDI tracks */ if (is_midi_track()) { record_menu = new Menu; record_menu->set_name ("ArdourContextMenu"); - + using namespace Menu_Helpers; MenuList& items = record_menu->items(); - - items.push_back (CheckMenuElem (_("Step Edit"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit))); + + items.push_back (CheckMenuElem (_("Step Entry"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit))); step_edit_item = dynamic_cast (&items.back()); if (_route->record_enabled()) { @@ -613,8 +809,8 @@ RouteUI::step_edit_changed (bool yn) { if (yn) { if (rec_enable_button) { - rec_enable_button->set_visual_state (3); - } + rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); + } start_step_editing (); @@ -625,8 +821,8 @@ RouteUI::step_edit_changed (bool yn) } else { if (rec_enable_button) { - rec_enable_button->set_visual_state (0); - } + rec_enable_button->unset_active_state (); + } stop_step_editing (); @@ -659,24 +855,51 @@ RouteUI::build_sends_menu () sends_menu->set_name ("ArdourContextMenu"); MenuList& items = sends_menu->items(); - items.push_back (MenuElem(_("Assign all tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader))); - items.push_back (MenuElem(_("Assign all tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader))); - items.push_back (MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader))); - items.push_back (MenuElem(_("Assign selected tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PostFader))); - items.push_back (MenuElem(_("Copy track gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track))); + items.push_back ( + MenuElem(_("Assign all tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, false)) + ); + + items.push_back ( + MenuElem(_("Assign all tracks and buses (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PreFader, true)) + ); + + items.push_back ( + MenuElem(_("Assign all tracks (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, false)) + ); + + items.push_back ( + MenuElem(_("Assign all tracks and buses (postfader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_sends), PostFader, true)) + ); + + items.push_back ( + MenuElem(_("Assign selected tracks (prefader)"), sigc::bind (sigc::mem_fun (*this, &RouteUI::create_selected_sends), PreFader, false)) + ); + + items.push_back ( + MenuElem(_("Assign selected tracks and buses (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)) + ); + + items.push_back (MenuElem(_("Copy track/bus gains to sends"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_from_track))); items.push_back (MenuElem(_("Set sends gain to -inf"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_zero))); items.push_back (MenuElem(_("Set sends gain to 0dB"), sigc::mem_fun (*this, &RouteUI::set_sends_gain_to_unity))); } void -RouteUI::create_sends (Placement p) +RouteUI::create_sends (Placement p, bool include_buses) { - _session->globally_add_internal_sends (_route, p); + _session->globally_add_internal_sends (_route, p, include_buses); } void -RouteUI::create_selected_sends (Placement p) +RouteUI::create_selected_sends (Placement p, bool include_buses) { boost::shared_ptr rlist (new RouteList); TrackSelection& selected_tracks (ARDOUR_UI::instance()->the_editor().get_selection().tracks); @@ -686,13 +909,13 @@ RouteUI::create_selected_sends (Placement p) RouteUI* rui; if ((rtv = dynamic_cast(*i)) != 0) { if ((rui = dynamic_cast(rtv)) != 0) { - if (boost::dynamic_pointer_cast(rui->route())) { + if (include_buses || boost::dynamic_pointer_cast(rui->route())) { rlist->push_back (rui->route()); } } } } - + _session->add_internal_sends (_route, p, rlist); } @@ -738,22 +961,13 @@ RouteUI::show_sends_press(GdkEventButton* ev) } else { - /* change button state */ - - show_sends_button->set_active (!show_sends_button->get_active()); + boost::shared_ptr s = _showing_sends_to.lock (); - /* start blinking */ - - if (show_sends_button->get_active()) { - /* show sends to this bus */ - MixerStrip::SwitchIO (_route); - send_blink_connection = ARDOUR_UI::instance()->Blink.connect (sigc::mem_fun(*this, &RouteUI::send_blink)); + if (s == _route) { + set_showing_sends_to (boost::shared_ptr ()); } else { - /* everybody back to normal */ - send_blink_connection.disconnect (); - MixerStrip::SwitchIO (boost::shared_ptr()); + set_showing_sends_to (_route); } - } } @@ -774,121 +988,71 @@ RouteUI::send_blink (bool onoff) } if (onoff) { - show_sends_button->set_state (STATE_ACTIVE); + show_sends_button->set_active_state (Gtkmm2ext::ExplicitActive); } else { - show_sends_button->set_state (STATE_NORMAL); + show_sends_button->unset_active_state (); } } -int -RouteUI::solo_visual_state (boost::shared_ptr r) +Gtkmm2ext::ActiveState +RouteUI::solo_active_state (boost::shared_ptr r) { if (r->is_master() || r->is_monitor()) { - return 0; + return Gtkmm2ext::Off; } - + if (Config->get_solo_control_is_listen_control()) { - if (r->listening()) { - return 1; + if (r->listening_via_monitor()) { + return Gtkmm2ext::ExplicitActive; } else { - return 0; + return Gtkmm2ext::Off; } - } - + } + if (r->soloed()) { if (!r->self_soloed()) { - return 3; + return Gtkmm2ext::ImplicitActive; } else { - return 1; + return Gtkmm2ext::ExplicitActive; } } else { - return 0; + return Gtkmm2ext::Off; } } -int -RouteUI::solo_visual_state_with_isolate (boost::shared_ptr r) +Gtkmm2ext::ActiveState +RouteUI::solo_isolate_active_state (boost::shared_ptr r) { if (r->is_master() || r->is_monitor()) { - return 0; + return Gtkmm2ext::Off; } - - if (Config->get_solo_control_is_listen_control()) { - if (r->listening()) { - return 1; - } else { - return 0; - } - - } - if (r->solo_isolated()) { - return 2; - } else if (r->soloed()) { - if (!r->self_soloed()) { - return 3; - } else { - return 1; - } + return Gtkmm2ext::ExplicitActive; } else { - return 0; + return Gtkmm2ext::Off; } } -int -RouteUI::solo_isolate_visual_state (boost::shared_ptr r) +Gtkmm2ext::ActiveState +RouteUI::solo_safe_active_state (boost::shared_ptr r) { if (r->is_master() || r->is_monitor()) { - return 0; + return Gtkmm2ext::Off; } - - if (r->solo_isolated()) { - return 1; - } else { - return 0; - } -} -int -RouteUI::solo_safe_visual_state (boost::shared_ptr r) -{ - if (r->is_master() || r->is_monitor()) { - return 0; - } - if (r->solo_safe()) { - return 1; + return Gtkmm2ext::ExplicitActive; } else { - return 0; + return Gtkmm2ext::Off; } } void RouteUI::update_solo_display () { - bool x; - - if (Config->get_solo_control_is_listen_control()) { - - if (solo_button->get_active() != (x = _route->listening())) { - ++_i_am_the_modifier; - solo_button->set_active(x); - --_i_am_the_modifier; - } - - } else { - - if (solo_button->get_active() != (x = _route->soloed())) { - ++_i_am_the_modifier; - solo_button->set_active (x); - --_i_am_the_modifier; - } - - } - bool yn = _route->solo_safe (); if (solo_safe_check && solo_safe_check->get_active() != yn) { @@ -904,16 +1068,24 @@ RouteUI::update_solo_display () set_button_names (); if (solo_isolated_led) { - solo_isolated_led->set_visual_state (_route->solo_isolated() ? 1 : 0); + if (_route->solo_isolated()) { + solo_isolated_led->set_active_state (Gtkmm2ext::ExplicitActive); + } else { + solo_isolated_led->unset_active_state (); + } } if (solo_safe_led) { - solo_safe_led->set_visual_state (_route->solo_safe() ? 1 : 0); + if (_route->solo_safe()) { + solo_safe_led->set_active_state (Gtkmm2ext::ExplicitActive); + } else { + solo_safe_led->unset_active_state (); + } } - solo_button->set_visual_state (solo_visual_state (_route)); - - /* some changes to solo status can affect mute display, so catch up + solo_button->set_active_state (solo_active_state (_route)); + + /* some changes to solo status can affect mute display, so catch up */ update_mute_display (); @@ -931,37 +1103,39 @@ RouteUI::mute_changed(void* /*src*/) update_mute_display (); } -int -RouteUI::mute_visual_state (Session* s, boost::shared_ptr r) +ActiveState +RouteUI::mute_active_state (Session* s, boost::shared_ptr r) { - if (r->is_master() || r->is_monitor()) { - return 0; + if (r->is_monitor()) { + return ActiveState(0); } - if (Config->get_show_solo_mutes()) { + + if (Config->get_show_solo_mutes() && !Config->get_solo_control_is_listen_control ()) { if (r->muted ()) { /* full mute */ - return 2; - } else if (s->soloing() && !r->soloed() && !r->solo_isolated()) { - return 1; + return Gtkmm2ext::ExplicitActive; + } else if (!r->is_master() && s->soloing() && !r->soloed() && !r->solo_isolated()) { + /* master is NEVER muted by others */ + return Gtkmm2ext::ImplicitActive; } else { /* no mute at all */ - return 0; + return Gtkmm2ext::Off; } } else { if (r->muted()) { /* full mute */ - return 2; + return Gtkmm2ext::ExplicitActive; } else { /* no mute at all */ - return 0; + return Gtkmm2ext::Off; } } - return 0; + return ActiveState(0); } void @@ -971,32 +1145,21 @@ RouteUI::update_mute_display () return; } - bool model = _route->muted(); - bool view = mute_button->get_active(); - - /* first make sure the button's "depressed" visual - is correct. - */ - - if (model != view) { - ++_i_am_the_modifier; - mute_button->set_active (model); - --_i_am_the_modifier; - } - - mute_button->set_visual_state (mute_visual_state (_session, _route)); + mute_button->set_active_state (mute_active_state (_session, _route)); } void RouteUI::route_rec_enable_changed () { update_rec_display (); + update_monitoring_display (); } void RouteUI::session_rec_enable_changed () { update_rec_display (); + update_monitoring_display (); } void @@ -1005,33 +1168,18 @@ RouteUI::update_rec_display () if (!rec_enable_button || !_route) { return; } - - bool model = _route->record_enabled(); - bool view = rec_enable_button->get_active(); - /* first make sure the button's "depressed" visual - is correct. - */ - - if (model != view) { - ++_i_am_the_modifier; - rec_enable_button->set_active (model); - --_i_am_the_modifier; - } - - /* now make sure its color state is correct */ - - if (model) { + if (_route->record_enabled()) { switch (_session->record_status ()) { case Session::Recording: - rec_enable_button->set_visual_state (1); + rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); break; - + case Session::Disabled: case Session::Enabled: - rec_enable_button->set_visual_state (2); + rec_enable_button->set_active_state (Gtkmm2ext::ImplicitActive); break; - + } if (step_edit_item) { @@ -1039,13 +1187,13 @@ RouteUI::update_rec_display () } } else { - rec_enable_button->set_visual_state (0); + rec_enable_button->unset_active_state (); if (step_edit_item) { step_edit_item->set_sensitive (true); } } - + check_rec_enable_sensitivity (); } @@ -1175,7 +1323,7 @@ RouteUI::solo_isolate_button_release (GdkEventButton* ev) return true; } - bool view = (solo_isolated_led->visual_state() != 0); + bool view = solo_isolated_led->active_state(); bool model = _route->solo_isolated(); /* called BEFORE the view has changed */ @@ -1204,10 +1352,13 @@ RouteUI::solo_isolate_button_release (GdkEventButton* ev) } bool -RouteUI::solo_safe_button_release (GdkEventButton*) +RouteUI::solo_safe_button_release (GdkEventButton* ev) { - _route->set_solo_safe (!(solo_safe_led->visual_state() > 0), this); - return true; + if (ev->button == 1) { + _route->set_solo_safe (!solo_safe_led->active_state(), this); + return true; + } + return false; } void @@ -1229,108 +1380,84 @@ RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check) _route->set_solo_safe (check->get_active(), this); } -bool -RouteUI::choose_color() +/** Ask the user to choose a colour, and then set all selected tracks + * to that colour. + */ +void +RouteUI::choose_color () { bool picked; - Gdk::Color color; - - color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color); + Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color); if (picked) { - set_color (color); + ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui ( + boost::bind (&RouteUI::set_color, _1, color) + ); } - - return picked; } +/** Set the route's own color. This may not be used for display if + * the route is in a group which shares its color with its routes. + */ void RouteUI::set_color (const Gdk::Color & c) { - char buf[64]; + /* leave _color alone in the group case so that tracks can retain their + * own pre-group colors. + */ + char buf[64]; _color = c; - - ensure_xml_node (); snprintf (buf, sizeof (buf), "%d:%d:%d", c.get_red(), c.get_green(), c.get_blue()); - xml_node->add_property ("color", buf); - + + /* note: we use the route state ID here so that color is the same for both + the time axis view and the mixer strip + */ + + gui_object_state().set_property (route_state_id(), X_("color"), buf); _route->gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */ } - -void -RouteUI::ensure_xml_node () +/** @return GUI state ID for things that are common to the route in all its representations */ +string +RouteUI::route_state_id () const { - if (xml_node == 0) { - if ((xml_node = _route->extra_xml ("GUI")) == 0) { - xml_node = new XMLNode ("GUI"); - _route->add_extra_xml (*xml_node); - } - } + return string_compose (X_("route %1"), _route->id().to_s()); } -XMLNode* -RouteUI::get_automation_child_xml_node (Evoral::Parameter param, int version) +int +RouteUI::set_color_from_route () { - ensure_xml_node (); - - XMLNodeList kids = xml_node->children(); - XMLNodeConstIterator iter; - - const string sym = ARDOUR::EventTypeMap::instance().to_symbol(param); - - for (iter = kids.begin(); iter != kids.end(); ++iter) { + const string str = gui_object_state().get_string (route_state_id(), X_("color")); - if (version < 3000) { - if ((*iter)->name() == sym) { - return *iter; - } - } else { - if ((*iter)->name() == AutomationTimeAxisView::state_node_name) { - XMLProperty* type = (*iter)->property("automation-id"); - if (type && type->value() == sym) - return *iter; - } - } + if (str.empty()) { + return 1; } - // Didn't find it, make a new one - XMLNode* child = new XMLNode (AutomationTimeAxisView::state_node_name); - child->add_property("automation-id", sym); - xml_node->add_child_nocopy (*child); - - return child; -} + int r, g, b; -int -RouteUI::set_color_from_route () -{ - XMLProperty *prop; + sscanf (str.c_str(), "%d:%d:%d", &r, &g, &b); - RouteUI::ensure_xml_node (); + _color.set_red (r); + _color.set_green (g); + _color.set_blue (b); - if ((prop = xml_node->property ("color")) != 0) { - int r, g, b; - sscanf (prop->value().c_str(), "%d:%d:%d", &r, &g, &b); - _color.set_red(r); - _color.set_green(g); - _color.set_blue(b); - return 0; - } - return 1; + return 0; } void -RouteUI::remove_this_route () +RouteUI::remove_this_route (bool apply_to_selection) { - if ((route()->is_master() || route()->is_monitor()) && - !Config->get_allow_special_bus_removal()) { - MessageDialog msg (_("That would be bad news ...."), - false, - Gtk::MESSAGE_INFO, + if (apply_to_selection) { + ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteUI::remove_this_route, _1, false)); + } else { + if ((route()->is_master() || route()->is_monitor()) && + !Config->get_allow_special_bus_removal()) { + MessageDialog msg (_("That would be bad news ...."), + false, + Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK); - msg.set_secondary_text (string_compose (_( + msg.set_secondary_text (string_compose (_( "Removing the master or monitor bus is such a bad idea\n\ that %1 is not going to allow it.\n\ \n\ @@ -1338,34 +1465,35 @@ If you really want to do this sort of thing\n\ edit your ardour.rc file to set the\n\ \"allow-special-bus-removal\" option to be \"yes\""), PROGRAM_NAME)); - msg.present (); - msg.run (); - return; - } + msg.present (); + msg.run (); + return; + } - vector choices; - string prompt; + vector choices; + string prompt; - if (is_track()) { - prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); - } else { - prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); - } + if (is_track()) { + prompt = string_compose (_("Do you really want to remove track \"%1\" ?\n\nYou may also lose the playlist used by this track.\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); + } else { + prompt = string_compose (_("Do you really want to remove bus \"%1\" ?\n\n(This action cannot be undone, and the session file will be overwritten)"), _route->name()); + } - choices.push_back (_("No, do nothing.")); - choices.push_back (_("Yes, remove it.")); + choices.push_back (_("No, do nothing.")); + choices.push_back (_("Yes, remove it.")); - string title; - if (is_track()) { - title = _("Remove track"); - } else { - title = _("Remove bus"); - } + string title; + if (is_track()) { + title = _("Remove track"); + } else { + title = _("Remove bus"); + } - Choice prompter (title, prompt, choices); + Choice prompter (title, prompt, choices); - if (prompter.run () == 1) { - Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this)); + if (prompter.run () == 1) { + Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this)); + } } } @@ -1376,11 +1504,32 @@ RouteUI::idle_remove_this_route (RouteUI *rui) return false; } +/** @return true if this name should be used for the route, otherwise false */ +bool +RouteUI::verify_new_route_name (const std::string& name) +{ + if (name.find (':') == string::npos) { + return true; + } + + MessageDialog colon_msg ( + _("The use of colons (':') is discouraged in track and bus names.\nDo you want to use this new name?"), + false, MESSAGE_QUESTION, BUTTONS_NONE + ); + + colon_msg.add_button (_("Use the new name"), Gtk::RESPONSE_ACCEPT); + colon_msg.add_button (_("Re-edit the name"), Gtk::RESPONSE_CANCEL); + + return (colon_msg.run () == Gtk::RESPONSE_ACCEPT); +} + void RouteUI::route_rename () { ArdourPrompter name_prompter (true); string result; + bool done = false; + if (is_track()) { name_prompter.set_title (_("Rename Track")); } else { @@ -1392,14 +1541,28 @@ RouteUI::route_rename () name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); name_prompter.show_all (); - switch (name_prompter.run ()) { + while (!done) { + switch (name_prompter.run ()) { + case Gtk::RESPONSE_ACCEPT: + name_prompter.get_result (result); + name_prompter.hide (); + if (result.length()) { + if (verify_new_route_name (result)) { + _route->set_name (result); + done = true; + } else { + /* back to name prompter */ + } - case Gtk::RESPONSE_ACCEPT: - name_prompter.get_result (result); - if (result.length()) { - _route->set_name (result); + } else { + /* nothing entered, just get out of here */ + done = true; + } + break; + default: + done = true; + break; } - break; } return; @@ -1415,26 +1578,15 @@ RouteUI::property_changed (const PropertyChange& what_changed) } void -RouteUI::toggle_route_active () +RouteUI::set_route_active (bool a, bool apply_to_selection) { - bool yn; - - if (route_active_menu_item) { - if (route_active_menu_item->get_active() != (yn = _route->active())) { - _route->set_active (!yn); - } + if (apply_to_selection) { + ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui (boost::bind (&RouteTimeAxisView::set_route_active, _1, a, false)); + } else { + _route->set_active (a, this); } } -void -RouteUI::route_active_changed () -{ - if (route_active_menu_item) { - Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&CheckMenuItem::set_active, route_active_menu_item, _route->active())); - } -} - - void RouteUI::toggle_denormal_protection () { @@ -1546,14 +1698,14 @@ RouteUI::adjust_latency () void RouteUI::save_as_template () { - sys::path path; - Glib::ustring safe_name; + std::string path; + std::string safe_name; string name; path = ARDOUR::user_route_template_directory (); - if (g_mkdir_with_parents (path.to_string().c_str(), 0755)) { - error << string_compose (_("Cannot create route template directory %1"), path.to_string()) << endmsg; + if (g_mkdir_with_parents (path.c_str(), 0755)) { + error << string_compose (_("Cannot create route template directory %1"), path) << endmsg; return; } @@ -1561,6 +1713,7 @@ RouteUI::save_as_template () p.set_title (_("Save As Template")); p.set_prompt (_("Template name:")); + p.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); switch (p.run()) { case RESPONSE_ACCEPT: break; @@ -1574,30 +1727,34 @@ RouteUI::save_as_template () safe_name = legalize_for_path (name); safe_name += template_suffix; - path /= safe_name; + path = Glib::build_filename (path, safe_name); - _route->save_as_template (path.to_string(), name); + _route->save_as_template (path, name); } void RouteUI::check_rec_enable_sensitivity () { - if (_session->transport_rolling() && rec_enable_button->get_active() && Config->get_disable_disarm_during_roll()) { + if (_session->transport_rolling() && rec_enable_button->active_state() && Config->get_disable_disarm_during_roll()) { rec_enable_button->set_sensitive (false); } else { rec_enable_button->set_sensitive (true); } + + update_monitoring_display (); } void RouteUI::parameter_changed (string const & p) { + /* this handles RC and per-session parameter changes */ + if (p == "disable-disarm-during-roll") { check_rec_enable_sensitivity (); - } else if (p == "solo-control-is-listen-control") { - set_button_names (); - } else if (p == "listen-position") { + } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { set_button_names (); + } else if (p == "auto-input") { + update_monitoring_display (); } } @@ -1629,27 +1786,53 @@ void RouteUI::open_remote_control_id_dialog () { ArdourDialog dialog (_("Remote Control ID")); + SpinButton* spin = 0; - uint32_t const limit = _session->ntracks() + _session->nbusses () + 4; - - HBox* hbox = manage (new HBox); - hbox->set_spacing (6); - hbox->pack_start (*manage (new Label (_("Remote control ID:")))); - SpinButton* spin = manage (new SpinButton); - spin->set_digits (0); - spin->set_increments (1, 10); - spin->set_range (0, limit); - spin->set_value (_route->remote_control_id()); - hbox->pack_start (*spin); - dialog.get_vbox()->pack_start (*hbox); + dialog.get_vbox()->set_border_width (18); - dialog.add_button (Stock::CANCEL, RESPONSE_CANCEL); - dialog.add_button (Stock::APPLY, RESPONSE_ACCEPT); + if (Config->get_remote_model() == UserOrdered) { + uint32_t const limit = _session->ntracks() + _session->nbusses () + 4; + + HBox* hbox = manage (new HBox); + hbox->set_spacing (6); + hbox->pack_start (*manage (new Label (_("Remote control ID:")))); + spin = manage (new SpinButton); + spin->set_digits (0); + spin->set_increments (1, 10); + spin->set_range (0, limit); + spin->set_value (_route->remote_control_id()); + hbox->pack_start (*spin); + dialog.get_vbox()->pack_start (*hbox); + + dialog.add_button (Stock::CANCEL, RESPONSE_CANCEL); + dialog.add_button (Stock::APPLY, RESPONSE_ACCEPT); + } else { + Label* l = manage (new Label()); + if (_route->is_master() || _route->is_monitor()) { + l->set_markup (string_compose (_("The remote control ID of %1 is: %2\n\n\n" + "The remote control ID of %3 cannot be changed."), + Glib::Markup::escape_text (_route->name()), + _route->remote_control_id(), + (_route->is_master() ? _("the master bus") : _("the monitor bus")))); + } else { + l->set_markup (string_compose (_("The remote control ID of %6 is: %3\n\n\n" + "Remote Control IDs are currently determined by track/bus ordering in %1\n\n" + "%4Use the User Interaction tab of the Preferences window if you want to change this%5"), + (Config->get_remote_model() == MixerOrdered ? _("the mixer") : _("the editor")), + (is_track() ? _("track") : _("bus")), + _route->remote_control_id(), + "", + "", + Glib::Markup::escape_text (_route->name()))); + } + dialog.get_vbox()->pack_start (*l); + dialog.add_button (Stock::OK, RESPONSE_CANCEL); + } dialog.show_all (); int const r = dialog.run (); - if (r == RESPONSE_ACCEPT) { + if (r == RESPONSE_ACCEPT && spin) { _route->set_remote_control_id (spin->get_value_as_int ()); } } @@ -1658,7 +1841,7 @@ void RouteUI::setup_invert_buttons () { /* remove old invert buttons */ - for (list::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i) { + for (vector::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i) { _invert_button_box.remove (**i); } @@ -1673,27 +1856,33 @@ RouteUI::setup_invert_buttons () uint32_t const to_add = (N <= _max_invert_buttons) ? N : 1; for (uint32_t i = 0; i < to_add; ++i) { - BindableToggleButton* b = manage (new BindableToggleButton); - b->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_toggled), i, b)); + ArdourButton* b = manage (new ArdourButton); + b->set_size_request(20,20); b->signal_button_press_event().connect (sigc::mem_fun (*this, &RouteUI::invert_press)); - - b->set_name (X_("MixerInvertButton")); + b->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_release), i)); + + b->set_name (X_("invert button")); if (to_add == 1) { - b->add (*manage (new Label (X_("Ø")))); + if (N > 1) { + b->set_text (string_compose (X_("Ø (%1)"), N)); + } else { + b->set_text (X_("Ø")); + } } else { - b->add (*manage (new Label (string_compose (X_("Ø%1"), i + 1)))); + b->set_text (string_compose (X_("Ø%1"), i + 1)); } - if (N <= 4) { + 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)); } else { - UI::instance()->set_tip (*b, string_compose (_("Left-click to invert (phase reverse) all channels of this track. Right-click to show menu."), i + 1)); + UI::instance()->set_tip (*b, _("Click to show a menu of channels for inversion (phase reverse)")); } - + _invert_buttons.push_back (b); _invert_button_box.pack_start (*b); } - + + _invert_button_box.set_spacing (1); _invert_button_box.show_all (); } @@ -1701,56 +1890,72 @@ void RouteUI::set_invert_button_state () { ++_i_am_the_modifier; - + uint32_t const N = _route->input()->n_ports().n_audio(); if (N > _max_invert_buttons) { - _invert_buttons.front()->set_active (_route->phase_invert().any()); - --_i_am_the_modifier; - return; - } - int j = 0; - for (list::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i, ++j) { - (*i)->set_active (_route->phase_invert (j)); + /* One button for many channels; explicit active if all channels are inverted, + implicit active if some are, off if none are. + */ + + ArdourButton* b = _invert_buttons.front (); + + if (_route->phase_invert().count() == _route->phase_invert().size()) { + b->set_active_state (Gtkmm2ext::ExplicitActive); + } else if (_route->phase_invert().any()) { + b->set_active_state (Gtkmm2ext::ImplicitActive); + } else { + b->set_active_state (Gtkmm2ext::Off); + } + + } else { + + /* One button per channel; just set active */ + + int j = 0; + for (vector::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i, ++j) { + (*i)->set_active (_route->phase_invert (j)); + } + } --_i_am_the_modifier; } -void -RouteUI::invert_toggled (uint32_t i, BindableToggleButton* b) -{ - if (_i_am_the_modifier) { - return; - } - - uint32_t const N = _route->input()->n_ports().n_audio(); - if (N <= _max_invert_buttons) { - _route->set_phase_invert (i, b->get_active ()); - } else { - boost::dynamic_bitset<> p (N); - if (b->get_active ()) { - p.set (); +bool +RouteUI::invert_release (GdkEventButton* ev, uint32_t i) +{ + if (ev->button == 1 && i < _invert_buttons.size()) { + uint32_t const N = _route->input()->n_ports().n_audio (); + if (N <= _max_invert_buttons) { + /* left-click inverts phase so long as we have a button per channel */ + _route->set_phase_invert (i, !_invert_buttons[i]->get_active()); + return true; } - _route->set_phase_invert (p); } + return false; } + bool RouteUI::invert_press (GdkEventButton* ev) { using namespace Menu_Helpers; - if (ev->button != 3) { + uint32_t const N = _route->input()->n_ports().n_audio(); + if (N <= _max_invert_buttons && ev->button != 3) { + /* If we have an invert button per channel, we only pop + up a menu on right-click; left click is handled + on release. + */ return true; } - + delete _invert_menu; _invert_menu = new Menu; _invert_menu->set_name ("ArdourContextMenu"); MenuList& items = _invert_menu->items (); - uint32_t const N = _route->input()->n_ports().n_audio(); for (uint32_t i = 0; i < N; ++i) { items.push_back (CheckMenuElem (string_compose (X_("Ø%1"), i + 1), sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_menu_toggled), i))); CheckMenuItem* e = dynamic_cast (&items.back ()); @@ -1770,6 +1975,73 @@ RouteUI::invert_menu_toggled (uint32_t c) if (_i_am_the_modifier) { return; } - + _route->set_phase_invert (c, !_route->phase_invert (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 */ + } +} + +/** The Route's gui_changed signal has been emitted */ +void +RouteUI::route_gui_changed (string what_changed) +{ + if (what_changed == "color") { + if (set_color_from_route () == 0) { + route_color_changed (); + } + } +} + +/** @return the color that this route should use; it maybe its own, + or it maybe that of its route group. +*/ +Gdk::Color +RouteUI::color () const +{ + RouteGroup* g = _route->route_group (); + + if (g && g->is_color()) { + return GroupTabs::group_color (g); + } + + return _color; +} + +void +RouteUI::set_showing_sends_to (boost::shared_ptr send_to) +{ + _showing_sends_to = send_to; + BusSendDisplayChanged (send_to); /* EMIT SIGNAL */ +} + +void +RouteUI::bus_send_display_changed (boost::shared_ptr send_to) +{ + if (_route == send_to) { + show_sends_button->set_active (true); + send_blink_connection = ARDOUR_UI::instance()->Blink.connect (sigc::mem_fun (*this, &RouteUI::send_blink)); + } else { + show_sends_button->set_active (false); + send_blink_connection.disconnect (); + } +} + +RouteGroup* +RouteUI::route_group() const +{ + return _route->route_group(); +}