fix OSX compilation
[ardour.git] / gtk2_ardour / option_editor.h
index 47afa77868f6186be211db07894235c8992619e0..53c671287831a4288383490cf2abd5a933715644 100644 (file)
 #include <gtkmm/comboboxtext.h>
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/table.h>
+#include <gtkmm/window.h>
+
 #include "gtkmm2ext/slider_controller.h"
+
 #include "ardour_window.h"
 #include "audio_clock.h"
 #include "ardour/types.h"
@@ -46,7 +49,7 @@
  *  options dialog.
  */
 
-namespace ARDOUR {
+namespace PBD {
        class Configuration;
 }
 
@@ -78,7 +81,7 @@ public:
 
 private:
        void maybe_add_note (OptionEditorPage *, int);
-       
+
        std::string _note;
 };
 
@@ -121,6 +124,38 @@ protected:
        Gtk::VBox* _box; ///< constituent box for subclasses to add widgets to
 };
 
+class RcConfigDisplay : public OptionEditorComponent
+{
+public:
+       RcConfigDisplay (std::string const &, std::string const &, sigc::slot<std::string>, char s = '\0');
+       void add_to_page (OptionEditorPage *);
+       void parameter_changed (std::string const & p);
+       void set_state_from_config ();
+       Gtk::Widget& tip_widget() { return *_info; }
+protected:
+       sigc::slot<std::string> _get;
+       Gtk::Label* _label;
+       Gtk::Label* _info;
+       std::string _id;
+       char _sep;
+};
+
+class RcActionButton : public OptionEditorComponent
+{
+public:
+       RcActionButton (std::string const & t, const Glib::SignalProxy0< void >::SlotType & slot, std::string const & l = "");
+       void add_to_page (OptionEditorPage *);
+
+       void parameter_changed (std::string const & p) {}
+       void set_state_from_config () {}
+       Gtk::Widget& tip_widget() { return *_button; }
+
+protected:
+       Gtk::Button* _button;
+       Gtk::Label* _label;
+       std::string _name;
+};
+
 /** Base class for components which provide UI to change an option */
 class Option : public OptionEditorComponent
 {
@@ -169,11 +204,11 @@ public:
                _button->set_sensitive (yn);
        }
 
-        Gtk::Widget& tip_widget() { return *_button; }
+       Gtk::Widget& tip_widget() { return *_button; }
 
-private:
+protected:
 
-       void toggled ();
+       virtual 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
@@ -181,6 +216,31 @@ private:
        Gtk::Label*            _label; ///< label for button, so we can use markup
 };
 
+class RouteDisplayBoolOption : public BoolOption
+{
+public:
+       RouteDisplayBoolOption (std::string const &, std::string const &, sigc::slot<bool>, sigc::slot<bool, bool>);
+protected:
+       virtual void toggled ();
+};
+
+/** Component which allows to add any GTK Widget - intended for single buttons and custom stateless objects */
+class FooOption : public OptionEditorComponent
+{
+public:
+       FooOption (Gtk::Widget *w) : _w (w) {}
+
+       void add_to_page (OptionEditorPage* p) {
+               add_widget_to_page (p, _w);
+       }
+
+       Gtk::Widget& tip_widget() { return *_w; }
+       void set_state_from_config () {}
+       void parameter_changed (std::string const &) {}
+private:
+       Gtk::Widget *_w;
+};
+
 /** Component which provides the UI to handle a string option using a GTK Entry */
 class EntryOption : public Option
 {
@@ -189,17 +249,22 @@ 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*);
+       void set_sensitive (bool);
+       void set_invalid_chars (std::string i) { _invalid = i; }
 
-        Gtk::Widget& tip_widget() { return *_entry; }
+       Gtk::Widget& tip_widget() { return *_entry; }
 
 private:
 
        void activated ();
+       bool focus_out (GdkEventFocus*);
+       void filter_text (const Glib::ustring&, int*);
 
        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
+       std::string _invalid;
 };
 
 
@@ -347,6 +412,7 @@ public:
        }
 
        Gtk::Widget& tip_widget() { return *_hscale; }
+       Gtk::HScale& scale() { return *_hscale; }
 
 private:
        sigc::slot<float> _get;
@@ -475,6 +541,7 @@ public:
         *  @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)
+        *  @param digits Number of decimal digits to show.
         */
        SpinOption (
                std::string const & i,
@@ -486,7 +553,8 @@ public:
                T step,
                T page,
                std::string const & unit = "",
-               float scale = 1
+               float scale = 1,
+               unsigned digits = 0
                )
                : Option (i, n),
                  _get (g),
@@ -499,6 +567,7 @@ public:
                _spin = Gtk::manage (new Gtk::SpinButton);
                _spin->set_range (min, max);
                _spin->set_increments (step, page);
+               _spin->set_digits(digits);
 
                _box = Gtk::manage (new Gtk::HBox);
                _box->pack_start (*_spin, true, true);
@@ -548,6 +617,8 @@ public:
 
 private:
        void db_changed ();
+       void on_activate ();
+       bool on_key_press (GdkEventKey* ev);
 
        Gtk::Adjustment _db_adjustment;
        Gtkmm2ext::HSliderController* _db_slider;
@@ -590,9 +661,8 @@ public:
         Gtk::Widget& tip_widget() { return _file_chooser; }
 
 private:
-       void file_set ();
-       void current_folder_set ();
-       
+       void selection_changed ();
+
        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::FileChooserButton _file_chooser;
@@ -613,30 +683,68 @@ public:
 };
 
 /** The OptionEditor dialog base class */
-class OptionEditor : public ArdourWindow
+class OptionEditor : virtual public sigc::trackable
 {
 public:
-       OptionEditor (ARDOUR::Configuration *, std::string const &);
-       ~OptionEditor ();
+       OptionEditor (PBD::Configuration *);
+       virtual ~OptionEditor ();
 
        void add_option (std::string const &, OptionEditorComponent *);
+       void add_page (std::string const &, Gtk::Widget& page_widget);
 
        void set_current_page (std::string const &);
 
 protected:
-
        virtual void parameter_changed (std::string const &);
 
-       ARDOUR::Configuration* _config;
+       PBD::Configuration* _config;
+       Gtk::Notebook& notebook() { return _notebook; }
+       Gtk::TreeView& treeview() { return option_treeview; }
 
-private:
+       class OptionColumns : public Gtk::TreeModel::ColumnRecord
+       {
+          public:
+               Gtk::TreeModelColumn<std::string> name;
+               Gtk::TreeModelColumn<Gtk::Widget*> widget;
 
-       PBD::ScopedConnection config_connection;
+               OptionColumns() {
+                       add (name);
+                       add (widget);
+               }
+       };
+
+       OptionColumns option_columns;
+       Glib::RefPtr<Gtk::TreeStore> option_tree;
 
+private:
+       PBD::ScopedConnection config_connection;
        Gtk::Notebook _notebook;
+       Gtk::TreeView option_treeview;
        std::map<std::string, OptionEditorPage*> _pages;
+
+       void add_path_to_treeview (std::string const &, Gtk::Widget&);
+       void treeview_row_selected ();
 };
 
-#endif /* __gtk_ardour_option_editor_h__ */
+/** The OptionEditor dialog-as-container base class */
+class OptionEditorContainer : public OptionEditor, public Gtk::VBox
+{
+public:
+       OptionEditorContainer (PBD::Configuration *, std::string const &);
+       ~OptionEditorContainer() {}
+private:
+       Gtk::HBox hpacker;
+};
 
+/** The OptionEditor dialog-as-container base class */
+class OptionEditorWindow : public OptionEditor, public ArdourWindow
+{
+public:
+       OptionEditorWindow (PBD::Configuration *, std::string const &);
+       ~OptionEditorWindow() {}
+private:
+       Gtk::VBox container;
+       Gtk::HBox hpacker;
+};
 
+#endif /* __gtk_ardour_option_editor_h__ */