2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_ui_configuration_h__
21 #define __ardour_ui_configuration_h__
27 #include "pbd/stateful.h"
28 #include "pbd/xml++.h"
29 #include "ardour/configuration_variable.h"
33 /* This is very similar to ARDOUR::ConfigVariable but expects numeric values to
34 * be in hexadecimal. This is because it is intended for use with color
35 * specifications which are easier to scan for issues in "rrggbbaa" format than
39 class ColorVariable : public ARDOUR::ConfigVariableBase
42 ColorVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
43 ColorVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
57 std::string get_as_string () const {
66 void set_from_string (std::string const & s) {
74 T get_for_save() { return value; }
78 class UIConfiguration : public PBD::Stateful
84 std::map<std::string,ColorVariable<uint32_t> *> canvas_colors;
93 int set_state (const XMLNode&, int version);
94 XMLNode& get_state (void);
95 XMLNode& get_variables (std::string);
96 void set_variables (const XMLNode&);
97 void pack_canvasvars ();
99 uint32_t color_by_name (const std::string&);
101 sigc::signal<void,std::string> ParameterChanged;
102 void map_parameters (boost::function<void (std::string)>&);
104 #undef UI_CONFIG_VARIABLE
105 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
106 Type get_##var () const { return var.get(); } \
107 bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
108 #include "ui_config_vars.h"
109 #undef UI_CONFIG_VARIABLE
110 #undef CANVAS_VARIABLE
111 #undef CANVAS_STRING_VARIABLE
112 #define CANVAS_VARIABLE(var,name) \
113 uint32_t get_##var () const { return var.get(); } \
114 bool set_##var (uint32_t val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
115 #define CANVAS_STRING_VARIABLE(var,name) \
116 std::string get_##var () const { return var.get(); } \
117 bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
118 #define CANVAS_FONT_VARIABLE(var,name) \
119 Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
120 bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
121 #include "canvas_vars.h"
122 #undef CANVAS_VARIABLE
123 #undef CANVAS_STRING_VARIABLE
124 #undef CANVAS_FONT_VARIABLE
128 /* declare variables */
130 #undef UI_CONFIG_VARIABLE
131 #define UI_CONFIG_VARIABLE(Type,var,name,value) ARDOUR::ConfigVariable<Type> var;
132 #include "ui_config_vars.h"
133 #undef UI_CONFIG_VARIABLE
135 #undef CANVAS_VARIABLE
136 #define CANVAS_VARIABLE(var,name) ColorVariable<uint32_t> var;
137 #define CANVAS_STRING_VARIABLE(var,name) ARDOUR::ConfigVariable<std::string> var;
138 #define CANVAS_FONT_VARIABLE(var,name) ARDOUR::ConfigVariable<std::string> var;
139 #include "canvas_vars.h"
140 #undef CANVAS_VARIABLE
141 #undef CANVAS_STRING_VARIABLE
142 #undef CANVAS_FONT_VARIABLE
148 #endif /* __ardour_ui_configuration_h__ */