X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=cefe2ac517e4c84b72c860ef8021de5e735f4a47;hb=2e1332f74f803a1be4c8bb4911266aef4b63f145;hp=360ece25c944b7eebb59d2ee2287caff0f56b31f;hpb=72f76d4b95c099a591e8dac33b15a90d6db01c60;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 360ece25c9..cefe2ac517 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -22,23 +22,32 @@ #include #include #include +#include +#include #include #include #include #include +#include #include "route_ui.h" #include "keyboard.h" #include "utils.h" #include "prompter.h" #include "gui_thread.h" +#include "ardour_dialog.h" +#include "latency_gui.h" +#include "automation_time_axis.h" #include #include #include #include #include +#include +#include +#include #include "i18n.h" using namespace sigc; @@ -47,13 +56,33 @@ using namespace Gtkmm2ext; using namespace ARDOUR; using namespace PBD; -RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, const char* m_name, - const char* s_name, const char* r_name) - : AxisView(sess), - _route(rt), - mute_button(0), - solo_button(0), - rec_enable_button(0) +RouteUI::RouteUI (ARDOUR::Session& sess, const char* mute_name, const char* solo_name, const char* rec_name) + : AxisView(sess) +{ + init (); + set_button_names (mute_name, solo_name, rec_name); +} + +RouteUI::RouteUI (boost::shared_ptr rt, + ARDOUR::Session& sess, const char* mute_name, const char* solo_name, const char* rec_name) + : AxisView(sess) +{ + init (); + set_button_names (mute_name, solo_name, rec_name); + set_route (rt); +} + +RouteUI::~RouteUI() +{ + GoingAway (); /* EMIT SIGNAL */ + + delete solo_menu; + delete mute_menu; + delete remote_control_menu; +} + +void +RouteUI::init () { xml_node = 0; mute_menu = 0; @@ -63,65 +92,123 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, co wait_for_release = false; route_active_menu_item = 0; was_solo_safe = false; + polarity_menu_item = 0; + denormal_menu_item = 0; + multiple_mute_change = false; + multiple_solo_change = false; - if (set_color_from_route()) { - set_color (unique_random_color()); + mute_button = manage (new BindableToggleButton ("")); + mute_button->set_self_managed (true); + mute_button->set_name ("MuteButton"); + UI::instance()->set_tip (mute_button, _("Mute this track"), ""); + + solo_button = manage (new BindableToggleButton ("")); + solo_button->set_self_managed (true); + solo_button->set_name ("SoloButton"); + UI::instance()->set_tip (solo_button, _("Mute other (non-soloed) tracks"), ""); + + rec_enable_button = manage (new BindableToggleButton ("")); + rec_enable_button->set_name ("RecordEnableButton"); + rec_enable_button->set_self_managed (true); + UI::instance()->set_tip (rec_enable_button, _("Enable recording on this track"), ""); + + _session.SoloChanged.connect (mem_fun(*this, &RouteUI::solo_changed_so_update_mute)); +} + +void +RouteUI::reset () +{ + connections.clear (); + + delete solo_menu; + solo_menu = 0; + + delete mute_menu; + mute_menu = 0; + + if (xml_node) { + /* do not delete the node - its owned by the route */ + xml_node = 0; } - new PairedShiva (*_route, *this); + route_active_menu_item = 0; + polarity_menu_item = 0; + denormal_menu_item = 0; +} - _route->active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed)); +void +RouteUI::set_button_names (const char* mute, const char* solo, const char* rec) +{ + m_name = mute; + s_name = solo; + r_name = rec; +} - mute_button = manage (new BindableToggleButton (_route->mute_control(), m_name )); - mute_button->set_self_managed (true); +void +RouteUI::set_route (boost::shared_ptr rp) +{ + reset (); - solo_button = manage (new BindableToggleButton (_route->solo_control(), s_name )); - solo_button->set_self_managed (true); + _route = rp; - mute_button->set_name ("MuteButton"); - solo_button->set_name ("SoloButton"); + if (set_color_from_route()) { + set_color (unique_random_color()); + } - _route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed)); - _route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); - _route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed)); + /* no, there is no memory leak here. This object cleans itself (and other stuff) + up when the route is destroyed. + */ + new PairedShiva (*_route, *this); + + mute_button->set_controllable (_route->mute_control()); + mute_button->set_label (m_name); + + solo_button->set_controllable (_route->solo_control()); + solo_button->set_label (s_name); + + connections.push_back (_route->active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed))); + connections.push_back (_route->mute_changed.connect (mem_fun(*this, &RouteUI::mute_changed))); + connections.push_back (_route->solo_changed.connect (mem_fun(*this, &RouteUI::solo_changed))); + connections.push_back (_route->solo_safe_changed.connect (mem_fun(*this, &RouteUI::solo_changed))); + /* when solo changes, update mute state too, in case the user wants us to display it */ _session.SoloChanged.connect (mem_fun(*this, &RouteUI::solo_changed_so_update_mute)); - update_solo_display (); - update_mute_display (); - if (is_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast(_route); - t->diskstream()->RecordEnableChanged.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed)); - - _session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed)); + connections.push_back (t->diskstream()->RecordEnableChanged.connect (mem_fun (*this, &RouteUI::route_rec_enable_changed))); + connections.push_back (_session.RecordStateChanged.connect (mem_fun (*this, &RouteUI::session_rec_enable_changed))); - rec_enable_button = manage (new BindableToggleButton (t->rec_enable_control(), r_name )); - rec_enable_button->set_name ("RecordEnableButton"); - rec_enable_button->set_self_managed (true); + rec_enable_button->show(); + rec_enable_button->set_controllable (t->rec_enable_control()); + rec_enable_button->set_label (r_name); update_rec_display (); } + + mute_button->unset_flags (Gtk::CAN_FOCUS); + solo_button->unset_flags (Gtk::CAN_FOCUS); - _route->RemoteControlIDChanged.connect (mem_fun(*this, &RouteUI::refresh_remote_control_menu)); + mute_button->show(); + solo_button->show(); + + connections.push_back (_route->RemoteControlIDChanged.connect (mem_fun(*this, &RouteUI::refresh_remote_control_menu))); /* map the current state */ map_frozen (); } -RouteUI::~RouteUI() -{ - GoingAway (); /* EMIT SIGNAL */ - delete mute_menu; -} - bool RouteUI::mute_press(GdkEventButton* ev) { + if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) { + return true; + } + multiple_mute_change = false; if (!ignore_toggle) { if (Keyboard::is_context_menu_event (ev)) { @@ -134,22 +221,22 @@ RouteUI::mute_press(GdkEventButton* ev) } else { - if (ev->button == 2) { - // ctrl-button2 click is the midi binding click + if (Keyboard::is_button2_event (ev)) { + // Primary-button2 click is the midi binding click // button2-click is "momentary" - if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control))) { + if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) { wait_for_release = true; } else { return false; } } - if (ev->button == 1 || ev->button == 2) { + if (ev->button == 1 || Keyboard::is_button2_event (ev)) { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) { + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { - /* ctrl-shift-click applies change to all routes */ + /* Primary-Tertiary-click applies change to all routes */ _session.begin_reversible_command (_("mute change")); Session::GlobalMuteStateCommand *cmd = new Session::GlobalMuteStateCommand(_session, this); @@ -157,11 +244,12 @@ RouteUI::mute_press(GdkEventButton* ev) cmd->mark(); _session.add_command(cmd); _session.commit_reversible_command (); + multiple_mute_change = true; - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - /* ctrl-click applies change to the mix group. - ctrl-button2 is MIDI learn. + /* Primary-button1 applies change to the mix group. + NOTE: Primary-button2 is MIDI learn. */ if (ev->button == 1) { @@ -171,8 +259,11 @@ RouteUI::mute_press(GdkEventButton* ev) } else { /* plain click applies change to this route */ - - reversibly_apply_route_boolean ("mute change", &Route::set_mute, !_route->muted(), this); + if (wait_for_release) { + _route->set_mute (!_route->muted(), this); + } else { + reversibly_apply_route_boolean ("mute change", &Route::set_mute, !_route->muted(), this); + } } } } @@ -188,9 +279,14 @@ RouteUI::mute_release(GdkEventButton* ev) if (!ignore_toggle) { if (wait_for_release){ wait_for_release = false; - // undo the last op - // because the press was the last undoable thing we did - _session.undo (1U); + if (multiple_mute_change) { + multiple_mute_change = false; + // undo the last op + // because the press was the last undoable thing we did + _session.undo (1U); + } else { + _route->set_mute (!_route->muted(), this); + } } } return true; @@ -199,10 +295,16 @@ RouteUI::mute_release(GdkEventButton* ev) bool RouteUI::solo_press(GdkEventButton* ev) { + /* ignore double/triple clicks */ + + if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) { + return true; + } + multiple_solo_change = false; if (!ignore_toggle) { if (Keyboard::is_context_menu_event (ev)) { - + if (solo_menu == 0) { build_solo_menu (); } @@ -211,34 +313,47 @@ RouteUI::solo_press(GdkEventButton* ev) } else { - if (ev->button == 2) { + if (Keyboard::is_button2_event (ev)) { - // ctrl-button2 click is the midi binding click + // Primary-button2 click is the midi binding click // button2-click is "momentary" - if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control))) { + if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier))) { wait_for_release = true; } else { return false; } } - if (ev->button == 1 || ev->button == 2) { + if (ev->button == 1 || Keyboard::is_button2_event (ev)) { - if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) { - - /* ctrl-shift-click applies change to all routes */ + if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { + /* Primary-Tertiary-click applies change to all routes */ + bool was_not_latched = false; + if (!Config->get_solo_latched ()) { + was_not_latched = true; + /* + XXX it makes no sense to solo all tracks if we're + not in latched mode, but doing nothing feels like a bug, + so do it anyway + */ + Config->set_solo_latched (true); + } _session.begin_reversible_command (_("solo change")); Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand(_session, this); _session.set_all_solo (!_route->soloed()); cmd->mark(); _session.add_command (cmd); _session.commit_reversible_command (); + multiple_solo_change = true; + if (was_not_latched) { + Config->set_solo_latched (false); + } - } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Alt))) { + } else if (Keyboard::modifier_state_contains (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::SecondaryModifier))) { - // ctrl-alt-click: exclusively solo this track, not a toggle */ + // Primary-Secondary-click: exclusively solo this track, not a toggle */ _session.begin_reversible_command (_("solo change")); Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand (_session, this); @@ -248,17 +363,26 @@ RouteUI::solo_press(GdkEventButton* ev) _session.add_command(cmd); _session.commit_reversible_command (); - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Shift)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) { // shift-click: set this route to solo safe - _route->set_solo_safe (!_route->solo_safe(), this); - wait_for_release = false; + if (Profile->get_sae() && ev->button == 1) { + // button 1 and shift-click: disables solo_latched for this click + if (!Config->get_solo_latched ()) { + Config->set_solo_latched (true); + reversibly_apply_route_boolean ("solo change", &Route::set_solo, !_route->soloed(), this); + Config->set_solo_latched (false); + } + } else { + _route->set_solo_safe (!_route->solo_safe(), this); + wait_for_release = false; + } - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { - /* ctrl-click: solo mix group. - ctrl-button2 is MIDI learn. + /* Primary-button1: solo mix group. + NOTE: Primary-button2 is MIDI learn. */ if (ev->button == 1) { @@ -268,8 +392,11 @@ RouteUI::solo_press(GdkEventButton* ev) } else { /* click: solo this route */ - - reversibly_apply_route_boolean ("solo change", &Route::set_solo, !_route->soloed(), this); + if (wait_for_release) { + _route->set_solo (!_route->soloed(), this); + } else { + reversibly_apply_route_boolean ("solo change", &Route::set_solo, !_route->soloed(), this); + } } } } @@ -284,10 +411,16 @@ RouteUI::solo_release(GdkEventButton* ev) if (!ignore_toggle) { if (wait_for_release) { wait_for_release = false; - // undo the last op - // because the press was the last undoable thing we did - - _session.undo (1U); + if (multiple_solo_change) { + multiple_solo_change = false; + // undo the last op + // because the press was the last undoable thing we did + _session.undo (1U); + } else { + // we don't use "undo the last op" + // here because its expensive for the GUI + _route->set_solo (!_route->soloed(), this); + } } } @@ -297,6 +430,10 @@ RouteUI::solo_release(GdkEventButton* ev) bool RouteUI::rec_enable_press(GdkEventButton* ev) { + if (ev->type == GDK_2BUTTON_PRESS || ev->type == GDK_3BUTTON_PRESS ) { + return true; + } + if (!_session.engine().connected()) { MessageDialog msg (_("Not connected to JACK - cannot engage record")); msg.run (); @@ -305,11 +442,12 @@ RouteUI::rec_enable_press(GdkEventButton* ev) if (!ignore_toggle && is_track() && rec_enable_button) { - if (ev->button == 2 && Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { + if (Keyboard::is_button2_event (ev) && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { // do nothing on midi bind event + return false; - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier))) { _session.begin_reversible_command (_("rec-enable change")); Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(_session, this); @@ -324,13 +462,17 @@ RouteUI::rec_enable_press(GdkEventButton* ev) _session.add_command(cmd); _session.commit_reversible_command (); - } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { + } else if (Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + + /* Primary-button1 applies change to the mix group. + NOTE: Primary-button2 is MIDI learn. + */ set_mix_group_rec_enable (_route, !_route->record_enabled()); } else { - reversibly_apply_audio_track_boolean ("rec-enable change", &AudioTrack::set_record_enable, !audio_track()->record_enabled(), this); + reversibly_apply_track_boolean ("rec-enable change", &Track::set_record_enable, !track()->record_enabled(), this); } } @@ -346,6 +488,7 @@ RouteUI::rec_enable_release (GdkEventButton* ev) void RouteUI::solo_changed(void* src) { + Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &RouteUI::update_solo_display)); } @@ -360,7 +503,7 @@ RouteUI::update_solo_display () ignore_toggle = true; solo_button->set_active(x); ignore_toggle = false; - } + } if (_route->solo_safe()) { solo_button->set_visual_state (2); @@ -447,7 +590,7 @@ RouteUI::update_rec_display () rec_enable_button->set_active (model); ignore_toggle = false; } - + /* now make sure its color state is correct */ if (model) { @@ -472,7 +615,7 @@ RouteUI::update_rec_display () void RouteUI::build_remote_control_menu () { - remote_control_menu = manage (new Menu); + remote_control_menu = new Menu; refresh_remote_control_menu (); } @@ -640,21 +783,21 @@ void RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool, void *), bool yn, void *arg) { _session.begin_reversible_command (name); - XMLNode &before = _route->get_state(); - bind(mem_fun(*_route, func), yn, arg)(); - XMLNode &after = _route->get_state(); - _session.add_command (new MementoCommand(*_route, &before, &after)); + XMLNode &before = _route->get_state(); + bind(mem_fun(*_route, func), yn, arg)(); + XMLNode &after = _route->get_state(); + _session.add_command (new MementoCommand(*_route, &before, &after)); _session.commit_reversible_command (); } void -RouteUI::reversibly_apply_audio_track_boolean (string name, void (AudioTrack::*func)(bool, void *), bool yn, void *arg) +RouteUI::reversibly_apply_track_boolean (string name, void (Track::*func)(bool, void *), bool yn, void *arg) { _session.begin_reversible_command (name); - XMLNode &before = audio_track()->get_state(); - bind (mem_fun (*audio_track(), func), yn, arg)(); - XMLNode &after = audio_track()->get_state(); - _session.add_command (new MementoCommand(*audio_track(), &before, &after)); + XMLNode &before = track()->get_state(); + bind (mem_fun (*track(), func), yn, arg)(); + XMLNode &after = track()->get_state(); + _session.add_command (new MementoCommand(*track(), &before, &after)); _session.commit_reversible_command (); } @@ -735,18 +878,28 @@ RouteUI::ensure_xml_node () } XMLNode* -RouteUI::get_child_xml_node (const string & childname) +RouteUI::get_automation_child_xml_node (Evoral::Parameter param) { - XMLNode* child; - ensure_xml_node (); - - if ((child = find_named_node (*xml_node, childname)) == 0) { - child = new XMLNode (childname); - xml_node->add_child_nocopy (*child); + XMLNodeList kids = xml_node->children(); + XMLNodeConstIterator iter; + + 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) + return *iter; + } } + // Didn't find it, make a new one + XMLNode* child = new XMLNode (AutomationTimeAxisView::state_node_name); + child->add_property("automation-id", sym); + xml_node->add_child_nocopy (*child); + return child; } @@ -794,7 +947,7 @@ gint RouteUI::idle_remove_this_route (RouteUI *rui) { rui->_session.remove_route (rui->_route); - return FALSE; + return false; } void @@ -813,7 +966,7 @@ RouteUI::route_rename () case Gtk::RESPONSE_ACCEPT: name_prompter.get_result (result); if (result.length()) { - _route->set_name (result, this); + _route->set_name (result); } break; } @@ -823,9 +976,9 @@ RouteUI::route_rename () } void -RouteUI::name_changed (void *src) +RouteUI::name_changed () { - ENSURE_GUI_THREAD(bind (mem_fun (*this, &RouteUI::name_changed), src)); + ENSURE_GUI_THREAD(sigc::mem_fun(*this, &RouteUI::name_changed)); name_label.set_text (_route->name()); } @@ -876,6 +1029,28 @@ RouteUI::polarity_changed () /* no signal for this yet */ } +void +RouteUI::toggle_denormal_protection () +{ + if (denormal_menu_item) { + + bool x; + + ENSURE_GUI_THREAD(mem_fun (*this, &RouteUI::toggle_denormal_protection)); + + if ((x = denormal_menu_item->get_active()) != _route->denormal_protection()) { + _route->set_denormal_protection (x, this); + } + } +} + +void +RouteUI::denormal_protection_changed () +{ + /* no signal for this yet */ +} + + void RouteUI::solo_safe_toggle(void* src, Gtk::CheckMenuItem* check) { @@ -944,25 +1119,37 @@ RouteUI::disconnect_output () bool RouteUI::is_track () const { - return dynamic_cast(_route.get()) != 0; + return boost::dynamic_pointer_cast(_route) != 0; } -Track* +boost::shared_ptr RouteUI::track() const { - return dynamic_cast(_route.get()); + return boost::dynamic_pointer_cast(_route); } bool RouteUI::is_audio_track () const { - return dynamic_cast(_route.get()) != 0; + return boost::dynamic_pointer_cast(_route) != 0; } -AudioTrack* +boost::shared_ptr RouteUI::audio_track() const { - return dynamic_cast(_route.get()); + return boost::dynamic_pointer_cast(_route); +} + +bool +RouteUI::is_midi_track () const +{ + return boost::dynamic_pointer_cast(_route) != 0; +} + +boost::shared_ptr +RouteUI::midi_track() const +{ + return boost::dynamic_pointer_cast(_route); } boost::shared_ptr @@ -1002,3 +1189,8 @@ RouteUI::map_frozen () } } +void +RouteUI::adjust_latency () +{ + LatencyDialog dialog (_route->name() + _("latency"), *(_route.get()), _session.frame_rate(), _session.engine().frames_per_cycle()); +}