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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1053 - (hide annotations) (download) (as text)
Sat Mar 3 12:20:01 2007 UTC (17 years, 1 month ago) by persson
File MIME type: text/x-c++hdr
File size: 15690 byte(s)
This commit was generated by cvs2svn to compensate for changes in r1052,
which included commits to RCS files with non-trunk default branches.
1 persson 1052 /* -*- 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_MAINWINDOW_H
21     #define GIGEDIT_MAINWINDOW_H
22    
23     #include <gig.h>
24    
25     #include <gtkmm/actiongroup.h>
26     #include <gtkmm/alignment.h>
27     #include <gtkmm/box.h>
28     #include <gtkmm/buttonbox.h>
29     #include <gtkmm/combobox.h>
30     #include <gtkmm/comboboxtext.h>
31     #include <gtkmm/dialog.h>
32     #include <gtkmm/entry.h>
33     #include <gtkmm/label.h>
34     #include <gtkmm/liststore.h>
35     #include <gtkmm/notebook.h>
36     #include <gtkmm/paned.h>
37     #include <gtkmm/progressbar.h>
38     #include <gtkmm/scale.h>
39     #include <gtkmm/scrolledwindow.h>
40     #include <gtkmm/spinbutton.h>
41     #include <gtkmm/table.h>
42     #include <gtkmm/treestore.h>
43     #include <gtkmm/treeview.h>
44     #include <gtkmm/uimanager.h>
45     #include <gtkmm/window.h>
46    
47     #include "regionchooser.h"
48     #include "dimregionchooser.h"
49    
50     extern bool update_gui;
51    
52     class MainWindow;
53    
54     class PropDialog : public Gtk::Window {
55     public:
56     PropDialog();
57     void set_info(DLS::Info* info);
58     protected:
59     Gtk::Table table;
60     Gtk::Label label[16];
61     Gtk::Entry entry[16];
62     };
63    
64     class InstrumentProps : public Gtk::Window {
65     public:
66     InstrumentProps();
67     void set_instrument(gig::Instrument* instrument);
68     protected:
69     Gtk::VBox vbox;
70     Gtk::HButtonBox buttonBox;
71     Gtk::Button quitButton;
72     Gtk::Table table;
73     Gtk::Label label[10];
74     Gtk::Entry entry[8];
75     Gtk::CheckButton check[2];
76     };
77    
78     class LoadDialog : public Gtk::Dialog {
79     public:
80     LoadDialog();
81     void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
82     protected:
83     Gtk::ProgressBar progressBar;
84     };
85    
86     class Loader : public sigc::trackable {
87     public:
88     Loader(const char* filename);
89     void launch();
90     Glib::Dispatcher& signal_progress();
91     Glib::Dispatcher& signal_finished();
92     void progress_callback(float fraction);
93     float get_progress();
94     const char* filename;
95     gig::File* gig;
96    
97     private:
98     Glib::Thread* thread;
99     void thread_function();
100     Glib::Dispatcher finished_dispatcher;
101     Glib::Dispatcher progress_dispatcher;
102     Glib::Mutex progressMutex;
103     float progress;
104     };
105    
106     class LabelWidget {
107     public:
108     Gtk::Label label;
109     Gtk::Widget& widget;
110    
111     LabelWidget(char* labelText, Gtk::Widget& widget);
112     void set_sensitive(bool sensitive = true);
113     };
114    
115    
116     template<typename T2>
117     class NumEntry : public LabelWidget {
118     protected:
119     Gtk::Adjustment adjust;
120     Gtk::HScale scale;
121     Gtk::SpinButton spinbutton;
122     Gtk::HBox box;
123     T2* dimreg;
124     public:
125     NumEntry(char* labelText, double lower = 0, double upper = 127,
126     int decimals = 0);
127     void set_value(double value) {
128     spinbutton.set_value(value);
129     }
130     Glib::SignalProxy0<void> signal_value_changed() {
131     return spinbutton.signal_value_changed();
132     }
133     double get_value() const {
134     return spinbutton.get_value();
135     }
136     };
137    
138     template<typename T2>
139     NumEntry<T2>::NumEntry(char* labelText, double lower, double upper,
140     int decimals) :
141     adjust(lower, lower, upper, 1, 10),
142     scale(adjust),
143     spinbutton(adjust),
144     LabelWidget(labelText, box)
145     {
146     spinbutton.set_digits(decimals);
147     scale.set_draw_value(false);
148     box.pack_start(spinbutton, Gtk::PACK_SHRINK);
149     box.add(scale);
150     }
151    
152     class NumEntryGain : public NumEntry<gig::DimensionRegion> {
153     private:
154     void value_changed();
155     public:
156     NumEntryGain(char* labelText,
157     double lower, double upper, int decimals);
158     void set_dimreg(gig::DimensionRegion* dimreg);
159     };
160    
161     template<typename T>
162     class NumEntryX : public NumEntry<gig::DimensionRegion> {
163     private:
164     T& (*access)(gig::DimensionRegion*);
165     void value_changed();
166     public:
167     NumEntryX(char* labelText, T& (*access)(gig::DimensionRegion*),
168     double lower = 0, double upper = 127, int decimals = 0);
169     void set_dimreg(gig::DimensionRegion* dimreg);
170     };
171    
172     template<typename T>
173     NumEntryX<T>::NumEntryX(char* labelText, T& (*access)(gig::DimensionRegion*),
174     double lower, double upper, int decimals) :
175     NumEntry<gig::DimensionRegion>(labelText, lower, upper, decimals),
176     access(access)
177     {
178     spinbutton.signal_value_changed().connect(
179     sigc::mem_fun(*this, &NumEntryX::value_changed));
180     }
181    
182     template<typename T>
183     void NumEntryX<T>::value_changed()
184     {
185     if (dimreg && update_gui) {
186     access(dimreg) = T(spinbutton.get_value());
187     }
188     }
189    
190     template<typename T>
191     void NumEntryX<T>::set_dimreg(gig::DimensionRegion* dimreg)
192     {
193     this->dimreg = 0;
194     set_value(access(dimreg));
195     this->dimreg = dimreg;
196     }
197    
198    
199     class NoteEntry : public NumEntryX<uint8_t> {
200     public:
201     NoteEntry(char* labelText, uint8_t& (*access)(gig::DimensionRegion*));
202     private:
203     int on_input(double* new_value);
204     bool on_output();
205     };
206    
207    
208     template<typename T, typename T2 = gig::DimensionRegion>
209     class NumEntryTemp : public NumEntry<T2> {
210     using NumEntry<T2>::spinbutton;
211     using NumEntry<T2>::dimreg;
212     private:
213     T T2::* param;
214     void value_changed();
215     public:
216     NumEntryTemp(char* labelText, T T2::* param,
217     double lower = 0, double upper = 127, int decimals = 0);
218     void set_dimreg(gig::DimensionRegion* dimreg);
219     };
220    
221     template<typename T, typename T2>
222     NumEntryTemp<T, T2>::NumEntryTemp(char* labelText, T T2::* param,
223     double lower, double upper, int decimals) :
224     NumEntry<T2>(labelText, lower, upper, decimals),
225     param(param)
226     {
227     spinbutton.signal_value_changed().connect(
228     sigc::mem_fun(*this, &NumEntryTemp<T, T2>::value_changed));
229     }
230    
231     template<typename T, typename T2>
232     void NumEntryTemp<T, T2>::value_changed()
233     {
234     if (dimreg && update_gui) {
235     dimreg->*param = T(spinbutton.get_value());
236     }
237     }
238    
239     template<typename T, typename T2>
240     void NumEntryTemp<T, T2>::set_dimreg(gig::DimensionRegion* dimreg)
241     {
242     this->dimreg = 0;
243     set_value(dimreg->*param);
244     this->dimreg = dimreg;
245     }
246    
247    
248    
249     class NumEntryPermille : public NumEntry<gig::DimensionRegion> {
250     private:
251     uint16_t gig::DimensionRegion::* param;
252     void value_changed();
253     public:
254     NumEntryPermille(char* labelText, uint16_t gig::DimensionRegion::* param,
255     double lower = 0, double upper = 127, int decimals = 0);
256     void set_dimreg(gig::DimensionRegion* dimreg);
257     };
258    
259    
260     template<typename T>
261     class ChoiceEntry : public LabelWidget {
262     private:
263     Gtk::ComboBoxText combobox;
264     Gtk::Alignment align;
265     T gig::DimensionRegion::* param;
266     gig::DimensionRegion* dimreg;
267     void value_changed();
268     const T* values;
269     public:
270     ChoiceEntry(char* labelText,
271     T gig::DimensionRegion::* param);
272     void set_choices(char** texts, const T* values);
273     void set_dimreg(gig::DimensionRegion* dimreg);
274     int get_active_row_number() { return combobox.get_active_row_number(); }
275     Glib::SignalProxy0<void> signal_changed() {
276     return combobox.signal_changed();
277     }
278     };
279    
280     template<typename T>
281     ChoiceEntry<T>::ChoiceEntry(char* labelText,
282     T gig::DimensionRegion::* param) :
283     align(0, 0, 0, 0),
284     LabelWidget(labelText, align),
285     param(param)
286     {
287     combobox.signal_changed().connect(
288     sigc::mem_fun(*this, &ChoiceEntry::value_changed));
289     align.add(combobox);
290     }
291    
292     template<typename T>
293     void ChoiceEntry<T>::set_choices(char** texts, const T* values)
294     {
295     for (int i = 0 ; texts[i] ; i++) {
296     combobox.append_text(texts[i]);
297     }
298     this->values = values;
299     }
300    
301     template<typename T>
302     void ChoiceEntry<T>::value_changed()
303     {
304     if (dimreg && update_gui) {
305     int rowno = combobox.get_active_row_number();
306     if (rowno != -1) dimreg->*param = values[rowno];
307     }
308     }
309    
310     template<typename T>
311     void ChoiceEntry<T>::set_dimreg(gig::DimensionRegion* dimreg)
312     {
313     this->dimreg = 0;
314     T value = dimreg->*param;
315     int row = 0;
316     int nb_rows = combobox.get_model()->children().size();
317     for (; row < nb_rows ; row++) {
318     if (value == values[row]) break;
319     }
320     combobox.set_active(row == nb_rows ? -1 : row);
321     this->dimreg = dimreg;
322     }
323    
324    
325     class ChoiceEntryLeverageCtrl : public LabelWidget {
326     private:
327     Gtk::ComboBoxText combobox;
328     Gtk::Alignment align;
329     gig::leverage_ctrl_t gig::DimensionRegion::* param;
330     gig::DimensionRegion* dimreg;
331     void value_changed();
332     public:
333     ChoiceEntryLeverageCtrl(char* labelText,
334     gig::leverage_ctrl_t gig::DimensionRegion::* param);
335     void set_dimreg(gig::DimensionRegion* dimreg);
336     int get_active_row_number() { return combobox.get_active_row_number(); }
337     Glib::SignalProxy0<void> signal_changed() {
338     return combobox.signal_changed();
339     }
340     };
341    
342    
343    
344     class BoolEntry : public LabelWidget {
345     private:
346     Gtk::CheckButton checkbutton;
347     bool gig::DimensionRegion::* param;
348     gig::DimensionRegion* dimreg;
349     void value_changed();
350     public:
351     BoolEntry(char* labelText, bool gig::DimensionRegion::* param);
352     void set_dimreg(gig::DimensionRegion* dimreg);
353     bool get_active() { return checkbutton.get_active(); }
354     Glib::SignalProxy0<void> signal_toggled() {
355     return checkbutton.signal_toggled();
356     }
357     };
358    
359     class MainWindow : public Gtk::Window {
360     public:
361     MainWindow();
362     virtual ~MainWindow();
363     void getInfo(const char* filename);
364    
365     protected:
366     Glib::RefPtr<Gtk::ActionGroup> actionGroup;
367     Glib::RefPtr<Gtk::UIManager> uiManager;
368    
369     int rowno;
370     int pageno;
371     int firstRowInBlock;
372    
373     NumEntryTemp<uint8_t> eVelocityUpperLimit;
374     NumEntryPermille eEG1PreAttack;
375     NumEntryTemp<double> eEG1Attack;
376     NumEntryTemp<double> eEG1Decay1;
377     NumEntryTemp<double> eEG1Decay2;
378     BoolEntry eEG1InfiniteSustain;
379     NumEntryPermille eEG1Sustain;
380     NumEntryTemp<double> eEG1Release;
381     BoolEntry eEG1Hold;
382     ChoiceEntryLeverageCtrl eEG1Controller;
383     BoolEntry eEG1ControllerInvert;
384     NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
385     NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
386     NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
387     NumEntryTemp<double> eLFO1Frequency;
388     NumEntryTemp<uint16_t> eLFO1InternalDepth;
389     NumEntryTemp<uint16_t> eLFO1ControlDepth;
390     ChoiceEntry<gig::lfo1_ctrl_t> eLFO1Controller;
391     BoolEntry eLFO1FlipPhase;
392     BoolEntry eLFO1Sync;
393     NumEntryPermille eEG2PreAttack;
394     NumEntryTemp<double> eEG2Attack;
395     NumEntryTemp<double> eEG2Decay1;
396     NumEntryTemp<double> eEG2Decay2;
397     BoolEntry eEG2InfiniteSustain;
398     NumEntryPermille eEG2Sustain;
399     NumEntryTemp<double> eEG2Release;
400     ChoiceEntryLeverageCtrl eEG2Controller;
401     BoolEntry eEG2ControllerInvert;
402     NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
403     NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
404     NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
405     NumEntryTemp<double> eLFO2Frequency;
406     NumEntryTemp<uint16_t> eLFO2InternalDepth;
407     NumEntryTemp<uint16_t> eLFO2ControlDepth;
408     ChoiceEntry<gig::lfo2_ctrl_t> eLFO2Controller;
409     BoolEntry eLFO2FlipPhase;
410     BoolEntry eLFO2Sync;
411     NumEntryTemp<double> eEG3Attack;
412     NumEntryTemp<int16_t> eEG3Depth;
413     NumEntryTemp<double> eLFO3Frequency;
414     NumEntryTemp<int16_t> eLFO3InternalDepth;
415     NumEntryTemp<int16_t> eLFO3ControlDepth;
416     ChoiceEntry<gig::lfo3_ctrl_t> eLFO3Controller;
417     BoolEntry eLFO3Sync;
418     BoolEntry eVCFEnabled;
419     ChoiceEntry<gig::vcf_type_t> eVCFType;
420     ChoiceEntry<gig::vcf_cutoff_ctrl_t> eVCFCutoffController;
421     BoolEntry eVCFCutoffControllerInvert;
422     NumEntryTemp<uint8_t> eVCFCutoff;
423     ChoiceEntry<gig::curve_type_t> eVCFVelocityCurve;
424     NumEntryTemp<uint8_t> eVCFVelocityScale;
425     NumEntryTemp<uint8_t> eVCFVelocityDynamicRange;
426     NumEntryTemp<uint8_t> eVCFResonance;
427     BoolEntry eVCFResonanceDynamic;
428     ChoiceEntry<gig::vcf_res_ctrl_t> eVCFResonanceController;
429     BoolEntry eVCFKeyboardTracking;
430     NumEntryTemp<uint8_t> eVCFKeyboardTrackingBreakpoint;
431     ChoiceEntry<gig::curve_type_t> eVelocityResponseCurve;
432     NumEntryTemp<uint8_t> eVelocityResponseDepth;
433     NumEntryTemp<uint8_t> eVelocityResponseCurveScaling;
434     ChoiceEntry<gig::curve_type_t> eReleaseVelocityResponseCurve;
435     NumEntryTemp<uint8_t> eReleaseVelocityResponseDepth;
436     NumEntryTemp<uint8_t> eReleaseTriggerDecay;
437     NumEntryX<uint8_t> eCrossfade_in_start;
438     NumEntryX<uint8_t> eCrossfade_in_end;
439     NumEntryX<uint8_t> eCrossfade_out_start;
440     NumEntryX<uint8_t> eCrossfade_out_end;
441     BoolEntry ePitchTrack;
442     ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;
443     NumEntryTemp<int8_t> ePan;
444     BoolEntry eSelfMask;
445     ChoiceEntryLeverageCtrl eAttenuationController;
446     BoolEntry eInvertAttenuationController;
447     NumEntryTemp<uint8_t> eAttenuationControllerThreshold;
448     NumEntryTemp<uint8_t> eChannelOffset;
449     BoolEntry eSustainDefeat;
450     BoolEntry eMSDecode;
451     NumEntryTemp<uint16_t> eSampleStartOffset;
452     // NumEntryX<uint8_t> eUnityNote;
453     NoteEntry eUnityNote;
454     NumEntryX<int16_t> eFineTune;
455     NumEntryGain eGain;
456     NumEntryX<uint32_t> eSampleLoops;
457    
458     void addProp(LabelWidget& labelwidget);
459     void addString(char* labelText, Gtk::Label*& label,
460     Gtk::Entry*& widget);
461     void addHeader(char* text);
462     void nextPage();
463    
464     RegionChooser m_RegionChooser;
465     DimRegionChooser m_DimRegionChooser;
466    
467     void set_dim_region(gig::DimensionRegion* d);
468     PropDialog propDialog;
469     InstrumentProps instrumentProps;
470    
471     void on_sel_change();
472     void region_changed();
473     void dimreg_changed();
474     void on_loader_progress();
475     void on_loader_finished();
476    
477     class ModelColumns : public Gtk::TreeModel::ColumnRecord {
478     public:
479    
480     ModelColumns() {
481     add(m_col_name);
482     add(m_col_instr);
483     }
484    
485     Gtk::TreeModelColumn<Glib::ustring> m_col_name;
486     Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
487     };
488    
489     ModelColumns m_Columns;
490    
491     Gtk::VBox m_VBox;
492     Gtk::HPaned m_HPaned;
493    
494     Gtk::ScrolledWindow m_ScrolledWindow;
495     Gtk::TreeView m_TreeView;
496     Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
497    
498     Gtk::Notebook m_Notebook;
499    
500     Gtk::Table* table[5];
501    
502     // dimensionregion parameter widgets
503     // TODO: remove:
504     Gtk::Label* lSample;
505     Gtk::Entry* wSample;
506    
507     void VCFEnabled_toggled();
508     void VCFCutoffController_changed();
509     void VCFResonanceController_changed();
510     void EG1InfiniteSustain_toggled();
511     void EG2InfiniteSustain_toggled();
512     void EG1Controller_changed();
513     void EG2Controller_changed();
514     void AttenuationController_changed();
515     void LFO1Controller_changed();
516     void LFO2Controller_changed();
517     void LFO3Controller_changed();
518     void crossfade1_changed();
519     void crossfade2_changed();
520     void crossfade3_changed();
521     void crossfade4_changed();
522    
523     void on_action_file_new();
524     void on_action_file_open();
525     void on_action_file_save();
526     void on_action_file_save_as();
527     void on_action_file_properties();
528     void on_action_help_about();
529    
530     LoadDialog* load_dialog;
531     Loader* loader;
532     void load_gig(gig::File* gig, const char* filename);
533    
534     gig::File* file;
535    
536     void on_button_release(GdkEventButton* button);
537    
538     Gtk::Menu* popup_menu;
539     };
540    
541     #endif

  ViewVC Help
Powered by ViewVC