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 "ardour/types.h" // required for opeators used in pbd/configuration_variable.h
32 #include "pbd/stateful.h"
33 #include "pbd/xml++.h"
34 #include "pbd/configuration_variable.h"
36 #include "canvas/colors.h"
40 class UIConfiguration : public PBD::Stateful
47 static UIConfiguration& instance();
49 void load_rc_file (bool themechange, bool allow_own = true);
54 int load_color_theme (bool allow_own=true);
56 int set_state (const XMLNode&, int version);
57 XMLNode& get_state (void);
58 XMLNode& get_variables (std::string);
59 void set_variables (const XMLNode&);
61 typedef std::map<std::string,ArdourCanvas::Color> Colors;
62 typedef std::map<std::string,std::string> ColorAliases;
63 typedef std::map<std::string,ArdourCanvas::SVAModifier> Modifiers;
66 ColorAliases color_aliases;
69 void set_alias (std::string const & name, std::string const & alias);
70 void set_color (const std::string& name, ArdourCanvas::Color);
71 void set_modifier (std::string const &, ArdourCanvas::SVAModifier svam);
73 std::string color_as_alias (ArdourCanvas::Color c);
74 ArdourCanvas::Color quantized (ArdourCanvas::Color) const;
76 ArdourCanvas::Color color (const std::string&, bool* failed = 0) const;
77 ArdourCanvas::Color color_mod (std::string const & color, std::string const & modifier) const;
78 ArdourCanvas::Color color_mod (const ArdourCanvas::Color& color, std::string const & modifier) const;
79 ArdourCanvas::HSV color_hsv (const std::string&) const;
80 ArdourCanvas::SVAModifier modifier (const std::string&) const;
82 sigc::signal<void> ColorsChanged;
85 void set_pango_fontsize ();
87 float get_ui_scale ();
89 sigc::signal<void> DPIReset;
91 sigc::signal<void,std::string> ParameterChanged;
92 void map_parameters (boost::function<void (std::string)>&);
94 void parameter_changed (std::string);
96 /** called before initializing any part of the GUI. Sets up
97 * any runtime environment required to make the GUI work
102 /** called after the GUI toolkit has been initialized.
104 UIConfiguration* post_gui_init ();
106 #undef UI_CONFIG_VARIABLE
107 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
108 Type get_##var () const { return var.get(); } \
109 bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
110 #include "ui_config_vars.h"
111 #undef UI_CONFIG_VARIABLE
112 #define CANVAS_FONT_VARIABLE(var,name) \
113 Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
114 bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
115 #include "canvas_vars.h"
116 #undef CANVAS_FONT_VARIABLE
119 /* declare variables */
121 #undef UI_CONFIG_VARIABLE
122 #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
123 #include "ui_config_vars.h"
124 #undef UI_CONFIG_VARIABLE
126 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
127 #include "canvas_vars.h"
128 #undef CANVAS_FONT_VARIABLE
132 bool aliases_modified;
133 bool colors_modified;
134 bool modifiers_modified;
136 int store_color_theme ();
137 void load_color_aliases (XMLNode const &);
138 void load_colors (XMLNode const &);
139 void load_modifiers (XMLNode const &);
140 void reset_gtk_theme ();
141 void colors_changed ();
146 #endif /* __ardour_ui_configuration_h__ */