/[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 2446 by persson, Sun Apr 28 15:40:43 2013 UTC revision 3462 by persson, Sun Feb 3 13:27:28 2019 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006-2013 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    
57    int note_value(const Glib::ustring& note);
58    Glib::ustring note_str(int note);
59    
60  Glib::ustring gig_to_utf8(const gig::String& gig_string);  void spin_button_show_notes(Gtk::SpinButton& spin_button);
 gig::String gig_from_utf8(const Glib::ustring& utf8_string);  
   
61    
62  class LabelWidget {  class LabelWidget {
63  public:  public:
# Line 58  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 71  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 95  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 182  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 206  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      align(0, 0, 0, 0)      ChoiceEntryBase(labelText, align),
241        align(0, 0, 0, 0),
242    #else
243        ChoiceEntryBase(labelText, combobox),
244    #endif
245        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  {  {
256    #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++) {      for (int i = 0 ; texts[i] ; i++) {
 #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2  
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 249  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    
# Line 275  public: Line 323  public:
323      }      }
324  };  };
325    
326    class BoolBox : public Gtk::CheckButton {
327    public:
328        BoolBox(const char* labelText);
329        bool get_value() const { return get_active(); }
330        void set_value(bool value) { set_active(value); }
331        sigc::signal<void>& signal_value_changed() { return sig_changed; }
332    protected:
333        void on_show_tooltips_changed();
334    
335        sigc::signal<void> sig_changed;
336    };
337    
338    
339  class BoolEntryPlus6 : public LabelWidget {  class BoolEntryPlus6 : public LabelWidget {
340  private:  private:
# Line 282  private: Line 342  private:
342      void value_changed();      void value_changed();
343      NumEntryGain& eGain;      NumEntryGain& eGain;
344      int32_t plus6value;      int32_t plus6value;
345    protected:
346        void on_show_tooltips_changed();
347  public:  public:
348      BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value);      BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value);
349      int32_t get_value() const;      int32_t get_value() const;
# Line 304  private: Line 366  private:
366      Gtk::TextView text_view;      Gtk::TextView text_view;
367      Glib::RefPtr<Gtk::TextBuffer> text_buffer;      Glib::RefPtr<Gtk::TextBuffer> text_buffer;
368      Gtk::Frame frame;      Gtk::Frame frame;
369    protected:
370        void on_show_tooltips_changed();
371  public:  public:
372      StringEntryMultiLine(const char* labelText);      StringEntryMultiLine(const char* labelText);
373      gig::String get_value() const;      gig::String get_value() const;
# Line 314  public: Line 378  public:
378  /**  /**
379   * Container widget for LabelWidgets.   * Container widget for LabelWidgets.
380   */   */
381  class Table : public Gtk::Table  class Table :
382    #if USE_GTKMM_GRID
383        public Gtk::Grid
384    #else
385        public Gtk::Table
386    #endif
387  {  {
388  public:  public:
389      Table(int x, int y);      Table(int x, int y);
# Line 322  public: Line 391  public:
391      void add(BoolEntryPlus6& boolentry);      void add(BoolEntryPlus6& boolentry);
392      void add(LabelWidget& labelwidget);      void add(LabelWidget& labelwidget);
393  private:  private:
394    #if USE_GTKMM_GRID
395        int cols;
396    #endif
397      int rowno;      int rowno;
398  };  };
399    
# Line 341  public: Line 413  public:
413  protected:  protected:
414      M* m;      M* m;
415      int update_model; // to prevent infinite update loops      int update_model; // to prevent infinite update loops
416      PropEditor() : update_model(0) { }      PropEditor() : m(0), update_model(0) { }
417      sigc::signal<void> sig_changed;      sigc::signal<void> sig_changed;
418    
419      template<class C, typename T>      template<class C, typename T>
# Line 433  private: Line 505  private:
505    
506      void get_key_range(NoteEntry* eKeyRangeLow,      void get_key_range(NoteEntry* eKeyRangeLow,
507                         NoteEntry* eKeyRangeHigh,                         NoteEntry* eKeyRangeHigh,
508                         gig::range_t M::* range) {                         gig::range_t M::* range) const {
509          eKeyRangeLow->set_value((m->*range).low);          eKeyRangeLow->set_value((m->*range).low);
510          eKeyRangeHigh->set_value((m->*range).high);          eKeyRangeHigh->set_value((m->*range).high);
511      }      }

Legend:
Removed from v.2446  
changed lines
  Added in v.3462

  ViewVC Help
Powered by ViewVC