Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
25 
26 #include <sstream>
27 #include <ostream>
28 #include <iostream>
29 #include <map>
30 
31 
32 #include "ardour/types.h" // required for operators used in pbd/configuration_variable.h
33 #include "ardour/types_convert.h"
34 
35 #include "pbd/configuration.h"
37 #include "pbd/stateful.h"
38 #include "pbd/xml++.h"
39 
40 #include "gtkmm2ext/colors.h"
41 #include "widgets/ui_config.h"
42 
43 #include "editing.h"
44 #include "utils.h"
45 
47 {
48 private:
51 
52 public:
54 
55  static std::string color_file_suffix;
56  static void build_metadata ();
57 
58  void load_rc_file (bool themechange, bool allow_own = true);
59 
60  int load_state ();
61  int save_state ();
62  int load_defaults ();
63  int load_color_theme (bool allow_own);
64 
65  void map_parameters (std::function<void (std::string)>&);
66  int set_state (const XMLNode&, int version);
67  XMLNode& get_state () const;
68  XMLNode& get_variables (std::string const &) const;
69  void set_variables (const XMLNode&);
70 
71  std::string color_file_name (bool use_my, bool with_version, bool fallback = false) const;
72 
73  typedef std::map<std::string, Gtkmm2ext::Color> Colors;
74  typedef std::map<std::string, std::string> ColorAliases;
75  typedef std::map<std::string, Gtkmm2ext::SVAModifier> Modifiers;
76 
80 
81  void set_alias (std::string const& name, std::string const& alias);
82  void set_color (const std::string& name, Gtkmm2ext::Color);
83  void set_modifier (std::string const&, Gtkmm2ext::SVAModifier svam);
84 
86 
87  Gtkmm2ext::Color color (const std::string&, bool* failed = 0) const;
88  Gtkmm2ext::Color color_mod (std::string const& color, std::string const& modifier) const;
89  Gtkmm2ext::Color color_mod (const Gtkmm2ext::Color& color, std::string const& modifier) const;
90  Gtkmm2ext::SVAModifier modifier (const std::string&) const;
91 
92  static std::string color_to_hex_string (Gtkmm2ext::Color c);
94 
95  void reset_dpi ();
96  float get_ui_scale ();
97 
98  sigc::signal<void, std::string> ParameterChanged;
99 
100  void parameter_changed (std::string);
101 
106  int pre_gui_init ();
107 
110 
111  std::map<std::string,PBD::ConfigVariableBase*> _my_variables;
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.inc.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  Pango::FontDescription get_Ardour##var () const { return ARDOUR_UI_UTILS::ardour_font (var.get()); } \
122  bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
123 #include "canvas_vars.inc.h"
124 #undef CANVAS_FONT_VARIABLE
125 
126 private:
127  /* declare variables */
128 
129 #undef UI_CONFIG_VARIABLE
130 #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
131 #include "ui_config_vars.inc.h"
132 #undef UI_CONFIG_VARIABLE
133 
134 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
135 #include "canvas_vars.inc.h"
136 #undef CANVAS_FONT_VARIABLE
137 
138  XMLNode& state () const;
139  bool _dirty;
143 
146  void load_colors (XMLNode const&);
147  void load_modifiers (XMLNode const&);
149  int load_color_file (std::string const&);
150  void colors_changed ();
151 
152  uint32_t block_save;
153 };
154 
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 map_parameters(std::function< void(std::string)> &)
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
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
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