1 |
/* |
/* |
2 |
* Copyright (C) 2006-2017 Andreas Persson |
* Copyright (C) 2006-2019 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 |
23 |
#include "compat.h" |
#include "compat.h" |
24 |
#include "Settings.h" |
#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> |
#include <gtkmm/messagedialog.h> |
33 |
|
|
34 |
namespace { |
namespace { |
137 |
// (all other ones that follow [CC 120- CC 127] are hard coded channel |
// (all other ones that follow [CC 120- CC 127] are hard coded channel |
138 |
// mode messages, so those are discouraged to be used here) |
// 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)) |
#define controlChangeTextsSize (sizeof(controlChangeTexts) / sizeof(CCText)) |
149 |
|
#define lfoWaveTextsSize (sizeof(lfoWaveTexts) / sizeof(char*)) |
150 |
|
|
151 |
LabelWidget::LabelWidget(const char* labelText, Gtk::Widget& widget) : |
LabelWidget::LabelWidget(const char* labelText, Gtk::Widget& widget) : |
152 |
label(Glib::ustring(labelText) + ":"), |
label(Glib::ustring(labelText) + ":"), |
157 |
#else |
#else |
158 |
label.set_halign(Gtk::Align::START); |
label.set_halign(Gtk::Align::START); |
159 |
#endif |
#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) |
void LabelWidget::set_sensitive(bool sensitive) |
205 |
text.set_text(rightHandText); |
text.set_text(rightHandText); |
206 |
} |
} |
207 |
|
|
208 |
|
static double stepForDecimals(int decimals) { |
209 |
|
switch (decimals) { |
210 |
|
case 0: return 1.0; |
211 |
|
case 1: return 0.1; |
212 |
|
case 2: default: return 0.01; |
213 |
|
} |
214 |
|
} |
215 |
|
|
216 |
|
static double pageForDecimals(int decimals) { |
217 |
|
switch (decimals) { |
218 |
|
case 0: return 10.0; |
219 |
|
case 1: return 1.0; |
220 |
|
case 2: default: return 0.1; |
221 |
|
} |
222 |
|
} |
223 |
|
|
224 |
NumEntry::NumEntry(const char* labelText, double lower, double upper, |
NumEntry::NumEntry(const char* labelText, double lower, double upper, |
225 |
int decimals) : |
int decimals) : |
226 |
LabelWidget(labelText, box), |
LabelWidget(labelText, box), |
227 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
228 |
adjust(lower, lower, upper, 1, 10), |
adjust(lower, lower, upper, stepForDecimals(decimals), pageForDecimals(decimals)), |
229 |
#else |
#else |
230 |
adjust(Gtk::Adjustment::create(lower, lower, upper, 1, 10)), |
adjust(Gtk::Adjustment::create(lower, lower, upper, stepForDecimals(decimals), pageForDecimals(decimals))), |
231 |
#endif |
#endif |
232 |
scale(adjust), |
scale(adjust), |
233 |
spinbutton(adjust) |
spinbutton(adjust) |
241 |
box.add(scale); |
box.add(scale); |
242 |
} |
} |
243 |
|
|
244 |
|
void NumEntry::on_show_tooltips_changed() { |
245 |
|
LabelWidget::on_show_tooltips_changed(); |
246 |
|
|
247 |
|
const bool b = Settings::singleton()->showTooltips; |
248 |
|
spinbutton.set_has_tooltip(b); |
249 |
|
scale.set_has_tooltip(b); |
250 |
|
} |
251 |
|
|
252 |
NumEntryGain::NumEntryGain(const char* labelText, |
NumEntryGain::NumEntryGain(const char* labelText, |
253 |
double lower, double upper, |
double lower, double upper, |
254 |
int decimals, double coeff) : |
int decimals, double coeff) : |
257 |
coeff(coeff), |
coeff(coeff), |
258 |
connected(true) |
connected(true) |
259 |
{ |
{ |
260 |
|
spinbutton.set_increments(0.1, 1.0); |
261 |
spinbutton.signal_value_changed().connect( |
spinbutton.signal_value_changed().connect( |
262 |
sigc::mem_fun(*this, &NumEntryGain::value_changed)); |
sigc::mem_fun(*this, &NumEntryGain::value_changed)); |
263 |
} |
} |
280 |
this->value = value; |
this->value = value; |
281 |
|
|
282 |
connected = false; |
connected = false; |
283 |
bool plus6 = value < 0; |
spinbutton.set_value(value / coeff); |
|
spinbutton.set_value(plus6 ? 0 : value / coeff); |
|
|
set_sensitive(!plus6); |
|
284 |
connected = true; |
connected = true; |
285 |
|
|
286 |
sig_changed(); |
sig_changed(); |
288 |
} |
} |
289 |
|
|
290 |
|
|
|
BoolEntryPlus6::BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value) : |
|
|
LabelWidget(labelText, checkbutton), |
|
|
checkbutton(labelText), |
|
|
eGain(eGain), |
|
|
plus6value(plus6value) |
|
|
{ |
|
|
checkbutton.signal_toggled().connect( |
|
|
sigc::mem_fun(*this, &BoolEntryPlus6::value_changed)); |
|
|
} |
|
|
|
|
|
void BoolEntryPlus6::value_changed() |
|
|
{ |
|
|
if (checkbutton.get_active()) eGain.set_value(plus6value); |
|
|
else if (eGain.get_value() < 0) eGain.set_value(0); |
|
|
} |
|
|
|
|
|
int32_t BoolEntryPlus6::get_value() const |
|
|
{ |
|
|
return eGain.get_value(); |
|
|
} |
|
|
|
|
|
void BoolEntryPlus6::set_value(int32_t value) |
|
|
{ |
|
|
checkbutton.set_active(value < 0); |
|
|
} |
|
|
|
|
291 |
NumEntryPermille::NumEntryPermille(const char* labelText, |
NumEntryPermille::NumEntryPermille(const char* labelText, |
292 |
double lower, double upper, int decimals) : |
double lower, double upper, int decimals) : |
293 |
NumEntry(labelText, lower, upper, decimals), |
NumEntry(labelText, lower, upper, decimals), |
403 |
sigc::bind(sigc::ptr_fun(&on_output), &spin_button)); |
sigc::bind(sigc::ptr_fun(&on_output), &spin_button)); |
404 |
} |
} |
405 |
|
|
406 |
|
void ChoiceEntryBase::on_show_tooltips_changed() { |
407 |
|
LabelWidget::on_show_tooltips_changed(); |
408 |
|
|
409 |
|
const bool b = Settings::singleton()->showTooltips; |
410 |
|
combobox.set_has_tooltip(b); |
411 |
|
} |
412 |
|
|
413 |
ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) : |
ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) : |
414 |
#if HAS_GTKMM_ALIGNMENT |
#if HAS_GTKMM_ALIGNMENT |
415 |
LabelWidget(labelText, align), |
LabelWidget(labelText, align), |
431 |
#endif |
#endif |
432 |
} |
} |
433 |
} |
} |
434 |
|
combobox.set_wrap_width(4); |
435 |
combobox.signal_changed().connect( |
combobox.signal_changed().connect( |
436 |
sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed)); |
sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed)); |
437 |
#if HAS_GTKMM_ALIGNMENT |
#if HAS_GTKMM_ALIGNMENT |
444 |
value.controller_number = 0; |
value.controller_number = 0; |
445 |
} |
} |
446 |
|
|
447 |
|
void ChoiceEntryLeverageCtrl::on_show_tooltips_changed() { |
448 |
|
LabelWidget::on_show_tooltips_changed(); |
449 |
|
|
450 |
|
const bool b = Settings::singleton()->showTooltips; |
451 |
|
combobox.set_has_tooltip(b); |
452 |
|
} |
453 |
|
|
454 |
|
static void _showGigFormatExtWarning() { |
455 |
|
if (!Settings::singleton()->warnUserOnExtensions) return; |
456 |
|
Glib::ustring txt = |
457 |
|
_("<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.)"); |
458 |
|
Gtk::MessageDialog msg(txt, true, Gtk::MESSAGE_WARNING); |
459 |
|
msg.run(); |
460 |
|
} |
461 |
|
|
462 |
void ChoiceEntryLeverageCtrl::value_changed() |
void ChoiceEntryLeverageCtrl::value_changed() |
463 |
{ |
{ |
464 |
int rowno = combobox.get_active_row_number(); |
int rowno = combobox.get_active_row_number(); |
482 |
if (controlChangeTexts[cc + 3].txt) { |
if (controlChangeTexts[cc + 3].txt) { |
483 |
if (rowno == x) { |
if (rowno == x) { |
484 |
value.controller_number = cc; |
value.controller_number = cc; |
485 |
if (controlChangeTexts[cc + 3].isExtension && |
if (controlChangeTexts[cc + 3].isExtension) { |
486 |
Settings::singleton()->warnUserOnExtensions) |
_showGigFormatExtWarning(); |
|
{ |
|
|
Glib::ustring txt = _("<b>Format Extension</b>\n\nAll controllers 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.)"); |
|
|
Gtk::MessageDialog msg( |
|
|
txt, true, Gtk::MESSAGE_WARNING |
|
|
); |
|
|
msg.run(); |
|
487 |
} |
} |
488 |
break; |
break; |
489 |
} |
} |
531 |
} |
} |
532 |
|
|
533 |
|
|
534 |
|
ChoiceEntryLfoWave::ChoiceEntryLfoWave(const char* labelText) : |
535 |
|
#if HAS_GTKMM_ALIGNMENT |
536 |
|
LabelWidget(labelText, align), |
537 |
|
align(0, 0, 0, 0) |
538 |
|
#else |
539 |
|
LabelWidget(labelText, combobox) |
540 |
|
#endif |
541 |
|
{ |
542 |
|
for (int i = 0 ; i < lfoWaveTextsSize; i++) { |
543 |
|
if (lfoWaveTexts[i]) { |
544 |
|
Glib::ustring s = (i == 0) |
545 |
|
? lfoWaveTexts[i] |
546 |
|
: Glib::ustring::compose("%1 [EXT]", lfoWaveTexts[i]); |
547 |
|
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
548 |
|
combobox.append_text(s); |
549 |
|
#else |
550 |
|
combobox.append(s); |
551 |
|
#endif |
552 |
|
} |
553 |
|
} |
554 |
|
//combobox.set_wrap_width(4); |
555 |
|
combobox.signal_changed().connect( |
556 |
|
sigc::mem_fun(*this, &ChoiceEntryLfoWave::value_changed)); |
557 |
|
#if HAS_GTKMM_ALIGNMENT |
558 |
|
align.add(combobox); |
559 |
|
#else |
560 |
|
combobox.set_halign(Gtk::Align::FILL); |
561 |
|
combobox.set_valign(Gtk::Align::FILL); |
562 |
|
#endif |
563 |
|
value = gig::lfo_wave_sine; |
564 |
|
} |
565 |
|
|
566 |
|
void ChoiceEntryLfoWave::on_show_tooltips_changed() { |
567 |
|
LabelWidget::on_show_tooltips_changed(); |
568 |
|
|
569 |
|
const bool b = Settings::singleton()->showTooltips; |
570 |
|
combobox.set_has_tooltip(b); |
571 |
|
} |
572 |
|
|
573 |
|
void ChoiceEntryLfoWave::value_changed() { |
574 |
|
const int rowno = combobox.get_active_row_number(); |
575 |
|
switch (rowno) { |
576 |
|
case -1: |
577 |
|
break; |
578 |
|
case 0: |
579 |
|
value = gig::lfo_wave_sine; |
580 |
|
break; |
581 |
|
case 1: |
582 |
|
value = gig::lfo_wave_triangle; |
583 |
|
_showGigFormatExtWarning(); |
584 |
|
break; |
585 |
|
case 2: |
586 |
|
value = gig::lfo_wave_saw; |
587 |
|
_showGigFormatExtWarning(); |
588 |
|
break; |
589 |
|
case 3: |
590 |
|
value = gig::lfo_wave_square; |
591 |
|
_showGigFormatExtWarning(); |
592 |
|
break; |
593 |
|
} |
594 |
|
if (rowno >= 0) sig_changed(); |
595 |
|
} |
596 |
|
|
597 |
|
void ChoiceEntryLfoWave::set_value(gig::lfo_wave_t value) { |
598 |
|
int comboIndex; |
599 |
|
switch (value) { |
600 |
|
case gig::lfo_wave_sine: |
601 |
|
comboIndex = 0; |
602 |
|
break; |
603 |
|
case gig::lfo_wave_triangle: |
604 |
|
comboIndex = 1; |
605 |
|
break; |
606 |
|
case gig::lfo_wave_saw: |
607 |
|
comboIndex = 2; |
608 |
|
break; |
609 |
|
case gig::lfo_wave_square: |
610 |
|
comboIndex = 3; |
611 |
|
break; |
612 |
|
default: |
613 |
|
comboIndex = -1; |
614 |
|
break; |
615 |
|
} |
616 |
|
combobox.set_active(comboIndex); |
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
|
BoolBox::BoolBox(const char* labelText) : Gtk::CheckButton(labelText) { |
621 |
|
signal_toggled().connect(sig_changed.make_slot()); |
622 |
|
Settings::singleton()->showTooltips.get_proxy().signal_changed().connect( |
623 |
|
sigc::mem_fun(*this, &BoolBox::on_show_tooltips_changed) |
624 |
|
); |
625 |
|
on_show_tooltips_changed(); |
626 |
|
} |
627 |
|
|
628 |
|
void BoolBox::on_show_tooltips_changed() { |
629 |
|
const bool b = Settings::singleton()->showTooltips; |
630 |
|
set_has_tooltip(b); |
631 |
|
} |
632 |
|
|
633 |
|
|
634 |
BoolEntry::BoolEntry(const char* labelText) : |
BoolEntry::BoolEntry(const char* labelText) : |
635 |
LabelWidget(labelText, checkbutton), |
LabelWidget(labelText, checkbutton), |
636 |
checkbutton(labelText) |
checkbutton(labelText) |
680 |
text_buffer->set_text(text); |
text_buffer->set_text(text); |
681 |
} |
} |
682 |
|
|
683 |
|
void StringEntryMultiLine::on_show_tooltips_changed() { |
684 |
|
LabelWidget::on_show_tooltips_changed(); |
685 |
|
|
686 |
|
const bool b = Settings::singleton()->showTooltips; |
687 |
|
text_view.set_has_tooltip(b); |
688 |
|
} |
689 |
|
|
690 |
|
|
691 |
Table::Table(int x, int y) : |
Table::Table(int x, int y) : |
692 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
703 |
{ |
{ |
704 |
#if USE_GTKMM_GRID |
#if USE_GTKMM_GRID |
705 |
attach(boolentry.widget, 0, rowno, 2); |
attach(boolentry.widget, 0, rowno, 2); |
|
#else |
|
|
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
|
|
Gtk::FILL, Gtk::SHRINK); |
|
|
#endif |
|
|
rowno++; |
|
|
} |
|
|
|
|
|
void Table::add(BoolEntryPlus6& boolentry) |
|
|
{ |
|
|
#if USE_GTKMM_GRID |
|
|
attach(boolentry.widget, 0, rowno, 2); |
|
706 |
#else |
#else |
707 |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
attach(boolentry.widget, 0, 2, rowno, rowno + 1, |
708 |
Gtk::FILL, Gtk::SHRINK); |
Gtk::FILL, Gtk::SHRINK); |