X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=c02c4109b172367c77d1d75b66d07a76806eaa88;hb=e11b3f90c2d02735a071d526d67cfd0de90cbac3;hp=070ad4203777641be76b162bdb33c88723397379;hpb=532f6aad4ac79ca15d69deccd18fca90e444c437;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 070ad42037..c02c4109b1 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #include @@ -23,17 +22,22 @@ #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 @@ -65,24 +69,34 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, co ignore_toggle = false; wait_for_release = false; route_active_menu_item = 0; + was_solo_safe = false; + polarity_menu_item = 0; + denormal_menu_item = 0; if (set_color_from_route()) { set_color (unique_random_color()); } - new Shiva (*_route, *this); + new PairedShiva (*_route, *this); _route->active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed)); mute_button = manage (new BindableToggleButton (_route->mute_control(), m_name )); + mute_button->set_self_managed (true); + solo_button = manage (new BindableToggleButton (_route->solo_control(), s_name )); + solo_button->set_self_managed (true); - // mute_button->unset_flags (Gtk::CAN_FOCUS); - // solo_button->unset_flags (Gtk::CAN_FOCUS); + mute_button->set_name ("MuteButton"); + solo_button->set_name ("SoloButton"); _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)); + + /* 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)); if (is_track()) { boost::shared_ptr t = boost::dynamic_pointer_cast(_route); @@ -92,14 +106,21 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, co _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->unset_flags (Gtk::CAN_FOCUS); + rec_enable_button->set_name ("RecordEnableButton"); + rec_enable_button->set_self_managed (true); + rec_enable_button->show(); update_rec_display (); } mute_button->unset_flags (Gtk::CAN_FOCUS); solo_button->unset_flags (Gtk::CAN_FOCUS); + mute_button->show(); + solo_button->show(); + + _route->RemoteControlIDChanged.connect (mem_fun(*this, &RouteUI::refresh_remote_control_menu)); + /* map the current state */ map_frozen (); @@ -114,6 +135,10 @@ RouteUI::~RouteUI() bool RouteUI::mute_press(GdkEventButton* ev) { + if (ev->type == GDK_2BUTTON_PRESS) { + return true; + } + if (!ignore_toggle) { if (Keyboard::is_context_menu_event (ev)) { @@ -127,10 +152,10 @@ RouteUI::mute_press(GdkEventButton* ev) } else { if (ev->button == 2) { - // 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; @@ -139,9 +164,9 @@ RouteUI::mute_press(GdkEventButton* ev) if (ev->button == 1 || ev->button == 2) { - 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); @@ -150,10 +175,10 @@ RouteUI::mute_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)) { - /* 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) { @@ -191,6 +216,12 @@ RouteUI::mute_release(GdkEventButton* ev) bool RouteUI::solo_press(GdkEventButton* ev) { + /* ignore double clicks */ + + if (ev->type == GDK_2BUTTON_PRESS) { + return true; + } + if (!ignore_toggle) { if (Keyboard::is_context_menu_event (ev)) { @@ -205,10 +236,10 @@ RouteUI::solo_press(GdkEventButton* ev) if (ev->button == 2) { - // 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; @@ -217,9 +248,9 @@ RouteUI::solo_press(GdkEventButton* ev) if (ev->button == 1 || ev->button == 2) { - 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 (_("solo change")); Session::GlobalSoloStateCommand *cmd = new Session::GlobalSoloStateCommand(_session, this); @@ -228,9 +259,9 @@ RouteUI::solo_press(GdkEventButton* ev) _session.add_command (cmd); _session.commit_reversible_command (); - } 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); @@ -240,17 +271,17 @@ 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; - } 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) { @@ -260,7 +291,6 @@ RouteUI::solo_press(GdkEventButton* ev) } else { /* click: solo this route */ - reversibly_apply_route_boolean ("solo change", &Route::set_solo, !_route->soloed(), this); } } @@ -289,6 +319,10 @@ RouteUI::solo_release(GdkEventButton* ev) bool RouteUI::rec_enable_press(GdkEventButton* ev) { + if (ev->type == GDK_2BUTTON_PRESS) { + return true; + } + if (!_session.engine().connected()) { MessageDialog msg (_("Not connected to JACK - cannot engage record")); msg.run (); @@ -297,10 +331,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 (ev->button == 2 && Keyboard::modifier_state_equals (ev->state, Keyboard::PrimaryModifier)) { + // do nothing on midi bind event - } - else if (Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control|Keyboard::Shift))) { + return false; + + } 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); @@ -315,23 +351,27 @@ 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_track_boolean ("rec-enable change", &Track::set_record_enable, !track()->record_enabled(), this); - - ignore_toggle = true; - rec_enable_button->set_active(track()->record_enabled()); - ignore_toggle = false; } - - stop_signal (*rec_enable_button, "button-press-event"); } - return TRUE; + return true; +} + +bool +RouteUI::rec_enable_release (GdkEventButton* ev) +{ + return true; } void @@ -344,22 +384,30 @@ void RouteUI::update_solo_display () { bool x; - + vector fg_colors; + Gdk::Color c; + if (solo_button->get_active() != (x = _route->soloed())){ ignore_toggle = true; solo_button->set_active(x); ignore_toggle = false; - } + } - /* show solo safe */ - - if (_route->solo_safe()){ - solo_button->set_name(safe_solo_button_name()); + if (_route->solo_safe()) { + solo_button->set_visual_state (2); + } else if (_route->soloed()) { + solo_button->set_visual_state (1); } else { - solo_button->set_name(solo_button_name()); + solo_button->set_visual_state (0); } } +void +RouteUI::solo_changed_so_update_mute () +{ + Gtkmm2ext::UI::instance()->call_slot (mem_fun (*this, &RouteUI::update_mute_display)); +} + void RouteUI::mute_changed(void* src) { @@ -369,13 +417,38 @@ RouteUI::mute_changed(void* src) void RouteUI::update_mute_display () { - bool x; + bool model = _route->muted(); + bool view = mute_button->get_active(); - if (mute_button->get_active() != (x = _route->muted())){ + /* first make sure the button's "depressed" visual + is correct. + */ + + if (model != view) { ignore_toggle = true; - mute_button->set_active(x); + mute_button->set_active (model); ignore_toggle = false; } + + /* now attend to visual state */ + + if (Config->get_show_solo_mutes()) { + if (_route->muted()) { + mute_button->set_visual_state (2); + } else if (!_route->soloed() && _route->solo_muted()) { + + mute_button->set_visual_state (1); + } else { + mute_button->set_visual_state (0); + } + } else { + if (_route->muted()) { + mute_button->set_visual_state (2); + } else { + mute_button->set_visual_state (0); + } + } + } void @@ -399,36 +472,31 @@ RouteUI::update_rec_display () /* first make sure the button's "depressed" visual is correct. */ - + if (model != view) { ignore_toggle = true; rec_enable_button->set_active (model); ignore_toggle = false; } - + /* now make sure its color state is correct */ if (model) { switch (_session.record_status ()) { + case Session::Recording: + rec_enable_button->set_visual_state (1); + break; + case Session::Disabled: case Session::Enabled: - if (rec_enable_button->get_state() != Gtk::STATE_ACTIVE) { - rec_enable_button->set_state (Gtk::STATE_ACTIVE); - } + rec_enable_button->set_visual_state (2); break; - case Session::Recording: - if (rec_enable_button->get_state() != Gtk::STATE_SELECTED) { - rec_enable_button->set_state (Gtk::STATE_SELECTED); - } - break; } } else { - if (rec_enable_button->get_state() != Gtk::STATE_NORMAL) { - rec_enable_button->set_state (Gtk::STATE_NORMAL); - } + rec_enable_button->set_visual_state (0); } } @@ -442,11 +510,19 @@ RouteUI::build_remote_control_menu () void RouteUI::refresh_remote_control_menu () { + ENSURE_GUI_THREAD (mem_fun (*this, &RouteUI::refresh_remote_control_menu)); + + // only refresh the menu if it has been instantiated + + if (remote_control_menu == 0) { + return; + } + using namespace Menu_Helpers; RadioMenuItem::Group rc_group; CheckMenuItem* rc_active; - uint32_t limit = _session.ntracks(); + uint32_t limit = _session.ntracks() + _session.nbusses(); char buf[32]; MenuList& rc_items = remote_control_menu->items(); @@ -595,10 +671,10 @@ 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 (); } @@ -606,9 +682,9 @@ void RouteUI::reversibly_apply_track_boolean (string name, void (Track::*func)(bool, void *), bool yn, void *arg) { _session.begin_reversible_command (name); - XMLNode &before = track()->get_state(); + XMLNode &before = track()->get_state(); bind (mem_fun (*track(), func), yn, arg)(); - XMLNode &after = track()->get_state(); + XMLNode &after = track()->get_state(); _session.add_command (new MementoCommand(*track(), &before, &after)); _session.commit_reversible_command (); } @@ -690,18 +766,26 @@ RouteUI::ensure_xml_node () } XMLNode* -RouteUI::get_child_xml_node (const string & childname) +RouteUI::get_automation_child_xml_node (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; + + 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() == param.symbol()) + return *iter; + } } + // Didn't find it, make a new one + XMLNode* child = new XMLNode (AutomationTimeAxisView::state_node_name); + child->add_property("automation-id", param.symbol()); + xml_node->add_child_nocopy (*child); + return child; } @@ -768,7 +852,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; } @@ -778,9 +862,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()); } @@ -831,6 +915,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) { @@ -899,37 +1005,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 dynamic_cast(_route.get()) != 0; + return boost::dynamic_pointer_cast(_route) != 0; } -MidiTrack* +boost::shared_ptr RouteUI::midi_track() const { - return dynamic_cast(_route.get()); + return boost::dynamic_pointer_cast(_route); } boost::shared_ptr @@ -969,3 +1075,8 @@ RouteUI::map_frozen () } } +void +RouteUI::adjust_latency () +{ + LatencyDialog dialog (_route->name() + _("latency"), *(_route.get()), _session.frame_rate(), _session.engine().frames_per_cycle()); +}