/[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 3643 - (hide annotations) (download)
Sat Dec 7 15:04:51 2019 UTC (4 years, 5 months ago) by schoenebeck
File size: 21394 byte(s)
* Gain: Allow also any positive gain dB value (instead of only +6 dB) up
  to +96 dB and dropped the old "Gain +6dB" checkbox for that reason.

* Instrument Properties Dialog: Allow -96 dB .. +96 dB and dropped
  "Gain +6dB" checkbox there as well.

* Instrument Properties Dialog: Show unit for attenuation and pitchbend
  range.

* Bumped version (1.1.1.svn7).

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 schoenebeck 3643 spinbutton.set_value(value / coeff);
267 persson 1460 connected = true;
268    
269     sig_changed();
270     }
271 schoenebeck 1225 }
272    
273    
274     NumEntryPermille::NumEntryPermille(const char* labelText,
275     double lower, double upper, int decimals) :
276 persson 1460 NumEntry(labelText, lower, upper, decimals),
277     value(0)
278 schoenebeck 1225 {
279     spinbutton.signal_value_changed().connect(
280     sigc::mem_fun(*this, &NumEntryPermille::value_changed));
281     }
282    
283     void NumEntryPermille::value_changed()
284     {
285 persson 1460 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 schoenebeck 1225 }
290     }
291    
292 persson 1460 void NumEntryPermille::set_value(uint16_t value)
293 schoenebeck 1225 {
294 persson 1460 if (value != this->value) {
295     spinbutton.set_value(value / 10.0);
296     }
297 schoenebeck 1225 }
298    
299    
300     NoteEntry::NoteEntry(const char* labelText) :
301     NumEntryTemp<uint8_t>(labelText)
302     {
303 persson 2507 spin_button_show_notes(spinbutton);
304 schoenebeck 1225 }
305    
306 persson 2507 namespace {
307     const char* notes[] = {
308     _("C"), _("C#"), _("D"), _("D#"), _("E"), _("F"),_("F#"),
309     _("G"), _("G#"), _("A"), _("A#"), _("B")
310     };
311 schoenebeck 1225
312 persson 2507 int note_value(const Glib::ustring& note, double* value)
313     {
314     const char* str = note.c_str();
315 schoenebeck 1225
316 persson 2507 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 schoenebeck 3364
336     #if HAS_GTKMM_CPP11_ENUMS
337     return Gtk::SpinButton::INPUT_ERROR;
338     #else
339 persson 2507 return Gtk::INPUT_ERROR;
340 schoenebeck 3364 #endif
341 persson 2507 }
342     }
343    
344     int note_value(const Glib::ustring& note)
345 schoenebeck 1225 {
346 persson 2507 double value = 0;
347     note_value(note, &value);
348     return value;
349     }
350 schoenebeck 1225
351 persson 2507 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 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
361     int on_input(double& new_value, Gtk::SpinButton* spinbutton) {
362     return note_value(spinbutton->get_text(), &new_value);
363     }
364     #else
365 persson 2507 int on_input(double* new_value, Gtk::SpinButton* spinbutton) {
366     return note_value(spinbutton->get_text(), new_value);
367 schoenebeck 1225 }
368 schoenebeck 3364 #endif
369 persson 2507
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 schoenebeck 1225 }
376     }
377    
378 persson 2507 // Make a SpinButton show notes instead of numbers
379     void spin_button_show_notes(Gtk::SpinButton& spin_button)
380 schoenebeck 1225 {
381 persson 2507 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 schoenebeck 1225 }
388    
389 schoenebeck 3409 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 schoenebeck 1225 ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) :
397 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
398 persson 2151 LabelWidget(labelText, align),
399     align(0, 0, 0, 0)
400 schoenebeck 3364 #else
401     LabelWidget(labelText, combobox)
402     #endif
403 schoenebeck 1225 {
404 schoenebeck 2538 for (int i = 0 ; i < controlChangeTextsSize ; i++) {
405 schoenebeck 2541 if (controlChangeTexts[i].txt) {
406 schoenebeck 2538 const int cc = i - 3;
407     Glib::ustring s = (i < 3)
408 schoenebeck 2541 ? controlChangeTexts[i].txt
409     : Glib::ustring::compose("CC%1: %2%3", cc, controlChangeTexts[i].txt, controlChangeTexts[i].isExtension ? " [EXT]" : "");
410 persson 2507 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2
411 schoenebeck 2538 combobox.append_text(s);
412 persson 2169 #else
413 schoenebeck 2538 combobox.append(s);
414 persson 2169 #endif
415 schoenebeck 1225 }
416     }
417 persson 3460 combobox.set_wrap_width(4);
418 schoenebeck 1225 combobox.signal_changed().connect(
419     sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed));
420 schoenebeck 3364 #if HAS_GTKMM_ALIGNMENT
421 schoenebeck 1225 align.add(combobox);
422 schoenebeck 3364 #else
423     combobox.set_halign(Gtk::Align::FILL);
424     combobox.set_valign(Gtk::Align::FILL);
425     #endif
426 persson 1460 value.type = gig::leverage_ctrl_t::type_none;
427     value.controller_number = 0;
428 schoenebeck 1225 }
429    
430 schoenebeck 3409 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 schoenebeck 3624 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 schoenebeck 1225 void ChoiceEntryLeverageCtrl::value_changed()
446     {
447 persson 1460 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 schoenebeck 2538 for (uint cc = 0 ; cc < controlChangeTextsSize - 3 ; cc++) {
465 schoenebeck 2541 if (controlChangeTexts[cc + 3].txt) {
466 persson 1460 if (rowno == x) {
467     value.controller_number = cc;
468 schoenebeck 3624 if (controlChangeTexts[cc + 3].isExtension) {
469     _showGigFormatExtWarning();
470 schoenebeck 2541 }
471 persson 1460 break;
472 schoenebeck 1225 }
473 persson 1460 x++;
474 schoenebeck 1225 }
475     }
476 persson 1460 break;
477 schoenebeck 1225 }
478 persson 1460 if (rowno >= 0) sig_changed();
479 schoenebeck 1225 }
480    
481 persson 1460 void ChoiceEntryLeverageCtrl::set_value(gig::leverage_ctrl_t value)
482 schoenebeck 1225 {
483 schoenebeck 2538 int comboIndex;
484 persson 1460 switch (value.type)
485 schoenebeck 1225 {
486     case gig::leverage_ctrl_t::type_none:
487 schoenebeck 2538 comboIndex = 0;
488 schoenebeck 1225 break;
489     case gig::leverage_ctrl_t::type_channelaftertouch:
490 schoenebeck 2538 comboIndex = 1;
491 schoenebeck 1225 break;
492     case gig::leverage_ctrl_t::type_velocity:
493 schoenebeck 2538 comboIndex = 2;
494 schoenebeck 1225 break;
495 schoenebeck 2538 case gig::leverage_ctrl_t::type_controlchange: {
496     comboIndex = -1;
497     int x = 3;
498     for (uint cc = 0 ; cc < controlChangeTextsSize - 3 ; cc++) {
499 schoenebeck 2541 if (controlChangeTexts[cc + 3].txt) {
500 persson 1460 if (value.controller_number == cc) {
501 schoenebeck 2538 comboIndex = x;
502 schoenebeck 1225 break;
503     }
504 schoenebeck 2538 x++;
505 schoenebeck 1225 }
506     }
507     break;
508 schoenebeck 2538 }
509 schoenebeck 1225 default:
510 schoenebeck 2538 comboIndex = -1;
511 schoenebeck 1225 break;
512     }
513 schoenebeck 2538 combobox.set_active(comboIndex);
514 schoenebeck 1225 }
515    
516    
517 schoenebeck 3624 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 schoenebeck 3409 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 persson 3461 sigc::mem_fun(*this, &BoolBox::on_show_tooltips_changed)
607 schoenebeck 3409 );
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 schoenebeck 1225 BoolEntry::BoolEntry(const char* labelText) :
618     LabelWidget(labelText, checkbutton),
619 persson 1460 checkbutton(labelText)
620 schoenebeck 1225 {
621 persson 1460 checkbutton.signal_toggled().connect(sig_changed.make_slot());
622 schoenebeck 1225 }
623    
624    
625     StringEntry::StringEntry(const char* labelText) :
626     LabelWidget(labelText, entry)
627     {
628 persson 1582 entry.signal_changed().connect(sig_changed.make_slot());
629 schoenebeck 1225 }
630    
631 persson 2446 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 persson 1582 StringEntryMultiLine::StringEntryMultiLine(const char* labelText) :
642     LabelWidget(labelText, frame)
643 schoenebeck 1225 {
644 persson 1582 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 schoenebeck 1225 }
649    
650 persson 1582 gig::String StringEntryMultiLine::get_value() const
651 schoenebeck 1225 {
652 persson 1582 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 persson 2446 return gig_from_utf8(value);
656 schoenebeck 1225 }
657 persson 1582
658 persson 2446 void StringEntryMultiLine::set_value(const gig::String& value)
659 persson 1582 {
660 persson 2446 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 persson 1582 }
665 persson 2423
666 schoenebeck 3409 void StringEntryMultiLine::on_show_tooltips_changed() {
667     LabelWidget::on_show_tooltips_changed();
668 persson 2423
669 schoenebeck 3409 const bool b = Settings::singleton()->showTooltips;
670     text_view.set_has_tooltip(b);
671     }
672    
673    
674 schoenebeck 3364 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 persson 2423
685     void Table::add(BoolEntry& boolentry)
686     {
687 schoenebeck 3364 #if USE_GTKMM_GRID
688     attach(boolentry.widget, 0, rowno, 2);
689     #else
690 persson 2423 attach(boolentry.widget, 0, 2, rowno, rowno + 1,
691     Gtk::FILL, Gtk::SHRINK);
692 schoenebeck 3364 #endif
693 persson 2423 rowno++;
694     }
695    
696     void Table::add(LabelWidget& prop)
697     {
698 schoenebeck 3364 #if USE_GTKMM_GRID
699     attach(prop.label, 1, rowno);
700     attach(prop.widget, 2, rowno);
701     #else
702 persson 2423 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 schoenebeck 3364 #endif
707 persson 2423 rowno++;
708     }

  ViewVC Help
Powered by ViewVC