Ardour  9.0-rc1-12-g0f3760a8d1
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 #include "ytkmm/enums.h"
32 
33 #include "ardour/types.h" // required for operators used in pbd/configuration_variable.h
34 #include "ardour/types_convert.h"
35 
36 #include "pbd/configuration.h"
38 #include "pbd/stateful.h"
39 #include "pbd/xml++.h"
40 
41 #include "gtkmm2ext/colors.h"
42 #include "gtkmm2ext/ui_config.h"
43 
44 #include "editing.h"
45 #include "utils.h"
46 
48 {
49 private:
52 
53 public:
55 
56  static std::string color_file_suffix;
57  static void build_metadata ();
58 
59  void load_rc_file (bool themechange, bool allow_own = true);
60 
61  int load_state ();
62  int save_state ();
63  int load_defaults ();
64  int load_color_theme (bool allow_own);
65 
66  void map_parameters (std::function<void (std::string)>&);
67  int set_state (const XMLNode&, int version);
68  XMLNode& get_state () const;
69  XMLNode& get_variables (std::string const &) const;
70  void set_variables (const XMLNode&);
71 
72  std::string color_file_name (bool use_my, bool with_version, bool fallback = false) const;
73 
74  typedef std::map<std::string, Gtkmm2ext::Color> Colors;
75  typedef std::map<std::string, std::string> ColorAliases;
76  typedef std::map<std::string, Gtkmm2ext::SVAModifier> Modifiers;
77 
81 
82  void set_alias (std::string const& name, std::string const& alias);
83  void set_color (const std::string& name, Gtkmm2ext::Color);
84  void set_modifier (std::string const&, Gtkmm2ext::SVAModifier svam);
85  void set_modifier (std::string const& name, std::string const& mod_str);
86 
88 
89  Gtkmm2ext::Color color (const std::string&, bool* failed = 0) const;
90  Gtkmm2ext::Color color_mod (std::string const& color, std::string const& modifier) const;
91  Gtkmm2ext::Color color_mod (const Gtkmm2ext::Color& color, std::string const& modifier) const;
92  Gtkmm2ext::SVAModifier modifier (const std::string&) const;
93 
94  static std::string color_to_hex_string (Gtkmm2ext::Color c);
96 
97  void reset_dpi ();
98  float get_ui_scale ();
99 
100  sigc::signal<void, std::string> ParameterChanged;
101 
102  void parameter_changed (std::string);
103 
108  int pre_gui_init ();
109 
112 
113  std::map<std::string,PBD::ConfigVariableBase*> _my_variables;
114 
115 #undef UI_CONFIG_VARIABLE
116 #define UI_CONFIG_VARIABLE(Type,var,name,value) \
117  Type get_##var () const { return var.get(); } \
118  bool set_##var (Type val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
119 #include "ui_config_vars.inc.h"
120 #undef UI_CONFIG_VARIABLE
121 #define CANVAS_FONT_VARIABLE(var,name) \
122  Pango::FontDescription get_##var () const { return ARDOUR_UI_UTILS::sanitized_font (var.get()); } \
123  Pango::FontDescription get_Ardour##var () const { return ARDOUR_UI_UTILS::ardour_font (var.get()); } \
124  bool set_##var (const std::string& val) { bool ret = var.set (val); if (ret) { ParameterChanged (name); } return ret; }
125 #include "canvas_vars.inc.h"
126 #undef CANVAS_FONT_VARIABLE
127 
128 private:
129  /* declare variables */
130 
131 #undef UI_CONFIG_VARIABLE
132 #define UI_CONFIG_VARIABLE(Type,var,name,value) PBD::ConfigVariable<Type> var;
133 #include "ui_config_vars.inc.h"
134 #undef UI_CONFIG_VARIABLE
135 
136 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
137 #include "canvas_vars.inc.h"
138 #undef CANVAS_FONT_VARIABLE
139 
140  XMLNode& state () const;
141  bool _dirty;
145 
148  void load_colors (XMLNode const&);
149  void load_modifiers (XMLNode const&);
151  int load_color_file (std::string const&);
152  void colors_changed ();
153 
154  uint32_t block_save;
155 };
156 
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
void set_modifier(std::string const &name, std::string const &mod_str)
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