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 <boost/function.hpp>
28 #include <boost/bind.hpp>
30 #include "pbd/stateful.h"
31 #include "pbd/xml++.h"
32 #include "ardour/configuration_variable.h"
34 #include "canvas/colors.h"
38 class UIConfiguration : public PBD::Stateful
42 RelativeHSV (const std::string& b, const ArdourCanvas::HSV& mod)
45 , quantized_hue (-1.0) {}
46 std::string base_color;
47 ArdourCanvas::HSV modifier;
50 ArdourCanvas::HSV get() const;
56 static UIConfiguration* instance() { return _instance; }
58 void load_rc_file (bool themechange, bool allow_own = true);
64 int set_state (const XMLNode&, int version);
65 XMLNode& get_state (void);
66 XMLNode& get_variables (std::string);
67 void set_variables (const XMLNode&);
69 typedef std::map<std::string,RelativeHSV> RelativeColors;
70 typedef std::map<std::string,std::string> ColorAliases;
71 typedef std::map<std::string,ArdourCanvas::Color> BaseColors;
73 BaseColors base_colors;
74 RelativeColors relative_colors;
75 ColorAliases color_aliases;
77 void set_alias (std::string const & name, std::string const & alias);
78 void set_relative (const std::string& name, const RelativeHSV& new_value);
79 void set_base (const std::string& name, ArdourCanvas::Color);
81 RelativeHSV color_as_relative_hsv (ArdourCanvas::Color c);
82 std::string color_as_alias (ArdourCanvas::Color c);
83 ArdourCanvas::Color quantized (ArdourCanvas::Color) const;
85 ArdourCanvas::Color base_color_by_name (const std::string&) const;
86 ArdourCanvas::Color color (const std::string&) const;
87 ArdourCanvas::HSV color_hsv (const std::string&) const;
89 sigc::signal<void,std::string> ParameterChanged;
90 void map_parameters (boost::function<void (std::string)>&);
92 void parameter_changed (std::string);
94 #undef UI_CONFIG_VARIABLE
95 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
96 Type get_##var () const { return var.get(); } \
97 bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
98 #include "ui_config_vars.h"
99 #undef UI_CONFIG_VARIABLE
100 #define CANVAS_FONT_VARIABLE(var,name) \
101 Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
102 bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
103 #include "canvas_vars.h"
104 #undef CANVAS_FONT_VARIABLE
106 #undef CANVAS_BASE_COLOR
107 #define CANVAS_BASE_COLOR(var,name,val) \
108 ArdourCanvas::Color get_##var() const { return base_color_by_name (name); }
109 #include "base_colors.h"
110 #undef CANVAS_BASE_COLOR
113 #define COLOR_ALIAS(var,name,alias) ArdourCanvas::Color get_##var() const { return color (name); }
114 #include "color_aliases.h"
118 /* declare variables */
120 #undef UI_CONFIG_VARIABLE
121 #define UI_CONFIG_VARIABLE(Type,var,name,value) ARDOUR::ConfigVariable<Type> var;
122 #include "ui_config_vars.h"
123 #undef UI_CONFIG_VARIABLE
125 #define CANVAS_FONT_VARIABLE(var,name) ARDOUR::ConfigVariable<std::string> var;
126 #include "canvas_vars.h"
127 #undef CANVAS_FONT_VARIABLE
132 bool aliases_modified;
133 bool derived_modified;
135 static UIConfiguration* _instance;
137 int store_color_theme ();
138 void load_base_colors (XMLNode const &);
139 void load_color_aliases (XMLNode const &);
140 void load_relative_colors (XMLNode const &);
141 void reset_gtk_theme ();
142 void colors_changed ();
143 int load_color_theme (bool allow_own=true);
148 std::ostream& operator<< (std::ostream& o, const UIConfiguration::RelativeHSV& rhsv);
150 #endif /* __ardour_ui_configuration_h__ */