X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Froute_ui.cc;h=e0591f080639b947f9e6043e83245350f17a84f0;hb=cd9fdb935f08966cc8c7170a39870e8adcae69d8;hp=c122f666ebb79d58a75bba8dce235f97f051cf85;hpb=8e79cd5610789b377d0975640a555cc45d9300cb;p=ardour.git diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index c122f666eb..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 @@ -40,6 +39,8 @@ #include #include #include +#include +#include #include "i18n.h" using namespace sigc; @@ -64,6 +65,8 @@ 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; if (set_color_from_route()) { set_color (unique_random_color()); @@ -73,30 +76,15 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, co _route->active_changed.connect (mem_fun (*this, &RouteUI::route_active_changed)); - mute_button = manage (new BindableToggleButton (_route->mute_control(), m_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 = manage (new BindableToggleButton (_route->solo_control(), s_name )); + solo_button->set_self_managed (true); mute_button->set_name ("MuteButton"); solo_button->set_name ("SoloButton"); - vector colors; - Gdk::Color c; - - ::set_color(c, rgba_from_style (X_("MuteButton"), 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_SELECTED, false )); - colors.push_back (c); - ::set_color(c, rgba_from_style (X_("MuteButton"), 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false )); - colors.push_back (c); - mute_button->set_colors (colors); - - colors.clear (); - - /* mute+solo buttons get 2 color states, so add one here to supplement the existing one */ - ::set_color(c, rgba_from_style (X_("SoloButton"), 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false )); - colors.push_back (c); - solo_button->set_colors (colors); - _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)); @@ -105,9 +93,6 @@ RouteUI::RouteUI (boost::shared_ptr rt, ARDOUR::Session& sess, co _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); @@ -116,27 +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 )); - - /* we manage colors for the rec button, since it has 3 (disabled,enabled,recording), - not just 2 (active&inactive) - */ - + rec_enable_button->set_name ("RecordEnableButton"); rec_enable_button->set_self_managed (true); - colors.clear (); - - /* record button has 3 color states, so we set 2 extra here */ - ::set_color(c, rgba_from_style (X_("RecordEnableButton"), 0xff, 0, 0, 0, "bg", Gtk::STATE_SELECTED, false )); - colors.push_back (c); - - ::set_color(c, rgba_from_style (X_("RecordEnableButton"), 0xff, 0, 0, 0, "bg", Gtk::STATE_ACTIVE, false )); - colors.push_back (c); - - rec_enable_button->set_colors (colors); - 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 (); @@ -359,7 +334,7 @@ RouteUI::rec_enable_press(GdkEventButton* ev) } 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); } } @@ -382,32 +357,22 @@ void RouteUI::update_solo_display () { bool x; - vector colors; + vector fg_colors; Gdk::Color c; - - if (_route->solo_safe() != was_solo_safe){ - - if (_route->solo_safe()) { - /* show solo safe */ - ::set_color(c, rgba_from_style (safe_solo_button_name(), 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false )); - solo_button->set_name(safe_solo_button_name()); - } else { - ::set_color(c, rgba_from_style (solo_button_name(), 0x7f, 0xff, 0x7f, 0, "bg", Gtk::STATE_ACTIVE, false )); - solo_button->set_name(solo_button_name()); - } - - colors.push_back (c); - solo_button->set_colors (colors); - - was_solo_safe = !was_solo_safe; - } - + if (solo_button->get_active() != (x = _route->soloed())){ ignore_toggle = true; solo_button->set_active(x); ignore_toggle = false; } + if (_route->solo_safe()) { + solo_button->set_visual_state (2); + } else if (_route->soloed()) { + solo_button->set_visual_state (1); + } else { + solo_button->set_visual_state (0); + } } void @@ -425,7 +390,7 @@ RouteUI::mute_changed(void* src) void RouteUI::update_mute_display () { - bool model = _route->record_enabled(); + bool model = _route->muted(); bool view = mute_button->get_active(); /* first make sure the button's "depressed" visual @@ -492,14 +457,15 @@ RouteUI::update_rec_display () if (model) { switch (_session.record_status ()) { - case Session::Disabled: - case Session::Enabled: + case Session::Recording: rec_enable_button->set_visual_state (1); break; - case Session::Recording: + case Session::Disabled: + case Session::Enabled: rec_enable_button->set_visual_state (2); break; + } } else { @@ -517,6 +483,14 @@ 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; @@ -678,13 +652,13 @@ RouteUI::reversibly_apply_route_boolean (string name, void (Route::*func)(bool, } 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 (); } @@ -906,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) { @@ -974,25 +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 boost::dynamic_pointer_cast(_route) != 0; +} + +boost::shared_ptr +RouteUI::midi_track() const +{ + return boost::dynamic_pointer_cast(_route); } boost::shared_ptr