fix pango font style (prev commit)
[ardour.git] / gtk2_ardour / ui_config.h
index f96659de76a661a60a2e00744392f3c06fca9494..ec9e1ad940acb23e2cb4e569c775c351fd447708 100644 (file)
 #include "pbd/xml++.h"
 #include "ardour/configuration_variable.h"
 
+/* This is very similar to ARDOUR::ConfigVariable but expects numeric values to
+ * be in hexadecimal. This is because it is intended for use with color
+ * specifications which are easier to scan for issues in "rrggbbaa" format than
+ * as decimals.
+ */
 template<class T>
-class UIConfigVariable : public ARDOUR::ConfigVariableBase
+class ColorVariable : public ARDOUR::ConfigVariableBase
 {
   public:
-       UIConfigVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
-       UIConfigVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
+       ColorVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
+       ColorVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
 
        bool set (T val) {
                if (val == value) {
@@ -74,7 +79,7 @@ class UIConfiguration : public PBD::Stateful
        UIConfiguration();
        ~UIConfiguration();
 
-       std::map<std::string,UIConfigVariable<uint32_t> *> canvas_colors;
+       std::map<std::string,ColorVariable<uint32_t> *> canvas_colors;
 
        bool dirty () const;
        void set_dirty ();
@@ -91,18 +96,43 @@ class UIConfiguration : public PBD::Stateful
 
        uint32_t color_by_name (const std::string&);
 
-       sigc::signal<void,const char*> ParameterChanged;
+        sigc::signal<void,std::string> ParameterChanged;
+       void map_parameters (boost::function<void (std::string)>&);
 
+#undef UI_CONFIG_VARIABLE
+#define UI_CONFIG_VARIABLE(Type,var,name,value) \
+       Type get_##var () const { return var.get(); } \
+       bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
+#include "ui_config_vars.h"
 #undef  UI_CONFIG_VARIABLE
+#undef CANVAS_VARIABLE
+#undef CANVAS_STRING_VARIABLE
+#define CANVAS_VARIABLE(var,name) \
+       uint32_t get_##var () const { return var.get(); } \
+       bool set_##var (uint32_t val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
+#define CANVAS_STRING_VARIABLE(var,name) \
+       std::string get_##var () const { return var.get(); }                    \
+       bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
+#include "canvas_vars.h"
 #undef  CANVAS_VARIABLE
-#define UI_CONFIG_VARIABLE(Type,var,name,val) UIConfigVariable<Type> var;
-#define CANVAS_VARIABLE(var,name) UIConfigVariable<uint32_t> var;
+#undef CANVAS_STRING_VARIABLE
+
+  private:
+
+       /* declare variables */
+
+#undef  UI_CONFIG_VARIABLE
+#define UI_CONFIG_VARIABLE(Type,var,name,value) ARDOUR::ConfigVariable<Type> var;
 #include "ui_config_vars.h"
+#undef UI_CONFIG_VARIABLE
+
+#undef CANVAS_VARIABLE
+#define CANVAS_VARIABLE(var,name) ColorVariable<uint32_t> var;
+#define CANVAS_STRING_VARIABLE(var,name) ARDOUR::ConfigVariable<std::string> var;
 #include "canvas_vars.h"
-#undef  UI_CONFIG_VARIABLE
 #undef  CANVAS_VARIABLE
+#undef CANVAS_STRING_VARIABLE
 
-  private:
        XMLNode& state ();
        bool _dirty;
 };