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