Allow overrides of the user-set visibility stuff and use it to make sure the master...
authorCarl Hetherington <carl@carlh.net>
Thu, 3 Nov 2011 01:44:17 +0000 (01:44 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 3 Nov 2011 01:44:17 +0000 (01:44 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10407 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_strip.h
gtk2_ardour/visibility_group.cc
gtk2_ardour/visibility_group.h

index 4f4d400a5686261f491cd6e4e610ca52136c8951..288e9f830d0cde0293e0d06d2a2c456aefdde17e 100644 (file)
@@ -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<bool>
+MixerStrip::override_solo_visibility () const
+{
+       if (_route && _route->is_master ()) {
+               return boost::optional<bool> (false);
+       }
+       
+       return boost::optional<bool> ();
+}
index 6cb084922abfab6e924db676b55cc5b2133737c1..5c2cf50f332d941f49f137e5ca649088a35914d2 100644 (file)
@@ -301,6 +301,7 @@ class MixerStrip : public RouteUI, public Gtk::EventBox
         *  the RC option editor.
         */
        VisibilityGroup _visibility;
+       boost::optional<bool> override_solo_visibility () const;
 
        PBD::ScopedConnection _config_connection;
 
index c817ff3fcb1dba86429d0c98ea075bc8d24fdcc9..69afed9814045e0e8150f42cf5435636a179d7f8 100644 (file)
@@ -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<boost::optional<bool> ()> 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<bool> 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<Member>::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 ();
index d9e13e1e930c04ec5ec706de8be08980cf499506..940b8bcc528b8077a87275da31059276e8e691ce 100644 (file)
@@ -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<boost::optional<bool> ()> = 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<boost::optional<bool> ()> override;
        };
 
        class ModelColumns : public Gtk::TreeModelColumnRecord {
@@ -74,6 +82,7 @@ private:
        void toggle (std::vector<Member>::iterator);
        void list_view_visible_changed (std::string const &);
        void update_list_view ();
+       bool should_actually_be_visible (Member const &) const;
 
        std::vector<Member> _members;
        std::string _xml_property_name;