X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=ab83206a8c36f3bf18ffbdcea794f1941a574522;hb=da8eec7a8311295ee91308eca9fae2146385c512;hp=60683855879ec50aa65ebc2d0225cd63002bb93e;hpb=c83389b8ec5fef9553a401e6123b7e55702af9e2;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 6068385587..ab83206a8c 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -35,6 +34,7 @@ #include "ardour_ui.h" #include "editor.h" #include "route_ui.h" +#include "led.h" #include "keyboard.h" #include "utils.h" #include "prompter.h" @@ -50,9 +50,7 @@ #include "ardour/session.h" #include "ardour/audioengine.h" #include "ardour/audio_track.h" -#include "ardour/audio_diskstream.h" #include "ardour/midi_track.h" -#include "ardour/midi_diskstream.h" #include "ardour/template_utils.h" #include "ardour/filename_extensions.h" #include "ardour/directory_names.h" @@ -64,6 +62,8 @@ using namespace Gtkmm2ext; using namespace ARDOUR; using namespace PBD; +uint32_t RouteUI::_max_invert_buttons = 4; + RouteUI::RouteUI (ARDOUR::Session* sess) : AxisView(sess) { @@ -79,9 +79,14 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session* sess) RouteUI::~RouteUI() { + _route.reset (); /* drop reference to route, so that it can be cleaned up */ + route_connections.drop_connections (); + delete solo_menu; delete mute_menu; delete sends_menu; + delete record_menu; + delete _invert_menu; } void @@ -92,28 +97,36 @@ RouteUI::init () mute_menu = 0; solo_menu = 0; sends_menu = 0; + record_menu = 0; + _invert_menu = 0; pre_fader_mute_check = 0; post_fader_mute_check = 0; listen_mute_check = 0; main_mute_check = 0; - ignore_toggle = false; + solo_safe_check = 0; + solo_isolated_check = 0; + solo_isolated_led = 0; + solo_safe_led = 0; _solo_release = 0; _mute_release = 0; route_active_menu_item = 0; - polarity_menu_item = 0; denormal_menu_item = 0; + step_edit_item = 0; multiple_mute_change = false; multiple_solo_change = false; + _i_am_the_modifier = 0; + + setup_invert_buttons (); mute_button = manage (new BindableToggleButton ()); - mute_button->set_self_managed (true); + // mute_button->set_self_managed (true); mute_button->set_name ("MuteButton"); mute_button->add (mute_button_label); mute_button_label.show (); UI::instance()->set_tip (mute_button, _("Mute this track"), ""); solo_button = manage (new BindableToggleButton ()); - solo_button->set_self_managed (true); + // solo_button->set_self_managed (true); solo_button->set_name ("SoloButton"); solo_button->add (solo_button_label); solo_button_label.show (); @@ -122,21 +135,32 @@ RouteUI::init () rec_enable_button = manage (new BindableToggleButton ()); rec_enable_button->set_name ("RecordEnableButton"); - rec_enable_button->set_self_managed (true); + // rec_enable_button->set_self_managed (true); rec_enable_button->add (rec_enable_button_label); rec_enable_button_label.show (); 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->set_self_managed (true); UI::instance()->set_tip (show_sends_button, _("make mixer strips show sends to this bus"), ""); - _session->SoloChanged.connect (_session_connections, boost::bind (&RouteUI::solo_changed_so_update_mute, this), gui_context()); - _session->TransportStateChange.connect (_session_connections, boost::bind (&RouteUI::check_rec_enable_sensitivity, this), gui_context()); - _session->RecordStateChanged.connect (_session_connections, boost::bind (&RouteUI::session_rec_enable_changed, this), gui_context()); + _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()); + + 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); + + show_sends_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_press), false); + show_sends_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_release)); - Config->ParameterChanged.connect (*this, ui_bind (&RouteUI::parameter_changed, this, _1), gui_context()); + solo_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::solo_press), false); + 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); } void @@ -156,7 +180,6 @@ RouteUI::reset () } route_active_menu_item = 0; - polarity_menu_item = 0; denormal_menu_item = 0; } @@ -165,9 +188,6 @@ RouteUI::self_delete () { /* This may be called from a non-GUI thread. Keep it safe */ - cerr << "\n\nExpect to see route " << _route->name() << " be deleted\n"; - _route.reset (); /* drop reference to route, so that it can be cleaned up */ - route_connections.drop_connections (); delete_when_idle (this); } @@ -183,27 +203,40 @@ RouteUI::set_route (boost::shared_ptr rp) } if (self_destruct) { - rp->DropReferences.connect (route_connections, boost::bind (&RouteUI::self_delete, this), gui_context()); + 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, boost::bind (&RouteUI::route_active_changed, this), gui_context()); - _route->mute_changed.connect (route_connections, ui_bind (&RouteUI::mute_changed, this, _1), gui_context()); - _route->solo_changed.connect (route_connections, ui_bind (&RouteUI::solo_changed, this, _1), gui_context()); - _route->listen_changed.connect (route_connections, ui_bind (&RouteUI::listen_changed, this, _1), gui_context()); - _route->solo_isolated_changed.connect (route_connections, ui_bind (&RouteUI::solo_changed, this, _1), gui_context()); + _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->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()); + _route->listen_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); + _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->io_changed.connect (route_connections, invalidator (*this), ui_bind (&RouteUI::setup_invert_buttons, this), gui_context ()); if (_session->writable() && is_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast(_route); - t->diskstream()->RecordEnableChanged.connect (route_connections, boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context()); + 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()); + } + } mute_button->unset_flags (Gtk::CAN_FOCUS); @@ -211,18 +244,26 @@ RouteUI::set_route (boost::shared_ptr rp) mute_button->show(); - if (_route->is_control()) { + if (_route->is_monitor()) { solo_button->hide (); } else { solo_button->show(); } - /* map the current state */ + map_frozen (); - mute_changed (0); - solo_changed (0); + setup_invert_buttons (); + set_invert_button_state (); +} - map_frozen (); +void +RouteUI::polarity_changed () +{ + if (!_route) { + return; + } + + set_invert_button_state (); } bool @@ -234,7 +275,7 @@ RouteUI::mute_press (GdkEventButton* ev) multiple_mute_change = false; - if (!ignore_toggle) { + if (!_i_am_the_modifier) { if (Keyboard::is_context_menu_event (ev)) { @@ -250,9 +291,10 @@ RouteUI::mute_press (GdkEventButton* ev) // Primary-button2 click is the midi binding click // button2-click is "momentary" - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) { - return false; - } + + if (mute_button->on_button_press_event (ev)) { + return true; + } _mute_release = new SoloMuteRelease (_route->muted ()); } @@ -306,7 +348,7 @@ RouteUI::mute_press (GdkEventButton* ev) bool RouteUI::mute_release (GdkEventButton*) { - if (!ignore_toggle) { + if (!_i_am_the_modifier) { if (_mute_release){ _session->set_mute (_mute_release->routes, _mute_release->active, Session::rt_cleanup, true); delete _mute_release; @@ -328,15 +370,18 @@ RouteUI::solo_press(GdkEventButton* ev) multiple_solo_change = false; - if (!ignore_toggle) { + if (!_i_am_the_modifier) { if (Keyboard::is_context_menu_event (ev)) { - if (solo_menu == 0) { - build_solo_menu (); - } - - solo_menu->popup (1, ev->time); + if (!solo_isolated_led) { + + if (solo_menu == 0) { + build_solo_menu (); + } + + solo_menu->popup (1, ev->time); + } } else { @@ -345,11 +390,11 @@ RouteUI::solo_press(GdkEventButton* ev) // Primary-button2 click is the midi binding click // button2-click is "momentary" - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) { - return false; - } + if (solo_button->on_button_press_event (ev)) { + return true; + } - _solo_release = new SoloMuteRelease (_route->soloed()); + _solo_release = new SoloMuteRelease (_route->self_soloed()); } if (ev->button == 1 || Keyboard::is_button2_event (ev)) { @@ -365,7 +410,7 @@ RouteUI::solo_press(GdkEventButton* ev) if (Config->get_solo_control_is_listen_control()) { _session->set_listen (_session->get_routes(), !_route->listening(), Session::rt_cleanup, true); } else { - _session->set_solo (_session->get_routes(), !_route->soloed(), Session::rt_cleanup, true); + _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))) { @@ -415,7 +460,7 @@ RouteUI::solo_press(GdkEventButton* ev) if (Config->get_solo_control_is_listen_control()) { _session->set_listen (_route->route_group()->route_list(), !_route->listening(), Session::rt_cleanup, true); } else { - _session->set_solo (_route->route_group()->route_list(), !_route->soloed(), Session::rt_cleanup, true); + _session->set_solo (_route->route_group()->route_list(), !_route->self_soloed(), Session::rt_cleanup, true); } } @@ -433,7 +478,7 @@ RouteUI::solo_press(GdkEventButton* ev) if (Config->get_solo_control_is_listen_control()) { _session->set_listen (rl, !_route->listening()); } else { - _session->set_solo (rl, !_route->soloed()); + _session->set_solo (rl, !_route->self_soloed()); } } } @@ -446,14 +491,18 @@ RouteUI::solo_press(GdkEventButton* ev) bool RouteUI::solo_release (GdkEventButton*) { - if (!ignore_toggle) { + if (!_i_am_the_modifier) { if (_solo_release) { if (_solo_release->exclusive) { } else { - _session->set_solo (_solo_release->routes, _solo_release->active, Session::rt_cleanup, true); + if (Config->get_solo_control_is_listen_control()) { + _session->set_listen (_solo_release->routes, _solo_release->active, Session::rt_cleanup, true); + } else { + _session->set_solo (_solo_release->routes, _solo_release->active, Session::rt_cleanup, true); + } } delete _solo_release; @@ -477,16 +526,25 @@ RouteUI::rec_enable_press(GdkEventButton* ev) return true; } - if (!ignore_toggle && is_track() && rec_enable_button) { + if (is_midi_track()) { - if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + /* cannot rec-enable while step-editing */ + + if (midi_track()->step_editing()) { + return true; + } + } + + if (!_i_am_the_modifier && is_track() && rec_enable_button) { + + if (Keyboard::is_button2_event (ev)) { // do nothing on midi sigc::bind event - return false; + return rec_enable_button->on_button_press_event (ev); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - _session->set_record_enable (_session->get_routes(), !rec_enable_button->get_active()); + _session->set_record_enabled (_session->get_routes(), !rec_enable_button->get_active()); } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { @@ -494,7 +552,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev) NOTE: Primary-button2 is MIDI learn. */ if (ev->button == 1 && _route->route_group()) { - _session->set_record_enable (_route->route_group()->route_list(), !rec_enable_button->get_active(), Session::rt_cleanup, true); + _session->set_record_enabled (_route->route_group()->route_list(), !rec_enable_button->get_active(), Session::rt_cleanup, true); } } else if (Keyboard::is_context_menu_event (ev)) { @@ -505,16 +563,90 @@ RouteUI::rec_enable_press(GdkEventButton* ev) boost::shared_ptr rl (new RouteList); rl->push_back (route()); - _session->set_record_enable (rl, !rec_enable_button->get_active()); + _session->set_record_enabled (rl, !rec_enable_button->get_active()); } } return true; } +void +RouteUI::build_record_menu () +{ + if (record_menu) { + return; + } + + /* 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))); + step_edit_item = dynamic_cast (&items.back()); + + if (_route->record_enabled()) { + step_edit_item->set_sensitive (false); + } + + step_edit_item->set_active (midi_track()->step_editing()); + } +} + +void +RouteUI::toggle_step_edit () +{ + if (!is_midi_track() || _route->record_enabled()) { + return; + } + + midi_track()->set_step_editing (step_edit_item->get_active()); +} + +void +RouteUI::step_edit_changed (bool yn) +{ + if (yn) { + if (rec_enable_button) { + rec_enable_button->set_visual_state (3); + } + + start_step_editing (); + + if (step_edit_item) { + step_edit_item->set_active (true); + } + + } else { + + if (rec_enable_button) { + rec_enable_button->set_visual_state (0); + } + + stop_step_editing (); + + if (step_edit_item) { + step_edit_item->set_active (false); + } + } +} + bool -RouteUI::rec_enable_release (GdkEventButton*) +RouteUI::rec_enable_release (GdkEventButton* ev) { + if (Keyboard::is_context_menu_event (ev)) { + build_record_menu (); + if (record_menu) { + record_menu->popup (1, ev->time); + } + return true; + } + return true; } @@ -589,7 +721,7 @@ RouteUI::show_sends_press(GdkEventButton* ev) return true; } - if (!ignore_toggle && !is_track() && show_sends_button) { + if (!_i_am_the_modifier && !is_track() && show_sends_button) { if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { @@ -648,23 +780,10 @@ RouteUI::send_blink (bool onoff) } } -void -RouteUI::solo_changed(void* /*src*/) -{ - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteUI::update_solo_display, this)); -} - - -void -RouteUI::listen_changed(void* /*src*/) -{ - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteUI::update_solo_display, this)); -} - int RouteUI::solo_visual_state (boost::shared_ptr r) { - if (r->is_master() || r->is_control()) { + if (r->is_master() || r->is_monitor()) { return 0; } @@ -679,7 +798,11 @@ RouteUI::solo_visual_state (boost::shared_ptr r) } if (r->soloed()) { - return 1; + if (!r->self_soloed()) { + return 3; + } else { + return 1; + } } else { return 0; } @@ -688,7 +811,7 @@ RouteUI::solo_visual_state (boost::shared_ptr r) int RouteUI::solo_visual_state_with_isolate (boost::shared_ptr r) { - if (r->is_master() || r->is_control()) { + if (r->is_master() || r->is_monitor()) { return 0; } @@ -697,7 +820,7 @@ RouteUI::solo_visual_state_with_isolate (boost::shared_ptr r) if (r->listening()) { return 1; } else { - return 0; + return 0; } } @@ -705,7 +828,11 @@ RouteUI::solo_visual_state_with_isolate (boost::shared_ptr r) if (r->solo_isolated()) { return 2; } else if (r->soloed()) { - return 1; + if (!r->self_soloed()) { + return 3; + } else { + return 1; + } } else { return 0; } @@ -714,12 +841,26 @@ RouteUI::solo_visual_state_with_isolate (boost::shared_ptr r) int RouteUI::solo_isolate_visual_state (boost::shared_ptr r) { - if (r->is_master() || r->is_control()) { + if (r->is_master() || r->is_monitor()) { return 0; } if (r->solo_isolated()) { - return 1; + 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; } else { return 0; } @@ -733,50 +874,76 @@ RouteUI::update_solo_display () if (Config->get_solo_control_is_listen_control()) { if (solo_button->get_active() != (x = _route->listening())) { - ignore_toggle = true; + ++_i_am_the_modifier; solo_button->set_active(x); - ignore_toggle = false; + --_i_am_the_modifier; } } else { if (solo_button->get_active() != (x = _route->soloed())) { - ignore_toggle = true; + ++_i_am_the_modifier; solo_button->set_active (x); - ignore_toggle = false; + --_i_am_the_modifier; } } - solo_button->set_visual_state (solo_visual_state_with_isolate (_route)); + bool yn = _route->solo_safe (); + + if (solo_safe_check && solo_safe_check->get_active() != yn) { + solo_safe_check->set_active (yn); + } + + yn = _route->solo_isolated (); + + if (solo_isolated_check && solo_isolated_check->get_active() != yn) { + solo_isolated_check->set_active (yn); + } + + set_button_names (); + + if (solo_isolated_led) { + solo_isolated_led->set_visual_state (_route->solo_isolated() ? 1 : 0); + } + + if (solo_safe_led) { + solo_safe_led->set_visual_state (_route->solo_safe() ? 1 : 0); + } + + solo_button->set_visual_state (solo_visual_state (_route)); + + /* some changes to solo status can affect mute display, so catch up + */ + + update_mute_display (); } void RouteUI::solo_changed_so_update_mute () { - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteUI::update_mute_display, this)); + update_mute_display (); } void RouteUI::mute_changed(void* /*src*/) { - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteUI::update_mute_display, this)); + update_mute_display (); } int RouteUI::mute_visual_state (Session* s, boost::shared_ptr r) { - if (r->is_master() || r->is_control()) { + if (r->is_master() || r->is_monitor()) { return 0; } - + if (Config->get_show_solo_mutes()) { - + if (r->muted ()) { /* full mute */ return 2; } else if (s->soloing() && !r->soloed() && !r->solo_isolated()) { - /* mute-because-not-soloed */ return 1; } else { /* no mute at all */ @@ -800,6 +967,10 @@ RouteUI::mute_visual_state (Session* s, boost::shared_ptr r) void RouteUI::update_mute_display () { + if (!_route) { + return; + } + bool model = _route->muted(); bool view = mute_button->get_active(); @@ -808,9 +979,9 @@ RouteUI::update_mute_display () */ if (model != view) { - ignore_toggle = true; + ++_i_am_the_modifier; mute_button->set_active (model); - ignore_toggle = false; + --_i_am_the_modifier; } mute_button->set_visual_state (mute_visual_state (_session, _route)); @@ -819,23 +990,19 @@ RouteUI::update_mute_display () void RouteUI::route_rec_enable_changed () { - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteUI::update_rec_display, this)); + update_rec_display (); } void RouteUI::session_rec_enable_changed () { - if (!rec_enable_button) { - return; - } - - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&RouteUI::update_rec_display, this)); + update_rec_display (); } void RouteUI::update_rec_display () { - if (!rec_enable_button) { + if (!rec_enable_button || !_route) { return; } @@ -847,30 +1014,38 @@ RouteUI::update_rec_display () */ if (model != view) { - ignore_toggle = true; + ++_i_am_the_modifier; rec_enable_button->set_active (model); - ignore_toggle = false; + --_i_am_the_modifier; } /* now make sure its color state is correct */ if (model) { - - switch (_session->record_status ()) { - case Session::Recording: - rec_enable_button->set_visual_state (1); - break; - - case Session::Disabled: - case Session::Enabled: - rec_enable_button->set_visual_state (2); - break; - - } + switch (_session->record_status ()) { + case Session::Recording: + rec_enable_button->set_visual_state (1); + break; + + case Session::Disabled: + case Session::Enabled: + rec_enable_button->set_visual_state (2); + break; + + } + + if (step_edit_item) { + step_edit_item->set_sensitive (false); + } } else { rec_enable_button->set_visual_state (0); + + if (step_edit_item) { + step_edit_item->set_sensitive (true); + } } + check_rec_enable_sensitivity (); } @@ -888,15 +1063,15 @@ RouteUI::build_solo_menu (void) check = new CheckMenuItem(_("Solo Isolate")); check->set_active (_route->solo_isolated()); check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_isolated), check)); - _route->solo_isolated_changed.connect (route_connections, ui_bind (&RouteUI::solo_isolated_toggle, this, _1, check), gui_context()); items.push_back (CheckMenuElem(*check)); + solo_isolated_check = dynamic_cast(&items.back()); check->show_all(); check = new CheckMenuItem(_("Solo Safe")); check->set_active (_route->solo_safe()); check->signal_toggled().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_solo_safe), check)); - _route->solo_safe_changed.connect (route_connections, ui_bind (&RouteUI::solo_safe_toggle, this, _1, check), gui_context()); items.push_back (CheckMenuElem(*check)); + solo_safe_check = dynamic_cast(&items.back()); check->show_all(); //items.push_back (SeparatorElem()); @@ -941,7 +1116,7 @@ RouteUI::build_mute_menu(void) //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, boost::bind (&RouteUI::muting_change, this), gui_context()); + _route->mute_points_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::muting_change, this), gui_context()); } void @@ -993,10 +1168,59 @@ RouteUI::muting_change () } } +bool +RouteUI::solo_isolate_button_release (GdkEventButton* ev) +{ + if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) { + return true; + } + + bool view = (solo_isolated_led->visual_state() != 0); + bool model = _route->solo_isolated(); + + /* called BEFORE the view has changed */ + + if (ev->button == 1) { + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + + if (model) { + /* disable isolate for all routes */ + _session->set_solo_isolated (_session->get_routes(), false, Session::rt_cleanup, true); + } + + } else { + if (model == view) { + + /* flip just this route */ + + boost::shared_ptr rl (new RouteList); + rl->push_back (_route); + _session->set_solo_isolated (rl, !view, Session::rt_cleanup, true); + } + } + } + + return true; +} + +bool +RouteUI::solo_safe_button_release (GdkEventButton*) +{ + _route->set_solo_safe (!(solo_safe_led->visual_state() > 0), this); + return true; +} + void RouteUI::toggle_solo_isolated (Gtk::CheckMenuItem* check) { - _route->set_solo_isolated (check->get_active(), this); + bool view = check->get_active(); + bool model = _route->solo_isolated(); + + /* called AFTER the view has changed */ + + if (model != view) { + _route->set_solo_isolated (view, this); + } } void @@ -1011,7 +1235,7 @@ RouteUI::choose_color() bool picked; Gdk::Color color; - color = Gtkmm2ext::UI::instance()->get_color (_("ardour: color selection"), picked, &_color); + color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color); if (picked) { set_color (color); @@ -1047,7 +1271,7 @@ RouteUI::ensure_xml_node () } XMLNode* -RouteUI::get_automation_child_xml_node (Evoral::Parameter param) +RouteUI::get_automation_child_xml_node (Evoral::Parameter param, int version) { ensure_xml_node (); @@ -1057,10 +1281,17 @@ RouteUI::get_automation_child_xml_node (Evoral::Parameter param) const string sym = ARDOUR::EventTypeMap::instance().to_symbol(param); for (iter = kids.begin(); iter != kids.end(); ++iter) { - if ((*iter)->name() == AutomationTimeAxisView::state_node_name) { - XMLProperty* type = (*iter)->property("automation-id"); - if (type && type->value() == sym) + + 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; + } } } @@ -1093,19 +1324,45 @@ RouteUI::set_color_from_route () void RouteUI::remove_this_route () { + 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 (_( +"Removing the master or monitor bus is such a bad idea\n\ +that %1 is not going to allow it.\n\ +\n\ +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; + } + 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(cannot be undone)"), _route->name()); + 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(cannot be undone)"), _route->name()); + 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()); } choices.push_back (_("No, do nothing.")); choices.push_back (_("Yes, remove it.")); - Choice prompter (prompt, choices); + string title; + if (is_track()) { + title = _("Remove track"); + } else { + title = _("Remove bus"); + } + + Choice prompter (title, prompt, choices); if (prompter.run () == 1) { Glib::signal_idle().connect (sigc::bind (sigc::ptr_fun (&RouteUI::idle_remove_this_route), this)); @@ -1115,7 +1372,7 @@ RouteUI::remove_this_route () gint RouteUI::idle_remove_this_route (RouteUI *rui) { - rui->_session->remove_route (rui->_route); + rui->_session->remove_route (rui->route()); return false; } @@ -1124,17 +1381,21 @@ RouteUI::route_rename () { ArdourPrompter name_prompter (true); string result; - name_prompter.set_prompt (_("New Name: ")); + if (is_track()) { + name_prompter.set_title (_("Rename Track")); + } else { + name_prompter.set_title (_("Rename Bus")); + } + name_prompter.set_prompt (_("New name:")); name_prompter.set_initial_text (_route->name()); name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT); name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false); name_prompter.show_all (); switch (name_prompter.run ()) { - case Gtk::RESPONSE_ACCEPT: - name_prompter.get_result (result); - if (result.length()) { + name_prompter.get_result (result); + if (result.length()) { _route->set_name (result); } break; @@ -1145,11 +1406,11 @@ RouteUI::route_rename () } void -RouteUI::name_changed () +RouteUI::property_changed (const PropertyChange& what_changed) { - ENSURE_GUI_THREAD (*this, &RouteUI::name_changed); - - name_label.set_text (_route->name()); + if (what_changed.contains (ARDOUR::Properties::name)) { + name_label.set_text (_route->name()); + } } void @@ -1168,39 +1429,10 @@ void RouteUI::route_active_changed () { if (route_active_menu_item) { - Gtkmm2ext::UI::instance()->call_slot (boost::bind (&CheckMenuItem::set_active, route_active_menu_item, _route->active())); - } -} - -void -RouteUI::toggle_polarity () -{ - if (polarity_menu_item) { - - bool x; - - ENSURE_GUI_THREAD (*this, &RouteUI::toggle_polarity) - - if ((x = polarity_menu_item->get_active()) != _route->phase_invert()) { - _route->set_phase_invert (x); - if (x) { - name_label.set_text (X_("Ø ") + name_label.get_text()); - } else { - name_label.set_text (_route->name()); - } - } + Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&CheckMenuItem::set_active, route_active_menu_item, _route->active())); } } -void -RouteUI::polarity_changed () -{ - if (_route->phase_invert()) { - name_label.set_text (X_("Ø ") + name_label.get_text()); - } else { - name_label.set_text (_route->name()); - } -} void RouteUI::toggle_denormal_protection () @@ -1225,27 +1457,6 @@ RouteUI::denormal_protection_changed () } } -void -RouteUI::solo_isolated_toggle(void* /*src*/, Gtk::CheckMenuItem* check) -{ - bool yn = _route->solo_isolated (); - - if (check->get_active() != yn) { - check->set_active (yn); - } -} - - -void -RouteUI::solo_safe_toggle(void* /*src*/, Gtk::CheckMenuItem* check) -{ - bool yn = _route->solo_safe (); - - if (check->get_active() != yn) { - check->set_active (yn); - } -} - void RouteUI::disconnect_input () { @@ -1294,16 +1505,10 @@ RouteUI::midi_track() const return boost::dynamic_pointer_cast(_route); } -boost::shared_ptr -RouteUI::get_diskstream () const +bool +RouteUI::has_audio_outputs () const { - boost::shared_ptr t; - - if ((t = boost::dynamic_pointer_cast(_route)) != 0) { - return t->diskstream(); - } else { - return boost::shared_ptr ((Diskstream*) 0); - } + return (_route->n_outputs().n_audio() > 0); } string @@ -1341,7 +1546,7 @@ void RouteUI::save_as_template () { sys::path path; - Glib::ustring safe_name; + std::string safe_name; string name; path = ARDOUR::user_route_template_directory (); @@ -1353,6 +1558,7 @@ RouteUI::save_as_template () Prompter p (true); // modal + p.set_title (_("Save As Template")); p.set_prompt (_("Template name:")); switch (p.run()) { case RESPONSE_ACCEPT: @@ -1385,8 +1591,6 @@ RouteUI::check_rec_enable_sensitivity () void RouteUI::parameter_changed (string const & p) { - ENSURE_GUI_THREAD (*this, &RouteUI::parameter_changed, p) - if (p == "disable-disarm-during-roll") { check_rec_enable_sensitivity (); } else if (p == "solo-control-is-listen-control") { @@ -1448,3 +1652,123 @@ RouteUI::open_remote_control_id_dialog () _route->set_remote_control_id (spin->get_value_as_int ()); } } + +void +RouteUI::setup_invert_buttons () +{ + /* remove old invert buttons */ + for (list::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i) { + _invert_button_box.remove (**i); + } + + _invert_buttons.clear (); + + if (!_route || !_route->input()) { + return; + } + + uint32_t const N = _route->input()->n_ports().n_audio (); + + 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)); + b->signal_button_press_event().connect (sigc::mem_fun (*this, &RouteUI::invert_press)); + + b->set_name (X_("MixerInvertButton")); + if (to_add == 1) { + b->add (*manage (new Label (X_("Ø")))); + } else { + b->add (*manage (new Label (string_compose (X_("Ø%1"), i + 1)))); + } + + if (N <= 4) { + 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)); + } + + _invert_buttons.push_back (b); + _invert_button_box.pack_start (*b); + } + + _invert_button_box.show_all (); +} + +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)); + } + + --_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 (); + } + _route->set_phase_invert (p); + } +} + +bool +RouteUI::invert_press (GdkEventButton* ev) +{ + using namespace Menu_Helpers; + + if (ev->button != 3) { + 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 ()); + ++_i_am_the_modifier; + e->set_active (_route->phase_invert (i)); + --_i_am_the_modifier; + } + + _invert_menu->popup (0, ev->time); + + return false; +} + +void +RouteUI::invert_menu_toggled (uint32_t c) +{ + if (_i_am_the_modifier) { + return; + } + + _route->set_phase_invert (c, !_route->phase_invert (c)); +}