diff options
author | Carl Hetherington <carl@carlh.net> | 2011-11-03 01:44:17 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-11-03 01:44:17 +0000 |
commit | 154c2a35d7a14eda847a6a610f5fbe8fb17109d8 (patch) | |
tree | 0ab60ea0bd686f2fde078a5ff3a0d7a74135f7d6 /gtk2_ardour/visibility_group.cc | |
parent | 22d87a18dc602ef29a82f5c1fa68ba00ecacfe4b (diff) |
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
Diffstat (limited to 'gtk2_ardour/visibility_group.cc')
-rw-r--r-- | gtk2_ardour/visibility_group.cc | 22 |
1 files changed, 20 insertions, 2 deletions
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<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 (); |