X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=e0591f080639b947f9e6043e83245350f17a84f0;hb=cd9fdb935f08966cc8c7170a39870e8adcae69d8;hp=040dac6e0ee920cf09c00819a608acea4cadbd5d;hpb=7bd41538d951c3e476655df741adfbebbb990bde;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 040dac6e0e..e0591f0806 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 @@ -26,6 +25,8 @@ #include #include +#include +#include #include "route_ui.h" #include "keyboard.h" @@ -34,6 +35,8 @@ #include "gui_thread.h" #include +#include +#include #include #include #include @@ -46,7 +49,6 @@ 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), @@ -62,16 +64,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()); } - _route->GoingAway.connect (mem_fun (*this, &RouteUI::route_removed)); + 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 )); - solo_button = manage (new BindableToggleButton (_route->solo_control(), s_name )); + 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->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); @@ -81,15 +101,17 @@ 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->set_name ("RecordEnableButton"); + rec_enable_button->set_self_managed (true); - rec_enable_button->unset_flags (Gtk::CAN_FOCUS); - 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)); + /* map the current state */ map_frozen (); @@ -97,6 +119,7 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, co RouteUI::~RouteUI() { + GoingAway (); /* EMIT SIGNAL */ delete mute_menu; } @@ -111,7 +134,7 @@ RouteUI::mute_press(GdkEventButton* ev) build_mute_menu(); } - mute_menu->popup(0,0); + mute_menu->popup(0,ev->time); } else { @@ -121,6 +144,8 @@ RouteUI::mute_press(GdkEventButton* ev) if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control))) { wait_for_release = true; + } else { + return false; } } @@ -186,7 +211,7 @@ RouteUI::solo_press(GdkEventButton* ev) build_solo_menu (); } - solo_menu->popup (1, 0); + solo_menu->popup (1, ev->time); } else { @@ -197,6 +222,8 @@ RouteUI::solo_press(GdkEventButton* ev) if (!Keyboard::modifier_state_equals (ev->state, Keyboard::ModifierMask (Keyboard::Control))) { wait_for_release = true; + } else { + return false; } } @@ -274,12 +301,19 @@ RouteUI::solo_release(GdkEventButton* ev) bool RouteUI::rec_enable_press(GdkEventButton* ev) { + if (!_session.engine().connected()) { + MessageDialog msg (_("Not connected to JACK - cannot engage record")); + msg.run (); + return true; + } + if (!ignore_toggle && is_track() && rec_enable_button) { if (ev->button == 2 && Keyboard::modifier_state_equals (ev->state, Keyboard::Control)) { + // do nothing on midi bind event - } - 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::Control|Keyboard::Shift))) { _session.begin_reversible_command (_("rec-enable change")); Session::GlobalRecordEnableStateCommand *cmd = new Session::GlobalRecordEnableStateCommand(_session, this); @@ -301,16 +335,16 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } 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 @@ -323,22 +357,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) { @@ -348,13 +390,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 @@ -378,7 +445,7 @@ 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); @@ -390,24 +457,19 @@ RouteUI::update_rec_display () 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); } } @@ -421,11 +483,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(); @@ -486,7 +556,7 @@ RouteUI::build_solo_menu (void) items.push_back (CheckMenuElem(*check)); check->show_all(); - items.push_back (SeparatorElem()); + //items.push_back (SeparatorElem()); // items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn))); } @@ -529,7 +599,7 @@ RouteUI::build_mute_menu(void) items.push_back (CheckMenuElem(*check)); check->show_all(); - items.push_back (SeparatorElem()); + //items.push_back (SeparatorElem()); // items.push_back (MenuElem (_("MIDI Bind"), mem_fun (*mute_button, &BindableToggleButton::midi_learn))); } @@ -581,17 +651,6 @@ RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool, _session.commit_reversible_command (); } -void -RouteUI::reversibly_apply_audio_track_boolean (string name, void (AudioTrack::*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)); - _session.commit_reversible_command (); -} - void RouteUI::reversibly_apply_track_boolean (string name, void (Track::*func)(bool, void *), bool yn, void *arg) { @@ -664,7 +723,7 @@ RouteUI::set_color (const Gdk::Color & c) snprintf (buf, sizeof (buf), "%d:%d:%d", c.get_red(), c.get_green(), c.get_blue()); xml_node->add_property ("color", buf); - _route->gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */ + _route->gui_changed ("color", (void *) 0); /* EMIT_SIGNAL */ } @@ -742,13 +801,6 @@ RouteUI::idle_remove_this_route (RouteUI *rui) return FALSE; } -void -RouteUI::route_removed () -{ - ENSURE_GUI_THREAD(mem_fun (*this, &RouteUI::route_removed)); - delete this; -} - void RouteUI::route_rename () { @@ -828,6 +880,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) { @@ -896,37 +970,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