1 |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006-2019 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_DIMREGIONEDIT_H |
21 |
#define GIGEDIT_DIMREGIONEDIT_H |
22 |
|
23 |
#ifdef LIBGIG_HEADER_FILE |
24 |
# include LIBGIG_HEADER_FILE(gig.h) |
25 |
#else |
26 |
# include <gig.h> |
27 |
#endif |
28 |
|
29 |
#include "compat.h" |
30 |
|
31 |
#include <cairomm/context.h> |
32 |
#include <gtkmm/box.h> |
33 |
#include <gtkmm/drawingarea.h> |
34 |
#include <gtkmm/entry.h> |
35 |
#include <gtkmm/label.h> |
36 |
#include <gtkmm/notebook.h> |
37 |
#if USE_GTKMM_GRID |
38 |
# include <gtkmm/grid.h> |
39 |
#else |
40 |
# include <gtkmm/table.h> |
41 |
#endif |
42 |
|
43 |
#ifdef LIBLINUXSAMPLER_HEADER_FILE |
44 |
# include LIBLINUXSAMPLER_HEADER_FILE(engines/LFO.h) |
45 |
#else |
46 |
# include <linuxsampler/engines/LFO.h> |
47 |
#endif |
48 |
|
49 |
#include <set> |
50 |
|
51 |
#include "paramedit.h" |
52 |
#include "global.h" |
53 |
#include "ScriptPatchVars.h" |
54 |
#include "wrapLabel.hh" |
55 |
|
56 |
class VelocityCurve : public Gtk::DrawingArea { |
57 |
public: |
58 |
VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)); |
59 |
void set_dim_region(gig::DimensionRegion* d) { dimreg = d; } |
60 |
|
61 |
protected: |
62 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
63 |
bool on_expose_event(GdkEventExpose* e); |
64 |
#else |
65 |
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); |
66 |
#endif |
67 |
|
68 |
private: |
69 |
double (gig::DimensionRegion::* const getter)(uint8_t); |
70 |
gig::DimensionRegion* dimreg; |
71 |
}; |
72 |
|
73 |
class CrossfadeCurve : public Gtk::DrawingArea { |
74 |
public: |
75 |
CrossfadeCurve(); |
76 |
void set_dim_region(gig::DimensionRegion* d) { dimreg = d; } |
77 |
|
78 |
protected: |
79 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
80 |
bool on_expose_event(GdkEventExpose* e); |
81 |
#else |
82 |
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); |
83 |
#endif |
84 |
|
85 |
private: |
86 |
gig::DimensionRegion* dimreg; |
87 |
void draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr, |
88 |
const gig::DimensionRegion* d, |
89 |
bool sensitive); |
90 |
}; |
91 |
|
92 |
class LFOGraph : public Gtk::DrawingArea { |
93 |
public: |
94 |
LFOGraph(); |
95 |
void set_dim_region(gig::DimensionRegion* d) { dimreg = d; } |
96 |
|
97 |
protected: |
98 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
99 |
bool on_expose_event(GdkEventExpose* e); |
100 |
#else |
101 |
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); |
102 |
#endif |
103 |
|
104 |
virtual LinuxSampler::LFO::wave_t waveType() const = 0; |
105 |
virtual float frequency() const = 0; |
106 |
virtual float phase() const = 0; |
107 |
virtual uint internalDepth() const = 0; |
108 |
virtual uint controllerDepth() const = 0; |
109 |
virtual bool flipPolarity() const = 0; |
110 |
virtual bool signedRange() const = 0; |
111 |
virtual LinuxSampler::LFO::start_level_t startLevel() const = 0; |
112 |
virtual bool hasControllerAssigned() const = 0; |
113 |
|
114 |
gig::DimensionRegion* dimreg; |
115 |
LinuxSampler::LFO lfo; |
116 |
}; |
117 |
|
118 |
class LFO1Graph : public LFOGraph { |
119 |
public: |
120 |
LinuxSampler::LFO::wave_t waveType() const OVERRIDE { |
121 |
// simply assuming here libgig's and LS's enums are equally value mapped |
122 |
return (LinuxSampler::LFO::wave_t) dimreg->LFO1WaveForm; |
123 |
} |
124 |
float frequency() const OVERRIDE { return dimreg->LFO1Frequency; } |
125 |
float phase() const OVERRIDE { return dimreg->LFO1Phase; } |
126 |
uint internalDepth() const OVERRIDE { |
127 |
const gig::lfo1_ctrl_t ctrl = dimreg->LFO1Controller; |
128 |
const bool hasInternalDepth = ( |
129 |
ctrl != gig::lfo1_ctrl_modwheel && ctrl != gig::lfo1_ctrl_breath |
130 |
); |
131 |
return (hasInternalDepth) ? dimreg->LFO1InternalDepth : 0; |
132 |
} |
133 |
uint controllerDepth() const OVERRIDE { return dimreg->LFO1ControlDepth; } |
134 |
bool flipPolarity() const OVERRIDE { return dimreg->LFO1FlipPhase; } |
135 |
bool signedRange() const OVERRIDE { return false; } |
136 |
virtual LinuxSampler::LFO::start_level_t startLevel() const OVERRIDE { return LinuxSampler::LFO::start_level_mid; } // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029 |
137 |
bool hasControllerAssigned() const OVERRIDE { return dimreg->LFO1Controller; } |
138 |
}; |
139 |
|
140 |
class LFO2Graph : public LFOGraph { |
141 |
public: |
142 |
LinuxSampler::LFO::wave_t waveType() const OVERRIDE { |
143 |
// simply assuming here libgig's and LS's enums are equally value mapped |
144 |
return (LinuxSampler::LFO::wave_t) dimreg->LFO2WaveForm; |
145 |
} |
146 |
float frequency() const OVERRIDE { return dimreg->LFO2Frequency; } |
147 |
float phase() const OVERRIDE { return dimreg->LFO2Phase; } |
148 |
uint internalDepth() const OVERRIDE { |
149 |
const gig::lfo2_ctrl_t ctrl = dimreg->LFO2Controller; |
150 |
const bool hasInternalDepth = ( |
151 |
ctrl != gig::lfo2_ctrl_modwheel && ctrl != gig::lfo2_ctrl_foot |
152 |
); |
153 |
return (hasInternalDepth) ? dimreg->LFO2InternalDepth : 0; |
154 |
} |
155 |
uint controllerDepth() const OVERRIDE { return dimreg->LFO2ControlDepth; } |
156 |
bool flipPolarity() const OVERRIDE { return dimreg->LFO2FlipPhase; } |
157 |
bool signedRange() const OVERRIDE { return false; } |
158 |
virtual LinuxSampler::LFO::start_level_t startLevel() const OVERRIDE { return LinuxSampler::LFO::start_level_mid; } // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029 |
159 |
bool hasControllerAssigned() const OVERRIDE { return dimreg->LFO2Controller; } |
160 |
}; |
161 |
|
162 |
class LFO3Graph : public LFOGraph { |
163 |
public: |
164 |
LinuxSampler::LFO::wave_t waveType() const OVERRIDE { |
165 |
// simply assuming here libgig's and LS's enums are equally value mapped |
166 |
return (LinuxSampler::LFO::wave_t) dimreg->LFO3WaveForm; |
167 |
} |
168 |
float frequency() const OVERRIDE { return dimreg->LFO3Frequency; } |
169 |
float phase() const OVERRIDE { return dimreg->LFO3Phase; } |
170 |
uint internalDepth() const OVERRIDE { |
171 |
const gig::lfo3_ctrl_t ctrl = dimreg->LFO3Controller; |
172 |
const bool hasInternalDepth = ( |
173 |
ctrl != gig::lfo3_ctrl_modwheel && ctrl != gig::lfo3_ctrl_aftertouch |
174 |
); |
175 |
return (hasInternalDepth) ? dimreg->LFO3InternalDepth : 0; |
176 |
} |
177 |
uint controllerDepth() const OVERRIDE { return dimreg->LFO3ControlDepth; } |
178 |
bool flipPolarity() const OVERRIDE { return dimreg->LFO3FlipPhase; } |
179 |
bool signedRange() const OVERRIDE { return true; } |
180 |
virtual LinuxSampler::LFO::start_level_t startLevel() const OVERRIDE { return LinuxSampler::LFO::start_level_max; } // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029 |
181 |
bool hasControllerAssigned() const OVERRIDE { return dimreg->LFO3Controller; } |
182 |
}; |
183 |
|
184 |
class EGStateOptions : public HBox { |
185 |
public: |
186 |
Gtk::Label label; |
187 |
BoolBox checkBoxAttack; |
188 |
BoolBox checkBoxAttackHold; |
189 |
BoolBox checkBoxDecay1; |
190 |
BoolBox checkBoxDecay2; |
191 |
BoolBox checkBoxRelease; |
192 |
|
193 |
EGStateOptions(); |
194 |
void on_show_tooltips_changed(); |
195 |
}; |
196 |
|
197 |
class DimRegionEdit : public Gtk::Notebook |
198 |
{ |
199 |
public: |
200 |
DimRegionEdit(); |
201 |
virtual ~DimRegionEdit(); |
202 |
void set_dim_region(gig::DimensionRegion* d); |
203 |
bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop); |
204 |
bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop); |
205 |
Gtk::Entry* wSample; |
206 |
Gtk::Button* buttonNullSampleReference; |
207 |
sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed(); |
208 |
sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed(); |
209 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed(); |
210 |
sigc::signal<void, gig::Sample*>& signal_select_sample(); |
211 |
|
212 |
std::set<gig::DimensionRegion*> dimregs; |
213 |
|
214 |
ScriptPatchVars scriptVars; |
215 |
Gtk::Button editScriptSlotsButton; |
216 |
|
217 |
protected: |
218 |
sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal; |
219 |
sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal; |
220 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal; |
221 |
sigc::signal<void> instrument_changed; |
222 |
sigc::signal<void, gig::Sample*> select_sample_signal; |
223 |
|
224 |
/** |
225 |
* Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and |
226 |
* DimRegionEdit::dimreg_changed_signal are always triggered correctly as a |
227 |
* pair. It behaves similar to a "mutex lock guard" design pattern. |
228 |
*/ |
229 |
class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> { |
230 |
public: |
231 |
DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) : |
232 |
SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg) |
233 |
{ |
234 |
} |
235 |
}; |
236 |
|
237 |
gig::DimensionRegion* dimregion; |
238 |
|
239 |
#ifdef OLD_TOOLTIPS |
240 |
Gtk::Tooltips tooltips; |
241 |
#endif |
242 |
|
243 |
static const int tableSize = 10; |
244 |
#if USE_GTKMM_GRID |
245 |
Gtk::Grid* table[tableSize]; |
246 |
#else |
247 |
Gtk::Table* table[tableSize]; |
248 |
#endif |
249 |
|
250 |
Gtk::Label* lSample; |
251 |
|
252 |
VelocityCurve velocity_curve; |
253 |
VelocityCurve release_curve; |
254 |
VelocityCurve cutoff_curve; |
255 |
CrossfadeCurve crossfade_curve; |
256 |
LFO1Graph lfo1Graph; ///< Graphic of Amplitude (Volume) LFO waveform. |
257 |
LFO2Graph lfo2Graph; ///< Graphic of Filter Cutoff LFO waveform. |
258 |
LFO3Graph lfo3Graph; ///< Graphic of Pitch LFO waveform. |
259 |
|
260 |
NumEntryPermille eEG1PreAttack; |
261 |
NumEntryTemp<double> eEG1Attack; |
262 |
NumEntryTemp<double> eEG1Decay1; |
263 |
NumEntryTemp<double> eEG1Decay2; |
264 |
BoolEntry eEG1InfiniteSustain; |
265 |
NumEntryPermille eEG1Sustain; |
266 |
NumEntryTemp<double> eEG1Release; |
267 |
BoolEntry eEG1Hold; |
268 |
ChoiceEntryLeverageCtrl eEG1Controller; |
269 |
BoolEntry eEG1ControllerInvert; |
270 |
NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence; |
271 |
NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence; |
272 |
NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence; |
273 |
EGStateOptions eEG1StateOptions; |
274 |
ChoiceEntryLfoWave eLFO1Wave; |
275 |
NumEntryTemp<double> eLFO1Frequency; |
276 |
NumEntryTemp<double> eLFO1Phase; |
277 |
NumEntryTemp<uint16_t> eLFO1InternalDepth; |
278 |
NumEntryTemp<uint16_t> eLFO1ControlDepth; |
279 |
ChoiceEntry<gig::lfo1_ctrl_t> eLFO1Controller; |
280 |
BoolEntry eLFO1FlipPhase; |
281 |
BoolEntry eLFO1Sync; |
282 |
NumEntryPermille eEG2PreAttack; |
283 |
NumEntryTemp<double> eEG2Attack; |
284 |
NumEntryTemp<double> eEG2Decay1; |
285 |
NumEntryTemp<double> eEG2Decay2; |
286 |
BoolEntry eEG2InfiniteSustain; |
287 |
NumEntryPermille eEG2Sustain; |
288 |
NumEntryTemp<double> eEG2Release; |
289 |
ChoiceEntryLeverageCtrl eEG2Controller; |
290 |
BoolEntry eEG2ControllerInvert; |
291 |
NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence; |
292 |
NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence; |
293 |
NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence; |
294 |
EGStateOptions eEG2StateOptions; |
295 |
ChoiceEntryLfoWave eLFO2Wave; |
296 |
NumEntryTemp<double> eLFO2Frequency; |
297 |
NumEntryTemp<double> eLFO2Phase; |
298 |
NumEntryTemp<uint16_t> eLFO2InternalDepth; |
299 |
NumEntryTemp<uint16_t> eLFO2ControlDepth; |
300 |
ChoiceEntry<gig::lfo2_ctrl_t> eLFO2Controller; |
301 |
BoolEntry eLFO2FlipPhase; |
302 |
BoolEntry eLFO2Sync; |
303 |
NumEntryTemp<double> eEG3Attack; |
304 |
NumEntryTemp<int16_t> eEG3Depth; |
305 |
ChoiceEntryLfoWave eLFO3Wave; |
306 |
NumEntryTemp<double> eLFO3Frequency; |
307 |
NumEntryTemp<double> eLFO3Phase; |
308 |
NumEntryTemp<int16_t> eLFO3InternalDepth; |
309 |
NumEntryTemp<int16_t> eLFO3ControlDepth; |
310 |
ChoiceEntry<gig::lfo3_ctrl_t> eLFO3Controller; |
311 |
BoolEntry eLFO3FlipPhase; |
312 |
BoolEntry eLFO3Sync; |
313 |
BoolEntry eVCFEnabled; |
314 |
ChoiceEntry<gig::vcf_type_t> eVCFType; |
315 |
ChoiceEntry<gig::vcf_cutoff_ctrl_t> eVCFCutoffController; |
316 |
BoolEntry eVCFCutoffControllerInvert; |
317 |
NumEntryTemp<uint8_t> eVCFCutoff; |
318 |
ChoiceEntry<gig::curve_type_t> eVCFVelocityCurve; |
319 |
NumEntryTemp<uint8_t> eVCFVelocityScale; |
320 |
NumEntryTemp<uint8_t> eVCFVelocityDynamicRange; |
321 |
NumEntryTemp<uint8_t> eVCFResonance; |
322 |
BoolEntry eVCFResonanceDynamic; |
323 |
ChoiceEntry<gig::vcf_res_ctrl_t> eVCFResonanceController; |
324 |
BoolEntry eVCFKeyboardTracking; |
325 |
NumEntryTemp<uint8_t> eVCFKeyboardTrackingBreakpoint; |
326 |
ChoiceEntry<gig::curve_type_t> eVelocityResponseCurve; |
327 |
NumEntryTemp<uint8_t> eVelocityResponseDepth; |
328 |
NumEntryTemp<uint8_t> eVelocityResponseCurveScaling; |
329 |
ChoiceEntry<gig::curve_type_t> eReleaseVelocityResponseCurve; |
330 |
NumEntryTemp<uint8_t> eReleaseVelocityResponseDepth; |
331 |
NumEntryTemp<uint8_t> eReleaseTriggerDecay; |
332 |
NumEntryTemp<uint8_t> eCrossfade_in_start; |
333 |
NumEntryTemp<uint8_t> eCrossfade_in_end; |
334 |
NumEntryTemp<uint8_t> eCrossfade_out_start; |
335 |
NumEntryTemp<uint8_t> eCrossfade_out_end; |
336 |
BoolEntry ePitchTrack; |
337 |
ChoiceEntry<gig::sust_rel_trg_t> eSustainReleaseTrigger; |
338 |
BoolEntry eNoNoteOffReleaseTrigger; |
339 |
ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass; |
340 |
NumEntryTemp<int8_t> ePan; |
341 |
BoolEntry eSelfMask; |
342 |
ChoiceEntryLeverageCtrl eAttenuationController; |
343 |
BoolEntry eInvertAttenuationController; |
344 |
NumEntryTemp<uint8_t> eAttenuationControllerThreshold; |
345 |
NumEntryTemp<uint8_t> eChannelOffset; |
346 |
BoolEntry eSustainDefeat; |
347 |
BoolEntry eMSDecode; |
348 |
NumEntryTemp<uint16_t> eSampleStartOffset; |
349 |
NoteEntry eUnityNote; |
350 |
ReadOnlyLabelWidget eSampleGroup; |
351 |
ReadOnlyLabelWidget eSampleFormatInfo; |
352 |
ReadOnlyLabelWidget eSampleID; |
353 |
ReadOnlyLabelWidget eChecksum; |
354 |
NumEntryTemp<int16_t> eFineTune; |
355 |
NumEntryGain eGain; |
356 |
BoolEntry eSampleLoopEnabled; |
357 |
NumEntryTemp<uint32_t> eSampleLoopStart; |
358 |
NumEntryTemp<uint32_t> eSampleLoopLength; |
359 |
ChoiceEntry<uint32_t> eSampleLoopType; |
360 |
BoolEntry eSampleLoopInfinite; |
361 |
NumEntryTemp<uint32_t> eSampleLoopPlayCount; |
362 |
Gtk::Label* lEG2; |
363 |
Gtk::Label* lLFO2; |
364 |
|
365 |
Gtk::Button buttonSelectSample; |
366 |
|
367 |
Gtk::HBox scriptVarsDescrBox; |
368 |
#if GTKMM_MAJOR_VERSION < 3 |
369 |
view::WrapLabel m_labelPatchVarsDescr; |
370 |
#else |
371 |
MultiLineLabel m_labelPatchVarsDescr; |
372 |
#endif |
373 |
|
374 |
int rowno; |
375 |
int pageno; |
376 |
int firstRowInBlock; |
377 |
|
378 |
|
379 |
void addProp(BoolEntry& boolentry); |
380 |
void addProp(LabelWidget& labelwidget); |
381 |
void addLine(HBox& line); |
382 |
void addString(const char* labelText, Gtk::Label*& label, |
383 |
Gtk::Entry*& widget); |
384 |
void addString(const char* labelText, Gtk::Label*& label, |
385 |
Gtk::Entry*& widget, Gtk::Button*& button); |
386 |
Gtk::Label* addHeader(const char* text); |
387 |
void addRightHandSide(Gtk::Widget& widget); |
388 |
void nextPage(); |
389 |
|
390 |
void VCFEnabled_toggled(); |
391 |
void VCFCutoffController_changed(); |
392 |
void VCFResonanceController_changed(); |
393 |
void EG1InfiniteSustain_toggled(); |
394 |
void EG2InfiniteSustain_toggled(); |
395 |
void EG1Controller_changed(); |
396 |
void EG2Controller_changed(); |
397 |
void AttenuationController_changed(); |
398 |
void LFO1Controller_changed(); |
399 |
void LFO2Controller_changed(); |
400 |
void LFO3Controller_changed(); |
401 |
void crossfade1_changed(); |
402 |
void crossfade2_changed(); |
403 |
void crossfade3_changed(); |
404 |
void crossfade4_changed(); |
405 |
void update_loop_elements(); |
406 |
void loop_start_changed(); |
407 |
void loop_length_changed(); |
408 |
void loop_infinite_toggled(); |
409 |
void nullOutSampleReference(); |
410 |
void on_show_tooltips_changed(); |
411 |
|
412 |
int update_model; |
413 |
|
414 |
// connect a widget to a setter function in DimRegionEdit |
415 |
template<typename C, typename T> |
416 |
void connect(C& widget, |
417 |
void (DimRegionEdit::*setter)(gig::DimensionRegion&, T)) { |
418 |
connect<C, T>(widget, |
419 |
sigc::mem_fun(setter)); |
420 |
} |
421 |
|
422 |
// connect a widget to a member variable in gig::DimensionRegion |
423 |
template<typename C, typename T> |
424 |
void connect(C& widget, T gig::DimensionRegion::* member) { |
425 |
connect<C, T>(widget, |
426 |
sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member)); |
427 |
} |
428 |
|
429 |
// connect a widget to a member of a struct member in gig::DimensionRegion |
430 |
template<typename C, typename T, typename S> |
431 |
void connect(C& widget, S gig::DimensionRegion::* member, T S::* member2) { |
432 |
connect<C, T>(widget, |
433 |
sigc::bind(sigc::mem_fun(&DimRegionEdit::set_sub_member<T, S>), member, member2)); |
434 |
} |
435 |
|
436 |
// connect a widget to a setter function in gig::DimensionRegion |
437 |
template<typename C, typename T> |
438 |
void connect(C& widget, |
439 |
void (gig::DimensionRegion::*setter)(T)) { |
440 |
connect<C, T>(widget, |
441 |
sigc::hide<0>(sigc::mem_fun(setter))); |
442 |
} |
443 |
|
444 |
// helper function for the connect functions above |
445 |
template<typename C, typename T> |
446 |
void connect(C& widget, |
447 |
sigc::slot<void, DimRegionEdit&, gig::DimensionRegion&, T> setter) { |
448 |
widget.signal_value_changed().connect( |
449 |
sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter), |
450 |
sigc::mem_fun(widget, &C::get_value))); |
451 |
} |
452 |
|
453 |
// loop through all dimregions being edited and set a value in |
454 |
// each of them |
455 |
template<typename T> |
456 |
void set_many(T value, |
457 |
sigc::slot<void, DimRegionEdit&, gig::DimensionRegion&, T> setter) { |
458 |
if (update_model == 0) { |
459 |
for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ; |
460 |
i != dimregs.end() ; ++i) |
461 |
{ |
462 |
DimRegionChangeGuard(this, *i); |
463 |
setter(*this, **i, value); |
464 |
} |
465 |
} |
466 |
} |
467 |
|
468 |
// set a value of a member variable in the given dimregion |
469 |
template<typename T> |
470 |
void set_member(gig::DimensionRegion& d, T value, |
471 |
T gig::DimensionRegion::* member) { |
472 |
d.*member = value; |
473 |
} |
474 |
|
475 |
// set a value of a member of a struct member variable in the given dimregion |
476 |
template<typename T, typename S> |
477 |
void set_sub_member(gig::DimensionRegion& d, T value, |
478 |
S gig::DimensionRegion::* member, T S::* member2) { |
479 |
d.*member.*member2 = value; |
480 |
} |
481 |
|
482 |
// setters for specific dimregion parameters |
483 |
|
484 |
void set_UnityNote(gig::DimensionRegion& d, uint8_t value); |
485 |
void set_FineTune(gig::DimensionRegion& d, int16_t value); |
486 |
void set_Crossfade_in_start(gig::DimensionRegion& d, uint8_t value); |
487 |
void set_Crossfade_in_end(gig::DimensionRegion& d, uint8_t value); |
488 |
void set_Crossfade_out_start(gig::DimensionRegion& d, uint8_t value); |
489 |
void set_Crossfade_out_end(gig::DimensionRegion& d, uint8_t value); |
490 |
void set_Gain(gig::DimensionRegion& d, int32_t value); |
491 |
void set_LoopEnabled(gig::DimensionRegion& d, bool value); |
492 |
void set_LoopType(gig::DimensionRegion& d, uint32_t value); |
493 |
void set_LoopStart(gig::DimensionRegion& d, uint32_t value); |
494 |
void set_LoopLength(gig::DimensionRegion& d, uint32_t value); |
495 |
void set_LoopInfinite(gig::DimensionRegion& d, bool value); |
496 |
void set_LoopPlayCount(gig::DimensionRegion& d, uint32_t value); |
497 |
|
498 |
void onButtonSelectSamplePressed(); |
499 |
}; |
500 |
|
501 |
#endif |