2 * Copyright (C) 2007 Doug McLain <doug@nostar.net>
3 * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
4 * Copyright (C) 2009-2016 Paul Davis <paul@linuxaudiosystems.com>
5 * Copyright (C) 2009 Carl Hetherington <carl@carlh.net>
6 * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
7 * Copyright (C) 2015-2016 Tim Mayberry <mojofunk@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #ifndef __ardour_ui_configuration_h__
25 #define __ardour_ui_configuration_h__
31 #include <boost/function.hpp>
32 #include <boost/bind.hpp>
34 #include "ardour/types.h" // required for opeators used in pbd/configuration_variable.h
35 #include "ardour/types_convert.h"
37 #include "pbd/stateful.h"
38 #include "pbd/xml++.h"
39 #include "pbd/configuration_variable.h"
41 #include "gtkmm2ext/colors.h"
42 #include "widgets/ui_config.h"
46 class UIConfiguration : public ArdourWidgets::UIConfigurationBase
53 static UIConfiguration& instance();
55 static std::string color_file_suffix;
57 void load_rc_file (bool themechange, bool allow_own = true);
62 int load_color_theme (bool allow_own);
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 std::string color_file_name (bool use_my, bool with_version) const;
71 typedef std::map<std::string,Gtkmm2ext::Color> Colors;
72 typedef std::map<std::string,std::string> ColorAliases;
73 typedef std::map<std::string,Gtkmm2ext::SVAModifier> Modifiers;
76 ColorAliases color_aliases;
79 void set_alias (std::string const & name, std::string const & alias);
80 void set_color (const std::string& name, Gtkmm2ext::Color);
81 void set_modifier (std::string const &, Gtkmm2ext::SVAModifier svam);
83 std::string color_as_alias (Gtkmm2ext::Color c);
84 Gtkmm2ext::Color quantized (Gtkmm2ext::Color) const;
86 Gtkmm2ext::Color color (const std::string&, bool* failed = 0) const;
87 Gtkmm2ext::Color color_mod (std::string const & color, std::string const & modifier) const;
88 Gtkmm2ext::Color color_mod (const Gtkmm2ext::Color& color, std::string const & modifier) const;
89 Gtkmm2ext::HSV color_hsv (const std::string&) const;
90 Gtkmm2ext::SVAModifier modifier (const std::string&) const;
92 static std::string color_to_hex_string (Gtkmm2ext::Color c);
93 static std::string color_to_hex_string_no_alpha (Gtkmm2ext::Color c);
96 float get_ui_scale ();
98 sigc::signal<void,std::string> ParameterChanged;
99 void map_parameters (boost::function<void (std::string)>&);
101 void parameter_changed (std::string);
103 /** called before initializing any part of the GUI. Sets up
104 * any runtime environment required to make the GUI work
109 /** called after the GUI toolkit has been initialized. */
110 UIConfiguration* post_gui_init ();
112 #undef UI_CONFIG_VARIABLE
113 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
114 Type get_##var () const { return var.get(); } \
115 bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
116 #include "ui_config_vars.h"
117 #undef UI_CONFIG_VARIABLE
118 #define CANVAS_FONT_VARIABLE(var,name) \
119 Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
120 bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
121 #include "canvas_vars.h"
122 #undef CANVAS_FONT_VARIABLE
125 /* declare variables */
127 #undef UI_CONFIG_VARIABLE
128 #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
129 #include "ui_config_vars.h"
130 #undef UI_CONFIG_VARIABLE
132 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
133 #include "canvas_vars.h"
134 #undef CANVAS_FONT_VARIABLE
138 bool aliases_modified;
139 bool colors_modified;
140 bool modifiers_modified;
142 int store_color_theme ();
143 void load_color_aliases (XMLNode const &);
144 void load_colors (XMLNode const &);
145 void load_modifiers (XMLNode const &);
146 void reset_gtk_theme ();
147 int load_color_file (std::string const &);
148 void colors_changed ();
153 #endif /* __ardour_ui_configuration_h__ */