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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3364 - (hide annotations) (download) (as text)
Tue Nov 14 18:07:25 2017 UTC (6 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 13415 byte(s)
* Added experimental support for upcoming GTK(MM)4
  (for now up to GTKMM 3.91.2 while still preserving backward compatibility
  down to GTKMM 2).
* Re-merged r2845 to compile now with and without Gtk "Stock ID" API
  (see also r3158).

1 schoenebeck 1225 /* -*- c++ -*-
2 schoenebeck 3068 * Copyright (C) 2006-2017 Andreas Persson
3 schoenebeck 1225 *
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_DIMREGIONEDIT_H
21     #define GIGEDIT_DIMREGIONEDIT_H
22    
23 schoenebeck 3068 #ifdef LIBGIG_HEADER_FILE
24     # include LIBGIG_HEADER_FILE(gig.h)
25     #else
26     # include <gig.h>
27     #endif
28 schoenebeck 1225
29 schoenebeck 3364 #include "compat.h"
30    
31 persson 2442 #include <cairomm/context.h>
32 persson 2844 #include <gtkmm/box.h>
33 persson 2392 #include <gtkmm/drawingarea.h>
34 schoenebeck 1225 #include <gtkmm/entry.h>
35     #include <gtkmm/label.h>
36     #include <gtkmm/notebook.h>
37 schoenebeck 3364 #if USE_GTKMM_GRID
38     # include <gtkmm/grid.h>
39     #else
40     # include <gtkmm/table.h>
41     #endif
42 schoenebeck 1225
43 persson 1460 #include <set>
44    
45 schoenebeck 1225 #include "paramedit.h"
46 schoenebeck 3177 #include "global.h"
47 schoenebeck 1225
48 persson 2392 class VelocityCurve : public Gtk::DrawingArea {
49     public:
50     VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t));
51     void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
52    
53     protected:
54     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
55     bool on_expose_event(GdkEventExpose* e);
56     #else
57     bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
58     #endif
59    
60     private:
61     double (gig::DimensionRegion::* const getter)(uint8_t);
62     gig::DimensionRegion* dimreg;
63     };
64    
65     class CrossfadeCurve : public Gtk::DrawingArea {
66     public:
67     CrossfadeCurve();
68     void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
69    
70     protected:
71     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
72     bool on_expose_event(GdkEventExpose* e);
73     #else
74     bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
75     #endif
76    
77     private:
78     gig::DimensionRegion* dimreg;
79 persson 2430 void draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
80     const gig::DimensionRegion* d,
81     bool sensitive);
82 persson 2392 };
83    
84 schoenebeck 3364 class EGStateOptions : public HBox {
85 schoenebeck 3329 public:
86     Gtk::Label label;
87     BoolBox checkBoxAttack;
88     BoolBox checkBoxAttackHold;
89     BoolBox checkBoxDecay1;
90     BoolBox checkBoxDecay2;
91     BoolBox checkBoxRelease;
92    
93     EGStateOptions();
94     };
95    
96 schoenebeck 1225 class DimRegionEdit : public Gtk::Notebook
97     {
98     public:
99     DimRegionEdit();
100     virtual ~DimRegionEdit();
101     void set_dim_region(gig::DimensionRegion* d);
102 schoenebeck 2464 bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
103 schoenebeck 2925 bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
104 schoenebeck 1225 Gtk::Entry* wSample;
105 schoenebeck 2720 Gtk::Button* buttonNullSampleReference;
106 schoenebeck 1339 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
107     sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
108     sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
109 schoenebeck 2691 sigc::signal<void, gig::Sample*>& signal_select_sample();
110 schoenebeck 1225
111 persson 1533 std::set<gig::DimensionRegion*> dimregs;
112    
113 schoenebeck 1225 protected:
114 schoenebeck 1322 sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
115     sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
116     sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
117 persson 1261 sigc::signal<void> instrument_changed;
118 schoenebeck 2691 sigc::signal<void, gig::Sample*> select_sample_signal;
119 persson 1261
120 schoenebeck 3177 /**
121     * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
122     * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
123     * pair. It behaves similar to a "mutex lock guard" design pattern.
124     */
125     class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
126     public:
127     DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
128     SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
129     {
130     }
131     };
132    
133 schoenebeck 1225 gig::DimensionRegion* dimregion;
134    
135 persson 2151 #ifdef OLD_TOOLTIPS
136 schoenebeck 1225 Gtk::Tooltips tooltips;
137 persson 2151 #endif
138 schoenebeck 1225
139 schoenebeck 3364 #if USE_GTKMM_GRID
140     Gtk::Grid* table[7];
141     #else
142 schoenebeck 1225 Gtk::Table* table[7];
143 schoenebeck 3364 #endif
144 schoenebeck 1225
145     Gtk::Label* lSample;
146    
147 persson 2392 VelocityCurve velocity_curve;
148     VelocityCurve release_curve;
149     VelocityCurve cutoff_curve;
150     CrossfadeCurve crossfade_curve;
151    
152 schoenebeck 1225 NumEntryPermille eEG1PreAttack;
153     NumEntryTemp<double> eEG1Attack;
154     NumEntryTemp<double> eEG1Decay1;
155     NumEntryTemp<double> eEG1Decay2;
156     BoolEntry eEG1InfiniteSustain;
157     NumEntryPermille eEG1Sustain;
158     NumEntryTemp<double> eEG1Release;
159     BoolEntry eEG1Hold;
160     ChoiceEntryLeverageCtrl eEG1Controller;
161     BoolEntry eEG1ControllerInvert;
162     NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
163     NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
164     NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
165 schoenebeck 3329 EGStateOptions eEG1StateOptions;
166 schoenebeck 1225 NumEntryTemp<double> eLFO1Frequency;
167     NumEntryTemp<uint16_t> eLFO1InternalDepth;
168     NumEntryTemp<uint16_t> eLFO1ControlDepth;
169     ChoiceEntry<gig::lfo1_ctrl_t> eLFO1Controller;
170     BoolEntry eLFO1FlipPhase;
171     BoolEntry eLFO1Sync;
172     NumEntryPermille eEG2PreAttack;
173     NumEntryTemp<double> eEG2Attack;
174     NumEntryTemp<double> eEG2Decay1;
175     NumEntryTemp<double> eEG2Decay2;
176     BoolEntry eEG2InfiniteSustain;
177     NumEntryPermille eEG2Sustain;
178     NumEntryTemp<double> eEG2Release;
179     ChoiceEntryLeverageCtrl eEG2Controller;
180     BoolEntry eEG2ControllerInvert;
181     NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
182     NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
183     NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
184 schoenebeck 3329 EGStateOptions eEG2StateOptions;
185 schoenebeck 1225 NumEntryTemp<double> eLFO2Frequency;
186     NumEntryTemp<uint16_t> eLFO2InternalDepth;
187     NumEntryTemp<uint16_t> eLFO2ControlDepth;
188     ChoiceEntry<gig::lfo2_ctrl_t> eLFO2Controller;
189     BoolEntry eLFO2FlipPhase;
190     BoolEntry eLFO2Sync;
191     NumEntryTemp<double> eEG3Attack;
192     NumEntryTemp<int16_t> eEG3Depth;
193     NumEntryTemp<double> eLFO3Frequency;
194     NumEntryTemp<int16_t> eLFO3InternalDepth;
195     NumEntryTemp<int16_t> eLFO3ControlDepth;
196     ChoiceEntry<gig::lfo3_ctrl_t> eLFO3Controller;
197     BoolEntry eLFO3Sync;
198     BoolEntry eVCFEnabled;
199     ChoiceEntry<gig::vcf_type_t> eVCFType;
200     ChoiceEntry<gig::vcf_cutoff_ctrl_t> eVCFCutoffController;
201     BoolEntry eVCFCutoffControllerInvert;
202     NumEntryTemp<uint8_t> eVCFCutoff;
203     ChoiceEntry<gig::curve_type_t> eVCFVelocityCurve;
204     NumEntryTemp<uint8_t> eVCFVelocityScale;
205     NumEntryTemp<uint8_t> eVCFVelocityDynamicRange;
206     NumEntryTemp<uint8_t> eVCFResonance;
207     BoolEntry eVCFResonanceDynamic;
208     ChoiceEntry<gig::vcf_res_ctrl_t> eVCFResonanceController;
209     BoolEntry eVCFKeyboardTracking;
210     NumEntryTemp<uint8_t> eVCFKeyboardTrackingBreakpoint;
211     ChoiceEntry<gig::curve_type_t> eVelocityResponseCurve;
212     NumEntryTemp<uint8_t> eVelocityResponseDepth;
213     NumEntryTemp<uint8_t> eVelocityResponseCurveScaling;
214     ChoiceEntry<gig::curve_type_t> eReleaseVelocityResponseCurve;
215     NumEntryTemp<uint8_t> eReleaseVelocityResponseDepth;
216     NumEntryTemp<uint8_t> eReleaseTriggerDecay;
217     NumEntryTemp<uint8_t> eCrossfade_in_start;
218     NumEntryTemp<uint8_t> eCrossfade_in_end;
219     NumEntryTemp<uint8_t> eCrossfade_out_start;
220     NumEntryTemp<uint8_t> eCrossfade_out_end;
221     BoolEntry ePitchTrack;
222     ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;
223     NumEntryTemp<int8_t> ePan;
224     BoolEntry eSelfMask;
225     ChoiceEntryLeverageCtrl eAttenuationController;
226     BoolEntry eInvertAttenuationController;
227     NumEntryTemp<uint8_t> eAttenuationControllerThreshold;
228     NumEntryTemp<uint8_t> eChannelOffset;
229     BoolEntry eSustainDefeat;
230     BoolEntry eMSDecode;
231     NumEntryTemp<uint16_t> eSampleStartOffset;
232     NoteEntry eUnityNote;
233 schoenebeck 2991 ReadOnlyLabelWidget eSampleGroup;
234 schoenebeck 2690 ReadOnlyLabelWidget eSampleFormatInfo;
235     ReadOnlyLabelWidget eSampleID;
236 schoenebeck 2991 ReadOnlyLabelWidget eChecksum;
237 schoenebeck 1225 NumEntryTemp<int16_t> eFineTune;
238     NumEntryGain eGain;
239     BoolEntryPlus6 eGainPlus6;
240     BoolEntry eSampleLoopEnabled;
241     NumEntryTemp<uint32_t> eSampleLoopStart;
242     NumEntryTemp<uint32_t> eSampleLoopLength;
243     ChoiceEntry<uint32_t> eSampleLoopType;
244     BoolEntry eSampleLoopInfinite;
245     NumEntryTemp<uint32_t> eSampleLoopPlayCount;
246 persson 1623 Gtk::Label* lEG2;
247     Gtk::Label* lLFO2;
248 schoenebeck 1225
249 schoenebeck 2691 Gtk::Button buttonSelectSample;
250    
251 schoenebeck 1225 int rowno;
252     int pageno;
253     int firstRowInBlock;
254    
255    
256     void addProp(BoolEntry& boolentry);
257 persson 1262 void addProp(BoolEntryPlus6& boolentry);
258 schoenebeck 1225 void addProp(LabelWidget& labelwidget);
259 schoenebeck 3364 void addLine(HBox& line);
260 schoenebeck 1225 void addString(const char* labelText, Gtk::Label*& label,
261     Gtk::Entry*& widget);
262 schoenebeck 2720 void addString(const char* labelText, Gtk::Label*& label,
263     Gtk::Entry*& widget, Gtk::Button*& button);
264 persson 1623 Gtk::Label* addHeader(const char* text);
265 schoenebeck 2691 void addRightHandSide(Gtk::Widget& widget);
266 schoenebeck 1225 void nextPage();
267    
268     void VCFEnabled_toggled();
269     void VCFCutoffController_changed();
270     void VCFResonanceController_changed();
271     void EG1InfiniteSustain_toggled();
272     void EG2InfiniteSustain_toggled();
273     void EG1Controller_changed();
274     void EG2Controller_changed();
275     void AttenuationController_changed();
276     void LFO1Controller_changed();
277     void LFO2Controller_changed();
278     void LFO3Controller_changed();
279     void crossfade1_changed();
280     void crossfade2_changed();
281     void crossfade3_changed();
282     void crossfade4_changed();
283 persson 1460 void update_loop_elements();
284     void loop_start_changed();
285     void loop_length_changed();
286 schoenebeck 1225 void loop_infinite_toggled();
287 schoenebeck 2720 void nullOutSampleReference();
288 schoenebeck 1225
289 persson 1460 int update_model;
290    
291 schoenebeck 3329 /**
292     * Workaround for the circumstance that C++ does not allow to cast to
293     * member pointers.
294     */
295     template<typename classT, typename memberT>
296     union ClassMemberPtr {
297     memberT classT::*pmember;
298     void* pvoid;
299    
300     ClassMemberPtr(size_t s) : pvoid((void*)s) {}
301     ClassMemberPtr(void* p) : pvoid(p) {}
302     };
303    
304 persson 1460 // connect a widget to a setter function in DimRegionEdit
305     template<typename C, typename T>
306     void connect(C& widget,
307     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
308     connect<C, T>(widget,
309     sigc::mem_fun(setter));
310     }
311    
312     // connect a widget to a member variable in gig::DimensionRegion
313     template<typename C, typename T>
314     void connect(C& widget, T gig::DimensionRegion::* member) {
315     connect<C, T>(widget,
316     sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
317     }
318    
319     // connect a widget to a setter function in gig::DimensionRegion
320     template<typename C, typename T>
321     void connect(C& widget,
322     void (gig::DimensionRegion::*setter)(T)) {
323     connect<C, T>(widget,
324     sigc::hide<0>(sigc::mem_fun(setter)));
325     }
326    
327     // helper function for the connect functions above
328     template<typename C, typename T>
329     void connect(C& widget,
330     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
331     widget.signal_value_changed().connect(
332     sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
333     sigc::mem_fun(widget, &C::get_value)));
334     }
335    
336 schoenebeck 2925 // loop through all dimregions being edited and set a value in
337 persson 1460 // each of them
338     template<typename T>
339     void set_many(T value,
340     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
341     if (update_model == 0) {
342     for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
343 persson 2841 i != dimregs.end() ; ++i)
344 persson 1460 {
345 schoenebeck 3177 DimRegionChangeGuard(this, *i);
346 persson 1460 setter(this, *i, value);
347     }
348     }
349     }
350    
351     // set a value of a member variable in the given dimregion
352     template<typename T>
353     void set_member(gig::DimensionRegion* d, T value,
354     T gig::DimensionRegion::* member) {
355     d->*member = value;
356     }
357    
358     // setters for specific dimregion parameters
359    
360     void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
361     void set_FineTune(gig::DimensionRegion* d, int16_t value);
362     void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
363     void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
364     void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
365     void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
366     void set_Gain(gig::DimensionRegion* d, int32_t value);
367     void set_LoopEnabled(gig::DimensionRegion* d, bool value);
368     void set_LoopType(gig::DimensionRegion* d, uint32_t value);
369     void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
370     void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
371     void set_LoopInfinite(gig::DimensionRegion* d, bool value);
372     void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
373 schoenebeck 2691
374     void onButtonSelectSamplePressed();
375 schoenebeck 1225 };
376    
377     #endif

  ViewVC Help
Powered by ViewVC