diff options
author | Carl Hetherington <carl@carlh.net> | 2009-05-16 01:22:43 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-05-16 01:22:43 +0000 |
commit | 29e8fe16987548d44b6376a38c81da7737efde28 (patch) | |
tree | 492c7b25e94f6d531699bb31b5786657276296bf /gtk2_ardour/option_editor.h | |
parent | f4e6f8fec5c4ed705b2f0124666d632c392dbbc3 (diff) |
Add session preferences dialog.
git-svn-id: svn://localhost/ardour2/branches/3.0@5082 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/option_editor.h')
-rw-r--r-- | gtk2_ardour/option_editor.h | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index 0f0c5956f8..37ae91d0cb 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -145,16 +145,37 @@ public: BoolOption (std::string const &, std::string const &, sigc::slot<bool>, sigc::slot<bool, bool>); void set_state_from_config (); - void toggled (); void add_to_page (OptionEditorPage*); private: + + void toggled (); sigc::slot<bool> _get; ///< slot to get the configuration variable's value sigc::slot<bool, bool> _set; ///< slot to set the configuration variable's value Gtk::CheckButton* _button; ///< UI button }; +/** Component which provides the UI to handle a string option using a GTK Entry */ +class EntryOption : public Option { + +public: + + EntryOption (std::string const &, std::string const &, sigc::slot<std::string>, sigc::slot<bool, std::string>); + void set_state_from_config (); + void add_to_page (OptionEditorPage*); + +private: + + void activated (); + + sigc::slot<std::string> _get; ///< slot to get the configuration variable's value + sigc::slot<bool, std::string> _set; ///< slot to set the configuration variable's value + Gtk::Label* _label; ///< UI label + Gtk::Entry* _entry; ///< UI entry +}; + + /** Component which provides the UI to handle an enumerated option using a GTK CheckButton. * The template parameter is the enumeration. */ @@ -241,6 +262,8 @@ public: * @param max Variable maximum value. * @param step Step for the spin button. * @param page Page step for the spin button. + * @param unit Unit name. + * @param scale Scaling factor (such that for a value x in the spinbutton, x * scale is written to the config) */ SpinOption ( std::string const & i, @@ -250,39 +273,53 @@ public: T min, T max, T step, - T page + T page, + std::string const & unit = "", + float scale = 1 ) : Option (i, n), _get (g), - _set (s) + _set (s), + _scale (scale) { _label = manage (new Gtk::Label (n + ":")); _label->set_alignment (1, 0.5); + _spin = manage (new Gtk::SpinButton); _spin->set_range (min, max); _spin->set_increments (step, page); + + _box = manage (new Gtk::HBox); + _box->pack_start (*_spin, true, true); + _box->set_spacing (4); + if (unit.length()) { + _box->pack_start (*manage (new Gtk::Label (unit)), false, false); + } + _spin->signal_value_changed().connect (sigc::mem_fun (*this, &SpinOption::changed)); } void set_state_from_config () { - _spin->set_value (_get ()); + _spin->set_value (_get () / _scale); } void add_to_page (OptionEditorPage* p) { - add_widgets_to_page (p, _label, _spin); + add_widgets_to_page (p, _label, _box); } void changed () { - _set (static_cast<T> (_spin->get_value ())); + _set (static_cast<T> (_spin->get_value ()) * _scale); } private: sigc::slot<T> _get; sigc::slot<bool, T> _set; + float _scale; Gtk::Label* _label; + Gtk::HBox* _box; Gtk::SpinButton* _spin; }; @@ -314,6 +351,7 @@ protected: ARDOUR::Configuration* _config; private: + void parameter_changed (std::string const &); Gtk::Notebook _notebook; |