X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=68c9a0909e103a538efa4e64cb89d65505b2e97c;hb=2dc3c8b3650266eba09cf7fe53c39c6728d4d5b6;hp=424e59aee4c4b32965958550519431b79fe3ce8d;hpb=e279b9892b467aa823e253d97b6e9504cca0e252;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 424e59aee4..68c9a0909e 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -17,74 +17,129 @@ */ -#include -#include -#include -#include -#include -#include +#include +#include + +#include -#include "ardour/route_group.h" -#include "ardour/dB.h" #include "pbd/memento_command.h" #include "pbd/stacktrace.h" #include "pbd/controllable.h" #include "pbd/enumwriter.h" -#include "ardour_ui.h" -#include "editor.h" -#include "route_ui.h" -#include "ardour_button.h" -#include "keyboard.h" -#include "utils.h" -#include "prompter.h" -#include "gui_thread.h" -#include "ardour_dialog.h" -#include "latency_gui.h" -#include "mixer_strip.h" -#include "automation_time_axis.h" -#include "route_time_axis.h" -#include "group_tabs.h" - +#include "ardour/dB.h" +#include "ardour/route_group.h" +#include "ardour/solo_isolate_control.h" +#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" #include "ardour/route.h" #include "ardour/session.h" #include "ardour/template_utils.h" -#include "i18n.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 "group_tabs.h" +#include "gui_object.h" +#include "gui_thread.h" +#include "keyboard.h" +#include "latency_gui.h" +#include "mixer_strip.h" +#include "patch_change_widget.h" +#include "plugin_pin_dialog.h" +#include "rgb_macros.h" +#include "route_time_axis.h" +#include "route_ui.h" +#include "save_template_dialog.h" +#include "timers.h" +#include "ui_config.h" +#include "utils.h" + +#include "pbd/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; uint32_t RouteUI::_max_invert_buttons = 3; PBD::Signal1 > RouteUI::BusSendDisplayChanged; boost::weak_ptr RouteUI::_showing_sends_to; +std::string RouteUI::program_port_prefix; RouteUI::RouteUI (ARDOUR::Session* sess) - : AxisView(sess) + : monitor_input_button (0) + , monitor_disk_button (0) , mute_menu(0) , solo_menu(0) , sends_menu(0) , record_menu(0) + , comment_window(0) + , comment_area(0) + , input_selector (0) + , output_selector (0) , _invert_menu(0) { - if (sess) init (); + if (program_port_prefix.empty()) { + // compare to gtk2_ardour/port_group.cc + string lpn (PROGRAM_NAME); + boost::to_lower (lpn); + program_port_prefix = lpn + ":"; // e.g. "ardour:" + } + + if (sess) { + init (); + } } RouteUI::~RouteUI() { + if (_route) { + 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 (); delete solo_menu; delete mute_menu; delete sends_menu; - delete record_menu; + delete record_menu; + delete comment_window; + delete input_selector; + delete output_selector; + delete monitor_input_button; + delete monitor_disk_button; delete _invert_menu; + + send_blink_connection.disconnect (); + rec_blink_connection.disconnect (); } void @@ -94,24 +149,28 @@ RouteUI::init () mute_menu = 0; solo_menu = 0; sends_menu = 0; - record_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; - solo_safe_check = 0; - solo_isolated_check = 0; - solo_isolated_led = 0; - solo_safe_led = 0; + solo_safe_check = 0; + solo_isolated_check = 0; + solo_isolated_led = 0; + solo_safe_led = 0; _solo_release = 0; _mute_release = 0; denormal_menu_item = 0; - step_edit_item = 0; + step_edit_item = 0; + rec_safe_item = 0; multiple_mute_change = false; multiple_solo_change = false; _i_am_the_modifier = 0; + input_selector = 0; + output_selector = 0; + setup_invert_buttons (); mute_button = manage (new ArdourButton); @@ -125,20 +184,24 @@ RouteUI::init () rec_enable_button = manage (new ArdourButton); rec_enable_button->set_name ("record enable button"); - rec_enable_button->set_tweaks (ArdourButton::ImplicitUsesSolidColor); + rec_enable_button->set_icon (ArdourIcon::RecButton); UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), ""); + if (UIConfiguration::instance().get_blink_rec_arm()) { + rec_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display)); + } + 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 = 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"), ""); @@ -150,26 +213,27 @@ RouteUI::init () _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); 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)); + show_sends_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::show_sends_release), false); 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); - + 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_input_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_input_press), false); + monitor_input_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_input_release), false); - 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)); + monitor_disk_button->signal_button_press_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_disk_press), false); + monitor_disk_button->signal_button_release_event().connect (sigc::mem_fun(*this, &RouteUI::monitor_disk_release), false); BusSendDisplayChanged.connect_same_thread (*this, boost::bind(&RouteUI::bus_send_display_changed, this, _1)); } @@ -185,6 +249,9 @@ RouteUI::reset () delete mute_menu; mute_menu = 0; + delete_patch_change_dialog (); + _color_picker.reset (); + denormal_menu_item = 0; } @@ -201,55 +268,103 @@ 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 (unique_random_color()); + set_color (gdk_color_to_rgba (AxisView::unique_random_color ())); } if (self_destruct) { rp->DropReferences.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::self_delete, this), gui_context()); } + delete input_selector; + input_selector = 0; + + delete output_selector; + output_selector = 0; + 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), 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()); - _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->comment_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::comment_changed, this), gui_context()); + + _route->mute_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_mute_display, this), gui_context()); + _route->solo_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_solo_display, this), gui_context()); + _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, true, true), gui_context()); + + if (is_track()) { + track()->FreezeChange.connect (*this, invalidator (*this), boost::bind (&RouteUI::map_frozen, this), gui_context()); + track_mode_changed(); + } + - _route->phase_invert_changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::polarity_changed, this), gui_context()); - _route->PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::property_changed, this, _1), gui_context()); + _route->PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_property_changed, this, _1), gui_context()); + _route->presentation_info().PropertyChanged.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_gui_changed, this, _1), 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()); - + t->rec_enable_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::route_rec_enable_changed, this), gui_context()); + t->rec_safe_control()->Changed.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()); + 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()); + } - } + } /* 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()); + t->monitoring_control()->Changed.connect (route_connections, invalidator (*this), boost::bind (&RouteUI::update_monitoring_display, this), gui_context()); update_monitoring_display (); } @@ -275,14 +390,23 @@ RouteUI::set_route (boost::shared_ptr rp) update_mute_display (); update_solo_display (); + + if (!UIConfiguration::instance().get_blink_rec_arm()) { + blink_rec_display(true); // set initial rec-en button state + } + + 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 (); } @@ -294,121 +418,170 @@ RouteUI::mute_press (GdkEventButton* ev) return true; } - multiple_mute_change = false; - - if (!_i_am_the_modifier) { + //if this is a binding action, let the ArdourButton handle it + if (BindingProxy::is_bind_action(ev) ) + return false; - if (Keyboard::is_context_menu_event (ev)) { + multiple_mute_change = false; - if (mute_menu == 0){ - build_mute_menu(); - } + if (Keyboard::is_context_menu_event (ev)) { - mute_menu->popup(0,ev->time); + if (mute_menu == 0){ + build_mute_menu(); + } - } else { + mute_menu->popup(0,ev->time); - if (Keyboard::is_button2_event (ev)) { - // Primary-button2 click is the midi binding click - // button2-click is "momentary" + return true; + } else { - if (mute_button->on_button_press_event (ev)) { - return true; - } + if (Keyboard::is_button2_event (ev)) { + // button2-click is "momentary" - _mute_release = new SoloMuteRelease (_route->muted ()); - } + _mute_release = new SoloMuteRelease (_route->mute_control()->muted ()); + } - if (ev->button == 1 || Keyboard::is_button2_event (ev)) { + if (ev->button == 1 || Keyboard::is_button2_event (ev)) { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + 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); + /* 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. + */ - *copy = *_session->get_routes (); + boost::shared_ptr copy (new RouteList); - for (RouteList::iterator i = copy->begin(); i != copy->end(); ) { - if ((*i)->is_master() || (*i)->is_monitor()) { - i = copy->erase (i); - } else { - ++i; - } - } + *copy = *_session->get_routes (); - if (_mute_release) { - _mute_release->routes = copy; + for (RouteList::iterator i = copy->begin(); i != copy->end(); ) { + if ((*i)->is_master() || (*i)->is_monitor()) { + i = copy->erase (i); + } else { + ++i; } + } - _session->set_mute (copy, !_route->muted()); - - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - - /* Primary-button1 applies change to the mix group even if it is not active - NOTE: Primary-button2 is MIDI learn. - */ + if (_mute_release) { + _mute_release->routes = copy; + } - boost::shared_ptr rl; + _session->set_controls (route_list_to_control_list (copy, &Stripable::mute_control), _route->muted_by_self() ? 0.0 : 1.0, Controllable::UseGroup); - if (ev->button == 1) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - 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); - } + /* Primary-button1 inverts the implication of + the group being active. If the group is + active (for mute), then this modifier means + "do not apply to mute". If the group is + inactive (for mute), then this modifier + means "apply to route". This is all + accomplished by passing just the actual + route, along with the InverseGroup group + control disposition. - _session->set_mute (rl, !_route->muted(), Session::rt_cleanup, true); - } + NOTE: Primary-button2 is MIDI learn. + */ - } else { + boost::shared_ptr rl; - /* plain click applies change to this route */ + if (ev->button == 1) { - boost::shared_ptr rl (new RouteList); + rl.reset (new RouteList); rl->push_back (_route); - + if (_mute_release) { _mute_release->routes = rl; } - _session->set_mute (rl, !_route->muted()); + 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); + } + + } 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; } + + boost::shared_ptr mc = _route->mute_control(); + mc->start_touch (_session->audible_sample ()); + mc->set_value (!_route->muted_by_self(), Controllable::UseGroup); } } - } - return true; + return false; } bool -RouteUI::mute_release (GdkEventButton*) +RouteUI::mute_release (GdkEventButton* /*ev*/) +{ + if (_mute_release){ + _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; +} + +void +RouteUI::edit_output_configuration () { - if (!_i_am_the_modifier) { - if (_mute_release){ - _session->set_mute (_mute_release->routes, _mute_release->active, Session::rt_cleanup, true); - delete _mute_release; - _mute_release = 0; + if (output_selector == 0) { + + boost::shared_ptr send; + boost::shared_ptr output; + + if ((send = boost::dynamic_pointer_cast(_current_delivery)) != 0) { + if (!boost::dynamic_pointer_cast(send)) { + output = send->output(); + } else { + output = _route->output (); + } + } else { + output = _route->output (); } + + output_selector = new IOSelectorWindow (_session, output); } - return true; + if (output_selector->is_visible()) { + output_selector->get_toplevel()->get_window()->raise(); + } else { + output_selector->present (); + } + + //output_selector->set_keep_above (true); +} + +void +RouteUI::edit_input_configuration () +{ + if (input_selector == 0) { + input_selector = new IOSelectorWindow (_session, _route->input()); + } + + if (input_selector->is_visible()) { + input_selector->get_toplevel()->get_window()->raise(); + } else { + input_selector->present (); + } + + //input_selector->set_keep_above (true); } bool @@ -420,164 +593,173 @@ RouteUI::solo_press(GdkEventButton* ev) return true; } - multiple_solo_change = false; - - if (!_i_am_the_modifier) { - - if (Keyboard::is_context_menu_event (ev)) { + //if this is a binding action, let the ArdourButton handle it + if (BindingProxy::is_bind_action(ev) ) + return false; - if (! (solo_isolated_led && solo_isolated_led->is_visible()) || - ! (solo_safe_led && solo_safe_led->is_visible())) { + multiple_solo_change = false; - if (solo_menu == 0) { - build_solo_menu (); - } + if (Keyboard::is_context_menu_event (ev)) { - solo_menu->popup (1, ev->time); - } + if (! (solo_isolated_led && solo_isolated_led->is_visible()) || + ! (solo_safe_led && solo_safe_led->is_visible())) { - } else { + if (solo_menu == 0) { + build_solo_menu (); + } - if (Keyboard::is_button2_event (ev)) { + solo_menu->popup (1, ev->time); + } - // Primary-button2 click is the midi binding click - // button2-click is "momentary" + } else { - if (solo_button->on_button_press_event (ev)) { - return true; - } + if (Keyboard::is_button2_event (ev)) { - _solo_release = new SoloMuteRelease (_route->self_soloed()); - } + // button2-click is "momentary" + _solo_release = new SoloMuteRelease (_route->self_soloed()); + } - if (ev->button == 1 || Keyboard::is_button2_event (ev)) { + if (ev->button == 1 || Keyboard::is_button2_event (ev)) { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - /* Primary-Tertiary-click applies change to all routes */ + /* Primary-Tertiary-click applies change to all routes */ - if (_solo_release) { - _solo_release->routes = _session->get_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_via_monitor(), Session::rt_cleanup, true); - } else { - _session->set_solo (_session->get_routes(), !_route->self_soloed(), Session::rt_cleanup, true); - } + _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))) { + } 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; + 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) { - if ((*i)->soloed ()) { - _solo_release->routes_on->push_back (*i); - } else { - _solo_release->routes_off->push_back (*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 { + _solo_release->routes_off->push_back (*i); } } + } - if (Config->get_solo_control_is_listen_control()) { - /* ??? we need a just_one_listen() method */ - } else { - _session->set_just_one_solo (_route, true); + 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); - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { - - // shift-click: toggle solo isolated status + if (Config->get_solo_control_is_listen_control()) { + /* ??? we need a just_one_listen() method */ + } else { + DisplaySuspender ds; + _route->solo_control()->set_value (1.0, Controllable::NoGroup); + } - _route->set_solo_isolated (!_route->solo_isolated(), this); - delete _solo_release; - _solo_release = 0; + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + // shift-click: toggle solo isolated status - /* Primary-button1: solo mix group. - NOTE: Primary-button2 is MIDI learn. - */ + _route->solo_isolate_control()->set_value (_route->solo_isolate_control()->get_value() ? 0.0 : 1.0, Controllable::UseGroup); + delete _solo_release; + _solo_release = 0; - /* Primary-button1 applies change to the mix group even if it is not active - NOTE: Primary-button2 is MIDI learn. - */ + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - boost::shared_ptr rl; + /* Primary-button1: solo mix group. + NOTE: Primary-button2 is MIDI learn. + */ - if (ev->button == 1) { + /* Primary-button1 applies change to the mix group even if it is not active + NOTE: Primary-button2 is MIDI learn. + */ - 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); - } + boost::shared_ptr rl; - if (Config->get_solo_control_is_listen_control()) { - _session->set_listen (rl, !_route->listening_via_monitor(), Session::rt_cleanup, true); - } else { - _session->set_solo (rl, !_route->self_soloed(), Session::rt_cleanup, true); - } - } + if (ev->button == 1) { - } else { + /* Primary-button1 inverts the implication of + the group being active. If the group is + active (for solo), then this modifier means + "do not apply to solo". If the group is + inactive (for mute), then this modifier + means "apply to route". This is all + accomplished by passing just the actual + route, along with the InverseGroup group + control disposition. - /* click: solo this route */ + NOTE: Primary-button2 is MIDI learn. + */ - boost::shared_ptr rl (new RouteList); - rl->push_back (route()); + rl.reset (new RouteList); + rl->push_back (_route); if (_solo_release) { _solo_release->routes = rl; } - if (Config->get_solo_control_is_listen_control()) { - _session->set_listen (rl, !_route->listening_via_monitor()); - } else { - _session->set_solo (rl, !_route->self_soloed()); - } + _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), !_route->self_soloed(), Controllable::InverseGroup); + } + + delete _solo_release; + _solo_release = 0; + + } else { + + /* click: solo this route */ + + boost::shared_ptr rl (new RouteList); + rl->push_back (route()); + + if (_solo_release) { + _solo_release->routes = rl; } + + _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_control), !_route->self_soloed(), Controllable::UseGroup); } } } - return true; + return false; } bool -RouteUI::solo_release (GdkEventButton*) +RouteUI::solo_release (GdkEventButton* /*ev*/) { - if (!_i_am_the_modifier) { - - if (_solo_release) { - - if (_solo_release->exclusive) { - - } else { - 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; - _solo_release = 0; + 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 { + _session->set_controls (route_list_to_control_list (_solo_release->routes, &Stripable::solo_control), _solo_release->active ? 1.0 : 0.0, Controllable::UseGroup); } + + delete _solo_release; + _solo_release = 0; } - return true; + return false; } bool @@ -587,32 +769,34 @@ RouteUI::rec_enable_press(GdkEventButton* ev) return true; } - if (!_session->engine().connected()) { - MessageDialog msg (_("Not connected to JACK - cannot engage record")); - msg.run (); - return true; + //if this is a binding action, let the ArdourButton handle it + if (BindingProxy::is_bind_action(ev) ) + return false; + + if (!ARDOUR_UI_UTILS::engine_is_running ()) { + return false; } - if (is_midi_track()) { + if (is_midi_track()) { - /* rec-enable button exits from step editing */ + /* rec-enable button exits from step editing */ - if (midi_track()->step_editing()) { + if (midi_track()->step_editing()) { midi_track()->set_step_editing (false); - return true; - } - } + return false; + } + } - if (!_i_am_the_modifier && is_track() && rec_enable_button) { + if (is_track() && rec_enable_button) { if (Keyboard::is_button2_event (ev)) { - // do nothing on midi sigc::bind event - return rec_enable_button->on_button_press_event (ev); + //rec arm does not have a momentary mode + return false; } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - _session->set_record_enabled (_session->get_routes(), !rec_enable_button->active_state()); + _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)) { @@ -623,17 +807,11 @@ RouteUI::rec_enable_press(GdkEventButton* ev) 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); + + rl.reset (new RouteList); + rl->push_back (_route); + + _session->set_controls (route_list_to_control_list (rl, &Stripable::rec_enable_control), !track()->rec_enable_control()->get_value(), Controllable::InverseGroup); } } else if (Keyboard::is_context_menu_event (ev)) { @@ -642,19 +820,12 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } else { - boost::shared_ptr rl (new RouteList); - rl->push_back (route()); - _session->set_record_enabled (rl, !rec_enable_button->active_state()); + boost::shared_ptr trk = track(); + trk->rec_enable_control()->set_value (!trk->rec_enable_control()->get_value(), Controllable::UseGroup); } } - return true; -} - -void -RouteUI::monitoring_changed () -{ - update_monitoring_display (); + return false; } void @@ -672,7 +843,7 @@ RouteUI::update_monitoring_display () MonitorState ms = t->monitoring_state(); - if (t->monitoring_choice() & MonitorInput) { + if (t->monitoring_control()->monitoring_choice() & MonitorInput) { monitor_input_button->set_active_state (Gtkmm2ext::ExplicitActive); } else { if (ms & MonitoringInput) { @@ -682,7 +853,7 @@ RouteUI::update_monitoring_display () } } - if (t->monitoring_choice() & MonitorDisk) { + if (t->monitoring_control()->monitoring_choice() & MonitorDisk) { monitor_disk_button->set_active_state (Gtkmm2ext::ExplicitActive); } else { if (ms & MonitoringDisk) { @@ -696,7 +867,7 @@ RouteUI::update_monitoring_display () bool RouteUI::monitor_input_press(GdkEventButton*) { - return true; + return false; } bool @@ -708,7 +879,7 @@ RouteUI::monitor_input_release(GdkEventButton* ev) bool RouteUI::monitor_disk_press (GdkEventButton*) { - return true; + return false; } bool @@ -719,7 +890,7 @@ RouteUI::monitor_disk_release (GdkEventButton* ev) bool RouteUI::monitor_release (GdkEventButton* ev, MonitorChoice monitor_choice) -{ +{ if (ev->button != 1) { return false; } @@ -732,118 +903,132 @@ 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_choice() & monitor_choice) { - mc = MonitorChoice (t->monitoring_choice() & ~monitor_choice); + 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))) { + 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); } - _session->set_monitoring (rl, mc, Session::rt_cleanup, true); - - return true; + return false; } void RouteUI::build_record_menu () { - if (record_menu) { - return; - } + if (!record_menu) { + record_menu = new Menu; + record_menu->set_name ("ArdourContextMenu"); + using namespace Menu_Helpers; + MenuList& items = record_menu->items(); - /* no rec-button context menu for non-MIDI tracks - */ + items.push_back (CheckMenuElem (_("Rec-Safe"), sigc::mem_fun (*this, &RouteUI::toggle_rec_safe))); + rec_safe_item = dynamic_cast (&items.back()); - 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 Entry"), 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); - } + if (is_midi_track()) { + items.push_back (SeparatorElem()); + items.push_back (CheckMenuElem (_("Step Entry"), sigc::mem_fun (*this, &RouteUI::toggle_step_edit))); + step_edit_item = dynamic_cast (&items.back()); + } + } - step_edit_item->set_active (midi_track()->step_editing()); - } + if (step_edit_item) { + if (track()->rec_enable_control()->get_value()) { + step_edit_item->set_sensitive (false); + } + step_edit_item->set_active (midi_track()->step_editing()); + } + if (rec_safe_item) { + rec_safe_item->set_sensitive (!_route->rec_enable_control()->get_value()); + rec_safe_item->set_active (_route->rec_safe_control()->get_value()); + } } void RouteUI::toggle_step_edit () { - if (!is_midi_track() || _route->record_enabled()) { - return; - } + if (!is_midi_track() || track()->rec_enable_control()->get_value()) { + return; + } - midi_track()->set_step_editing (step_edit_item->get_active()); + midi_track()->set_step_editing (step_edit_item->get_active()); +} + +void +RouteUI::toggle_rec_safe () +{ + boost::shared_ptr rs = _route->rec_safe_control(); + + if (!rs) { + return; + } + + /* This check is made inside the control too, but dong it here can't + * hurt. + */ + + if (_route->rec_enable_control()->get_value()) { + return; + } + + rs->set_value (rec_safe_item->get_active (), Controllable::UseGroup); } void RouteUI::step_edit_changed (bool yn) { - if (yn) { - if (rec_enable_button) { - rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); - } + if (yn) { + if (rec_enable_button) { + rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); + } - start_step_editing (); + start_step_editing (); - if (step_edit_item) { - step_edit_item->set_active (true); - } + if (step_edit_item) { + step_edit_item->set_active (true); + } - } else { + } else { - if (rec_enable_button) { - rec_enable_button->unset_active_state (); - } + if (rec_enable_button) { + rec_enable_button->unset_active_state (); + } - stop_step_editing (); + stop_step_editing (); - if (step_edit_item) { - step_edit_item->set_active (false); - } - } + if (step_edit_item) { + step_edit_item->set_active (false); + } + } } bool 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; - } + if (Keyboard::is_context_menu_event (ev)) { + build_record_menu (); + if (record_menu) { + record_menu->popup (1, ev->time); + } + return false; + } - return true; + return false; } void @@ -944,7 +1129,7 @@ RouteUI::show_sends_press(GdkEventButton* ev) return true; } - if (!_i_am_the_modifier && !is_track() && show_sends_button) { + if (!is_track() && show_sends_button) { if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { @@ -995,41 +1180,42 @@ RouteUI::send_blink (bool onoff) } Gtkmm2ext::ActiveState -RouteUI::solo_active_state (boost::shared_ptr r) +RouteUI::solo_active_state (boost::shared_ptr s) { - if (r->is_master() || r->is_monitor()) { + boost::shared_ptr sc = s->solo_control(); + + if (!sc) { return Gtkmm2ext::Off; } - if (Config->get_solo_control_is_listen_control()) { - - if (r->listening_via_monitor()) { - return Gtkmm2ext::ExplicitActive; - } else { - return Gtkmm2ext::Off; - } - + if (!sc->can_solo()) { + return Gtkmm2ext::Off; } - if (r->soloed()) { - if (!r->self_soloed()) { - return Gtkmm2ext::ImplicitActive; - } else { - return Gtkmm2ext::ExplicitActive; - } + + if (sc->self_soloed()) { + return Gtkmm2ext::ExplicitActive; + } else if (sc->soloed_by_others()) { + return Gtkmm2ext::ImplicitActive; } else { return Gtkmm2ext::Off; } } Gtkmm2ext::ActiveState -RouteUI::solo_isolate_active_state (boost::shared_ptr r) +RouteUI::solo_isolate_active_state (boost::shared_ptr s) { - if (r->is_master() || r->is_monitor()) { + boost::shared_ptr sc = s->solo_isolate_control(); + + if (!sc) { + return Gtkmm2ext::Off; + } + + if (s->is_master() || s->is_monitor()) { return Gtkmm2ext::Off; } - if (r->solo_isolated()) { + if (sc->solo_isolated()) { return Gtkmm2ext::ExplicitActive; } else { return Gtkmm2ext::Off; @@ -1037,13 +1223,19 @@ RouteUI::solo_isolate_active_state (boost::shared_ptr r) } Gtkmm2ext::ActiveState -RouteUI::solo_safe_active_state (boost::shared_ptr r) +RouteUI::solo_safe_active_state (boost::shared_ptr s) { - if (r->is_master() || r->is_monitor()) { + boost::shared_ptr sc = s->solo_safe_control(); + + if (!sc) { return Gtkmm2ext::Off; } - if (r->solo_safe()) { + if (s->is_master() || s->is_monitor()) { + return Gtkmm2ext::Off; + } + + if (sc->solo_safe()) { return Gtkmm2ext::ExplicitActive; } else { return Gtkmm2ext::Off; @@ -1053,71 +1245,70 @@ RouteUI::solo_safe_active_state (boost::shared_ptr r) void RouteUI::update_solo_display () { - bool yn = _route->solo_safe (); + bool yn = _route->solo_safe_control()->solo_safe (); if (solo_safe_check && solo_safe_check->get_active() != yn) { solo_safe_check->set_active (yn); } - yn = _route->solo_isolated (); + yn = _route->solo_isolate_control()->solo_isolated (); if (solo_isolated_check && solo_isolated_check->get_active() != yn) { solo_isolated_check->set_active (yn); } - set_button_names (); + set_button_names (); - if (solo_isolated_led) { - if (_route->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()) { + 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 - */ - - update_mute_display (); -} + /* some changes to solo status can affect mute display, so catch up + */ -void -RouteUI::solo_changed_so_update_mute () -{ update_mute_display (); } void -RouteUI::mute_changed(void* /*src*/) +RouteUI::solo_changed_so_update_mute () { update_mute_display (); } ActiveState -RouteUI::mute_active_state (Session* s, boost::shared_ptr r) +RouteUI::mute_active_state (Session*, boost::shared_ptr s) { - if (r->is_monitor()) { - return ActiveState(0); + boost::shared_ptr mc = s->mute_control(); + + if (s->is_monitor()) { + return Gtkmm2ext::Off; } + if (!mc) { + return Gtkmm2ext::Off; + } if (Config->get_show_solo_mutes() && !Config->get_solo_control_is_listen_control ()) { - if (r->muted ()) { + if (mc->muted_by_self ()) { /* full mute */ return Gtkmm2ext::ExplicitActive; - } else if (!r->is_master() && s->soloing() && !r->soloed() && !r->solo_isolated()) { - /* master is NEVER muted by others */ + } else if (mc->muted_by_others_soloing () || mc->muted_by_masters ()) { + /* this will reflect both solo mutes AND master mutes */ return Gtkmm2ext::ImplicitActive; } else { /* no mute at all */ @@ -1126,9 +1317,12 @@ RouteUI::mute_active_state (Session* s, boost::shared_ptr r) } else { - if (r->muted()) { + if (mc->muted_by_self()) { /* full mute */ return Gtkmm2ext::ExplicitActive; + } else if (mc->muted_by_masters ()) { + /* this shows only master mutes, not mute-by-others-soloing */ + return Gtkmm2ext::ImplicitActive; } else { /* no mute at all */ return Gtkmm2ext::Off; @@ -1141,60 +1335,69 @@ RouteUI::mute_active_state (Session* s, boost::shared_ptr r) void RouteUI::update_mute_display () { - if (!_route) { - return; - } + if (!_route) { + return; + } - mute_button->set_active_state (mute_active_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 (); + blink_rec_display (true); //this lets the button change "immediately" rather than wait for the next blink } void RouteUI::session_rec_enable_changed () { - update_rec_display (); - update_monitoring_display (); + blink_rec_display (true); //this lets the button change "immediately" rather than wait for the next blink } void -RouteUI::update_rec_display () +RouteUI::blink_rec_display (bool blinkOn) { if (!rec_enable_button || !_route) { return; } - if (_route->record_enabled()) { - switch (_session->record_status ()) { - case Session::Recording: - rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); - break; + if (boost::dynamic_pointer_cast(_current_delivery)) { + return; + } - case Session::Disabled: - case Session::Enabled: - rec_enable_button->set_active_state (Gtkmm2ext::ImplicitActive); - break; + if (!is_track()) { + return; + } - } + if (track()->rec_enable_control()->get_value()) { + switch (_session->record_status ()) { + case Session::Recording: + rec_enable_button->set_active_state (Gtkmm2ext::ExplicitActive); + break; - if (step_edit_item) { - step_edit_item->set_sensitive (false); - } + 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 (); } @@ -1209,22 +1412,18 @@ RouteUI::build_solo_menu (void) Gtk::CheckMenuItem* check; check = new Gtk::CheckMenuItem(_("Solo Isolate")); - check->set_active (_route->solo_isolated()); + 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()); + 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 @@ -1237,13 +1436,13 @@ RouteUI::build_mute_menu(void) MenuList& items = mute_menu->items(); - pre_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Pre Fader"))); + pre_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Pre Fader Sends"))); init_mute_menu(MuteMaster::PreFader, pre_fader_mute_check); pre_fader_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::PreFader, pre_fader_mute_check)); items.push_back (CheckMenuElem(*pre_fader_mute_check)); pre_fader_mute_check->show_all(); - post_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Post Fader"))); + post_fader_mute_check = manage (new Gtk::CheckMenuItem(_("Post Fader Sends"))); init_mute_menu(MuteMaster::PostFader, post_fader_mute_check); post_fader_mute_check->signal_toggled().connect(sigc::bind (sigc::mem_fun (*this, &RouteUI::toggle_mute_menu), MuteMaster::PostFader, post_fader_mute_check)); items.push_back (CheckMenuElem(*post_fader_mute_check)); @@ -1261,25 +1460,22 @@ 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()); } void RouteUI::init_mute_menu(MuteMaster::MutePoint mp, Gtk::CheckMenuItem* check) { - check->set_active (_route->mute_points() & mp); + check->set_active (_route->mute_control()->mute_points() & mp); } void RouteUI::toggle_mute_menu(MuteMaster::MutePoint mp, Gtk::CheckMenuItem* check) { if (check->get_active()) { - _route->set_mute_points (MuteMaster::MutePoint (_route->mute_points() | mp)); + _route->mute_control()->set_mute_points (MuteMaster::MutePoint (_route->mute_control()->mute_points() | mp)); } else { - _route->set_mute_points (MuteMaster::MutePoint (_route->mute_points() & ~mp)); + _route->mute_control()->set_mute_points (MuteMaster::MutePoint (_route->mute_control()->mute_points() & ~mp)); } } @@ -1289,7 +1485,7 @@ RouteUI::muting_change () ENSURE_GUI_THREAD (*this, &RouteUI::muting_change) bool yn; - MuteMaster::MutePoint current = _route->mute_points (); + MuteMaster::MutePoint current = _route->mute_control()->mute_points (); yn = (current & MuteMaster::PreFader); @@ -1319,103 +1515,146 @@ RouteUI::muting_change () bool RouteUI::solo_isolate_button_release (GdkEventButton* ev) { - if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) { - return true; - } + if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) { + return true; + } - bool view = solo_isolated_led->active_state(); - bool model = _route->solo_isolated(); + bool view = solo_isolated_led->active_state(); + bool model = _route->solo_isolate_control()->solo_isolated(); - /* called BEFORE the view has changed */ + /* called BEFORE the view has changed */ - if (ev->button == 1) { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + 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); - } + if (model) { + /* disable isolate for all routes */ + _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 */ + _session->set_controls (route_list_to_control_list (_session->get_routes(), &Stripable::solo_isolate_control), 1.0, Controllable::NoGroup); + } - } else { - if (model == view) { + } else { - /* flip just this route */ + if (model == view) { - boost::shared_ptr rl (new RouteList); - rl->push_back (_route); - _session->set_solo_isolated (rl, !view, Session::rt_cleanup, true); - } - } - } + /* flip just this route */ - return true; + boost::shared_ptr rl (new RouteList); + rl->push_back (_route); + _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_isolate_control), view ? 0.0 : 1.0, Controllable::NoGroup); + } + } + } + + return false; } bool RouteUI::solo_safe_button_release (GdkEventButton* ev) { - if (ev->button == 1) { - _route->set_solo_safe (!solo_safe_led->active_state(), this); + if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS) { return true; } + + bool view = solo_safe_led->active_state(); + bool model = _route->solo_safe_control()->solo_safe(); + + if (ev->button == 1) { + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + boost::shared_ptr rl (_session->get_routes()); + if (model) { + /* disable solo safe for all routes */ + DisplaySuspender ds; + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + (*i)->solo_safe_control()->set_value (0.0, Controllable::NoGroup); + } + } else { + /* enable solo safe for all routes */ + DisplaySuspender ds; + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { + (*i)->solo_safe_control()->set_value (1.0, Controllable::NoGroup); + } + } + } + else { + if (model == view) { + /* flip just this route */ + _route->solo_safe_control()->set_value (view ? 0.0 : 1.0, Controllable::NoGroup); + } + } + } + return false; } void RouteUI::toggle_solo_isolated (Gtk::CheckMenuItem* check) { - bool view = check->get_active(); - bool model = _route->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->set_solo_isolated (view, this); - } + if (model != view) { + _route->solo_isolate_control()->set_value (view ? 1.0 : 0.0, Controllable::UseGroup); + } } void RouteUI::toggle_solo_safe (Gtk::CheckMenuItem* check) { - _route->set_solo_safe (check->get_active(), this); + _route->solo_safe_control()->set_value (check->get_active() ? 1.0 : 0.0, Controllable::UseGroup); } -/** Ask the user to choose a colour, and then set all selected tracks - * to that colour. - */ void -RouteUI::choose_color () +RouteUI::delete_patch_change_dialog () { - bool picked; - Gdk::Color const color = Gtkmm2ext::UI::instance()->get_color (_("Color Selection"), picked, &_color); + if (!_route) { + return; + } + delete _route->patch_selector_dialog (); + _route->set_patch_selector_dialog (0); +} - if (picked) { - ARDOUR_UI::instance()->the_editor().get_selection().tracks.foreach_route_ui ( - boost::bind (&RouteUI::set_color, _1, color) - ); +PatchChangeGridDialog* +RouteUI::patch_change_dialog () const +{ + return _route->patch_selector_dialog (); +} + +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 * the route is in a group which shares its color with its routes. */ void -RouteUI::set_color (const Gdk::Color & c) +RouteUI::set_color (uint32_t c) { - /* leave _color alone in the group case so that tracks can retain their - * own pre-group colors. - */ - - char buf[64]; - _color = c; - snprintf (buf, sizeof (buf), "%d:%d:%d", c.get_red(), c.get_green(), c.get_blue()); - - /* 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 */ + _route->presentation_info().set_color (c); } /** @return GUI state ID for things that are common to the route in all its representations */ @@ -1428,80 +1667,11 @@ RouteUI::route_state_id () const int RouteUI::set_color_from_route () { - const string str = gui_object_state().get_string (route_state_id(), X_("color")); - - if (str.empty()) { - return 1; - } - - int r, g, b; - - sscanf (str.c_str(), "%d:%d:%d", &r, &g, &b); - - _color.set_red (r); - _color.set_green (g); - _color.set_blue (b); - - return 0; -} - -void -RouteUI::remove_this_route (bool apply_to_selection) -{ - 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 (_( -"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\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.")); - - 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)); - } + if (_route->presentation_info().color_set()) { + return 0; /* nothing to do */ } -} -gint -RouteUI::idle_remove_this_route (RouteUI *rui) -{ - rui->_session->remove_route (rui->route()); - return false; + return 1; /* pick a color */ } /** @return true if this name should be used for the route, otherwise false */ @@ -1511,12 +1681,12 @@ 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); @@ -1526,7 +1696,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; @@ -1570,11 +1740,74 @@ RouteUI::route_rename () } void -RouteUI::property_changed (const PropertyChange& what_changed) +RouteUI::toggle_comment_editor () +{ +// if (ignore_toggle) { +// return; +// } + + if (comment_window && comment_window->is_visible ()) { + comment_window->hide (); + } else { + open_comment_editor (); + } +} + + +void +RouteUI::open_comment_editor () +{ + if (comment_window == 0) { + setup_comment_editor (); + } + + string title; + title = _route->name(); + title += _(": comment editor"); + + comment_window->set_title (title); + comment_window->present(); +} + +void +RouteUI::setup_comment_editor () +{ + comment_window = new ArdourWindow (""); // title will be reset to show route + comment_window->set_skip_taskbar_hint (true); + comment_window->signal_hide().connect (sigc::mem_fun(*this, &MixerStrip::comment_editor_done_editing)); + comment_window->set_default_size (400, 200); + + comment_area = manage (new TextView()); + comment_area->set_name ("MixerTrackCommentArea"); + comment_area->set_wrap_mode (WRAP_WORD); + comment_area->set_editable (true); + comment_area->get_buffer()->set_text (_route->comment()); + comment_area->show (); + + comment_window->add (*comment_area); +} + +void +RouteUI::comment_changed () +{ + ignore_comment_edit = true; + if (comment_area) { + comment_area->get_buffer()->set_text (_route->comment()); + } + ignore_comment_edit = false; +} + +void +RouteUI::comment_editor_done_editing () { - if (what_changed.contains (ARDOUR::Properties::name)) { - name_label.set_text (_route->name()); + ENSURE_GUI_THREAD (*this, &MixerStrip::comment_editor_done_editing, src) + + string const str = comment_area->get_buffer()->get_text(); + if (str == _route->comment ()) { + return; } + + _route->set_comment (str, this); } void @@ -1587,6 +1820,12 @@ RouteUI::set_route_active (bool a, bool apply_to_selection) } } +void +RouteUI::duplicate_selected_routes () +{ + ARDOUR_UI::instance()->start_duplicate_routes(); +} + void RouteUI::toggle_denormal_protection () { @@ -1664,83 +1903,88 @@ RouteUI::has_audio_outputs () const return (_route->n_outputs().n_audio() > 0); } -string -RouteUI::name() const -{ - return _route->name(); -} - void RouteUI::map_frozen () { ENSURE_GUI_THREAD (*this, &RouteUI::map_frozen) - AudioTrack* at = dynamic_cast(_route.get()); + AudioTrack* at = dynamic_cast(_route.get()); if (at) { - switch (at->freeze_state()) { - case AudioTrack::Frozen: - rec_enable_button->set_sensitive (false); - break; - default: - rec_enable_button->set_sensitive (true); - break; - } + check_rec_enable_sensitivity (); } } void RouteUI::adjust_latency () { - LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle()); + LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->sample_rate(), AudioEngine::instance()->samples_per_cycle()); } + void -RouteUI::save_as_template () +RouteUI::save_as_template_dialog_response (int response, SaveTemplateDialog* d) { - std::string path; - std::string safe_name; - 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); - path = ARDOUR::user_route_template_directory (); + 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?")); - if (g_mkdir_with_parents (path.c_str(), 0755)) { - error << string_compose (_("Cannot create route template directory %1"), path) << endmsg; - return; + if (!overwrite) { + d->show (); + return; + } + } + _route->save_as_template (path, name, desc); } - Prompter p (true); // modal + delete d; +} + +void +RouteUI::save_as_template () +{ + const std::string dir = ARDOUR::user_route_template_directory (); - 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; - default: + if (g_mkdir_with_parents (dir.c_str(), 0755)) { + error << string_compose (_("Cannot create route template directory %1"), dir) << endmsg; return; } - p.hide (); - p.get_result (name, true); - - safe_name = legalize_for_path (name); - safe_name += template_suffix; - - path = Glib::build_filename (path, safe_name); - - _route->save_as_template (path, name); + 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 RouteUI::check_rec_enable_sensitivity () { + if (!rec_enable_button) { + assert (0); // This should not happen + return; + } + if (!_session->writable()) { + rec_enable_button->set_sensitive (false); + return; + } + if (_session->transport_rolling() && rec_enable_button->active_state() && Config->get_disable_disarm_during_roll()) { rec_enable_button->set_sensitive (false); + } else if (is_audio_track () && track()->freeze_state() == AudioTrack::Frozen) { + rec_enable_button->set_sensitive (false); } else { rec_enable_button->set_sensitive (true); } - + if (_route && _route->rec_safe_control () && _route->rec_safe_control()->get_value()) { + rec_enable_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() | Gtkmm2ext::Insensitive)); + } else { + rec_enable_button->set_visual_state (Gtkmm2ext::VisualState (solo_button->visual_state() & ~Gtkmm2ext::Insensitive)); + } update_monitoring_display (); } @@ -1753,86 +1997,18 @@ RouteUI::parameter_changed (string const & p) check_rec_enable_sensitivity (); } else if (p == "use-monitor-bus" || 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 (); - } -} - -void -RouteUI::step_gain_up () -{ - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.1), this); -} - -void -RouteUI::page_gain_up () -{ - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) + 0.5), this); -} - -void -RouteUI::step_gain_down () -{ - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.1), this); -} - -void -RouteUI::page_gain_down () -{ - _route->set_gain (dB_to_coefficient (accurate_coefficient_to_dB (_route->gain_control()->get_value()) - 0.5), this); -} - -void -RouteUI::open_remote_control_id_dialog () -{ - ArdourDialog dialog (_("Remote Control ID")); - SpinButton* spin = 0; - - dialog.get_vbox()->set_border_width (18); - - 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 if (p == "blink-rec-arm") { + if (UIConfiguration::instance().get_blink_rec_arm()) { + rec_blink_connection.disconnect (); + rec_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::blink_rec_display)); } else { - l->set_markup (string_compose (_("The remote control ID of %5 is: %2\n\n\n" - "Remote Control IDs are currently determined by track/bus ordering in Ardour.\n\n" - "%3Use the User Interaction tab of the Preferences window if you want to change this%4"), - (is_track() ? _("track") : _("bus")), - _route->remote_control_id(), - "", - "", - Glib::Markup::escape_text (_route->name()))); + rec_blink_connection.disconnect (); + RouteUI::blink_rec_display(false); } - 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 && spin) { - _route->set_remote_control_id (spin->get_value_as_int ()); } } @@ -1856,9 +2032,8 @@ RouteUI::setup_invert_buttons () for (uint32_t i = 0; i < to_add; ++i) { 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->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_release), i)); + b->signal_button_press_event().connect (sigc::mem_fun (*this, &RouteUI::invert_press), false); + b->signal_button_release_event().connect (sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_release), i), false); b->set_name (X_("invert button")); if (to_add == 1) { @@ -1872,9 +2047,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); @@ -1888,8 +2063,6 @@ RouteUI::setup_invert_buttons () 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) { @@ -1898,10 +2071,10 @@ RouteUI::set_invert_button_state () */ ArdourButton* b = _invert_buttons.front (); - - if (_route->phase_invert().count() == _route->phase_invert().size()) { + + if (_route->phase_control()->count() == _route->phase_control()->size()) { b->set_active_state (Gtkmm2ext::ExplicitActive); - } else if (_route->phase_invert().any()) { + } else if (_route->phase_control()->any()) { b->set_active_state (Gtkmm2ext::ImplicitActive); } else { b->set_active_state (Gtkmm2ext::Off); @@ -1913,12 +2086,10 @@ RouteUI::set_invert_button_state () int j = 0; for (vector::iterator i = _invert_buttons.begin(); i != _invert_buttons.end(); ++i, ++j) { - (*i)->set_active (_route->phase_invert (j)); + (*i)->set_active (_route->phase_control()->inverted (j)); } - - } - --_i_am_the_modifier; + } } bool @@ -1928,8 +2099,8 @@ RouteUI::invert_release (GdkEventButton* ev, uint32_t i) 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->phase_control()->set_phase_invert (i, !_invert_buttons[i]->get_active()); + return false; } } return false; @@ -1947,9 +2118,9 @@ RouteUI::invert_press (GdkEventButton* ev) up a menu on right-click; left click is handled on release. */ - return true; + return false; } - + delete _invert_menu; _invert_menu = new Menu; _invert_menu->set_name ("ArdourContextMenu"); @@ -1959,13 +2130,13 @@ RouteUI::invert_press (GdkEventButton* ev) items.push_back (CheckMenuElem (string_compose (X_("Ø%1"), i + 1), sigc::bind (sigc::mem_fun (*this, &RouteUI::invert_menu_toggled), i))); Gtk::CheckMenuItem* e = dynamic_cast (&items.back ()); ++_i_am_the_modifier; - e->set_active (_route->phase_invert (i)); + e->set_active (_route->phase_control()->inverted (i)); --_i_am_the_modifier; } _invert_menu->popup (0, ev->time); - return false; + return true; } void @@ -1975,49 +2146,62 @@ RouteUI::invert_menu_toggled (uint32_t c) 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); - } + _route->phase_control()->set_phase_invert (c, !_route->phase_control()->inverted (c)); } void -RouteUI::request_redraw () +RouteUI::set_invert_sensitive (bool yn) { - 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); } } /** The Route's gui_changed signal has been emitted */ void -RouteUI::route_gui_changed (string what_changed) +RouteUI::route_gui_changed (PropertyChange const& what_changed) { - if (what_changed == "color") { + if (what_changed.contains (Properties::color)) { if (set_color_from_route () == 0) { route_color_changed (); } } } +void +RouteUI::track_mode_changed (void) +{ + assert(is_track()); + switch (track()->mode()) { + case ARDOUR::NonLayered: + case ARDOUR::Normal: + rec_enable_button->set_icon (ArdourIcon::RecButton); + break; + case ARDOUR::Destructive: + rec_enable_button->set_icon (ArdourIcon::RecTapeMode); + break; + } + rec_enable_button->queue_draw(); +} + /** @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::color () const +RouteUI::route_color () const { + Gdk::Color c; RouteGroup* g = _route->route_group (); - + string p; + if (g && g->is_color()) { - return GroupTabs::group_color (g); + set_color_from_rgba (c, GroupTabs::group_color (g)); + } else { + set_color_from_rgba (c, _route->presentation_info().color()); } - return _color; + return c; } void @@ -2032,7 +2216,7 @@ 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)); + send_blink_connection = Timers::blink_connect (sigc::mem_fun (*this, &RouteUI::send_blink)); } else { show_sends_button->set_active (false); send_blink_connection.disconnect (); @@ -2044,3 +2228,219 @@ RouteUI::route_group() const { return _route->route_group(); } + + +RoutePinWindowProxy::RoutePinWindowProxy(std::string const &name, boost::shared_ptr route) + : WM::ProxyBase (name, string()) + , _route (boost::weak_ptr (route)) +{ + route->DropReferences.connect (going_away_connection, MISSING_INVALIDATOR, boost::bind (&RoutePinWindowProxy::route_going_away, this), gui_context()); +} + +RoutePinWindowProxy::~RoutePinWindowProxy() +{ + _window = 0; +} + +ARDOUR::SessionHandlePtr* +RoutePinWindowProxy::session_handle () +{ + ArdourWindow* aw = dynamic_cast (_window); + if (aw) { return aw; } + return 0; +} + +Gtk::Window* +RoutePinWindowProxy::get (bool create) +{ + boost::shared_ptr r = _route.lock (); + if (!r) { + return 0; + } + + if (!_window) { + if (!create) { + return 0; + } + _window = new PluginPinDialog (r); + ArdourWindow* aw = dynamic_cast (_window); + if (aw) { + aw->set_session (_session); + } + _window->show_all (); + } + return _window; +} + +void +RoutePinWindowProxy::route_going_away () +{ + delete _window; + _window = 0; + WM::Manager::instance().remove (this); + going_away_connection.disconnect(); + delete this; +} + +void +RouteUI::maybe_add_route_print_mgr () +{ + if (_route->pinmgr_proxy ()) { + return; + } + RoutePinWindowProxy* wp = new RoutePinWindowProxy ( + string_compose ("RPM-%1", _route->id()), _route); + wp->set_session (_session); + + const XMLNode* ui_xml = _session->extra_xml (X_("UI")); + if (ui_xml) { + wp->set_state (*ui_xml, 0); + } + +#if 0 + void* existing_ui = _route->pinmgr_proxy (); + if (existing_ui) { + wp->use_window (*(reinterpret_cast(existing_ui))); + } +#endif + _route->set_pingmgr_proxy (wp); + + WM::Manager::instance().register_window (wp); +} + +void +RouteUI::manage_pins () +{ + RoutePinWindowProxy* proxy = _route->pinmgr_proxy (); + if (proxy) { + proxy->get (true); + proxy->present(); + } +} + +void +RouteUI::fan_out (bool to_busses, bool group) +{ + 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); + + 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 +RouteUI::mark_hidden (bool yn) +{ + if (yn != _route->presentation_info().hidden()) { + _route->presentation_info().set_hidden (yn); + return true; // things changed + } + 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); + } +}