+/** A class which allows control of visibility of some editor components usign
+ * a VisibilityGroup. The caller should pass in a `dummy' VisibilityGroup
+ * which has the correct members, but with null widget pointers. This
+ * class allows the user to set visibility of the members, the details
+ * of which are stored in a configuration variable which can be watched
+ * by parts of the editor that actually contain the widgets whose visibility
+ * is being controlled.
+ */
+
+class VisibilityOption : public Option
+{
+public:
+ /** @param name User-visible name for this group.
+ * @param g `Dummy' VisibilityGroup (as described above).
+ * @param get Method to get the value of the appropriate configuration variable.
+ * @param set Method to set the value of the appropriate configuration variable.
+ */
+ VisibilityOption (string name, VisibilityGroup* g, sigc::slot<string> get, sigc::slot<bool, string> set)
+ : Option (g->get_state_name(), name)
+ , _heading (name)
+ , _visibility_group (g)
+ , _get (get)
+ , _set (set)
+ {
+ /* Watch for changes made by the user to our members */
+ _visibility_group->VisibilityChanged.connect_same_thread (
+ _visibility_group_connection, sigc::bind (&VisibilityOption::changed, this)
+ );
+ }
+
+ void set_state_from_config ()
+ {
+ /* Set our state from the current configuration */
+ _visibility_group->set_state (_get ());
+ }
+
+ void add_to_page (OptionEditorPage* p)
+ {
+ _heading.add_to_page (p);
+ add_widget_to_page (p, _visibility_group->list_view ());
+ }
+
+private:
+ void changed ()
+ {
+ /* The user has changed something, so reflect this change
+ in the RCConfiguration.
+ */
+ _set (_visibility_group->get_state_value ());
+ }
+
+ OptionEditorHeading _heading;
+ VisibilityGroup* _visibility_group;
+ sigc::slot<std::string> _get;
+ sigc::slot<bool, std::string> _set;
+ PBD::ScopedConnection _visibility_group_connection;
+};
+