comment fix
[ardour2.git] / gtk2_ardour / ui_config.h
blob09e844883161653f5ecd7c942d86256b41a49e51
1 /*
2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_ui_configuration_h__
21 #define __ardour_ui_configuration_h__
23 #include <sstream>
24 #include <ostream>
25 #include <iostream>
27 #include "pbd/stateful.h"
28 #include "pbd/xml++.h"
29 #include "ardour/configuration_variable.h"
31 template<class T>
32 class UIConfigVariable : public ARDOUR::ConfigVariableBase
34 public:
35 UIConfigVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
36 UIConfigVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
38 bool set (T val) {
39 if (val == value) {
40 return false;
42 value = val;
43 return true;
46 T get() const {
47 return value;
50 std::string get_as_string () const {
51 std::stringstream ss;
52 ss << std::hex;
53 ss.fill('0');
54 ss.width(8);
55 ss << value;
56 return ss.str ();
59 void set_from_string (std::string const & s) {
60 std::stringstream ss;
61 ss << std::hex;
62 ss << s;
63 ss >> value;
66 protected:
67 T get_for_save() { return value; }
68 T value;
71 class UIConfiguration : public PBD::Stateful
73 public:
74 UIConfiguration();
75 ~UIConfiguration();
77 std::vector<UIConfigVariable<uint32_t> *> canvas_colors;
79 int load_state ();
80 int save_state ();
81 int load_defaults ();
83 int set_state (const XMLNode&, int version);
84 XMLNode& get_state (void);
85 XMLNode& get_variables (std::string);
86 void set_variables (const XMLNode&);
87 void pack_canvasvars ();
89 sigc::signal<void,const char*> ParameterChanged;
91 #undef UI_CONFIG_VARIABLE
92 #undef CANVAS_VARIABLE
93 #define UI_CONFIG_VARIABLE(Type,var,name,val) UIConfigVariable<Type> var;
94 #define CANVAS_VARIABLE(var,name) UIConfigVariable<uint32_t> var;
95 #include "ui_config_vars.h"
96 #include "canvas_vars.h"
97 #undef UI_CONFIG_VARIABLE
98 #undef CANVAS_VARIABLE
100 private:
101 XMLNode& state ();
102 bool hack;
105 #endif /* __ardour_ui_configuration_h__ */