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
This commit is contained in:
Carl Hetherington 2011-11-03 01:44:17 +00:00
parent 22d87a18dc
commit 154c2a35d7
4 changed files with 48 additions and 5 deletions

View 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> ();
}

View 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;

View 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 ();

View 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;