Ardour  8.12
gtk2_ardour/ui_config.h
Go to the documentation of this file.
1 /*
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>
8  *
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.
13  *
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.
18  *
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.
22  */
23 
24 #ifndef __ardour_ui_configuration_h__
25 #define __ardour_ui_configuration_h__
26 
27 #include <sstream>
28 #include <ostream>
29 #include <iostream>
30 #include <map>
31 
32 #include <boost/function.hpp>
33 #include <boost/bind.hpp>
34 
35 #include "ardour/types.h" // required for operators used in pbd/configuration_variable.h
36 #include "ardour/types_convert.h"
37 
38 #include "pbd/configuration.h"
40 #include "pbd/stateful.h"
41 #include "pbd/xml++.h"
42 
43 #include "gtkmm2ext/colors.h"
44 #include "widgets/ui_config.h"
45 
46 #include "editing.h"
47 #include "utils.h"
48 
50 {
51 private:
54 
55 public:
57 
58  static std::string color_file_suffix;
59  static void build_metadata ();
60 
61  void load_rc_file (bool themechange, bool allow_own = true);
62 
63  int load_state ();
64  int save_state ();
65  int load_defaults ();
66  int load_color_theme (bool allow_own);
67 
68  void map_parameters (boost::function<void (std::string)>&);
69  int set_state (const XMLNode&, int version);
70  XMLNode& get_state () const;
71  XMLNode& get_variables (std::string const &) const;
72  void set_variables (const XMLNode&);
73 
74  std::string color_file_name (bool use_my, bool with_version, bool fallback = false) const;
75 
76  typedef std::map<std::string, Gtkmm2ext::Color> Colors;
77  typedef std::map<std::string, std::string> ColorAliases;
78  typedef std::map<std::string, Gtkmm2ext::SVAModifier> Modifiers;
79 
83 
84  void set_alias (std::string const& name, std::string const& alias);
85  void set_color (const std::string& name, Gtkmm2ext::Color);
86  void set_modifier (std::string const&, Gtkmm2ext::SVAModifier svam);
87 
89 
90  Gtkmm2ext::Color color (const std::string&, bool* failed = 0) const;
91  Gtkmm2ext::Color color_mod (std::string const& color, std::string const& modifier) const;
92  Gtkmm2ext::Color color_mod (const Gtkmm2ext::Color& color, std::string const& modifier) const;
93  Gtkmm2ext::SVAModifier modifier (const std::string&) const;
94 
95  static std::string color_to_hex_string (Gtkmm2ext::Color c);
97 
98  void reset_dpi ();
99  float get_ui_scale ();
100 
101  sigc::signal<void, std::string> ParameterChanged;
102 
103  void parameter_changed (std::string);
104 
109  int pre_gui_init ();
110 
113 
114  std::map<std::string,PBD::ConfigVariableBase*> _my_variables;
115 
116 #undef UI_CONFIG_VARIABLE
117 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
118  Type get_##var () const { return var.get(); } \
119  bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
120 #include "ui_config_vars.h"
121 #undef UI_CONFIG_VARIABLE
122 #define CANVAS_FONT_VARIABLE(var,name) \
123  Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
124  Pango::FontDescription get_Ardour##var () const { return ARDOUR_UI_UTILS::ardour_font (var.get()); } \
125  bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
126 #include "canvas_vars.h"
127 #undef CANVAS_FONT_VARIABLE
128 
129 private:
130  /* declare variables */
131 
132 #undef UI_CONFIG_VARIABLE
133 #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
134 #include "ui_config_vars.h"
135 #undef UI_CONFIG_VARIABLE
136 
137 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
138 #include "canvas_vars.h"
139 #undef CANVAS_FONT_VARIABLE
140 
141  XMLNode& state () const;
142  bool _dirty;
146 
149  void load_colors (XMLNode const&);
150  void load_modifiers (XMLNode const&);
152  int load_color_file (std::string const&);
153  void colors_changed ();
154 
155  uint32_t block_save;
156 };
157 
158 #endif /* __ardour_ui_configuration_h__ */
void reset_gtk_theme()
std::map< std::string, std::string > ColorAliases
float get_ui_scale()
void set_color(const std::string &name, Gtkmm2ext::Color)
void set_variables(const XMLNode &)
XMLNode & get_state() const
Gtkmm2ext::SVAModifier modifier(const std::string &) const
Gtkmm2ext::Color color_mod(std::string const &color, std::string const &modifier) const
static std::string color_file_suffix
ColorAliases color_aliases
void parameter_changed(std::string)
void colors_changed()
static std::string color_to_hex_string_no_alpha(Gtkmm2ext::Color c)
Gtkmm2ext::Color quantized(Gtkmm2ext::Color) const
int load_color_file(std::string const &)
UIConfiguration * post_gui_init()
int store_color_theme()
void set_modifier(std::string const &, Gtkmm2ext::SVAModifier svam)
void load_modifiers(XMLNode const &)
int load_color_theme(bool allow_own)
Gtkmm2ext::Color color(const std::string &, bool *failed=0) const
std::string color_file_name(bool use_my, bool with_version, bool fallback=false) const
void map_parameters(boost::function< void(std::string)> &)
int set_state(const XMLNode &, int version)
void load_rc_file(bool themechange, bool allow_own=true)
void load_colors(XMLNode const &)
static UIConfiguration & instance()
void set_alias(std::string const &name, std::string const &alias)
std::map< std::string, Gtkmm2ext::Color > Colors
static void build_metadata()
sigc::signal< void, std::string > ParameterChanged
std::map< std::string, PBD::ConfigVariableBase * > _my_variables
XMLNode & state() const
Gtkmm2ext::Color color_mod(const Gtkmm2ext::Color &color, std::string const &modifier) const
std::map< std::string, Gtkmm2ext::SVAModifier > Modifiers
XMLNode & get_variables(std::string const &) const
static std::string color_to_hex_string(Gtkmm2ext::Color c)
void load_color_aliases(XMLNode const &)
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
uint32_t Color
Definition: colors.h:33