/[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 2720 - (show annotations) (download) (as text)
Sun Mar 1 15:43:42 2015 UTC (9 years, 1 month ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 11675 byte(s)
* Added "X" button next to sample reference field, which allows to remove
  the current sample reference, allowing to create a "silent case" where
  no sample shall be played.

1 /* -*- c++ -*-
2 * Copyright (C) 2006-2015 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 #include <gig.h>
24
25 #include <cairomm/context.h>
26 #include <gtkmm/drawingarea.h>
27 #include <gtkmm/entry.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/notebook.h>
30 #include <gtkmm/table.h>
31
32 #include <set>
33
34 #include "paramedit.h"
35
36 class VelocityCurve : public Gtk::DrawingArea {
37 public:
38 VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t));
39 void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
40
41 protected:
42 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
43 bool on_expose_event(GdkEventExpose* e);
44 #else
45 bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
46 #endif
47
48 private:
49 double (gig::DimensionRegion::* const getter)(uint8_t);
50 gig::DimensionRegion* dimreg;
51 };
52
53 class CrossfadeCurve : public Gtk::DrawingArea {
54 public:
55 CrossfadeCurve();
56 void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
57
58 protected:
59 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
60 bool on_expose_event(GdkEventExpose* e);
61 #else
62 bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
63 #endif
64
65 private:
66 gig::DimensionRegion* dimreg;
67 void draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
68 const gig::DimensionRegion* d,
69 bool sensitive);
70 };
71
72 class DimRegionEdit : public Gtk::Notebook
73 {
74 public:
75 DimRegionEdit();
76 virtual ~DimRegionEdit();
77 void set_dim_region(gig::DimensionRegion* d);
78 bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
79 Gtk::Entry* wSample;
80 Gtk::Button* buttonNullSampleReference;
81 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
82 sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
83 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
84 sigc::signal<void, gig::Sample*>& signal_select_sample();
85
86 std::set<gig::DimensionRegion*> dimregs;
87
88 protected:
89 sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
90 sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
91 sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
92 sigc::signal<void> instrument_changed;
93 sigc::signal<void, gig::Sample*> select_sample_signal;
94
95 gig::DimensionRegion* dimregion;
96
97 #ifdef OLD_TOOLTIPS
98 Gtk::Tooltips tooltips;
99 #endif
100
101 Gtk::Table* table[7];
102
103 Gtk::Label* lSample;
104
105 VelocityCurve velocity_curve;
106 VelocityCurve release_curve;
107 VelocityCurve cutoff_curve;
108 CrossfadeCurve crossfade_curve;
109
110 NumEntryPermille eEG1PreAttack;
111 NumEntryTemp<double> eEG1Attack;
112 NumEntryTemp<double> eEG1Decay1;
113 NumEntryTemp<double> eEG1Decay2;
114 BoolEntry eEG1InfiniteSustain;
115 NumEntryPermille eEG1Sustain;
116 NumEntryTemp<double> eEG1Release;
117 BoolEntry eEG1Hold;
118 ChoiceEntryLeverageCtrl eEG1Controller;
119 BoolEntry eEG1ControllerInvert;
120 NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
121 NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
122 NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
123 NumEntryTemp<double> eLFO1Frequency;
124 NumEntryTemp<uint16_t> eLFO1InternalDepth;
125 NumEntryTemp<uint16_t> eLFO1ControlDepth;
126 ChoiceEntry<gig::lfo1_ctrl_t> eLFO1Controller;
127 BoolEntry eLFO1FlipPhase;
128 BoolEntry eLFO1Sync;
129 NumEntryPermille eEG2PreAttack;
130 NumEntryTemp<double> eEG2Attack;
131 NumEntryTemp<double> eEG2Decay1;
132 NumEntryTemp<double> eEG2Decay2;
133 BoolEntry eEG2InfiniteSustain;
134 NumEntryPermille eEG2Sustain;
135 NumEntryTemp<double> eEG2Release;
136 ChoiceEntryLeverageCtrl eEG2Controller;
137 BoolEntry eEG2ControllerInvert;
138 NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
139 NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
140 NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
141 NumEntryTemp<double> eLFO2Frequency;
142 NumEntryTemp<uint16_t> eLFO2InternalDepth;
143 NumEntryTemp<uint16_t> eLFO2ControlDepth;
144 ChoiceEntry<gig::lfo2_ctrl_t> eLFO2Controller;
145 BoolEntry eLFO2FlipPhase;
146 BoolEntry eLFO2Sync;
147 NumEntryTemp<double> eEG3Attack;
148 NumEntryTemp<int16_t> eEG3Depth;
149 NumEntryTemp<double> eLFO3Frequency;
150 NumEntryTemp<int16_t> eLFO3InternalDepth;
151 NumEntryTemp<int16_t> eLFO3ControlDepth;
152 ChoiceEntry<gig::lfo3_ctrl_t> eLFO3Controller;
153 BoolEntry eLFO3Sync;
154 BoolEntry eVCFEnabled;
155 ChoiceEntry<gig::vcf_type_t> eVCFType;
156 ChoiceEntry<gig::vcf_cutoff_ctrl_t> eVCFCutoffController;
157 BoolEntry eVCFCutoffControllerInvert;
158 NumEntryTemp<uint8_t> eVCFCutoff;
159 ChoiceEntry<gig::curve_type_t> eVCFVelocityCurve;
160 NumEntryTemp<uint8_t> eVCFVelocityScale;
161 NumEntryTemp<uint8_t> eVCFVelocityDynamicRange;
162 NumEntryTemp<uint8_t> eVCFResonance;
163 BoolEntry eVCFResonanceDynamic;
164 ChoiceEntry<gig::vcf_res_ctrl_t> eVCFResonanceController;
165 BoolEntry eVCFKeyboardTracking;
166 NumEntryTemp<uint8_t> eVCFKeyboardTrackingBreakpoint;
167 ChoiceEntry<gig::curve_type_t> eVelocityResponseCurve;
168 NumEntryTemp<uint8_t> eVelocityResponseDepth;
169 NumEntryTemp<uint8_t> eVelocityResponseCurveScaling;
170 ChoiceEntry<gig::curve_type_t> eReleaseVelocityResponseCurve;
171 NumEntryTemp<uint8_t> eReleaseVelocityResponseDepth;
172 NumEntryTemp<uint8_t> eReleaseTriggerDecay;
173 NumEntryTemp<uint8_t> eCrossfade_in_start;
174 NumEntryTemp<uint8_t> eCrossfade_in_end;
175 NumEntryTemp<uint8_t> eCrossfade_out_start;
176 NumEntryTemp<uint8_t> eCrossfade_out_end;
177 BoolEntry ePitchTrack;
178 ChoiceEntry<gig::dim_bypass_ctrl_t> eDimensionBypass;
179 NumEntryTemp<int8_t> ePan;
180 BoolEntry eSelfMask;
181 ChoiceEntryLeverageCtrl eAttenuationController;
182 BoolEntry eInvertAttenuationController;
183 NumEntryTemp<uint8_t> eAttenuationControllerThreshold;
184 NumEntryTemp<uint8_t> eChannelOffset;
185 BoolEntry eSustainDefeat;
186 BoolEntry eMSDecode;
187 NumEntryTemp<uint16_t> eSampleStartOffset;
188 NoteEntry eUnityNote;
189 ReadOnlyLabelWidget eSampleFormatInfo;
190 ReadOnlyLabelWidget eSampleID;
191 NumEntryTemp<int16_t> eFineTune;
192 NumEntryGain eGain;
193 BoolEntryPlus6 eGainPlus6;
194 BoolEntry eSampleLoopEnabled;
195 NumEntryTemp<uint32_t> eSampleLoopStart;
196 NumEntryTemp<uint32_t> eSampleLoopLength;
197 ChoiceEntry<uint32_t> eSampleLoopType;
198 BoolEntry eSampleLoopInfinite;
199 NumEntryTemp<uint32_t> eSampleLoopPlayCount;
200 Gtk::Label* lEG2;
201 Gtk::Label* lLFO2;
202
203 Gtk::Button buttonSelectSample;
204
205 int rowno;
206 int pageno;
207 int firstRowInBlock;
208
209
210 void addProp(BoolEntry& boolentry);
211 void addProp(BoolEntryPlus6& boolentry);
212 void addProp(LabelWidget& labelwidget);
213 void addString(const char* labelText, Gtk::Label*& label,
214 Gtk::Entry*& widget);
215 void addString(const char* labelText, Gtk::Label*& label,
216 Gtk::Entry*& widget, Gtk::Button*& button);
217 Gtk::Label* addHeader(const char* text);
218 void addRightHandSide(Gtk::Widget& widget);
219 void nextPage();
220
221 void VCFEnabled_toggled();
222 void VCFCutoffController_changed();
223 void VCFResonanceController_changed();
224 void EG1InfiniteSustain_toggled();
225 void EG2InfiniteSustain_toggled();
226 void EG1Controller_changed();
227 void EG2Controller_changed();
228 void AttenuationController_changed();
229 void LFO1Controller_changed();
230 void LFO2Controller_changed();
231 void LFO3Controller_changed();
232 void crossfade1_changed();
233 void crossfade2_changed();
234 void crossfade3_changed();
235 void crossfade4_changed();
236 void update_loop_elements();
237 void loop_start_changed();
238 void loop_length_changed();
239 void loop_infinite_toggled();
240 void nullOutSampleReference();
241
242 int update_model;
243
244 // connect a widget to a setter function in DimRegionEdit
245 template<typename C, typename T>
246 void connect(C& widget,
247 void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
248 connect<C, T>(widget,
249 sigc::mem_fun(setter));
250 }
251
252 // connect a widget to a member variable in gig::DimensionRegion
253 template<typename C, typename T>
254 void connect(C& widget, T gig::DimensionRegion::* member) {
255 connect<C, T>(widget,
256 sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
257 }
258
259 // connect a widget to a setter function in gig::DimensionRegion
260 template<typename C, typename T>
261 void connect(C& widget,
262 void (gig::DimensionRegion::*setter)(T)) {
263 connect<C, T>(widget,
264 sigc::hide<0>(sigc::mem_fun(setter)));
265 }
266
267 // helper function for the connect functions above
268 template<typename C, typename T>
269 void connect(C& widget,
270 sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
271 widget.signal_value_changed().connect(
272 sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
273 sigc::mem_fun(widget, &C::get_value)));
274 }
275
276 // loop through all dimregions being edited ant set a value in
277 // each of them
278 template<typename T>
279 void set_many(T value,
280 sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
281 if (update_model == 0) {
282 for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
283 i != dimregs.end() ; i++)
284 {
285 dimreg_changed_signal(*i);
286 setter(this, *i, value);
287 }
288 }
289 }
290
291 // set a value of a member variable in the given dimregion
292 template<typename T>
293 void set_member(gig::DimensionRegion* d, T value,
294 T gig::DimensionRegion::* member) {
295 d->*member = value;
296 }
297
298 // setters for specific dimregion parameters
299
300 void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
301 void set_FineTune(gig::DimensionRegion* d, int16_t value);
302 void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
303 void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
304 void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
305 void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
306 void set_Gain(gig::DimensionRegion* d, int32_t value);
307 void set_LoopEnabled(gig::DimensionRegion* d, bool value);
308 void set_LoopType(gig::DimensionRegion* d, uint32_t value);
309 void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
310 void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
311 void set_LoopInfinite(gig::DimensionRegion* d, bool value);
312 void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
313
314 void onButtonSelectSamplePressed();
315 };
316
317 #endif

  ViewVC Help
Powered by ViewVC