/[svn]/gigedit/trunk/src/gigedit/paramedit.cpp
ViewVC logotype

Annotation of /gigedit/trunk/src/gigedit/paramedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3624 - (hide annotations) (download)
Wed Oct 2 17:11:30 2019 UTC (4 years, 6 months ago) by schoenebeck
File size: 22480 byte(s)
* GIG SOUND FORMAT EXTENSION: Added combo box for selecting a wave form
  type for each one of the 3 LFOs (i.e. for overriding the default LFO
  sine wave form to either triangle, saw or square instead).

* GIG SOUND FORMAT EXTENSION: Added slider for each one of the 3 LFOs
  for altering the phase displacement of the respective LFO (that is
  for moving the LFO's start level horizontally on the time axis).

* GIG SOUND FORMAT EXTENSION: Added checkbox "Flip Phase" to LFO 3
  (the original Gigasampler/GigaStudio software only supported that
  option for LFO 1 and LFO 2).

* Bumped version (1.1.1.svn3).

1 schoenebeck 1225 /*
2 persson 3460 * Copyright (C) 2006-2019 Andreas Persson
3 schoenebeck 1225 *
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 persson 3202 #include "global.h"
21 schoenebeck 1225 #include "paramedit.h"
22    
23 persson 2169 #include "compat.h"
24 schoenebeck 2541 #include "Settings.h"
25 persson 1831
26 schoenebeck 3411 #ifdef GLIBMM_HEADER_FILE
27     # include GLIBMM_HEADER_FILE(glibmm.h)
28     #else
29     # include <glibmm.h>
30     #endif
31    
32 schoenebeck 2541 #include <gtkmm/messagedialog.h>
33    
34 schoenebeck 1225 namespace {
35 schoenebeck 2541 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 schoenebeck 2538
75     // LSB variant of the various controllers above
76     // (so discouraged to be used here for now)
77 schoenebeck 2541 {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 schoenebeck 2538
81 schoenebeck 2541 { _("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 schoenebeck 2538 // (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 schoenebeck 1225 };
140 schoenebeck 3624 static const char* const lfoWaveTexts[] = {
141     _("Sine"),
142     _("Triangle"),
143     _("Saw"),
144     _("Square"),
145     };
146 schoenebeck 1225 }
147    
148 schoenebeck 2541 #define controlChangeTextsSize (sizeof(controlChangeTexts) / sizeof(CCText))
149 schoenebeck 3624 #define lfoWaveTextsSize (sizeof(lfoWaveTexts) / sizeof(char*))
150 schoenebeck 2538
151 schoenebeck 1225 LabelWidget::LabelWidget(const char* labelText, Gtk::Widget& widget) :
152     label(Glib::ustring(labelText) + ":"),
153     widget(widget)
154     {
155 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
156 persson 2169 label.set_alignment(Gtk::ALIGN_START);
157 schoenebeck 3364 #else
158     label.set_halign(Gtk::Align::START);
159     #endif
160 schoenebeck 3409 Settings::singleton()->showTooltips.get_proxy().signal_changed().connect(
161 persson 3461 sigc::mem_fun(*this, &LabelWidget::on_show_tooltips_changed)
162 schoenebeck 3409 );
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 schoenebeck 1225 }
172    
173 schoenebeck 3409 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 schoenebeck 1225 void LabelWidget::set_sensitive(bool sensitive)
180     {
181     label.set_sensitive(sensitive);
182     widget.set_sensitive(sensitive);
183     }
184    
185 schoenebeck 2690 ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText)
186     : LabelWidget(leftHandText, text)
187     {
188 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
189 schoenebeck 2690 text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);
190 schoenebeck 3364 #else
191     label.set_halign(Gtk::Align::START);
192     label.set_valign(Gtk::Align::START);
193     #endif
194 schoenebeck 2690 }
195    
196     ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText)
197     : LabelWidget(leftHandText, text)
198     {
199 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
200 schoenebeck 2690 text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);
201 schoenebeck 3364 #else
202     text.set_halign(Gtk::Align::START);
203     text.set_valign(Gtk::Align::START);
204     #endif
205 schoenebeck 2690 text.set_text(rightHandText);
206     }
207    
208 schoenebeck 1225 NumEntry::NumEntry(const char* labelText, double lower, double upper,
209     int decimals) :
210 persson 2151 LabelWidget(labelText, box),
211 persson 2169 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
212 schoenebeck 1225 adjust(lower, lower, upper, 1, 10),
213 persson 2169 #else
214     adjust(Gtk::Adjustment::create(lower, lower, upper, 1, 10)),
215     #endif
216 schoenebeck 1225 scale(adjust),
217 persson 2151 spinbutton(adjust)
218 schoenebeck 1225 {
219 persson 2423 scale.set_size_request(70);
220 schoenebeck 1225 spinbutton.set_digits(decimals);
221 persson 1460 spinbutton.set_value(0);
222 persson 2507 spinbutton.set_numeric();
223 schoenebeck 1225 scale.set_draw_value(false);
224     box.pack_start(spinbutton, Gtk::PACK_SHRINK);
225     box.add(scale);
226     }
227    
228 schoenebeck 3409 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 schoenebeck 1225 NumEntryGain::NumEntryGain(const char* labelText,
237     double lower, double upper,
238     int decimals, double coeff) :
239     NumEntry(labelText, lower, upper, decimals),
240 persson 2151 value(0),
241 persson 1460 coeff(coeff),
242     connected(true)
243 schoenebeck 1225 {
244     spinbutton.signal_value_changed().connect(
245     sigc::mem_fun(*this, &NumEntryGain::value_changed));
246     }
247    
248     void NumEntryGain::value_changed()
249     {
250 persson 1460 if (!connected) return;
251    
252 schoenebeck 1359 const double f = pow(10, spinbutton.get_digits());
253     int new_value = round_to_int(spinbutton.get_value() * f);
254 persson 1460 if (new_value != round_to_int(value / coeff * f)) {
255     value = round_to_int(new_value / f * coeff);
256     sig_changed();
257 schoenebeck 1225 }
258     }
259    
260 persson 1460 void NumEntryGain::set_value(int32_t value)
261 schoenebeck 1225 {
262 persson 1460 if (value != this->value) {
263     this->value = value;
264    
265     connected = false;
266     bool plus6 = value < 0;
267     spinbutton.set_value(plus6 ? 0 : value / coeff);
268     set_sensitive(!plus6);
269     connected = true;
270    
271     sig_changed();
272     }
273 schoenebeck 1225 }
274    
275    
276     BoolEntryPlus6::BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value) :
277     LabelWidget(labelText, checkbutton),
278 persson 1262 checkbutton(labelText),
279 schoenebeck 1225 eGain(eGain),
280     plus6value(plus6value)
281     {
282     checkbutton.signal_toggled().connect(
283     sigc::mem_fun(*this, &BoolEntryPlus6::value_changed));
284     }
285    
286 schoenebeck 3409 void BoolEntryPlus6::on_show_tooltips_changed() {
287     LabelWidget::on_show_tooltips_changed();
288    
289     eGain.on_show_tooltips_changed();
290     }
291    
292 schoenebeck 1225 void BoolEntryPlus6::value_changed()
293     {
294 persson 1460 if (checkbutton.get_active()) eGain.set_value(plus6value);
295     else if (eGain.get_value() < 0) eGain.set_value(0);
296 schoenebeck 1225 }
297    
298 persson 1460 int32_t BoolEntryPlus6::get_value() const
299 schoenebeck 1225 {
300 persson 1460 return eGain.get_value();
301 schoenebeck 1225 }
302    
303 persson 1460 void BoolEntryPlus6::set_value(int32_t value)
304     {
305     checkbutton.set_active(value < 0);
306     }
307    
308 schoenebeck 1225 NumEntryPermille::NumEntryPermille(const char* labelText,
309     double lower, double upper, int decimals) :
310 persson 1460 NumEntry(labelText, lower, upper, decimals),
311     value(0)
312 schoenebeck 1225 {
313     spinbutton.signal_value_changed().connect(
314     sigc::mem_fun(*this, &NumEntryPermille::value_changed));
315     }
316    
317     void NumEntryPermille::value_changed()
318     {
319 persson 1460 uint16_t new_value = uint16_t(spinbutton.get_value() * 10 + 0.5);
320     if (new_value != value) {
321     value = uint16_t(spinbutton.get_value() * 10 + 0.5);
322     sig_changed();
323 schoenebeck 1225 }
324     }
325    
326 persson 1460 void NumEntryPermille::set_value(uint16_t value)
327 schoenebeck 1225 {
328 persson 1460 if (value != this->value) {
329     spinbutton.set_value(value / 10.0);
330     }
331 schoenebeck 1225 }
332    
333    
334     NoteEntry::NoteEntry(const char* labelText) :
335     NumEntryTemp<uint8_t>(labelText)
336     {
337 persson 2507 spin_button_show_notes(spinbutton);
338 schoenebeck 1225 }
339    
340 persson 2507 namespace {
341     const char* notes[] = {
342     _("C"), _("C#"), _("D"), _("D#"), _("E"), _("F"),_("F#"),
343     _("G"), _("G#"), _("A"), _("A#"), _("B")
344     };
345 schoenebeck 1225
346 persson 2507 int note_value(const Glib::ustring& note, double* value)
347     {
348     const char* str = note.c_str();
349 schoenebeck 1225
350 persson 2507 int i;
351     for (i = 11 ; i >= 0 ; i--) {
352     if (strncasecmp(str, notes[i], strlen(notes[i])) == 0) break;
353     }
354     if (i >= 0) {
355     char* endptr;
356     long x = strtol(str + strlen(notes[i]), &endptr, 10);
357     if (endptr != str + strlen(notes[i])) {
358     *value = std::max(0L, std::min(i + (x + 1) * 12, 127L));
359     return true;
360     }
361     } else {
362     char* endptr;
363     long x = strtol(str, &endptr, 10);
364     if (endptr != str) {
365     *value = std::max(0L, std::min(x, 127L));
366     return true;
367     }
368     }
369 schoenebeck 3364
370     #if HAS_GTKMM_CPP11_ENUMS
371     return Gtk::SpinButton::INPUT_ERROR;
372     #else
373 persson 2507 return Gtk::INPUT_ERROR;
374 schoenebeck 3364 #endif
375 persson 2507 }
376     }
377    
378     int note_value(const Glib::ustring& note)
379 schoenebeck 1225 {
380 persson 2507 double value = 0;
381     note_value(note, &value);
382     return value;
383     }
384 schoenebeck 1225
385 persson 2507 Glib::ustring note_str(int note)
386     {
387     char buf[10];
388     sprintf(buf, "%s%d", notes[note % 12], note / 12 - 1);
389     return buf;
390     }
391    
392     namespace {
393     // Convert the Entry text to a number
394 schoenebeck 3364 #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
395     int on_input(double& new_value, Gtk::SpinButton* spinbutton) {
396     return note_value(spinbutton->get_text(), &new_value);
397     }
398     #else
399 persson 2507 int on_input(double* new_value, Gtk::SpinButton* spinbutton) {
400     return note_value(spinbutton->get_text(), new_value);
401 schoenebeck 1225 }
402 schoenebeck 3364 #endif
403 persson 2507
404     // Convert the Adjustment position to text
405     bool on_output(Gtk::SpinButton* spinbutton) {
406     spinbutton->set_text(
407     note_str(spinbutton->get_adjustment()->get_value() + 0.5));
408     return true;
409 schoenebeck 1225 }
410     }
411    
412 persson 2507 // Make a SpinButton show notes instead of numbers
413     void spin_button_show_notes(Gtk::SpinButton& spin_button)
414 schoenebeck 1225 {
415 persson 2507 spin_button.set_numeric(false);
416     spin_button.set_width_chars(4);
417     spin_button.signal_input().connect(
418     sigc::bind(sigc::ptr_fun(&on_input), &spin_button));
419     spin_button.signal_output().connect(
420     sigc::bind(sigc::ptr_fun(&on_output), &spin_button));
421 schoenebeck 1225 }
422    
423 schoenebeck 3409 void ChoiceEntryBase::on_show_tooltips_changed() {
424     LabelWidget::on_show_tooltips_changed();
425    
426     const bool b = Settings::singleton()->showTooltips;
427     combobox.set_has_tooltip(b);
428     }
429    
430 schoenebeck 1225 ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) :
431 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
432 persson 2151 LabelWidget(labelText, align),
433     align(0, 0, 0, 0)
434 schoenebeck 3364 #else
435     LabelWidget(labelText, combobox)
436     #endif
437 schoenebeck 1225 {
438 schoenebeck 2538 for (int i = 0 ; i < controlChangeTextsSize ; i++) {
439 schoenebeck 2541 if (controlChangeTexts[i].txt) {
440 schoenebeck 2538 const int cc = i - 3;
441     Glib::ustring s = (i < 3)
442 schoenebeck 2541 ? controlChangeTexts[i].txt
443     : Glib::ustring::compose("CC%1: %2%3", cc, controlChangeTexts[i].txt, controlChangeTexts[i].isExtension ? " [EXT]" : "");
444 persson 2507 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2
445 schoenebeck 2538 combobox.append_text(s);
446 persson 2169 #else
447 schoenebeck 2538 combobox.append(s);
448 persson 2169 #endif
449 schoenebeck 1225 }
450     }
451 persson 3460 combobox.set_wrap_width(4);
452 schoenebeck 1225 combobox.signal_changed().connect(
453     sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed));
454 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
455 schoenebeck 1225 align.add(combobox);
456 schoenebeck 3364 #else
457     combobox.set_halign(Gtk::Align::FILL);
458     combobox.set_valign(Gtk::Align::FILL);
459     #endif
460 persson 1460 value.type = gig::leverage_ctrl_t::type_none;
461     value.controller_number = 0;
462 schoenebeck 1225 }
463    
464 schoenebeck 3409 void ChoiceEntryLeverageCtrl::on_show_tooltips_changed() {
465     LabelWidget::on_show_tooltips_changed();
466    
467     const bool b = Settings::singleton()->showTooltips;
468     combobox.set_has_tooltip(b);
469     }
470    
471 schoenebeck 3624 static void _showGigFormatExtWarning() {
472     if (!Settings::singleton()->warnUserOnExtensions) return;
473     Glib::ustring txt =
474     _("<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.)");
475     Gtk::MessageDialog msg(txt, true, Gtk::MESSAGE_WARNING);
476     msg.run();
477     }
478    
479 schoenebeck 1225 void ChoiceEntryLeverageCtrl::value_changed()
480     {
481 persson 1460 int rowno = combobox.get_active_row_number();
482     switch (rowno)
483     {
484     case -1:
485     break;
486     case 0:
487     value.type = gig::leverage_ctrl_t::type_none;
488     break;
489     case 1:
490     value.type = gig::leverage_ctrl_t::type_channelaftertouch;
491     break;
492     case 2:
493     value.type = gig::leverage_ctrl_t::type_velocity;
494     break;
495     default:
496     value.type = gig::leverage_ctrl_t::type_controlchange;
497     int x = 3;
498 schoenebeck 2538 for (uint cc = 0 ; cc < controlChangeTextsSize - 3 ; cc++) {
499 schoenebeck 2541 if (controlChangeTexts[cc + 3].txt) {
500 persson 1460 if (rowno == x) {
501     value.controller_number = cc;
502 schoenebeck 3624 if (controlChangeTexts[cc + 3].isExtension) {
503     _showGigFormatExtWarning();
504 schoenebeck 2541 }
505 persson 1460 break;
506 schoenebeck 1225 }
507 persson 1460 x++;
508 schoenebeck 1225 }
509     }
510 persson 1460 break;
511 schoenebeck 1225 }
512 persson 1460 if (rowno >= 0) sig_changed();
513 schoenebeck 1225 }
514    
515 persson 1460 void ChoiceEntryLeverageCtrl::set_value(gig::leverage_ctrl_t value)
516 schoenebeck 1225 {
517 schoenebeck 2538 int comboIndex;
518 persson 1460 switch (value.type)
519 schoenebeck 1225 {
520     case gig::leverage_ctrl_t::type_none:
521 schoenebeck 2538 comboIndex = 0;
522 schoenebeck 1225 break;
523     case gig::leverage_ctrl_t::type_channelaftertouch:
524 schoenebeck 2538 comboIndex = 1;
525 schoenebeck 1225 break;
526     case gig::leverage_ctrl_t::type_velocity:
527 schoenebeck 2538 comboIndex = 2;
528 schoenebeck 1225 break;
529 schoenebeck 2538 case gig::leverage_ctrl_t::type_controlchange: {
530     comboIndex = -1;
531     int x = 3;
532     for (uint cc = 0 ; cc < controlChangeTextsSize - 3 ; cc++) {
533 schoenebeck 2541 if (controlChangeTexts[cc + 3].txt) {
534 persson 1460 if (value.controller_number == cc) {
535 schoenebeck 2538 comboIndex = x;
536 schoenebeck 1225 break;
537     }
538 schoenebeck 2538 x++;
539 schoenebeck 1225 }
540     }
541     break;
542 schoenebeck 2538 }
543 schoenebeck 1225 default:
544 schoenebeck 2538 comboIndex = -1;
545 schoenebeck 1225 break;
546     }
547 schoenebeck 2538 combobox.set_active(comboIndex);
548 schoenebeck 1225 }
549    
550    
551 schoenebeck 3624 ChoiceEntryLfoWave::ChoiceEntryLfoWave(const char* labelText) :
552     #if HAS_GTKMM_ALIGNMENT
553     LabelWidget(labelText, align),
554     align(0, 0, 0, 0)
555     #else
556     LabelWidget(labelText, combobox)
557     #endif
558     {
559     for (int i = 0 ; i < lfoWaveTextsSize; i++) {
560     if (lfoWaveTexts[i]) {
561     Glib::ustring s = (i == 0)
562     ? lfoWaveTexts[i]
563     : Glib::ustring::compose("%1 [EXT]", lfoWaveTexts[i]);
564     #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2
565     combobox.append_text(s);
566     #else
567     combobox.append(s);
568     #endif
569     }
570     }
571     //combobox.set_wrap_width(4);
572     combobox.signal_changed().connect(
573     sigc::mem_fun(*this, &ChoiceEntryLfoWave::value_changed));
574     #if HAS_GTKMM_ALIGNMENT
575     align.add(combobox);
576     #else
577     combobox.set_halign(Gtk::Align::FILL);
578     combobox.set_valign(Gtk::Align::FILL);
579     #endif
580     value = gig::lfo_wave_sine;
581     }
582    
583     void ChoiceEntryLfoWave::on_show_tooltips_changed() {
584     LabelWidget::on_show_tooltips_changed();
585    
586     const bool b = Settings::singleton()->showTooltips;
587     combobox.set_has_tooltip(b);
588     }
589    
590     void ChoiceEntryLfoWave::value_changed() {
591     const int rowno = combobox.get_active_row_number();
592     switch (rowno) {
593     case -1:
594     break;
595     case 0:
596     value = gig::lfo_wave_sine;
597     break;
598     case 1:
599     value = gig::lfo_wave_triangle;
600     _showGigFormatExtWarning();
601     break;
602     case 2:
603     value = gig::lfo_wave_saw;
604     _showGigFormatExtWarning();
605     break;
606     case 3:
607     value = gig::lfo_wave_square;
608     _showGigFormatExtWarning();
609     break;
610     }
611     if (rowno >= 0) sig_changed();
612     }
613    
614     void ChoiceEntryLfoWave::set_value(gig::lfo_wave_t value) {
615     int comboIndex;
616     switch (value) {
617     case gig::lfo_wave_sine:
618     comboIndex = 0;
619     break;
620     case gig::lfo_wave_triangle:
621     comboIndex = 1;
622     break;
623     case gig::lfo_wave_saw:
624     comboIndex = 2;
625     break;
626     case gig::lfo_wave_square:
627     comboIndex = 3;
628     break;
629     default:
630     comboIndex = -1;
631     break;
632     }
633     combobox.set_active(comboIndex);
634     }
635    
636    
637 schoenebeck 3409 BoolBox::BoolBox(const char* labelText) : Gtk::CheckButton(labelText) {
638     signal_toggled().connect(sig_changed.make_slot());
639     Settings::singleton()->showTooltips.get_proxy().signal_changed().connect(
640 persson 3461 sigc::mem_fun(*this, &BoolBox::on_show_tooltips_changed)
641 schoenebeck 3409 );
642     on_show_tooltips_changed();
643     }
644    
645     void BoolBox::on_show_tooltips_changed() {
646     const bool b = Settings::singleton()->showTooltips;
647     set_has_tooltip(b);
648     }
649    
650    
651 schoenebeck 1225 BoolEntry::BoolEntry(const char* labelText) :
652     LabelWidget(labelText, checkbutton),
653 persson 1460 checkbutton(labelText)
654 schoenebeck 1225 {
655 persson 1460 checkbutton.signal_toggled().connect(sig_changed.make_slot());
656 schoenebeck 1225 }
657    
658    
659     StringEntry::StringEntry(const char* labelText) :
660     LabelWidget(labelText, entry)
661     {
662 persson 1582 entry.signal_changed().connect(sig_changed.make_slot());
663 schoenebeck 1225 }
664    
665 persson 2446 gig::String StringEntry::get_value() const
666     {
667     return gig_from_utf8(entry.get_text());
668     }
669    
670     void StringEntry::set_value(const gig::String& value) {
671     entry.set_text(gig_to_utf8(value));
672     }
673    
674    
675 persson 1582 StringEntryMultiLine::StringEntryMultiLine(const char* labelText) :
676     LabelWidget(labelText, frame)
677 schoenebeck 1225 {
678 persson 1582 text_buffer = text_view.get_buffer();
679     frame.set_shadow_type(Gtk::SHADOW_IN);
680     frame.add(text_view);
681     text_buffer->signal_changed().connect(sig_changed.make_slot());
682 schoenebeck 1225 }
683    
684 persson 1582 gig::String StringEntryMultiLine::get_value() const
685 schoenebeck 1225 {
686 persson 1582 Glib::ustring value = text_buffer->get_text();
687     for (int i = 0 ; (i = value.find("\x0a", i)) >= 0 ; i += 2)
688     value.replace(i, 1, "\x0d\x0a");
689 persson 2446 return gig_from_utf8(value);
690 schoenebeck 1225 }
691 persson 1582
692 persson 2446 void StringEntryMultiLine::set_value(const gig::String& value)
693 persson 1582 {
694 persson 2446 Glib::ustring text = gig_to_utf8(value);
695     for (int i = 0 ; (i = text.find("\x0d\x0a", i, 2)) >= 0 ; i++)
696     text.replace(i, 2, "\x0a");
697     text_buffer->set_text(text);
698 persson 1582 }
699 persson 2423
700 schoenebeck 3409 void StringEntryMultiLine::on_show_tooltips_changed() {
701     LabelWidget::on_show_tooltips_changed();
702 persson 2423
703 schoenebeck 3409 const bool b = Settings::singleton()->showTooltips;
704     text_view.set_has_tooltip(b);
705     }
706    
707    
708 schoenebeck 3364 Table::Table(int x, int y) :
709     #if USE_GTKMM_GRID
710     Gtk::Grid(),
711     cols(x),
712     #else
713     Gtk::Table(x, y),
714     #endif
715     rowno(0)
716     {
717     }
718 persson 2423
719     void Table::add(BoolEntry& boolentry)
720     {
721 schoenebeck 3364 #if USE_GTKMM_GRID
722     attach(boolentry.widget, 0, rowno, 2);
723     #else
724 persson 2423 attach(boolentry.widget, 0, 2, rowno, rowno + 1,
725     Gtk::FILL, Gtk::SHRINK);
726 schoenebeck 3364 #endif
727 persson 2423 rowno++;
728     }
729    
730     void Table::add(BoolEntryPlus6& boolentry)
731     {
732 schoenebeck 3364 #if USE_GTKMM_GRID
733     attach(boolentry.widget, 0, rowno, 2);
734     #else
735 persson 2423 attach(boolentry.widget, 0, 2, rowno, rowno + 1,
736     Gtk::FILL, Gtk::SHRINK);
737 schoenebeck 3364 #endif
738 persson 2423 rowno++;
739     }
740    
741     void Table::add(LabelWidget& prop)
742     {
743 schoenebeck 3364 #if USE_GTKMM_GRID
744     attach(prop.label, 1, rowno);
745     attach(prop.widget, 2, rowno);
746     #else
747 persson 2423 attach(prop.label, 1, 2, rowno, rowno + 1,
748     Gtk::FILL, Gtk::SHRINK);
749     attach(prop.widget, 2, 3, rowno, rowno + 1,
750     Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
751 schoenebeck 3364 #endif
752 persson 2423 rowno++;
753     }

  ViewVC Help
Powered by ViewVC