/[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 1225 by schoenebeck, Sun Jun 10 10:56:11 2007 UTC revision 1300 by schoenebeck, Fri Aug 24 19:11:41 2007 UTC
# Line 22  Line 22 
22    
23  #include <gig.h>  #include <gig.h>
24    
25    #include <math.h>
26    
27  #include <gtkmm/adjustment.h>  #include <gtkmm/adjustment.h>
28  #include <gtkmm/alignment.h>  #include <gtkmm/alignment.h>
29  #include <gtkmm/box.h>  #include <gtkmm/box.h>
# Line 31  Line 33 
33  #include <gtkmm/spinbutton.h>  #include <gtkmm/spinbutton.h>
34  #include <gtkmm/tooltips.h>  #include <gtkmm/tooltips.h>
35    
 extern bool update_gui;  
   
36  class LabelWidget {  class LabelWidget {
37  public:  public:
38      Gtk::Label label;      Gtk::Label label;
# 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() {
44            return sig_changed;
45        }
46  protected:  protected:
47      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
48        sigc::signal<void> sig_changed;
49  };  };
50    
51  class NumEntry : public LabelWidget {  class NumEntry : public LabelWidget {
# Line 50  protected: Line 54  protected:
54      Gtk::HScale scale;      Gtk::HScale scale;
55      Gtk::SpinButton spinbutton;      Gtk::SpinButton spinbutton;
56      Gtk::HBox box;      Gtk::HBox box;
57    
58        int round_to_int(double x) {
59            return int(x < 0.0 ? x - 0.5 : x + 0.5);
60        }
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);
64      void set_value(double value) {      void set_value(double value) {
65          spinbutton.set_value(value);          spinbutton.set_value(value);
66      }      }
     Glib::SignalProxy0<void> signal_value_changed() {  
         return spinbutton.signal_value_changed();  
     }  
67      double get_value() const {      double get_value() const {
68          return spinbutton.get_value();          return spinbutton.get_value();
69      }      }
# Line 104  NumEntryTemp<T>::NumEntryTemp(const char Line 109  NumEntryTemp<T>::NumEntryTemp(const char
109  template<typename T>  template<typename T>
110  void NumEntryTemp<T>::value_changed()  void NumEntryTemp<T>::value_changed()
111  {  {
112      if (ptr && update_gui) {      if (ptr) {
113          *ptr = T(spinbutton.get_value());          const double f = pow(10, spinbutton.get_digits());
114            int new_value = round_to_int(spinbutton.get_value() * f);
115            if (new_value != round_to_int(*ptr * f)) {
116                *ptr = T(new_value / f);
117                sig_changed();
118            }
119      }      }
120  }  }
121    
# Line 181  void ChoiceEntry<T>::set_choices(const c Line 191  void ChoiceEntry<T>::set_choices(const c
191  template<typename T>  template<typename T>
192  void ChoiceEntry<T>::value_changed()  void ChoiceEntry<T>::value_changed()
193  {  {
194      if (ptr && update_gui) {      if (ptr) {
195          int rowno = combobox.get_active_row_number();          int rowno = combobox.get_active_row_number();
196          if (rowno != -1) *ptr = values[rowno];          if (rowno != -1) {
197                *ptr = values[rowno];
198                sig_changed();
199            }
200      }      }
201  }  }
202    

Legend:
Removed from v.1225  
changed lines
  Added in v.1300

  ViewVC Help
Powered by ViewVC