/[svn]/gigedit/trunk/src/gigedit/Settings.h
ViewVC logotype

Annotation of /gigedit/trunk/src/gigedit/Settings.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3711 - (hide annotations) (download) (as text)
Fri Jan 10 14:22:25 2020 UTC (4 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7906 byte(s)
* Added boolean setting to main menu -> "View" -> "Instrument Properties
  by Double Click", which allows to prevent double clicking an
  instrument on the instruments list view from opening its properties
  dialog.

* Bumped version (1.1.1.svn11).

1 schoenebeck 2541 /*
2 schoenebeck 3711 Copyright (c) 2014-2020 Christian Schoenebeck
3    
4 schoenebeck 2541 This file is part of "gigedit" and released under the terms of the
5     GNU General Public License version 2.
6     */
7    
8     #ifndef GIGEDIT_SETTINGS
9     #define GIGEDIT_SETTINGS
10    
11 schoenebeck 2891 #include <typeinfo>
12     #include <glibmm/object.h>
13     #include <glibmm/property.h>
14     #include <vector>
15 schoenebeck 3157 #include "global.h"
16 schoenebeck 2773
17 schoenebeck 2891 /**
18     * Reflects, saves and restores all settings for the gigedit application.
19     *
20     * This class holds a bunch of custom Property objects which can be accessed
21     * as if they were basic data types (i.e. by using assignment operator, etc.).
22     * As soon as a property gets modified this way, it will automatically be saved
23     * to a local config file.
24     */
25     class Settings : public Glib::Object {
26     public:
27     /**
28     * Data types for the individual settings.
29     */
30     enum RawValueType_t {
31     BOOLEAN,
32     INTEGER,
33     UNKNOWN
34     };
35    
36     /**
37     * All settings are grouped into these settings groups.
38     */
39     enum Group_t {
40 schoenebeck 2893 GLOBAL,
41     MAIN_WINDOW,
42     SCRIPT_EDITOR,
43 schoenebeck 2894 DIMENSION_MANAGER,
44     SCRIPT_SLOTS,
45     COMBINE_INSTRUMENTS,
46     MIDI_RULES,
47     FILE_PROPS,
48     INSTR_PROPS,
49 schoenebeck 3637 SAMPLE_PROPS,
50 schoenebeck 2894 SAMPLE_REFS,
51 schoenebeck 3151 MACRO_EDITOR,
52 schoenebeck 3157 MACROS_SETUP,
53     MACROS,
54 schoenebeck 2891 };
55    
56     /**
57     * Extension of regular Glib::Property template class; this one
58     * automatically calls Settings::onPropertyChanged() method passing this
59     * property object as pointer; and it allows to assign new values to this
60     * property by using the regular assignment operator; and requires a
61     * "Setting group" to be assigned to the property at construction time.
62     */
63     template<typename T>
64     class Property : public Glib::Property<T> {
65     public:
66     Property(Settings& object, Group_t group, const Glib::ustring& name)
67     : Glib::Property<T>::Property(object, name)
68     {
69     m_settings = &object;
70     m_group = group;
71     const RawValueType_t type = rawValueType();
72     Glib::Property<T>::get_proxy().signal_changed().connect(
73     sigc::bind(
74     sigc::bind(
75     sigc::bind(
76 persson 3461 sigc::mem_fun(*m_settings, &Settings::onPropertyChanged),
77 schoenebeck 2891 m_group
78     ),
79     type
80     ),
81     this
82     )
83     );
84     }
85    
86     Property(Settings& object, Group_t group, const Glib::ustring& name, const T& default_value)
87     : Glib::Property<T>::Property(object, name, default_value)
88     {
89     m_settings = &object;
90     m_group = group;
91     const RawValueType_t type = rawValueType();
92     Glib::Property<T>::get_proxy().signal_changed().connect(
93     sigc::bind(
94     sigc::bind(
95     sigc::bind(
96 persson 3461 sigc::mem_fun(*m_settings, &Settings::onPropertyChanged),
97 schoenebeck 2891 m_group
98     ),
99     type
100     ),
101     this
102     )
103     );
104     }
105    
106     Property<T>& operator=(const T value) {
107     Glib::Property<T>::set_value(value);
108     return *this;
109     }
110    
111     RawValueType_t rawValueType() const {
112     const std::string name = typeid(T).name();
113     if (name == "bool" || name == "b") return BOOLEAN;
114     if (name == "int" || name == "i") return INTEGER;
115     return UNKNOWN;
116     }
117    
118     Group_t group() const { return m_group; }
119    
120     private:
121     Settings* m_settings;
122     Group_t m_group;
123     };
124    
125 schoenebeck 2893 // settings of "Global" group
126 schoenebeck 2891 Property<bool> warnUserOnExtensions; ///< if enabled, the user shall he be warned if he is trying to use a gig format extension that will not work with Gigasampler/GigaStudio
127     Property<bool> syncSamplerInstrumentSelection; ///< if enabled, the sampler's current instrument will automatically be switched whenever another instrument was selected in gigedit
128     Property<bool> moveRootNoteWithRegionMoved; ///< if enabled, the root note(s) of regions are automatically moving when the user drags a region around at the virtual keyboard
129 schoenebeck 2918 Property<bool> autoRestoreWindowDimension;
130 schoenebeck 2967 Property<bool> saveWithTemporaryFile; ///< If enabled and the user selects "Save" from the main menu, then the file is first saved as separate temporary file and after the save operation completed the temporary file is moved over the original file.
131 schoenebeck 3409 Property<bool> showTooltips; ///< Whether tooltips specifically intended for newbies should be displayed throughout the application (default: yes).
132 schoenebeck 3711 Property<bool> instrumentDoubleClickOpensProps; ///< If enabled then double clicking on an instrument of the instruments list view will show the selected instrument's properties dialog.
133 schoenebeck 2891
134 schoenebeck 2893 // settings of "MainWindow" group
135     Property<int> mainWindowX;
136     Property<int> mainWindowY;
137     Property<int> mainWindowW;
138     Property<int> mainWindowH;
139    
140     // settings of "ScriptEditor" group
141     Property<int> scriptEditorWindowX;
142     Property<int> scriptEditorWindowY;
143     Property<int> scriptEditorWindowW;
144     Property<int> scriptEditorWindowH;
145 schoenebeck 2956 Property<int> scriptEditorFontSize;
146 schoenebeck 2893
147 schoenebeck 2894 // settings of "DimensionManager" group
148     Property<int> dimensionManagerWindowX;
149     Property<int> dimensionManagerWindowY;
150     Property<int> dimensionManagerWindowW;
151     Property<int> dimensionManagerWindowH;
152    
153     // settings of "ScriptSlots" group
154     Property<int> scriptSlotsWindowX;
155     Property<int> scriptSlotsWindowY;
156     Property<int> scriptSlotsWindowW;
157     Property<int> scriptSlotsWindowH;
158    
159     // settings of "CombineInstruments" group
160     Property<int> combineInstrumentsWindowX;
161     Property<int> combineInstrumentsWindowY;
162     Property<int> combineInstrumentsWindowW;
163     Property<int> combineInstrumentsWindowH;
164    
165     // settings of "MidiRules" group
166     Property<int> midiRulesWindowX;
167     Property<int> midiRulesWindowY;
168     Property<int> midiRulesWindowW;
169     Property<int> midiRulesWindowH;
170    
171     // settings of "FileProps" group
172     Property<int> filePropsWindowX;
173     Property<int> filePropsWindowY;
174     Property<int> filePropsWindowW;
175     Property<int> filePropsWindowH;
176    
177     // settings of "InstrProps" group
178     Property<int> instrPropsWindowX;
179     Property<int> instrPropsWindowY;
180     Property<int> instrPropsWindowW;
181     Property<int> instrPropsWindowH;
182    
183 schoenebeck 3637 // settings of "SampleProps" group
184     Property<int> samplePropsWindowX;
185     Property<int> samplePropsWindowY;
186     Property<int> samplePropsWindowW;
187     Property<int> samplePropsWindowH;
188    
189 schoenebeck 2894 // settings of "SampleRefs" group
190     Property<int> sampleRefsWindowX;
191     Property<int> sampleRefsWindowY;
192     Property<int> sampleRefsWindowW;
193     Property<int> sampleRefsWindowH;
194    
195 schoenebeck 3151 // settings of "MacroEditor" group
196     Property<int> macroEditorWindowX;
197     Property<int> macroEditorWindowY;
198     Property<int> macroEditorWindowW;
199     Property<int> macroEditorWindowH;
200    
201 schoenebeck 3157 // settings of "MacrosSetup" group
202     Property<int> macrosSetupWindowX;
203     Property<int> macrosSetupWindowY;
204     Property<int> macrosSetupWindowW;
205     Property<int> macrosSetupWindowH;
206    
207 schoenebeck 2541 static Settings* singleton();
208     Settings();
209 schoenebeck 2891 void load();
210 schoenebeck 3157 void loadMacros(std::vector<Serialization::Archive>& macros);
211     void saveMacros(const std::vector<Serialization::Archive>& macros);
212 schoenebeck 2891
213     protected:
214     void onPropertyChanged(Glib::PropertyBase* pProperty, RawValueType_t type, Group_t group);
215    
216     private:
217     std::vector<Glib::PropertyBase*> m_boolProps; ///< Pointers to all 'bool' type properties this Setting class manages.
218     std::vector<Glib::PropertyBase*> m_intProps; ///< Pointers to all 'int' type properties this Setting class manages.
219     bool m_ignoreNotifies;
220 schoenebeck 2541 };
221    
222     #endif // GIGEDIT_SETTINGS

  ViewVC Help
Powered by ViewVC