1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006-2015 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 |
20 |
#ifndef GIGEDIT_PARAMEDIT_H |
#ifndef GIGEDIT_PARAMEDIT_H |
21 |
#define GIGEDIT_PARAMEDIT_H |
#define GIGEDIT_PARAMEDIT_H |
22 |
|
|
23 |
#include <gig.h> |
#ifdef LIBGIG_HEADER_FILE |
24 |
|
# include LIBGIG_HEADER_FILE(gig.h) |
25 |
|
#else |
26 |
|
# include <gig.h> |
27 |
|
#endif |
28 |
|
|
29 |
#include <cmath> |
#include <cmath> |
30 |
|
|
31 |
|
#include "compat.h" |
32 |
|
|
33 |
#include <glibmm/convert.h> |
#include <glibmm/convert.h> |
|
#include <gtkmm/adjustment.h> |
|
|
#include <gtkmm/alignment.h> |
|
34 |
#include <gtkmm/box.h> |
#include <gtkmm/box.h> |
35 |
|
#include <gtkmm/adjustment.h> |
36 |
|
#if HAS_GTKMM_ALIGNMENT |
37 |
|
# include <gtkmm/alignment.h> |
38 |
|
#endif |
39 |
#include <gtkmm/checkbutton.h> |
#include <gtkmm/checkbutton.h> |
40 |
#include <gtkmm/comboboxtext.h> |
#include <gtkmm/comboboxtext.h> |
41 |
#include <gtkmm/frame.h> |
#include <gtkmm/frame.h> |
42 |
#include <gtkmm/label.h> |
#include <gtkmm/label.h> |
43 |
#include <gtkmm/scale.h> |
#include <gtkmm/scale.h> |
44 |
#include <gtkmm/spinbutton.h> |
#include <gtkmm/spinbutton.h> |
45 |
#include <gtkmm/table.h> |
#if USE_GTKMM_GRID |
46 |
|
# include <gtkmm/grid.h> |
47 |
|
#else |
48 |
|
# include <gtkmm/table.h> |
49 |
|
#endif |
50 |
#include <gtkmm/textview.h> |
#include <gtkmm/textview.h> |
51 |
|
|
52 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 12) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 12) || GTKMM_MAJOR_VERSION < 2 |
54 |
#include <gtkmm/tooltips.h> |
#include <gtkmm/tooltips.h> |
55 |
#endif |
#endif |
56 |
|
|
|
|
|
|
Glib::ustring gig_to_utf8(const gig::String& gig_string); |
|
|
gig::String gig_from_utf8(const Glib::ustring& utf8_string); |
|
|
|
|
57 |
int note_value(const Glib::ustring& note); |
int note_value(const Glib::ustring& note); |
58 |
Glib::ustring note_str(int note); |
Glib::ustring note_str(int note); |
59 |
|
|
70 |
return sig_changed; |
return sig_changed; |
71 |
} |
} |
72 |
protected: |
protected: |
73 |
|
virtual void on_show_tooltips_changed(); |
74 |
#ifdef OLD_TOOLTIPS |
#ifdef OLD_TOOLTIPS |
75 |
Gtk::Tooltips tooltips; |
Gtk::Tooltips tooltips; |
76 |
#endif |
#endif |
92 |
#else |
#else |
93 |
Glib::RefPtr<Gtk::Adjustment> adjust; |
Glib::RefPtr<Gtk::Adjustment> adjust; |
94 |
#endif |
#endif |
95 |
Gtk::HScale scale; |
HScale scale; |
96 |
Gtk::SpinButton spinbutton; |
Gtk::SpinButton spinbutton; |
97 |
Gtk::HBox box; |
HBox box; |
98 |
|
|
99 |
int round_to_int(double x) { |
static int round_to_int(double x) { |
100 |
return int(x < 0.0 ? x - 0.5 : x + 0.5); |
return int(x < 0.0 ? x - 0.5 : x + 0.5); |
101 |
} |
} |
102 |
|
|
103 |
public: |
public: |
104 |
NumEntry(const char* labelText, double lower = 0, double upper = 127, |
NumEntry(const char* labelText, double lower = 0, double upper = 127, |
105 |
int decimals = 0); |
int decimals = 0); |
117 |
adjust->set_upper(upper); |
adjust->set_upper(upper); |
118 |
#endif |
#endif |
119 |
} |
} |
120 |
|
void on_show_tooltips_changed(); |
121 |
}; |
}; |
122 |
|
|
123 |
class NumEntryGain : public NumEntry { |
class NumEntryGain : public NumEntry { |
205 |
void set_value(uint16_t value); |
void set_value(uint16_t value); |
206 |
}; |
}; |
207 |
|
|
208 |
|
class ChoiceEntryBase : public LabelWidget { |
209 |
|
protected: |
210 |
|
ChoiceEntryBase(const char* labelText, Gtk::Widget& widget) : LabelWidget(labelText, widget) {}; |
211 |
|
Gtk::ComboBoxText combobox; |
212 |
|
void on_show_tooltips_changed(); |
213 |
|
}; |
214 |
|
|
215 |
template<typename T> |
template<typename T> |
216 |
class ChoiceEntry : public LabelWidget { |
class ChoiceEntry : public ChoiceEntryBase { |
217 |
private: |
private: |
218 |
Gtk::ComboBoxText combobox; |
#if HAS_GTKMM_ALIGNMENT |
219 |
Gtk::Alignment align; |
Gtk::Alignment align; |
220 |
|
#endif |
221 |
const T* values; |
const T* values; |
222 |
public: |
public: |
223 |
ChoiceEntry(const char* labelText); |
ChoiceEntry(const char* labelText); |
236 |
|
|
237 |
template<typename T> |
template<typename T> |
238 |
ChoiceEntry<T>::ChoiceEntry(const char* labelText) : |
ChoiceEntry<T>::ChoiceEntry(const char* labelText) : |
239 |
LabelWidget(labelText, align), |
#if HAS_GTKMM_ALIGNMENT |
240 |
|
ChoiceEntryBase(labelText, align), |
241 |
align(0, 0, 0, 0), |
align(0, 0, 0, 0), |
242 |
|
#else |
243 |
|
ChoiceEntryBase(labelText, combobox), |
244 |
|
#endif |
245 |
values(0) |
values(0) |
246 |
{ |
{ |
247 |
combobox.signal_changed().connect(sig_changed.make_slot()); |
combobox.signal_changed().connect(sig_changed.make_slot()); |
248 |
|
#if HAS_GTKMM_ALIGNMENT |
249 |
align.add(combobox); |
align.add(combobox); |
250 |
|
#endif |
251 |
} |
} |
252 |
|
|
253 |
template<typename T> |
template<typename T> |
254 |
void ChoiceEntry<T>::set_choices(const char** texts, const T* values) |
void ChoiceEntry<T>::set_choices(const char** texts, const T* values) |
255 |
{ |
{ |
|
for (int i = 0 ; texts[i] ; i++) { |
|
256 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 24) || GTKMM_MAJOR_VERSION < 2 |
257 |
|
combobox.clear_items(); |
258 |
|
for (int i = 0 ; texts[i] ; i++) { |
259 |
combobox.append_text(texts[i]); |
combobox.append_text(texts[i]); |
260 |
|
} |
261 |
#else |
#else |
262 |
|
combobox.remove_all(); |
263 |
|
for (int i = 0 ; texts[i] ; i++) { |
264 |
combobox.append(texts[i]); |
combobox.append(texts[i]); |
|
#endif |
|
265 |
} |
} |
266 |
|
#endif |
267 |
this->values = values; |
this->values = values; |
268 |
} |
} |
269 |
|
|
290 |
private: |
private: |
291 |
gig::leverage_ctrl_t value; |
gig::leverage_ctrl_t value; |
292 |
Gtk::ComboBoxText combobox; |
Gtk::ComboBoxText combobox; |
293 |
|
#if HAS_GTKMM_ALIGNMENT |
294 |
Gtk::Alignment align; |
Gtk::Alignment align; |
295 |
|
#endif |
296 |
void value_changed(); |
void value_changed(); |
297 |
|
protected: |
298 |
|
void on_show_tooltips_changed(); |
299 |
public: |
public: |
300 |
ChoiceEntryLeverageCtrl(const char* labelText); |
ChoiceEntryLeverageCtrl(const char* labelText); |
301 |
gig::leverage_ctrl_t get_value() const { return value; } |
gig::leverage_ctrl_t get_value() const { return value; } |
305 |
} |
} |
306 |
}; |
}; |
307 |
|
|
308 |
|
class ChoiceEntryLfoWave : public LabelWidget { |
309 |
|
private: |
310 |
|
gig::lfo_wave_t value; |
311 |
|
Gtk::ComboBoxText combobox; |
312 |
|
#if HAS_GTKMM_ALIGNMENT |
313 |
|
Gtk::Alignment align; |
314 |
|
#endif |
315 |
|
void value_changed(); |
316 |
|
protected: |
317 |
|
void on_show_tooltips_changed(); |
318 |
|
public: |
319 |
|
ChoiceEntryLfoWave(const char* labelText); |
320 |
|
gig::lfo_wave_t get_value() const { return value; } |
321 |
|
void set_value(gig::lfo_wave_t value); |
322 |
|
void set_tip(const Glib::ustring& tip_text) { |
323 |
|
combobox.set_tooltip_text(tip_text); |
324 |
|
} |
325 |
|
}; |
326 |
|
|
327 |
|
|
328 |
class BoolEntry : public LabelWidget { |
class BoolEntry : public LabelWidget { |
329 |
private: |
private: |
342 |
} |
} |
343 |
}; |
}; |
344 |
|
|
345 |
|
class BoolBox : public Gtk::CheckButton { |
|
class BoolEntryPlus6 : public LabelWidget { |
|
|
private: |
|
|
Gtk::CheckButton checkbutton; |
|
|
void value_changed(); |
|
|
NumEntryGain& eGain; |
|
|
int32_t plus6value; |
|
346 |
public: |
public: |
347 |
BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value); |
BoolBox(const char* labelText); |
348 |
int32_t get_value() const; |
bool get_value() const { return get_active(); } |
349 |
void set_value(int32_t value); |
void set_value(bool value) { set_active(value); } |
350 |
|
sigc::signal<void>& signal_value_changed() { return sig_changed; } |
351 |
|
protected: |
352 |
|
void on_show_tooltips_changed(); |
353 |
|
|
354 |
|
sigc::signal<void> sig_changed; |
355 |
}; |
}; |
356 |
|
|
357 |
|
|
370 |
Gtk::TextView text_view; |
Gtk::TextView text_view; |
371 |
Glib::RefPtr<Gtk::TextBuffer> text_buffer; |
Glib::RefPtr<Gtk::TextBuffer> text_buffer; |
372 |
Gtk::Frame frame; |
Gtk::Frame frame; |
373 |
|
protected: |
374 |
|
void on_show_tooltips_changed(); |
375 |
public: |
public: |
376 |
StringEntryMultiLine(const char* labelText); |
StringEntryMultiLine(const char* labelText); |
377 |
gig::String get_value() const; |
gig::String get_value() const; |
382 |
/** |
/** |
383 |
* Container widget for LabelWidgets. |
* Container widget for LabelWidgets. |
384 |
*/ |
*/ |
385 |
class Table : public Gtk::Table |
class Table : |
386 |
|
#if USE_GTKMM_GRID |
387 |
|
public Gtk::Grid |
388 |
|
#else |
389 |
|
public Gtk::Table |
390 |
|
#endif |
391 |
{ |
{ |
392 |
public: |
public: |
393 |
Table(int x, int y); |
Table(int x, int y); |
394 |
void add(BoolEntry& boolentry); |
void add(BoolEntry& boolentry); |
|
void add(BoolEntryPlus6& boolentry); |
|
395 |
void add(LabelWidget& labelwidget); |
void add(LabelWidget& labelwidget); |
396 |
private: |
private: |
397 |
|
#if USE_GTKMM_GRID |
398 |
|
int cols; |
399 |
|
#endif |
400 |
int rowno; |
int rowno; |
401 |
}; |
}; |
402 |
|
|
442 |
sigc::bind(sigc::mem_fun(*this, f), &widget, setter)); |
sigc::bind(sigc::mem_fun(*this, f), &widget, setter)); |
443 |
} |
} |
444 |
|
|
445 |
|
template<class C, class F> |
446 |
|
void connectLambda(C& widget, F fn) { |
447 |
|
widget.signal_value_changed().connect([&widget,fn]{ |
448 |
|
fn( widget.get_value() ); |
449 |
|
}); |
450 |
|
} |
451 |
|
|
452 |
void connect(NoteEntry& eKeyRangeLow, NoteEntry& eKeyRangeHigh, |
void connect(NoteEntry& eKeyRangeLow, NoteEntry& eKeyRangeHigh, |
453 |
gig::range_t M::* range) { |
gig::range_t M::* range) { |
454 |
eKeyRangeLow.signal_value_changed().connect( |
eKeyRangeLow.signal_value_changed().connect( |
515 |
|
|
516 |
void get_key_range(NoteEntry* eKeyRangeLow, |
void get_key_range(NoteEntry* eKeyRangeLow, |
517 |
NoteEntry* eKeyRangeHigh, |
NoteEntry* eKeyRangeHigh, |
518 |
gig::range_t M::* range) { |
gig::range_t M::* range) const { |
519 |
eKeyRangeLow->set_value((m->*range).low); |
eKeyRangeLow->set_value((m->*range).low); |
520 |
eKeyRangeHigh->set_value((m->*range).high); |
eKeyRangeHigh->set_value((m->*range).high); |
521 |
} |
} |