1 |
/* |
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 |
#include "global.h" |
21 |
#include "paramedit.h" |
22 |
|
23 |
#include "compat.h" |
24 |
#include "Settings.h" |
25 |
|
26 |
#ifdef GLIBMM_HEADER_FILE |
27 |
# include GLIBMM_HEADER_FILE(glibmm.h) |
28 |
#else |
29 |
# include <glibmm.h> |
30 |
#endif |
31 |
|
32 |
#include <gtkmm/messagedialog.h> |
33 |
|
34 |
namespace { |
35 |
struct CCText { |
36 |
const char* const txt; |
37 |
bool isExtension; ///< True if this is a controller only supported by LinuxSampler, but not supperted by Gigasampler/GigaStudio. |
38 |
}; |
39 |
static const CCText controlChangeTexts[] = { |
40 |
// 3 special ones (not being CCs) |
41 |
{ _("none") }, { _("channelaftertouch") }, { _("velocity") }, |
42 |
{0}, // bank select MSB (hard coded in sampler, so discouraged to be used here, even though considerable) |
43 |
{ _("modwheel") }, // "Modulation Wheel or Lever", |
44 |
{ _("breath") }, // "Breath Controller", |
45 |
{ _("undefined"), true }, |
46 |
{ _("foot") }, // "Foot Controller", |
47 |
{ _("portamentotime") }, // "Portamento Time", |
48 |
{ _("data entry MSB"), true }, |
49 |
{ _("volume"), true }, |
50 |
{ _("balance"), true }, |
51 |
{ _("undefined"), true }, |
52 |
{ _("pan"), true }, |
53 |
{ _("expression"), true }, |
54 |
{ _("effect1") }, // "Effect Control 1", |
55 |
{ _("effect2") }, // "Effect Control 2", |
56 |
{ _("undefined"), true }, |
57 |
{ _("undefined"), true }, |
58 |
{ _("genpurpose1") }, // "General Purpose Controller 1", |
59 |
{ _("genpurpose2") }, // "General Purpose Controller 2", |
60 |
{ _("genpurpose3") }, // "General Purpose Controller 3", |
61 |
{ _("genpurpose4") }, // "General Purpose Controller 4", |
62 |
{ _("undefined"), true }, |
63 |
{ _("undefined"), true }, |
64 |
{ _("undefined"), true }, |
65 |
{ _("undefined"), true }, |
66 |
{ _("undefined"), true }, |
67 |
{ _("undefined"), true }, |
68 |
{ _("undefined"), true }, |
69 |
{ _("undefined"), true }, |
70 |
{ _("undefined"), true }, |
71 |
{ _("undefined"), true }, |
72 |
{ _("undefined"), true }, |
73 |
{ _("undefined"), true }, |
74 |
|
75 |
// LSB variant of the various controllers above |
76 |
// (so discouraged to be used here for now) |
77 |
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, |
78 |
{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, |
79 |
{0}, {0}, {0}, {0}, |
80 |
|
81 |
{ _("sustainpedal") }, // "Damper Pedal on/off (Sustain)", |
82 |
{ _("portamento") }, // "Portamento On/Off", |
83 |
{ _("sostenuto") }, // "Sustenuto On/Off", |
84 |
{ _("softpedal") }, // "Soft Pedal On/Off", |
85 |
{ _("legato"), true }, |
86 |
{ _("hold2"), true }, |
87 |
{ _("soundvariation"), true }, |
88 |
{ _("timbre"), true }, |
89 |
{ _("releasetime"), true }, |
90 |
{ _("attacktime"), true }, |
91 |
{ _("brightness"), true }, |
92 |
{ _("decaytime"), true }, |
93 |
{ _("vibratorate"), true }, |
94 |
{ _("vibratodepth"), true }, |
95 |
{ _("vibratodelay"), true }, |
96 |
{ _("undefined"), true }, |
97 |
{ _("genpurpose5") }, // "General Purpose Controller 5", |
98 |
{ _("genpurpose6") }, // "General Purpose Controller 6", |
99 |
{ _("genpurpose7") }, // "General Purpose Controller 7", |
100 |
{ _("genpurpose8") }, // "General Purpose Controller 8", |
101 |
{ _("portamentoctrl"), true }, |
102 |
{ _("undefined"), true }, |
103 |
{ _("undefined"), true }, |
104 |
{ _("undefined"), true }, |
105 |
{0}, // high resolution velocity prefix (so discouraged to be used here) |
106 |
{ _("undefined"), true }, |
107 |
{ _("undefined"), true }, |
108 |
{ _("effect1depth") }, // "Effects 1 Depth", |
109 |
{ _("effect2depth") }, // "Effects 2 Depth", |
110 |
{ _("effect3depth") }, // "Effects 3 Depth", |
111 |
{ _("effect4depth") }, // "Effects 4 Depth", |
112 |
{ _("effect5depth") }, // "Effects 5 Depth" |
113 |
{ _("dataincrement"), true }, |
114 |
{ _("datadecrement"), true }, |
115 |
{0}, // NRPN LSB (so discouraged to be used here) |
116 |
{0}, // NRPN MSB (so discouraged to be used here) |
117 |
{0}, // RPN LSB (so discouraged to be used here) |
118 |
{0}, // RPN MSB (so discouraged to be used here) |
119 |
{ _("undefined"), true }, |
120 |
{ _("undefined"), true }, |
121 |
{ _("undefined"), true }, |
122 |
{ _("undefined"), true }, |
123 |
{ _("undefined"), true }, |
124 |
{ _("undefined"), true }, |
125 |
{ _("undefined"), true }, |
126 |
{ _("undefined"), true }, |
127 |
{ _("undefined"), true }, |
128 |
{ _("undefined"), true }, |
129 |
{ _("undefined"), true }, |
130 |
{ _("undefined"), true }, |
131 |
{ _("undefined"), true }, |
132 |
{ _("undefined"), true }, |
133 |
{ _("undefined"), true }, |
134 |
{ _("undefined"), true }, |
135 |
{ _("undefined"), true }, |
136 |
{ _("undefined"), true } // CC 119 |
137 |
// (all other ones that follow [CC 120- CC 127] are hard coded channel |
138 |
// mode messages, so those are discouraged to be used here) |
139 |
}; |
140 |
static const char* const lfoWaveTexts[] = { |
141 |
_("Sine"), |
142 |
_("Triangle"), |
143 |
_("Saw"), |
144 |
_("Square"), |
145 |
}; |
146 |
} |
147 |
|
148 |
#define controlChangeTextsSize (sizeof(controlChangeTexts) / sizeof(CCText)) |
149 |
#define lfoWaveTextsSize (sizeof(lfoWaveTexts) / sizeof(char*)) |
150 |
|
151 |
LabelWidget::LabelWidget(const char* labelText, Gtk::Widget& widget) : |
152 |
label(Glib::ustring(labelText) + ":"), |
153 |
widget(widget) |
154 |
{ |
155 |
#if HAS_GTKMM_ALIGNMENT |
156 |
label.set_alignment(Gtk::ALIGN_START); |
157 |
#else |
158 |
label.set_halign(Gtk::Align::START); |
159 |
#endif |
160 |
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
161 |
sigc::mem_fun(*this, &LabelWidget::on_show_tooltips_changed) |
162 |
); |
163 |
|
164 |
// workaround for a crash with certain gtkmm versions: postpone calling |
165 |
// on_show_tooltips_changed() because widget.gobj() might be uninitialized |
166 |
// at this point yet |
167 |
Glib::signal_idle().connect_once( // timeout starts given amount of ms after the main loop became idle again ... |
168 |
sigc::mem_fun(*this, &LabelWidget::on_show_tooltips_changed), |
169 |
300 |
170 |
); |
171 |
} |
172 |
|
173 |
void LabelWidget::on_show_tooltips_changed() { |
174 |
const bool b = Settings::singleton()->showTooltips; |
175 |
label.set_has_tooltip(b); |
176 |
widget.set_has_tooltip(b); |
177 |
} |
178 |
|
179 |
void LabelWidget::set_sensitive(bool sensitive) |
180 |
{ |
181 |
label.set_sensitive(sensitive); |
182 |
widget.set_sensitive(sensitive); |
183 |
} |
184 |
|
185 |
ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText) |
186 |
: LabelWidget(leftHandText, text) |
187 |
{ |
188 |
#if HAS_GTKMM_ALIGNMENT |
189 |
text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); |
190 |
#else |
191 |
label.set_halign(Gtk::Align::START); |
192 |
label.set_valign(Gtk::Align::START); |
193 |
#endif |
194 |
} |
195 |
|
196 |
ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText) |
197 |
: LabelWidget(leftHandText, text) |
198 |
{ |
199 |
#if HAS_GTKMM_ALIGNMENT |
200 |
text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START); |
201 |
#else |
202 |
text.set_halign(Gtk::Align::START); |
203 |
text.set_valign(Gtk::Align::START); |
204 |
#endif |
205 |
text.set_text(rightHandText); |
206 |
} |
207 |
|
208 |
NumEntry::NumEntry(const char* labelText, double lower, double upper, |
209 |
int decimals) : |
210 |
LabelWidget(labelText, box), |
211 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
212 |
adjust(lower, lower, upper, 1, 10), |
213 |
#else |
214 |
adjust(Gtk::Adjustment::create(lower, lower, upper, 1, 10)), |
215 |
#endif |
216 |
scale(adjust), |
217 |
spinbutton(adjust) |
218 |
{ |
219 |
scale.set_size_request(70); |
220 |
spinbutton.set_digits(decimals); |
221 |
spinbutton.set_value(0); |
222 |
spinbutton.set_numeric(); |
223 |
scale.set_draw_value(false); |
224 |
box.pack_start(spinbutton, Gtk::PACK_SHRINK); |
225 |
box.add(scale); |
226 |
} |
227 |
|
228 |
void NumEntry::on_show_tooltips_changed() { |
229 |
LabelWidget::on_show_tooltips_changed(); |
230 |
|
231 |
const bool b = Settings::singleton()->showTooltips; |
232 |
spinbutton.set_has_tooltip(b); |
233 |
scale.set_has_tooltip(b); |
234 |
} |
235 |
|
236 |
NumEntryGain::NumEntryGain(const char* labelText, |
237 |
double lower, double upper, |
238 |
int decimals, double coeff) : |
239 |
NumEntry(labelText, lower, upper, decimals), |
240 |
value(0), |
241 |
coeff(coeff), |
242 |
connected(true) |
243 |
{ |
244 |
spinbutton.signal_value_changed().connect( |
245 |
sigc::mem_fun(*this, &NumEntryGain::value_changed)); |
246 |
} |
247 |
|
248 |
void NumEntryGain::value_changed() |
249 |
{ |
250 |
if (!connected) return; |
251 |
|
252 |
const double f = pow(10, spinbutton.get_digits()); |
253 |
int new_value = round_to_int(spinbutton.get_value() * f); |
254 |
if (new_value != round_to_int(value / coeff * f)) { |
255 |
value = round_to_int(new_value / f * coeff); |
256 |
sig_changed(); |
257 |
} |
258 |
} |
259 |
|
260 |
void NumEntryGain::set_value(int32_t value) |
261 |
{ |
262 |
if (value != this->value) { |
263 |
this->value = value; |
264 |
|
265 |
connected = false; |
266 |
spinbutton.set_value(value / coeff); |
267 |
connected = true; |
268 |
|
269 |
sig_changed(); |
270 |
} |
271 |
} |
272 |
|
273 |
|
274 |
NumEntryPermille::NumEntryPermille(const char* labelText, |
275 |
double lower, double upper, int decimals) : |
276 |
NumEntry(labelText, lower, upper, decimals), |
277 |
value(0) |
278 |
{ |
279 |
spinbutton.signal_value_changed().connect( |
280 |
sigc::mem_fun(*this, &NumEntryPermille::value_changed)); |
281 |
} |
282 |
|
283 |
void NumEntryPermille::value_changed() |
284 |
{ |
285 |
uint16_t new_value = uint16_t(spinbutton.get_value() * 10 + 0.5); |
286 |
if (new_value != value) { |
287 |
value = uint16_t(spinbutton.get_value() * 10 + 0.5); |
288 |
sig_changed(); |
289 |
} |
290 |
} |
291 |
|
292 |
void NumEntryPermille::set_value(uint16_t value) |
293 |
{ |
294 |
if (value != this->value) { |
295 |
spinbutton.set_value(value / 10.0); |
296 |
} |
297 |
} |
298 |
|
299 |
|
300 |
NoteEntry::NoteEntry(const char* labelText) : |
301 |
NumEntryTemp<uint8_t>(labelText) |
302 |
{ |
303 |
spin_button_show_notes(spinbutton); |
304 |
} |
305 |
|
306 |
namespace { |
307 |
const char* notes[] = { |
308 |
_("C"), _("C#"), _("D"), _("D#"), _("E"), _("F"),_("F#"), |
309 |
_("G"), _("G#"), _("A"), _("A#"), _("B") |
310 |
}; |
311 |
|
312 |
int note_value(const Glib::ustring& note, double* value) |
313 |
{ |
314 |
const char* str = note.c_str(); |
315 |
|
316 |
int i; |
317 |
for (i = 11 ; i >= 0 ; i--) { |
318 |
if (strncasecmp(str, notes[i], strlen(notes[i])) == 0) break; |
319 |
} |
320 |
if (i >= 0) { |
321 |
char* endptr; |
322 |
long x = strtol(str + strlen(notes[i]), &endptr, 10); |
323 |
if (endptr != str + strlen(notes[i])) { |
324 |
*value = std::max(0L, std::min(i + (x + 1) * 12, 127L)); |
325 |
return true; |
326 |
} |
327 |
} else { |
328 |
char* endptr; |
329 |
long x = strtol(str, &endptr, 10); |
330 |
if (endptr != str) { |
331 |
*value = std::max(0L, std::min(x, 127L)); |
332 |
return true; |
333 |
} |
334 |
} |
335 |
|
336 |
#if HAS_GTKMM_CPP11_ENUMS |
337 |
return Gtk::SpinButton::INPUT_ERROR; |
338 |
#else |
339 |
return Gtk::INPUT_ERROR; |
340 |
#endif |
341 |
} |
342 |
} |
343 |
|
344 |
int note_value(const Glib::ustring& note) |
345 |
{ |
346 |
double value = 0; |
347 |
note_value(note, &value); |
348 |
return value; |
349 |
} |
350 |
|
351 |
Glib::ustring note_str(int note) |
352 |
{ |
353 |
char buf[10]; |
354 |
sprintf(buf, "%s%d", notes[note % 12], note / 12 - 1); |
355 |
return buf; |
356 |
} |
357 |
|
358 |
namespace { |
359 |
// Convert the Entry text to a number |
360 |
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2 |
361 |
int on_input(double& new_value, Gtk::SpinButton* spinbutton) { |
362 |
return note_value(spinbutton->get_text(), &new_value); |
363 |
} |
364 |
#else |
365 |
int on_input(double* new_value, Gtk::SpinButton* spinbutton) { |
366 |
return note_value(spinbutton->get_text(), new_value); |
367 |
} |
368 |
#endif |
369 |
|
370 |
// Convert the Adjustment position to text |
371 |
bool on_output(Gtk::SpinButton* spinbutton) { |
372 |
spinbutton->set_text( |
373 |
note_str(spinbutton->get_adjustment()->get_value() + 0.5)); |
374 |
return true; |
375 |
} |
376 |
} |
377 |
|
378 |
// Make a SpinButton show notes instead of numbers |
379 |
void spin_button_show_notes(Gtk::SpinButton& spin_button) |
380 |
{ |
381 |
spin_button.set_numeric(false); |
382 |
spin_button.set_width_chars(4); |
383 |
spin_button.signal_input().connect( |
384 |
sigc::bind(sigc::ptr_fun(&on_input), &spin_button)); |
385 |
spin_button.signal_output().connect( |
386 |
sigc::bind(sigc::ptr_fun(&on_output), &spin_button)); |
387 |
} |
388 |
|
389 |
void ChoiceEntryBase::on_show_tooltips_changed() { |
390 |
LabelWidget::on_show_tooltips_changed(); |
391 |
|
392 |
const bool b = Settings::singleton()->showTooltips; |
393 |
combobox.set_has_tooltip(b); |
394 |
} |
395 |
|
396 |
ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) : |
397 |
#if HAS_GTKMM_ALIGNMENT |
398 |
LabelWidget(labelText, align), |
399 |
align(0, 0, 0, 0) |
400 |
#else |
401 |
LabelWidget(labelText, combobox) |
402 |
#endif |
403 |
{ |
404 |
for (int i = 0 ; i < controlChangeTextsSize ; i++) { |
405 |
if (controlChangeTexts[i].txt) { |
406 |
const int cc = i - 3; |
407 |
Glib::ustring s = (i < 3) |
408 |
? controlChangeTexts[i].txt |
409 |
: Glib::ustring::compose("CC%1: %2%3", cc, controlChangeTexts[i].txt, controlChangeTexts[i].isExtension ? " [EXT]" : ""); |
410 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
411 |
combobox.append_text(s); |
412 |
#else |
413 |
combobox.append(s); |
414 |
#endif |
415 |
} |
416 |
} |
417 |
combobox.set_wrap_width(4); |
418 |
combobox.signal_changed().connect( |
419 |
sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed)); |
420 |
#if HAS_GTKMM_ALIGNMENT |
421 |
align.add(combobox); |
422 |
#else |
423 |
combobox.set_halign(Gtk::Align::FILL); |
424 |
combobox.set_valign(Gtk::Align::FILL); |
425 |
#endif |
426 |
value.type = gig::leverage_ctrl_t::type_none; |
427 |
value.controller_number = 0; |
428 |
} |
429 |
|
430 |
void ChoiceEntryLeverageCtrl::on_show_tooltips_changed() { |
431 |
LabelWidget::on_show_tooltips_changed(); |
432 |
|
433 |
const bool b = Settings::singleton()->showTooltips; |
434 |
combobox.set_has_tooltip(b); |
435 |
} |
436 |
|
437 |
static void _showGigFormatExtWarning() { |
438 |
if (!Settings::singleton()->warnUserOnExtensions) return; |
439 |
Glib::ustring txt = |
440 |
_("<b>Format Extension</b>\n\nAll options marked with \"<b>[EXT]</b>\" are an extension to the original gig sound format. They will only work with LinuxSampler, but they will <b>not work</b> with Gigasampler/GigaStudio!\n\n(You may disable this warning in the <i>Settings</i> menu.)"); |
441 |
Gtk::MessageDialog msg(txt, true, Gtk::MESSAGE_WARNING); |
442 |
msg.run(); |
443 |
} |
444 |
|
445 |
void ChoiceEntryLeverageCtrl::value_changed() |
446 |
{ |
447 |
int rowno = combobox.get_active_row_number(); |
448 |
switch (rowno) |
449 |
{ |
450 |
case -1: |
451 |
break; |
452 |
case 0: |
453 |
value.type = gig::leverage_ctrl_t::type_none; |
454 |
break; |
455 |
case 1: |
456 |
value.type = gig::leverage_ctrl_t::type_channelaftertouch; |
457 |
break; |
458 |
case 2: |
459 |
value.type = gig::leverage_ctrl_t::type_velocity; |
460 |
break; |
461 |
default: |
462 |
value.type = gig::leverage_ctrl_t::type_controlchange; |
463 |
int x = 3; |
464 |
for (uint cc = 0 ; cc < controlChangeTextsSize - 3 ; cc++) { |
465 |
if (controlChangeTexts[cc + 3].txt) { |
466 |
if (rowno == x) { |
467 |
value.controller_number = cc; |
468 |
if (controlChangeTexts[cc + 3].isExtension) { |
469 |
_showGigFormatExtWarning(); |
470 |
} |
471 |
break; |
472 |
} |
473 |
x++; |
474 |
} |
475 |
} |
476 |
break; |
477 |
} |
478 |
if (rowno >= 0) sig_changed(); |
479 |
} |
480 |
|
481 |
void ChoiceEntryLeverageCtrl::set_value(gig::leverage_ctrl_t value) |
482 |
{ |
483 |
int comboIndex; |
484 |
switch (value.type) |
485 |
{ |
486 |
case gig::leverage_ctrl_t::type_none: |
487 |
comboIndex = 0; |
488 |
break; |
489 |
case gig::leverage_ctrl_t::type_channelaftertouch: |
490 |
comboIndex = 1; |
491 |
break; |
492 |
case gig::leverage_ctrl_t::type_velocity: |
493 |
comboIndex = 2; |
494 |
break; |
495 |
case gig::leverage_ctrl_t::type_controlchange: { |
496 |
comboIndex = -1; |
497 |
int x = 3; |
498 |
for (uint cc = 0 ; cc < controlChangeTextsSize - 3 ; cc++) { |
499 |
if (controlChangeTexts[cc + 3].txt) { |
500 |
if (value.controller_number == cc) { |
501 |
comboIndex = x; |
502 |
break; |
503 |
} |
504 |
x++; |
505 |
} |
506 |
} |
507 |
break; |
508 |
} |
509 |
default: |
510 |
comboIndex = -1; |
511 |
break; |
512 |
} |
513 |
combobox.set_active(comboIndex); |
514 |
} |
515 |
|
516 |
|
517 |
ChoiceEntryLfoWave::ChoiceEntryLfoWave(const char* labelText) : |
518 |
#if HAS_GTKMM_ALIGNMENT |
519 |
LabelWidget(labelText, align), |
520 |
align(0, 0, 0, 0) |
521 |
#else |
522 |
LabelWidget(labelText, combobox) |
523 |
#endif |
524 |
{ |
525 |
for (int i = 0 ; i < lfoWaveTextsSize; i++) { |
526 |
if (lfoWaveTexts[i]) { |
527 |
Glib::ustring s = (i == 0) |
528 |
? lfoWaveTexts[i] |
529 |
: Glib::ustring::compose("%1 [EXT]", lfoWaveTexts[i]); |
530 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
531 |
combobox.append_text(s); |
532 |
#else |
533 |
combobox.append(s); |
534 |
#endif |
535 |
} |
536 |
} |
537 |
//combobox.set_wrap_width(4); |
538 |
combobox.signal_changed().connect( |
539 |
sigc::mem_fun(*this, &ChoiceEntryLfoWave::value_changed)); |
540 |
#if HAS_GTKMM_ALIGNMENT |
541 |
align.add(combobox); |
542 |
#else |
543 |
combobox.set_halign(Gtk::Align::FILL); |
544 |
combobox.set_valign(Gtk::Align::FILL); |
545 |
#endif |
546 |
value = gig::lfo_wave_sine; |
547 |
} |
548 |
|
549 |
void ChoiceEntryLfoWave::on_show_tooltips_changed() { |
550 |
LabelWidget::on_show_tooltips_changed(); |
551 |
|
552 |
const bool b = Settings::singleton()->showTooltips; |
553 |
combobox.set_has_tooltip(b); |
554 |
} |
555 |
|
556 |
void ChoiceEntryLfoWave::value_changed() { |
557 |
const int rowno = combobox.get_active_row_number(); |
558 |
switch (rowno) { |
559 |
case -1: |
560 |
break; |
561 |
case 0: |
562 |
value = gig::lfo_wave_sine; |
563 |
break; |
564 |
case 1: |
565 |
value = gig::lfo_wave_triangle; |
566 |
_showGigFormatExtWarning(); |
567 |
break; |
568 |
case 2: |
569 |
value = gig::lfo_wave_saw; |
570 |
_showGigFormatExtWarning(); |
571 |
break; |
572 |
case 3: |
573 |
value = gig::lfo_wave_square; |
574 |
_showGigFormatExtWarning(); |
575 |
break; |
576 |
} |
577 |
if (rowno >= 0) sig_changed(); |
578 |
} |
579 |
|
580 |
void ChoiceEntryLfoWave::set_value(gig::lfo_wave_t value) { |
581 |
int comboIndex; |
582 |
switch (value) { |
583 |
case gig::lfo_wave_sine: |
584 |
comboIndex = 0; |
585 |
break; |
586 |
case gig::lfo_wave_triangle: |
587 |
comboIndex = 1; |
588 |
break; |
589 |
case gig::lfo_wave_saw: |
590 |
comboIndex = 2; |
591 |
break; |
592 |
case gig::lfo_wave_square: |
593 |
comboIndex = 3; |
594 |
break; |
595 |
default: |
596 |
comboIndex = -1; |
597 |
break; |
598 |
} |
599 |
combobox.set_active(comboIndex); |
600 |
} |
601 |
|
602 |
|
603 |
BoolBox::BoolBox(const char* labelText) : Gtk::CheckButton(labelText) { |
604 |
signal_toggled().connect(sig_changed.make_slot()); |
605 |
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
606 |
sigc::mem_fun(*this, &BoolBox::on_show_tooltips_changed) |
607 |
); |
608 |
on_show_tooltips_changed(); |
609 |
} |
610 |
|
611 |
void BoolBox::on_show_tooltips_changed() { |
612 |
const bool b = Settings::singleton()->showTooltips; |
613 |
set_has_tooltip(b); |
614 |
} |
615 |
|
616 |
|
617 |
BoolEntry::BoolEntry(const char* labelText) : |
618 |
LabelWidget(labelText, checkbutton), |
619 |
checkbutton(labelText) |
620 |
{ |
621 |
checkbutton.signal_toggled().connect(sig_changed.make_slot()); |
622 |
} |
623 |
|
624 |
|
625 |
StringEntry::StringEntry(const char* labelText) : |
626 |
LabelWidget(labelText, entry) |
627 |
{ |
628 |
entry.signal_changed().connect(sig_changed.make_slot()); |
629 |
} |
630 |
|
631 |
gig::String StringEntry::get_value() const |
632 |
{ |
633 |
return gig_from_utf8(entry.get_text()); |
634 |
} |
635 |
|
636 |
void StringEntry::set_value(const gig::String& value) { |
637 |
entry.set_text(gig_to_utf8(value)); |
638 |
} |
639 |
|
640 |
|
641 |
StringEntryMultiLine::StringEntryMultiLine(const char* labelText) : |
642 |
LabelWidget(labelText, frame) |
643 |
{ |
644 |
text_buffer = text_view.get_buffer(); |
645 |
frame.set_shadow_type(Gtk::SHADOW_IN); |
646 |
frame.add(text_view); |
647 |
text_buffer->signal_changed().connect(sig_changed.make_slot()); |
648 |
} |
649 |
|
650 |
gig::String StringEntryMultiLine::get_value() const |
651 |
{ |
652 |
Glib::ustring value = text_buffer->get_text(); |
653 |
for (int i = 0 ; (i = value.find("\x0a", i)) >= 0 ; i += 2) |
654 |
value.replace(i, 1, "\x0d\x0a"); |
655 |
return gig_from_utf8(value); |
656 |
} |
657 |
|
658 |
void StringEntryMultiLine::set_value(const gig::String& value) |
659 |
{ |
660 |
Glib::ustring text = gig_to_utf8(value); |
661 |
for (int i = 0 ; (i = text.find("\x0d\x0a", i, 2)) >= 0 ; i++) |
662 |
text.replace(i, 2, "\x0a"); |
663 |
text_buffer->set_text(text); |
664 |
} |
665 |
|
666 |
void StringEntryMultiLine::on_show_tooltips_changed() { |
667 |
LabelWidget::on_show_tooltips_changed(); |
668 |
|
669 |
const bool b = Settings::singleton()->showTooltips; |
670 |
text_view.set_has_tooltip(b); |
671 |
} |
672 |
|
673 |
|
674 |
Table::Table(int x, int y) : |
675 |
#if USE_GTKMM_GRID |
676 |
Gtk::Grid(), |
677 |
cols(x), |
678 |
#else |
679 |
Gtk::Table(x, y), |
680 |
#endif |
681 |
rowno(0) |
682 |
{ |
683 |
} |
684 |
|
685 |
void Table::add(BoolEntry& boolentry) |
686 |
{ |
687 |
#if USE_GTKMM_GRID |
688 |
attach(boolentry.widget, 0, rowno, 2); |
689 |
#else |
690 |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
691 |
Gtk::FILL, Gtk::SHRINK); |
692 |
#endif |
693 |
rowno++; |
694 |
} |
695 |
|
696 |
void Table::add(LabelWidget& prop) |
697 |
{ |
698 |
#if USE_GTKMM_GRID |
699 |
attach(prop.label, 1, rowno); |
700 |
attach(prop.widget, 2, rowno); |
701 |
#else |
702 |
attach(prop.label, 1, 2, rowno, rowno + 1, |
703 |
Gtk::FILL, Gtk::SHRINK); |
704 |
attach(prop.widget, 2, 3, rowno, rowno + 1, |
705 |
Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); |
706 |
#endif |
707 |
rowno++; |
708 |
} |