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

Diff of /gigedit/trunk/src/gigedit/paramedit.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2507 by persson, Sun Jan 12 19:37:55 2014 UTC revision 3624 by schoenebeck, Wed Oct 2 17:11:30 2019 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006-2014 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
# Line 20  Line 20 
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
# Line 42  Line 54 
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    
# Line 62  public: Line 70  public:
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
77      sigc::signal<void> sig_changed;      sigc::signal<void> sig_changed;
78  };  };
79    
80    class ReadOnlyLabelWidget : public LabelWidget {
81    public:
82        Gtk::Label text;
83    
84        ReadOnlyLabelWidget(const char* leftHandText);
85        ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText);
86    };
87    
88  class NumEntry : public LabelWidget {  class NumEntry : public LabelWidget {
89  protected:  protected:
90  #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
# Line 75  protected: Line 92  protected:
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);
# Line 99  public: Line 117  public:
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 {
# Line 186  public: Line 205  public:
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);
# Line 210  public: Line 236  public:
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    
# Line 254  class ChoiceEntryLeverageCtrl : public L Line 290  class ChoiceEntryLeverageCtrl : public L
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; }
302      void set_value(gig::leverage_ctrl_t value);      void set_value(gig::leverage_ctrl_t value);
303        void set_tip(const Glib::ustring& tip_text) {
304            combobox.set_tooltip_text(tip_text);
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    
# Line 280  public: Line 342  public:
342      }      }
343  };  };
344    
345    class BoolBox : public Gtk::CheckButton {
346    public:
347        BoolBox(const char* labelText);
348        bool get_value() const { return get_active(); }
349        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    
358  class BoolEntryPlus6 : public LabelWidget {  class BoolEntryPlus6 : public LabelWidget {
359  private:  private:
# Line 287  private: Line 361  private:
361      void value_changed();      void value_changed();
362      NumEntryGain& eGain;      NumEntryGain& eGain;
363      int32_t plus6value;      int32_t plus6value;
364    protected:
365        void on_show_tooltips_changed();
366  public:  public:
367      BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value);      BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value);
368      int32_t get_value() const;      int32_t get_value() const;
# Line 309  private: Line 385  private:
385      Gtk::TextView text_view;      Gtk::TextView text_view;
386      Glib::RefPtr<Gtk::TextBuffer> text_buffer;      Glib::RefPtr<Gtk::TextBuffer> text_buffer;
387      Gtk::Frame frame;      Gtk::Frame frame;
388    protected:
389        void on_show_tooltips_changed();
390  public:  public:
391      StringEntryMultiLine(const char* labelText);      StringEntryMultiLine(const char* labelText);
392      gig::String get_value() const;      gig::String get_value() const;
# Line 319  public: Line 397  public:
397  /**  /**
398   * Container widget for LabelWidgets.   * Container widget for LabelWidgets.
399   */   */
400  class Table : public Gtk::Table  class Table :
401    #if USE_GTKMM_GRID
402        public Gtk::Grid
403    #else
404        public Gtk::Table
405    #endif
406  {  {
407  public:  public:
408      Table(int x, int y);      Table(int x, int y);
# Line 327  public: Line 410  public:
410      void add(BoolEntryPlus6& boolentry);      void add(BoolEntryPlus6& boolentry);
411      void add(LabelWidget& labelwidget);      void add(LabelWidget& labelwidget);
412  private:  private:
413    #if USE_GTKMM_GRID
414        int cols;
415    #endif
416      int rowno;      int rowno;
417  };  };
418    
# Line 438  private: Line 524  private:
524    
525      void get_key_range(NoteEntry* eKeyRangeLow,      void get_key_range(NoteEntry* eKeyRangeLow,
526                         NoteEntry* eKeyRangeHigh,                         NoteEntry* eKeyRangeHigh,
527                         gig::range_t M::* range) {                         gig::range_t M::* range) const {
528          eKeyRangeLow->set_value((m->*range).low);          eKeyRangeLow->set_value((m->*range).low);
529          eKeyRangeHigh->set_value((m->*range).high);          eKeyRangeHigh->set_value((m->*range).high);
530      }      }

Legend:
Removed from v.2507  
changed lines
  Added in v.3624

  ViewVC Help
Powered by ViewVC