fix mistaken "do not roll" conclusion in TransportFSM::compute_should_roll()
[ardour.git] / gtk2_ardour / ui_config.h
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
31 #include <boost/function.hpp>
32 #include <boost/bind.hpp>
33
34 #include "ardour/types.h" // required for opeators used in pbd/configuration_variable.h
35 #include "ardour/types_convert.h"
36
37 #include "pbd/stateful.h"
38 #include "pbd/xml++.h"
39 #include "pbd/configuration_variable.h"
40
41 #include "gtkmm2ext/colors.h"
42 #include "widgets/ui_config.h"
43
44 #include "utils.h"
45
46 class UIConfiguration : public ArdourWidgets::UIConfigurationBase
47 {
48 private:
49         UIConfiguration();
50         ~UIConfiguration();
51
52 public:
53         static UIConfiguration& instance();
54
55         static std::string color_file_suffix;
56
57         void load_rc_file (bool themechange, bool allow_own = true);
58
59         int load_state ();
60         int save_state ();
61         int load_defaults ();
62         int load_color_theme (bool allow_own);
63
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&);
68
69         std::string  color_file_name (bool use_my, bool with_version) const;
70
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;
74
75         Colors         colors;
76         ColorAliases   color_aliases;
77         Modifiers      modifiers;
78
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);
82
83         std::string color_as_alias (Gtkmm2ext::Color c);
84         Gtkmm2ext::Color quantized (Gtkmm2ext::Color) const;
85
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;
91
92         static std::string color_to_hex_string (Gtkmm2ext::Color c);
93         static std::string color_to_hex_string_no_alpha (Gtkmm2ext::Color c);
94
95         void reset_dpi ();
96         float get_ui_scale ();
97
98         sigc::signal<void,std::string> ParameterChanged;
99         void map_parameters (boost::function<void (std::string)>&);
100
101         void parameter_changed (std::string);
102
103         /** called before initializing any part of the GUI. Sets up
104          *  any runtime environment required to make the GUI work
105          *  in specific ways.
106          */
107         int pre_gui_init ();
108
109         /** called after the GUI toolkit has been initialized. */
110         UIConfiguration* post_gui_init ();
111
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
123
124 private:
125         /* declare variables */
126
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
131
132 #define CANVAS_FONT_VARIABLE(var,name) PBD::ConfigVariable<std::string> var;
133 #include "canvas_vars.h"
134 #undef CANVAS_FONT_VARIABLE
135
136         XMLNode& state ();
137         bool _dirty;
138         bool aliases_modified;
139         bool colors_modified;
140         bool modifiers_modified;
141
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 ();
149
150         uint32_t block_save;
151 };
152
153 #endif /* __ardour_ui_configuration_h__ */