/[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 1359 by schoenebeck, Sun Sep 30 18:30:52 2007 UTC revision 1460 by persson, Sat Oct 27 12:28:33 2007 UTC
# Line 40  public: Line 40  public:
40    
41      LabelWidget(const char* labelText, Gtk::Widget& widget);      LabelWidget(const char* labelText, Gtk::Widget& widget);
42      void set_sensitive(bool sensitive = true);      void set_sensitive(bool sensitive = true);
43      sigc::signal<void>& signal_changed_by_user() {      sigc::signal<void>& signal_value_changed() {
44          return sig_changed;          return sig_changed;
45      }      }
46  protected:  protected:
# Line 61  protected: Line 61  protected:
61  public:  public:
62      NumEntry(const char* labelText, double lower = 0, double upper = 127,      NumEntry(const char* labelText, double lower = 0, double upper = 127,
63               int decimals = 0);               int decimals = 0);
     void set_value(double value) {  
         spinbutton.set_value(value);  
     }  
     double get_value() const {  
         return spinbutton.get_value();  
     }  
64      void set_tip(const Glib::ustring& tip_text) {      void set_tip(const Glib::ustring& tip_text) {
65          tooltips.set_tip(spinbutton, tip_text);          tooltips.set_tip(spinbutton, tip_text);
66      }      }
# Line 77  public: Line 71  public:
71    
72  class NumEntryGain : public NumEntry {  class NumEntryGain : public NumEntry {
73  private:  private:
74        int32_t value;
75      void value_changed();      void value_changed();
     int32_t* ptr;  
76      double coeff;      double coeff;
77  protected:      bool connected;
     sigc::signal<void> sig_to_be_changed;  
     sigc::signal<void, int32_t> sig_val_changed;  
78  public:  public:
79      NumEntryGain(const char* labelText,      NumEntryGain(const char* labelText,
80                   double lower, double upper, int decimals, double coeff);                   double lower, double upper, int decimals, double coeff);
81      void set_ptr(int32_t* ptr);      int32_t get_value() const { return value; }
82      sigc::signal<void>& signal_to_be_changed() {      void set_value(int32_t value);
         return sig_to_be_changed;  
     }  
     sigc::signal<void, int32_t>& signal_value_changed() {  
         return sig_val_changed;  
     }  
83  };  };
84    
85  template<typename T>  template<typename T>
86  class NumEntryTemp : public NumEntry {  class NumEntryTemp : public NumEntry {
87  private:  private:
88      T* ptr;      T value;
89      void value_changed();      void value_changed();
 protected:  
     sigc::signal<void> sig_to_be_changed;  
     sigc::signal<void, T> sig_val_changed;  
90  public:  public:
91      NumEntryTemp(const char* labelText,      NumEntryTemp(const char* labelText,
92                   double lower = 0, double upper = 127, int decimals = 0);                   double lower = 0, double upper = 127, int decimals = 0);
93      void set_ptr(T* ptr);      T get_value() const { return value; }
94      sigc::signal<void>& signal_to_be_changed() {      void set_value(T value);
         return sig_to_be_changed;  
     }  
     sigc::signal<void, T>& signal_value_changed() {  
         return sig_val_changed;  
     }  
95  };  };
96    
97  template<typename T>  template<typename T>
98  NumEntryTemp<T>::NumEntryTemp(const char* labelText,  NumEntryTemp<T>::NumEntryTemp(const char* labelText,
99                                double lower, double upper, int decimals) :                                double lower, double upper, int decimals) :
100      NumEntry(labelText, lower, upper, decimals)      NumEntry(labelText, lower, upper, decimals),
101        value(0)
102  {  {
103      spinbutton.signal_value_changed().connect(      spinbutton.signal_value_changed().connect(
104          sigc::mem_fun(*this, &NumEntryTemp::value_changed));          sigc::mem_fun(*this, &NumEntryTemp::value_changed));
# Line 129  void NumEntryTemp<T>::value_changed() Line 109  void NumEntryTemp<T>::value_changed()
109  {  {
110      const double f = pow(10, spinbutton.get_digits());      const double f = pow(10, spinbutton.get_digits());
111      int new_value = round_to_int(spinbutton.get_value() * f);      int new_value = round_to_int(spinbutton.get_value() * f);
112      const T val = T(new_value / f);      if (new_value != round_to_int(value * f)) {
113      if (ptr) {          value = T(new_value / f);
114          if (new_value != round_to_int(*ptr * f)) {          sig_changed();
             sig_to_be_changed.emit();  
             *ptr = val;  
             sig_val_changed.emit(val);  
             sig_changed.emit();  
         }  
     } else {  
         sig_to_be_changed.emit();  
         sig_val_changed.emit(val);  
         sig_changed.emit();  
115      }      }
116  }  }
117    
118  template<typename T>  template<typename T>
119  void NumEntryTemp<T>::set_ptr(T* ptr)  void NumEntryTemp<T>::set_value(T value)
120  {  {
121      this->ptr = 0;      if (value > adjust.get_upper()) value = T(adjust.get_upper());
122      if (ptr) set_value(*ptr);      if (this->value != value) {
123      this->ptr = ptr;          this->value = value;
124            const double f = pow(10, spinbutton.get_digits());
125            if (round_to_int(spinbutton.get_value() * f) != round_to_int(value * f)) {
126                spinbutton.set_value(value);
127            }
128            sig_changed();
129        }
130  }  }
131    
132    
# Line 164  private: Line 141  private:
141    
142  class NumEntryPermille : public NumEntry {  class NumEntryPermille : public NumEntry {
143  private:  private:
144      uint16_t* ptr;      uint16_t value;
145      void value_changed();      void value_changed();
146  public:  public:
147      NumEntryPermille(const char* labelText,      NumEntryPermille(const char* labelText,
148                       double lower = 0, double upper = 127, int decimals = 0);                       double lower = 0, double upper = 127, int decimals = 0);
149      void set_ptr(uint16_t* ptr);      uint16_t get_value() const { return value; }
150        void set_value(uint16_t value);
151  };  };
152    
153    
# Line 178  class ChoiceEntry : public LabelWidget { Line 156  class ChoiceEntry : public LabelWidget {
156  private:  private:
157      Gtk::ComboBoxText combobox;      Gtk::ComboBoxText combobox;
158      Gtk::Alignment align;      Gtk::Alignment align;
     T* ptr;  
     void value_changed();  
159      const T* values;      const T* values;
 protected:  
     sigc::signal<void> sig_to_be_changed;  
     sigc::signal<void, T> sig_val_changed;  
160  public:  public:
161      ChoiceEntry(const char* labelText);      ChoiceEntry(const char* labelText);
162        T get_value() const;
163        void set_value(T value);
164      void set_choices(const char** texts, const T* values);      void set_choices(const char** texts, const T* values);
165      void set_ptr(T* ptr);  
     int get_active_row_number() { return combobox.get_active_row_number(); }  
     sigc::signal<void>& signal_to_be_changed() {  
         return sig_to_be_changed;  
     }  
     sigc::signal<void, T>& signal_value_changed() {  
         return sig_val_changed;  
     }  
     Glib::SignalProxy0<void> signal_changed() {  
         return combobox.signal_changed();  
     }  
166      void set_tip(const Glib::ustring& tip_text) {      void set_tip(const Glib::ustring& tip_text) {
167          tooltips.set_tip(combobox, tip_text); //FIXME: don't Gtk::ComboBoxes support tooltips ???          tooltips.set_tip(combobox, tip_text); //FIXME: don't Gtk::ComboBoxes support tooltips ???
168      }      }
# Line 208  ChoiceEntry<T>::ChoiceEntry(const char* Line 173  ChoiceEntry<T>::ChoiceEntry(const char*
173      align(0, 0, 0, 0),      align(0, 0, 0, 0),
174      LabelWidget(labelText, align)      LabelWidget(labelText, align)
175  {  {
176      combobox.signal_changed().connect(      combobox.signal_changed().connect(sig_changed.make_slot());
         sigc::mem_fun(*this, &ChoiceEntry::value_changed));  
177      align.add(combobox);      align.add(combobox);
178  }  }
179    
# Line 223  void ChoiceEntry<T>::set_choices(const c Line 187  void ChoiceEntry<T>::set_choices(const c
187  }  }
188    
189  template<typename T>  template<typename T>
190  void ChoiceEntry<T>::value_changed()  T ChoiceEntry<T>::get_value() const
191  {  {
192      int rowno = combobox.get_active_row_number();      int rowno = combobox.get_active_row_number();
193      if (rowno == -1) return;      return values[rowno];
     const T val = values[rowno];  
     sig_to_be_changed.emit();  
     if (ptr) *ptr = val;  
     sig_val_changed.emit(val);  
     sig_changed.emit();  
194  }  }
195    
196  template<typename T>  template<typename T>
197  void ChoiceEntry<T>::set_ptr(T* ptr)  void ChoiceEntry<T>::set_value(T value)
198  {  {
199      this->ptr = 0;      int row = 0;
200      if (ptr) {      int nb_rows = combobox.get_model()->children().size();
201          T value = *ptr;      for (; row < nb_rows ; row++) {
202          int row = 0;          if (value == values[row]) break;
203          int nb_rows = combobox.get_model()->children().size();      }
204          for (; row < nb_rows ; row++) {      combobox.set_active(row == nb_rows ? -1 : row);
             if (value == values[row]) break;  
         }  
         combobox.set_active(row == nb_rows ? -1 : row);  
     } else combobox.set_active(-1);  
     this->ptr = ptr;  
205  }  }
206    
207    
208  class ChoiceEntryLeverageCtrl : public LabelWidget {  class ChoiceEntryLeverageCtrl : public LabelWidget {
209  private:  private:
210        gig::leverage_ctrl_t value;
211      Gtk::ComboBoxText combobox;      Gtk::ComboBoxText combobox;
212      Gtk::Alignment align;      Gtk::Alignment align;
     gig::leverage_ctrl_t* ptr;  
213      void value_changed();      void value_changed();
214  public:  public:
215      ChoiceEntryLeverageCtrl(const char* labelText);      ChoiceEntryLeverageCtrl(const char* labelText);
216      void set_ptr(gig::leverage_ctrl_t* ptr);      gig::leverage_ctrl_t get_value() const { return value; }
217      int get_active_row_number() { return combobox.get_active_row_number(); }      void set_value(gig::leverage_ctrl_t value);
     Glib::SignalProxy0<void> signal_changed() {  
         return combobox.signal_changed();  
     }  
218  };  };
219    
220    
221  class BoolEntry : public LabelWidget {  class BoolEntry : public LabelWidget {
222  private:  private:
223      Gtk::CheckButton checkbutton;      Gtk::CheckButton checkbutton;
     bool* ptr;  
     void value_changed();  
224  public:  public:
225      BoolEntry(const char* labelText);      BoolEntry(const char* labelText);
226      bool get_active() { return checkbutton.get_active(); }      bool get_value() const { return checkbutton.get_active(); }
227      bool set_active(bool b) { checkbutton.set_active(b); }      void set_value(bool value) { checkbutton.set_active(value); }
228      Glib::SignalProxy0<void> signal_toggled() {  
         return checkbutton.signal_toggled();  
     }  
     void set_ptr(bool* ptr);  
229      void set_tip(const Glib::ustring& tip_text) {      void set_tip(const Glib::ustring& tip_text) {
230          tooltips.set_tip(checkbutton, tip_text);          tooltips.set_tip(checkbutton, tip_text);
231      }      }
# Line 289  public: Line 235  public:
235  class BoolEntryPlus6 : public LabelWidget {  class BoolEntryPlus6 : public LabelWidget {
236  private:  private:
237      Gtk::CheckButton checkbutton;      Gtk::CheckButton checkbutton;
     int32_t* ptr;  
238      void value_changed();      void value_changed();
239      NumEntryGain& eGain;      NumEntryGain& eGain;
240      int32_t plus6value;      int32_t plus6value;
241  public:  public:
242      BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value);      BoolEntryPlus6(const char* labelText, NumEntryGain& eGain, int32_t plus6value);
243      void set_ptr(int32_t* ptr);      int32_t get_value() const;
244      bool get_active() { return checkbutton.get_active(); }      void set_value(int32_t value);
     Glib::SignalProxy0<void> signal_toggled() {  
         return checkbutton.signal_toggled();  
     }  
245  };  };
246    
247  class StringEntry : public LabelWidget {  class StringEntry : public LabelWidget {

Legend:
Removed from v.1359  
changed lines
  Added in v.1460

  ViewVC Help
Powered by ViewVC