1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006, 2007 Andreas Persson |
* Copyright (C) 2006-2015 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
22 |
|
|
23 |
#include <gig.h> |
#include <gig.h> |
24 |
|
|
25 |
|
#include <cairomm/context.h> |
26 |
|
#include <gtkmm/box.h> |
27 |
|
#include <gtkmm/drawingarea.h> |
28 |
#include <gtkmm/entry.h> |
#include <gtkmm/entry.h> |
29 |
#include <gtkmm/label.h> |
#include <gtkmm/label.h> |
30 |
#include <gtkmm/notebook.h> |
#include <gtkmm/notebook.h> |
31 |
#include <gtkmm/table.h> |
#include <gtkmm/table.h> |
32 |
#include <gtkmm/tooltips.h> |
|
33 |
|
#include <set> |
34 |
|
|
35 |
#include "paramedit.h" |
#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 |
class DimRegionEdit : public Gtk::Notebook |
74 |
{ |
{ |
75 |
public: |
public: |
76 |
DimRegionEdit(); |
DimRegionEdit(); |
77 |
virtual ~DimRegionEdit(); |
virtual ~DimRegionEdit(); |
78 |
void set_dim_region(gig::DimensionRegion* d); |
void set_dim_region(gig::DimensionRegion* d); |
79 |
bool set_sample(gig::Sample* sample); |
bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop); |
80 |
|
bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop); |
81 |
Gtk::Entry* wSample; |
Gtk::Entry* wSample; |
82 |
|
Gtk::Button* buttonNullSampleReference; |
83 |
sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed(); |
sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed(); |
84 |
sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed(); |
sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed(); |
85 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed(); |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed(); |
86 |
|
sigc::signal<void, gig::Sample*>& signal_select_sample(); |
87 |
|
|
88 |
|
std::set<gig::DimensionRegion*> dimregs; |
89 |
|
|
90 |
protected: |
protected: |
91 |
sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal; |
sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal; |
92 |
sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal; |
sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal; |
93 |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal; |
sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal; |
94 |
sigc::signal<void> instrument_changed; |
sigc::signal<void> instrument_changed; |
95 |
|
sigc::signal<void, gig::Sample*> select_sample_signal; |
96 |
|
|
97 |
gig::DimensionRegion* dimregion; |
gig::DimensionRegion* dimregion; |
98 |
|
|
99 |
|
#ifdef OLD_TOOLTIPS |
100 |
Gtk::Tooltips tooltips; |
Gtk::Tooltips tooltips; |
101 |
|
#endif |
102 |
|
|
103 |
Gtk::Table* table[7]; |
Gtk::Table* table[7]; |
104 |
|
|
105 |
Gtk::Label* lSample; |
Gtk::Label* lSample; |
106 |
|
|
107 |
|
VelocityCurve velocity_curve; |
108 |
|
VelocityCurve release_curve; |
109 |
|
VelocityCurve cutoff_curve; |
110 |
|
CrossfadeCurve crossfade_curve; |
111 |
|
|
112 |
NumEntryPermille eEG1PreAttack; |
NumEntryPermille eEG1PreAttack; |
113 |
NumEntryTemp<double> eEG1Attack; |
NumEntryTemp<double> eEG1Attack; |
114 |
NumEntryTemp<double> eEG1Decay1; |
NumEntryTemp<double> eEG1Decay1; |
188 |
BoolEntry eMSDecode; |
BoolEntry eMSDecode; |
189 |
NumEntryTemp<uint16_t> eSampleStartOffset; |
NumEntryTemp<uint16_t> eSampleStartOffset; |
190 |
NoteEntry eUnityNote; |
NoteEntry eUnityNote; |
191 |
|
ReadOnlyLabelWidget eSampleGroup; |
192 |
|
ReadOnlyLabelWidget eSampleFormatInfo; |
193 |
|
ReadOnlyLabelWidget eSampleID; |
194 |
|
ReadOnlyLabelWidget eChecksum; |
195 |
NumEntryTemp<int16_t> eFineTune; |
NumEntryTemp<int16_t> eFineTune; |
196 |
NumEntryGain eGain; |
NumEntryGain eGain; |
197 |
BoolEntryPlus6 eGainPlus6; |
BoolEntryPlus6 eGainPlus6; |
201 |
ChoiceEntry<uint32_t> eSampleLoopType; |
ChoiceEntry<uint32_t> eSampleLoopType; |
202 |
BoolEntry eSampleLoopInfinite; |
BoolEntry eSampleLoopInfinite; |
203 |
NumEntryTemp<uint32_t> eSampleLoopPlayCount; |
NumEntryTemp<uint32_t> eSampleLoopPlayCount; |
204 |
|
Gtk::Label* lEG2; |
205 |
|
Gtk::Label* lLFO2; |
206 |
|
|
207 |
sigc::connection connection_eVCFCutoffController; |
Gtk::Button buttonSelectSample; |
|
sigc::connection connection_eVCFVelocityCurve; |
|
|
sigc::connection connection_eVCFVelocityScale; |
|
|
sigc::connection connection_eVCFVelocityDynamicRange; |
|
|
sigc::connection connection_eVelocityResponseCurve; |
|
|
sigc::connection connection_eVelocityResponseDepth; |
|
|
sigc::connection connection_eVelocityResponseCurveScaling; |
|
|
sigc::connection connection_eReleaseVelocityResponseCurve; |
|
|
sigc::connection connection_eReleaseVelocityResponseDepth; |
|
|
sigc::connection connection_eGain; |
|
208 |
|
|
209 |
int rowno; |
int rowno; |
210 |
int pageno; |
int pageno; |
216 |
void addProp(LabelWidget& labelwidget); |
void addProp(LabelWidget& labelwidget); |
217 |
void addString(const char* labelText, Gtk::Label*& label, |
void addString(const char* labelText, Gtk::Label*& label, |
218 |
Gtk::Entry*& widget); |
Gtk::Entry*& widget); |
219 |
void addHeader(const char* text); |
void addString(const char* labelText, Gtk::Label*& label, |
220 |
|
Gtk::Entry*& widget, Gtk::Button*& button); |
221 |
|
Gtk::Label* addHeader(const char* text); |
222 |
|
void addRightHandSide(Gtk::Widget& widget); |
223 |
void nextPage(); |
void nextPage(); |
224 |
|
|
225 |
void VCFEnabled_toggled(); |
void VCFEnabled_toggled(); |
237 |
void crossfade2_changed(); |
void crossfade2_changed(); |
238 |
void crossfade3_changed(); |
void crossfade3_changed(); |
239 |
void crossfade4_changed(); |
void crossfade4_changed(); |
240 |
void loop_enabled_toggled(); |
void update_loop_elements(); |
241 |
|
void loop_start_changed(); |
242 |
|
void loop_length_changed(); |
243 |
void loop_infinite_toggled(); |
void loop_infinite_toggled(); |
244 |
|
void nullOutSampleReference(); |
245 |
|
|
246 |
|
int update_model; |
247 |
|
|
248 |
|
// connect a widget to a setter function in DimRegionEdit |
249 |
|
template<typename C, typename T> |
250 |
|
void connect(C& widget, |
251 |
|
void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) { |
252 |
|
connect<C, T>(widget, |
253 |
|
sigc::mem_fun(setter)); |
254 |
|
} |
255 |
|
|
256 |
|
// connect a widget to a member variable in gig::DimensionRegion |
257 |
|
template<typename C, typename T> |
258 |
|
void connect(C& widget, T gig::DimensionRegion::* member) { |
259 |
|
connect<C, T>(widget, |
260 |
|
sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member)); |
261 |
|
} |
262 |
|
|
263 |
|
// connect a widget to a setter function in gig::DimensionRegion |
264 |
|
template<typename C, typename T> |
265 |
|
void connect(C& widget, |
266 |
|
void (gig::DimensionRegion::*setter)(T)) { |
267 |
|
connect<C, T>(widget, |
268 |
|
sigc::hide<0>(sigc::mem_fun(setter))); |
269 |
|
} |
270 |
|
|
271 |
|
// helper function for the connect functions above |
272 |
|
template<typename C, typename T> |
273 |
|
void connect(C& widget, |
274 |
|
sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) { |
275 |
|
widget.signal_value_changed().connect( |
276 |
|
sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter), |
277 |
|
sigc::mem_fun(widget, &C::get_value))); |
278 |
|
} |
279 |
|
|
280 |
|
// loop through all dimregions being edited and set a value in |
281 |
|
// each of them |
282 |
|
template<typename T> |
283 |
|
void set_many(T value, |
284 |
|
sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) { |
285 |
|
if (update_model == 0) { |
286 |
|
for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ; |
287 |
|
i != dimregs.end() ; ++i) |
288 |
|
{ |
289 |
|
dimreg_changed_signal(*i); |
290 |
|
setter(this, *i, value); |
291 |
|
} |
292 |
|
} |
293 |
|
} |
294 |
|
|
295 |
|
// set a value of a member variable in the given dimregion |
296 |
|
template<typename T> |
297 |
|
void set_member(gig::DimensionRegion* d, T value, |
298 |
|
T gig::DimensionRegion::* member) { |
299 |
|
d->*member = value; |
300 |
|
} |
301 |
|
|
302 |
|
// setters for specific dimregion parameters |
303 |
|
|
304 |
|
void set_UnityNote(gig::DimensionRegion* d, uint8_t value); |
305 |
|
void set_FineTune(gig::DimensionRegion* d, int16_t value); |
306 |
|
void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value); |
307 |
|
void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value); |
308 |
|
void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value); |
309 |
|
void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value); |
310 |
|
void set_Gain(gig::DimensionRegion* d, int32_t value); |
311 |
|
void set_LoopEnabled(gig::DimensionRegion* d, bool value); |
312 |
|
void set_LoopType(gig::DimensionRegion* d, uint32_t value); |
313 |
|
void set_LoopStart(gig::DimensionRegion* d, uint32_t value); |
314 |
|
void set_LoopLength(gig::DimensionRegion* d, uint32_t value); |
315 |
|
void set_LoopInfinite(gig::DimensionRegion* d, bool value); |
316 |
|
void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value); |
317 |
|
|
318 |
void updateLoopElements(); |
void onButtonSelectSamplePressed(); |
319 |
}; |
}; |
320 |
|
|
321 |
#endif |
#endif |