From: Carl Hetherington Date: Thu, 3 Nov 2011 01:44:17 +0000 (+0000) Subject: Allow overrides of the user-set visibility stuff and use it to make sure the master... X-Git-Tag: 3.0-beta1~180 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=154c2a35d7a14eda847a6a610f5fbe8fb17109d8;p=ardour.git Allow overrides of the user-set visibility stuff and use it to make sure the master bus doesn't get solo isolate etc. (#4431). git-svn-id: svn://localhost/ardour2/branches/3.0@10407 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 4f4d400a56..288e9f830d 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -338,8 +338,8 @@ MixerStrip::init () are recognised when they occur. */ _visibility.add (&_invert_button_box, X_("PhaseInvert"), _("Phase Invert")); - _visibility.add (solo_safe_led, X_("SoloSafe"), _("Solo Safe")); - _visibility.add (solo_isolated_led, X_("SoloIsolated"), _("Solo Isolated")); + _visibility.add (solo_safe_led, X_("SoloSafe"), _("Solo Safe"), true, boost::bind (&MixerStrip::override_solo_visibility, this)); + _visibility.add (solo_isolated_led, X_("SoloIsolated"), _("Solo Isolated"), true, boost::bind (&MixerStrip::override_solo_visibility, this)); _visibility.add (&_comment_button, X_("Comments"), _("Comments")); _visibility.add (&group_button, X_("Group"), _("Group")); _visibility.add (&meter_point_button, X_("MeterPoint"), _("Meter Point")); @@ -2000,3 +2000,18 @@ MixerStrip::parameter_changed (string p) _visibility.set_state (Config->get_mixer_strip_visibility ()); } } + +/** Called to decide whether the solo isolate / solo lock button visibility should + * be overridden from that configured by the user. We do this for the master bus. + * + * @return optional value that is present if visibility state should be overridden. + */ +boost::optional +MixerStrip::override_solo_visibility () const +{ + if (_route && _route->is_master ()) { + return boost::optional (false); + } + + return boost::optional (); +} diff --git a/gtk2_ardour/mixer_strip.h b/gtk2_ardour/mixer_strip.h index 6cb084922a..5c2cf50f33 100644 --- a/gtk2_ardour/mixer_strip.h +++ b/gtk2_ardour/mixer_strip.h @@ -301,6 +301,7 @@ class MixerStrip : public RouteUI, public Gtk::EventBox * the RC option editor. */ VisibilityGroup _visibility; + boost::optional override_solo_visibility () const; PBD::ScopedConnection _config_connection; diff --git a/gtk2_ardour/visibility_group.cc b/gtk2_ardour/visibility_group.cc index c817ff3fcb..69afed9814 100644 --- a/gtk2_ardour/visibility_group.cc +++ b/gtk2_ardour/visibility_group.cc @@ -40,16 +40,20 @@ VisibilityGroup::VisibilityGroup (std::string const & name) * @param id Some single-word ID to be used for the state of this member in XML. * @param name User-visible name for the widget. * @param visible true to default to visible, otherwise false. + * @param override A functor to decide whether the visibility specified by the member should be + * overridden by some external factor; if the returned optional value is given, it will be used + * to override whatever visibility setting the member has. */ void -VisibilityGroup::add (Gtk::Widget* widget, string const & id, string const & name, bool visible) +VisibilityGroup::add (Gtk::Widget* widget, string const & id, string const & name, bool visible, boost::function ()> override) { Member m; m.widget = widget; m.id = id; m.name = name; m.visible = visible; + m.override = override; _members.push_back (m); } @@ -84,13 +88,27 @@ VisibilityGroup::menu () return m; } +/** @return true if the member should be visible, even taking into account any override functor */ +bool +VisibilityGroup::should_actually_be_visible (Member const & m) const +{ + if (m.override) { + boost::optional o = m.override (); + if (o) { + return o; + } + } + + return m.visible; +} + /** Update visible consequences of any changes to our _members vector */ void VisibilityGroup::update () { for (vector::iterator i = _members.begin(); i != _members.end(); ++i) { if (i->widget) { - if (i->visible) { + if (should_actually_be_visible (*i)) { i->widget->show (); } else { i->widget->hide (); diff --git a/gtk2_ardour/visibility_group.h b/gtk2_ardour/visibility_group.h index d9e13e1e93..940b8bcc52 100644 --- a/gtk2_ardour/visibility_group.h +++ b/gtk2_ardour/visibility_group.h @@ -37,7 +37,14 @@ class VisibilityGroup public: VisibilityGroup (std::string const &); - void add (Gtk::Widget *, std::string const &, std::string const &, bool visible = true); + void add ( + Gtk::Widget *, + std::string const &, + std::string const &, + bool visible = 0, + boost::function ()> = 0 + ); + Gtk::Menu* menu (); Gtk::Widget* list_view (); bool button_press_event (GdkEventButton *); @@ -56,6 +63,7 @@ private: std::string id; std::string name; bool visible; + boost::function ()> override; }; class ModelColumns : public Gtk::TreeModelColumnRecord { @@ -74,6 +82,7 @@ private: void toggle (std::vector::iterator); void list_view_visible_changed (std::string const &); void update_list_view (); + bool should_actually_be_visible (Member const &) const; std::vector _members; std::string _xml_property_name;