diff options
Diffstat (limited to 'gtk2_ardour/rc_option_editor.cc')
-rw-r--r-- | gtk2_ardour/rc_option_editor.cc | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index df2c7ed227..b1fcc45570 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -790,10 +790,69 @@ private: Gtk::Window& _parent; }; +/** 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; +}; + RCOptionEditor::RCOptionEditor () : OptionEditor (Config, string_compose (_("%1 Preferences"), PROGRAM_NAME)) , _rc_config (Config) + , _mixer_strip_visibility ("mixer-strip-visibility") { /* MISC */ @@ -1460,6 +1519,25 @@ RCOptionEditor::RCOptionEditor () /* KEYBOARD */ add_option (_("Keyboard"), new KeyboardOptions); + + /* INTERFACE */ + + /* The names of these controls must be the same as those given in MixerStrip + for the actual widgets being controlled. + */ + _mixer_strip_visibility.add (0, X_("PhaseInvert"), _("Phase Invert")); + _mixer_strip_visibility.add (0, X_("SoloSafe"), _("Solo Safe")); + _mixer_strip_visibility.add (0, X_("SoloIsolated"), _("Solo Isolated")); + + add_option ( + _("Interface"), + new VisibilityOption ( + _("Mixer Strip"), + &_mixer_strip_visibility, + sigc::mem_fun (*_rc_config, &RCConfiguration::get_mixer_strip_visibility), + sigc::mem_fun (*_rc_config, &RCConfiguration::set_mixer_strip_visibility) + ) + ); } void |