/[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 2844 - (show annotations) (download) (as text)
Sun Sep 20 08:49:40 2015 UTC (8 years, 6 months ago) by persson
File MIME type: text/x-c++hdr
File size: 11698 byte(s)
* allow building with gtkmm 2 and G/GDK/GTK_DISABLE_DEPRECATED

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

  ViewVC Help
Powered by ViewVC