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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1117 - (hide annotations) (download) (as text)
Sat Mar 24 13:05:58 2007 UTC (13 years, 3 months ago) by persson
File MIME type: text/x-c++hdr
File size: 9042 byte(s)
* added +6dB parameter to DimRegionEdit
* preparations for improved instrument properties dialog

1 persson 1100 /* -*- c++ -*-
2     * Copyright (C) 2006, 2007 Andreas Persson
3     *
4     * This program is free software; you can redistribute it and/or
5     * modify it under the terms of the GNU General Public License as
6     * published by the Free Software Foundation; either version 2, or (at
7     * your option) any later version.
8     *
9     * This program is distributed in the hope that it will be useful, but
10     * WITHOUT ANY WARRANTY; without even the implied warranty of
11     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     * General Public License for more details.
13     *
14     * You should have received a copy of the GNU General Public License
15     * along with program; see the file COPYING. If not, write to the Free
16     * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17     * 02110-1301 USA.
18     */
19    
20     #ifndef GIGEDIT_PARAMEDIT_H
21     #define GIGEDIT_PARAMEDIT_H
22    
23     #include <gig.h>
24    
25     #include <gtkmm/adjustment.h>
26     #include <gtkmm/alignment.h>
27     #include <gtkmm/box.h>
28     #include <gtkmm/comboboxtext.h>
29     #include <gtkmm/label.h>
30     #include <gtkmm/scale.h>
31     #include <gtkmm/spinbutton.h>
32    
33     extern bool update_gui;
34    
35     class LabelWidget {
36     public:
37     Gtk::Label label;
38     Gtk::Widget& widget;
39    
40     LabelWidget(char* labelText, Gtk::Widget& widget);
41     void set_sensitive(bool sensitive = true);
42     };
43    
44     template<typename T2>
45     class NumEntry : public LabelWidget {
46     protected:
47     Gtk::Adjustment adjust;
48     Gtk::HScale scale;
49     Gtk::SpinButton spinbutton;
50     Gtk::HBox box;
51     T2* dimreg;
52     public:
53     NumEntry(char* labelText, double lower = 0, double upper = 127,
54     int decimals = 0);
55     void set_value(double value) {
56     spinbutton.set_value(value);
57     }
58     Glib::SignalProxy0<void> signal_value_changed() {
59     return spinbutton.signal_value_changed();
60     }
61     double get_value() const {
62     return spinbutton.get_value();
63     }
64     };
65    
66     template<typename T2>
67     NumEntry<T2>::NumEntry(char* labelText, double lower, double upper,
68     int decimals) :
69     adjust(lower, lower, upper, 1, 10),
70     scale(adjust),
71     spinbutton(adjust),
72     LabelWidget(labelText, box)
73     {
74     spinbutton.set_digits(decimals);
75     scale.set_draw_value(false);
76     box.pack_start(spinbutton, Gtk::PACK_SHRINK);
77     box.add(scale);
78     }
79    
80     class NumEntryGain : public NumEntry<gig::DimensionRegion> {
81     private:
82     void value_changed();
83     public:
84     NumEntryGain(char* labelText,
85 persson 1117 double lower, double upper, int decimals);
86 persson 1100 void set_dimreg(gig::DimensionRegion* dimreg);
87     };
88    
89 persson 1117 template<typename T, typename T2 = gig::DimensionRegion>
90     class NumEntryX : public NumEntry<T2> {
91     using NumEntry<T2>::spinbutton;
92     using NumEntry<T2>::dimreg;
93 persson 1100 private:
94 persson 1117 T& (*access)(T2*);
95 persson 1100 void value_changed();
96     public:
97 persson 1117 NumEntryX(char* labelText, T& (*access)(T2*),
98 persson 1100 double lower = 0, double upper = 127, int decimals = 0);
99 persson 1117 void set_dimreg(T2* dimreg);
100 persson 1100 };
101    
102 persson 1117 template<typename T, typename T2>
103     NumEntryX<T, T2>::NumEntryX(char* labelText, T& (*access)(T2*),
104     double lower, double upper, int decimals) :
105     NumEntry<T2>(labelText, lower, upper, decimals),
106 persson 1100 access(access)
107     {
108     spinbutton.signal_value_changed().connect(
109     sigc::mem_fun(*this, &NumEntryX::value_changed));
110     }
111    
112 persson 1117 template<typename T, typename T2>
113     void NumEntryX<T, T2>::value_changed()
114 persson 1100 {
115     if (dimreg && update_gui) {
116     access(dimreg) = T(spinbutton.get_value());
117     }
118     }
119    
120 persson 1117 template<typename T, typename T2>
121     void NumEntryX<T, T2>::set_dimreg(T2* dimreg)
122 persson 1100 {
123     this->dimreg = 0;
124     set_value(access(dimreg));
125     this->dimreg = dimreg;
126     }
127    
128    
129     class NoteEntry : public NumEntryX<uint8_t> {
130     public:
131     NoteEntry(char* labelText, uint8_t& (*access)(gig::DimensionRegion*));
132     private:
133     int on_input(double* new_value);
134     bool on_output();
135     };
136    
137    
138     template<typename T, typename T2 = gig::DimensionRegion>
139     class NumEntryTemp : public NumEntry<T2> {
140     using NumEntry<T2>::spinbutton;
141     using NumEntry<T2>::dimreg;
142     private:
143     T T2::* param;
144     void value_changed();
145     public:
146     NumEntryTemp(char* labelText, T T2::* param,
147     double lower = 0, double upper = 127, int decimals = 0);
148 persson 1117 void set_dimreg(T2* dimreg);
149 persson 1100 };
150    
151     template<typename T, typename T2>
152     NumEntryTemp<T, T2>::NumEntryTemp(char* labelText, T T2::* param,
153     double lower, double upper, int decimals) :
154     NumEntry<T2>(labelText, lower, upper, decimals),
155     param(param)
156     {
157     spinbutton.signal_value_changed().connect(
158 persson 1117 sigc::mem_fun(*this, &NumEntryTemp::value_changed));
159 persson 1100 }
160    
161     template<typename T, typename T2>
162     void NumEntryTemp<T, T2>::value_changed()
163     {
164     if (dimreg && update_gui) {
165     dimreg->*param = T(spinbutton.get_value());
166     }
167     }
168    
169     template<typename T, typename T2>
170 persson 1117 void NumEntryTemp<T, T2>::set_dimreg(T2* dimreg)
171 persson 1100 {
172     this->dimreg = 0;
173     set_value(dimreg->*param);
174     this->dimreg = dimreg;
175     }
176    
177    
178    
179     class NumEntryPermille : public NumEntry<gig::DimensionRegion> {
180     private:
181     uint16_t gig::DimensionRegion::* param;
182     void value_changed();
183     public:
184     NumEntryPermille(char* labelText, uint16_t gig::DimensionRegion::* param,
185     double lower = 0, double upper = 127, int decimals = 0);
186     void set_dimreg(gig::DimensionRegion* dimreg);
187     };
188    
189    
190     template<typename T>
191     class ChoiceEntry : public LabelWidget {
192     private:
193     Gtk::ComboBoxText combobox;
194     Gtk::Alignment align;
195     T gig::DimensionRegion::* param;
196     gig::DimensionRegion* dimreg;
197     void value_changed();
198     const T* values;
199     public:
200     ChoiceEntry(char* labelText,
201     T gig::DimensionRegion::* param);
202     void set_choices(char** texts, const T* values);
203     void set_dimreg(gig::DimensionRegion* dimreg);
204     int get_active_row_number() { return combobox.get_active_row_number(); }
205     Glib::SignalProxy0<void> signal_changed() {
206     return combobox.signal_changed();
207     }
208     };
209    
210     template<typename T>
211     ChoiceEntry<T>::ChoiceEntry(char* labelText,
212     T gig::DimensionRegion::* param) :
213     align(0, 0, 0, 0),
214     LabelWidget(labelText, align),
215     param(param)
216     {
217     combobox.signal_changed().connect(
218     sigc::mem_fun(*this, &ChoiceEntry::value_changed));
219     align.add(combobox);
220     }
221    
222     template<typename T>
223     void ChoiceEntry<T>::set_choices(char** texts, const T* values)
224     {
225     for (int i = 0 ; texts[i] ; i++) {
226     combobox.append_text(texts[i]);
227     }
228     this->values = values;
229     }
230    
231     template<typename T>
232     void ChoiceEntry<T>::value_changed()
233     {
234     if (dimreg && update_gui) {
235     int rowno = combobox.get_active_row_number();
236     if (rowno != -1) dimreg->*param = values[rowno];
237     }
238     }
239    
240     template<typename T>
241     void ChoiceEntry<T>::set_dimreg(gig::DimensionRegion* dimreg)
242     {
243     this->dimreg = 0;
244     T value = dimreg->*param;
245     int row = 0;
246     int nb_rows = combobox.get_model()->children().size();
247     for (; row < nb_rows ; row++) {
248     if (value == values[row]) break;
249     }
250     combobox.set_active(row == nb_rows ? -1 : row);
251     this->dimreg = dimreg;
252     }
253    
254    
255     class ChoiceEntryLeverageCtrl : public LabelWidget {
256     private:
257     Gtk::ComboBoxText combobox;
258     Gtk::Alignment align;
259     gig::leverage_ctrl_t gig::DimensionRegion::* param;
260     gig::DimensionRegion* dimreg;
261     void value_changed();
262     public:
263     ChoiceEntryLeverageCtrl(char* labelText,
264     gig::leverage_ctrl_t gig::DimensionRegion::* param);
265     void set_dimreg(gig::DimensionRegion* dimreg);
266     int get_active_row_number() { return combobox.get_active_row_number(); }
267     Glib::SignalProxy0<void> signal_changed() {
268     return combobox.signal_changed();
269     }
270     };
271    
272    
273 persson 1117 template<typename T2>
274 persson 1100 class BoolEntry : public LabelWidget {
275     private:
276     Gtk::CheckButton checkbutton;
277 persson 1117 bool T2::* param;
278     T2* dimreg;
279     void value_changed();
280     public:
281     BoolEntry(char* labelText, bool T2::* param);
282     void set_dimreg(T2* dimreg);
283     bool get_active() { return checkbutton.get_active(); }
284     Glib::SignalProxy0<void> signal_toggled() {
285     return checkbutton.signal_toggled();
286     }
287     };
288    
289     template<typename T2>
290     BoolEntry<T2>::BoolEntry(char* labelText, bool T2::* param) :
291     LabelWidget(labelText, checkbutton),
292     param(param)
293     {
294     checkbutton.signal_toggled().connect(
295     sigc::mem_fun(*this, &BoolEntry::value_changed));
296     }
297    
298     template<typename T2>
299     void BoolEntry<T2>::value_changed()
300     {
301     if (dimreg && update_gui) {
302     dimreg->*param = checkbutton.get_active();
303     }
304     }
305    
306     template<typename T2>
307     void BoolEntry<T2>::set_dimreg(T2* dimreg)
308     {
309     this->dimreg = 0;
310     checkbutton.set_active(dimreg->*param);
311     this->dimreg = dimreg;
312     }
313    
314     class BoolEntryPlus6 : public LabelWidget {
315     private:
316     Gtk::CheckButton checkbutton;
317 persson 1100 gig::DimensionRegion* dimreg;
318     void value_changed();
319 persson 1117 NumEntryGain& eGain;
320 persson 1100 public:
321 persson 1117 BoolEntryPlus6(char* labelText, NumEntryGain& eGain);
322 persson 1100 void set_dimreg(gig::DimensionRegion* dimreg);
323     bool get_active() { return checkbutton.get_active(); }
324     Glib::SignalProxy0<void> signal_toggled() {
325     return checkbutton.signal_toggled();
326     }
327     };
328    
329     #endif

  ViewVC Help
Powered by ViewVC