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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1069 - (hide annotations) (download) (as text)
Sun Mar 4 22:00:46 2007 UTC (17 years, 1 month ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 15770 byte(s)
* added new Menu "Instruments" where one of the loaded .gig files
  instrument can be selected (note: this Menu only appears when a .gig file
  is loaded)

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

  ViewVC Help
Powered by ViewVC