/[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 1260 by schoenebeck, Sun Jun 10 10:56:11 2007 UTC revision 1261 by persson, Thu Jul 5 17:12:20 2007 UTC
# Line 31  Line 31 
31  #include <gtkmm/spinbutton.h>  #include <gtkmm/spinbutton.h>
32  #include <gtkmm/tooltips.h>  #include <gtkmm/tooltips.h>
33    
 extern bool update_gui;  
   
34  class LabelWidget {  class LabelWidget {
35  public:  public:
36      Gtk::Label label;      Gtk::Label label;
# Line 40  public: Line 38  public:
38    
39      LabelWidget(const char* labelText, Gtk::Widget& widget);      LabelWidget(const char* labelText, Gtk::Widget& widget);
40      void set_sensitive(bool sensitive = true);      void set_sensitive(bool sensitive = true);
41        sigc::signal<void> signal_changed_by_user() {
42            return sig_changed;
43        }
44  protected:  protected:
45      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
46        sigc::signal<void> sig_changed;
47  };  };
48    
49  class NumEntry : public LabelWidget {  class NumEntry : public LabelWidget {
# Line 50  protected: Line 52  protected:
52      Gtk::HScale scale;      Gtk::HScale scale;
53      Gtk::SpinButton spinbutton;      Gtk::SpinButton spinbutton;
54      Gtk::HBox box;      Gtk::HBox box;
55    
56        int round_to_int(double x) {
57            return int(x < 0.0 ? x - 0.5 : x + 0.5);
58        }
59  public:  public:
60      NumEntry(const char* labelText, double lower = 0, double upper = 127,      NumEntry(const char* labelText, double lower = 0, double upper = 127,
61               int decimals = 0);               int decimals = 0);
62      void set_value(double value) {      void set_value(double value) {
63          spinbutton.set_value(value);          spinbutton.set_value(value);
64      }      }
     Glib::SignalProxy0<void> signal_value_changed() {  
         return spinbutton.signal_value_changed();  
     }  
65      double get_value() const {      double get_value() const {
66          return spinbutton.get_value();          return spinbutton.get_value();
67      }      }
# Line 104  NumEntryTemp<T>::NumEntryTemp(const char Line 107  NumEntryTemp<T>::NumEntryTemp(const char
107  template<typename T>  template<typename T>
108  void NumEntryTemp<T>::value_changed()  void NumEntryTemp<T>::value_changed()
109  {  {
110      if (ptr && update_gui) {      if (ptr) {
111          *ptr = T(spinbutton.get_value());          const double f = pow(10, spinbutton.get_digits());
112            int new_value = round_to_int(spinbutton.get_value() * f);
113            if (new_value != round_to_int(*ptr * f)) {
114                *ptr = T(new_value / f);
115                sig_changed();
116            }
117      }      }
118  }  }
119    
# Line 181  void ChoiceEntry<T>::set_choices(const c Line 189  void ChoiceEntry<T>::set_choices(const c
189  template<typename T>  template<typename T>
190  void ChoiceEntry<T>::value_changed()  void ChoiceEntry<T>::value_changed()
191  {  {
192      if (ptr && update_gui) {      if (ptr) {
193          int rowno = combobox.get_active_row_number();          int rowno = combobox.get_active_row_number();
194          if (rowno != -1) *ptr = values[rowno];          if (rowno != -1) {
195                *ptr = values[rowno];
196                sig_changed();
197            }
198      }      }
199  }  }
200    

Legend:
Removed from v.1260  
changed lines
  Added in v.1261

  ViewVC Help
Powered by ViewVC