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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1096 - (show annotations) (download) (as text)
Tue Mar 13 17:14:38 2007 UTC (17 years ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 17515 byte(s)
* implemented drag&drop samples tree view -> dimension region sample text
  entry field, to allow assigning / changing samples of dimension regions

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

  ViewVC Help
Powered by ViewVC