Add UIConfiguration::color_mod (colorname, modifiername) to get a modified color
[ardour.git] / gtk2_ardour / ui_config.h
1 /*
2     Copyright (C) 2000-2007 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_ui_configuration_h__
21 #define __ardour_ui_configuration_h__
22
23 #include <sstream>
24 #include <ostream>
25 #include <iostream>
26
27 #include <boost/function.hpp>
28 #include <boost/bind.hpp>
29
30 #include "pbd/stateful.h"
31 #include "pbd/xml++.h"
32 #include "ardour/configuration_variable.h"
33
34 #include "canvas/colors.h"
35
36 #include "utils.h"
37
38 class UIConfiguration : public PBD::Stateful
39 {
40     public:
41         UIConfiguration();
42         ~UIConfiguration();
43
44         static UIConfiguration* instance() { return _instance; }
45
46         void load_rc_file (bool themechange, bool allow_own = true);
47
48         int load_state ();
49         int save_state ();
50         int load_defaults ();
51
52         int set_state (const XMLNode&, int version);
53         XMLNode& get_state (void);
54         XMLNode& get_variables (std::string);
55         void set_variables (const XMLNode&);
56
57         typedef std::map<std::string,ArdourCanvas::Color> Colors;
58         typedef std::map<std::string,std::string> ColorAliases;
59         typedef std::map<std::string,ArdourCanvas::SVAModifier> Modifiers;
60
61         Colors         colors;
62         ColorAliases   color_aliases;
63         Modifiers      modifiers;
64
65         void set_alias (std::string const & name, std::string const & alias);
66         void set_color (const std::string& name, ArdourCanvas::Color);
67         
68         std::string color_as_alias (ArdourCanvas::Color c);
69         ArdourCanvas::Color quantized (ArdourCanvas::Color) const;
70
71         ArdourCanvas::Color color (const std::string&, bool* failed = 0) const;
72         ArdourCanvas::Color color_mod (std::string const & color, std::string const & modifier) const;
73         ArdourCanvas::HSV  color_hsv (const std::string&) const;
74         ArdourCanvas::SVAModifier modifier (const std::string&) const;
75                 
76         sigc::signal<void,std::string> ParameterChanged;
77         void map_parameters (boost::function<void (std::string)>&);
78
79         void parameter_changed (std::string);
80         
81 #undef UI_CONFIG_VARIABLE
82 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
83         Type get_##var () const { return var.get(); } \
84         bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
85 #include "ui_config_vars.h"
86 #undef  UI_CONFIG_VARIABLE
87 #define CANVAS_FONT_VARIABLE(var,name) \
88         Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
89         bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
90 #include "canvas_vars.h"
91 #undef CANVAS_FONT_VARIABLE
92
93   private:
94         /* declare variables */
95
96 #undef  UI_CONFIG_VARIABLE
97 #define UI_CONFIG_VARIABLE(Type,var,name,value) ARDOUR::ConfigVariable<Type> var;
98 #include "ui_config_vars.h"
99 #undef UI_CONFIG_VARIABLE
100
101 #define CANVAS_FONT_VARIABLE(var,name) ARDOUR::ConfigVariable<std::string> var;
102 #include "canvas_vars.h"
103 #undef CANVAS_FONT_VARIABLE
104
105         XMLNode& state ();
106         bool _dirty;
107         bool aliases_modified;
108         bool colors_modified;
109         
110         static UIConfiguration* _instance;
111
112         int store_color_theme ();
113         void load_color_aliases (XMLNode const &);
114         void load_colors (XMLNode const &);
115         void load_modifiers (XMLNode const &);
116         void reset_gtk_theme ();
117         void colors_changed ();
118         int load_color_theme (bool allow_own=true);
119
120         uint32_t block_save;
121 };
122
123 #endif /* __ardour_ui_configuration_h__ */
124