/[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 2691 - (show annotations) (download) (as text)
Sun Jan 4 19:46:54 2015 UTC (9 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 11471 byte(s)
* Dimension Region Editor: Added button "Select Sample" on the sample tab,
  which allows to conveniently select the dimension region's sample on the
  left hand side's samples tree view.

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

  ViewVC Help
Powered by ViewVC