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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3461 - (show annotations) (download) (as text)
Sat Feb 2 17:53:36 2019 UTC (2 years, 7 months ago) by persson
File MIME type: text/x-c++hdr
File size: 13884 byte(s)
* Avoid deprecated sigc++ usage

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

  ViewVC Help
Powered by ViewVC