Remove attempt to retrieve invalid Meterbridge properties
[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 "ardour/types.h" // required for opeators used in pbd/configuration_variable.h
31 #include "ardour/types_convert.h"
32
33 #include "pbd/stateful.h"
34 #include "pbd/xml++.h"
35 #include "pbd/configuration_variable.h"
36
37 #include "canvas/colors.h"
38
39 #include "utils.h"
40
41 class UIConfiguration : public PBD::Stateful
42 {
43 private:
44         UIConfiguration();
45         ~UIConfiguration();
46
47     public:
48         static UIConfiguration& instance();
49
50         static std::string color_file_suffix;
51
52         void load_rc_file (bool themechange, bool allow_own = true);
53
54         int load_state ();
55         int save_state ();
56         int load_defaults ();
57         int load_color_theme (bool allow_own);
58
59         int set_state (const XMLNode&, int version);
60         XMLNode& get_state (void);
61         XMLNode& get_variables (std::string);
62         void set_variables (const XMLNode&);
63
64         std::string  color_file_name (bool use_my, bool with_version) const;
65
66         typedef std::map<std::string,ArdourCanvas::Color> Colors;
67         typedef std::map<std::string,std::string> ColorAliases;
68         typedef std::map<std::string,ArdourCanvas::SVAModifier> Modifiers;
69
70         Colors         colors;
71         ColorAliases   color_aliases;
72         Modifiers      modifiers;
73
74         void set_alias (std::string const & name, std::string const & alias);
75         void set_color (const std::string& name, ArdourCanvas::Color);
76         void set_modifier (std::string const &, ArdourCanvas::SVAModifier svam);
77
78         std::string color_as_alias (ArdourCanvas::Color c);
79         ArdourCanvas::Color quantized (ArdourCanvas::Color) const;
80
81         ArdourCanvas::Color color (const std::string&, bool* failed = 0) const;
82         ArdourCanvas::Color color_mod (std::string const & color, std::string const & modifier) const;
83         ArdourCanvas::Color color_mod (const ArdourCanvas::Color& color, std::string const & modifier) const;
84         ArdourCanvas::HSV  color_hsv (const std::string&) const;
85         ArdourCanvas::SVAModifier modifier (const std::string&) const;
86
87         static std::string color_to_hex_string (ArdourCanvas::Color c);
88         static std::string color_to_hex_string_no_alpha (ArdourCanvas::Color c);
89
90         sigc::signal<void>  ColorsChanged;
91
92         void reset_dpi ();
93
94         float get_ui_scale ();
95
96         sigc::signal<void>  DPIReset;
97
98         sigc::signal<void,std::string> ParameterChanged;
99         void map_parameters (boost::function<void (std::string)>&);
100
101         void parameter_changed (std::string);
102
103         /** called before initializing any part of the GUI. Sets up
104          *  any runtime environment required to make the GUI work
105          *  in specific ways.
106          */
107         int pre_gui_init ();
108
109         /** called after the GUI toolkit has been initialized.
110          */
111         UIConfiguration* post_gui_init ();
112
113 #undef UI_CONFIG_VARIABLE
114 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
115         Type get_##var () const { return var.get(); } \
116         bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
117 #include "ui_config_vars.h"
118 #undef  UI_CONFIG_VARIABLE
119 #define CANVAS_FONT_VARIABLE(var,name) \
120         Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
121         bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret;  }
122 #include "canvas_vars.h"
123 #undef CANVAS_FONT_VARIABLE
124
125   private:
126         /* declare variables */
127
128 #undef  UI_CONFIG_VARIABLE
129 #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
130 #include "ui_config_vars.h"
131 #undef UI_CONFIG_VARIABLE
132
133 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
134 #include "canvas_vars.h"
135 #undef CANVAS_FONT_VARIABLE
136
137         XMLNode& state ();
138         bool _dirty;
139         bool aliases_modified;
140         bool colors_modified;
141         bool modifiers_modified;
142
143         int  store_color_theme ();
144         void load_color_aliases (XMLNode const &);
145         void load_colors (XMLNode const &);
146         void load_modifiers (XMLNode const &);
147         void reset_gtk_theme ();
148         int  load_color_file (std::string const &);
149         void colors_changed ();
150
151         uint32_t block_save;
152 };
153
154 #endif /* __ardour_ui_configuration_h__ */