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

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

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

revision 1117 by persson, Sat Mar 24 13:05:58 2007 UTC revision 1138 by persson, Sat Mar 31 09:33:40 2007 UTC
# Line 19  Line 19 
19    
20  #include "paramedit.h"  #include "paramedit.h"
21    
22    bool update_gui;
23    
24  namespace {  namespace {
25      const char* const controlChangeTexts[] = {      const char* const controlChangeTexts[] = {
26          "none", "channelaftertouch", "velocity",          "none", "channelaftertouch", "velocity",
# Line 70  void LabelWidget::set_sensitive(bool sen Line 72  void LabelWidget::set_sensitive(bool sen
72      widget.set_sensitive(sensitive);      widget.set_sensitive(sensitive);
73  }  }
74    
75    NumEntry::NumEntry(char* labelText, double lower, double upper,
76                       int decimals) :
77        adjust(lower, lower, upper, 1, 10),
78        scale(adjust),
79        spinbutton(adjust),
80        LabelWidget(labelText, box)
81    {
82        spinbutton.set_digits(decimals);
83        scale.set_draw_value(false);
84        box.pack_start(spinbutton, Gtk::PACK_SHRINK);
85        box.add(scale);
86    }
87    
88  NumEntryGain::NumEntryGain(char* labelText,  NumEntryGain::NumEntryGain(char* labelText,
89                             double lower = 0, double upper = 127,                             double lower, double upper,
90                             int decimals = 0) :                             int decimals, double coeff) :
91      NumEntry<gig::DimensionRegion>(labelText, lower, upper, decimals)      NumEntry(labelText, lower, upper, decimals),
92        coeff(coeff)
93  {  {
94      spinbutton.signal_value_changed().connect(      spinbutton.signal_value_changed().connect(
95          sigc::mem_fun(*this, &NumEntryGain::value_changed));          sigc::mem_fun(*this, &NumEntryGain::value_changed));
# Line 81  NumEntryGain::NumEntryGain(char* labelTe Line 97  NumEntryGain::NumEntryGain(char* labelTe
97    
98  void NumEntryGain::value_changed()  void NumEntryGain::value_changed()
99  {  {
100      if (dimreg && update_gui) {      if (ptr && update_gui) {
101        dimreg->Gain = int32_t(spinbutton.get_value() * -655360.0);          *ptr = int32_t(spinbutton.get_value() * coeff);
102      }      }
103  }  }
104    
105  void NumEntryGain::set_dimreg(gig::DimensionRegion* dimreg)  void NumEntryGain::set_ptr(int32_t* ptr)
106  {  {
107      this->dimreg = 0;      this->ptr = 0;
108      bool plus6 = dimreg->Gain < 0;      bool plus6 = *ptr < 0;
109      set_value(plus6 ? 0 : dimreg->Gain / -655360.0);      set_value(plus6 ? 0 : *ptr / coeff);
110      set_sensitive(!plus6);      set_sensitive(!plus6);
111      this->dimreg = dimreg;      this->ptr = ptr;
112  }  }
113    
114    
115  BoolEntryPlus6::BoolEntryPlus6(char* labelText, NumEntryGain& eGain) :  BoolEntryPlus6::BoolEntryPlus6(char* labelText, NumEntryGain& eGain, int32_t plus6value) :
116      LabelWidget(labelText, checkbutton),      LabelWidget(labelText, checkbutton),
117      eGain(eGain)      eGain(eGain),
118        plus6value(plus6value)
119  {  {
120      checkbutton.signal_toggled().connect(      checkbutton.signal_toggled().connect(
121          sigc::mem_fun(*this, &BoolEntryPlus6::value_changed));          sigc::mem_fun(*this, &BoolEntryPlus6::value_changed));
# Line 106  BoolEntryPlus6::BoolEntryPlus6(char* lab Line 123  BoolEntryPlus6::BoolEntryPlus6(char* lab
123    
124  void BoolEntryPlus6::value_changed()  void BoolEntryPlus6::value_changed()
125  {  {
126      if (dimreg && update_gui) {      if (ptr && update_gui) {
127          bool plus6 = checkbutton.get_active();          bool plus6 = checkbutton.get_active();
128          if (plus6) {          if (plus6) {
129              eGain.set_value(0);              eGain.set_value(0);
130              dimreg->Gain = 6 * -655360;              *ptr = plus6value;
131          } else {          } else {
132              if (dimreg->Gain < 0) {              if (*ptr < 0) {
133                  dimreg->Gain = 0;                  *ptr = 0;
134              }              }
135          }          }
136          eGain.set_sensitive(!plus6);          eGain.set_sensitive(!plus6);
137      }      }
138  }  }
139    
140  void BoolEntryPlus6::set_dimreg(gig::DimensionRegion* dimreg)  void BoolEntryPlus6::set_ptr(int32_t* ptr)
141  {  {
142      this->dimreg = 0;      this->ptr = 0;
143      checkbutton.set_active(dimreg->Gain < 0);      checkbutton.set_active(*ptr < 0);
144      this->dimreg = dimreg;      this->ptr = ptr;
145  }  }
146    
147  NumEntryPermille::NumEntryPermille(char* labelText,  NumEntryPermille::NumEntryPermille(char* labelText,
                                    uint16_t gig::DimensionRegion::* param,  
148                                     double lower, double upper, int decimals) :                                     double lower, double upper, int decimals) :
149      NumEntry<gig::DimensionRegion>(labelText, lower, upper, decimals),      NumEntry(labelText, lower, upper, decimals)
     param(param)  
150  {  {
151      spinbutton.signal_value_changed().connect(      spinbutton.signal_value_changed().connect(
152          sigc::mem_fun(*this, &NumEntryPermille::value_changed));          sigc::mem_fun(*this, &NumEntryPermille::value_changed));
# Line 139  NumEntryPermille::NumEntryPermille(char* Line 154  NumEntryPermille::NumEntryPermille(char*
154    
155  void NumEntryPermille::value_changed()  void NumEntryPermille::value_changed()
156  {  {
157      if (dimreg && update_gui) {      if (ptr && update_gui) {
158          dimreg->*param = uint16_t(spinbutton.get_value() * 10 + 0.5);          *ptr = uint16_t(spinbutton.get_value() * 10 + 0.5);
159      }      }
160  }  }
161    
162  void NumEntryPermille::set_dimreg(gig::DimensionRegion* dimreg)  void NumEntryPermille::set_ptr(uint16_t* ptr)
163  {  {
164      this->dimreg = 0;      this->ptr = 0;
165      set_value(dimreg->*param / 10.0);      set_value(*ptr / 10.0);
166      this->dimreg = dimreg;      this->ptr = ptr;
167  }  }
168    
169    
170  NoteEntry::NoteEntry(char* labelText, uint8_t& (*access)(gig::DimensionRegion*)) :  NoteEntry::NoteEntry(char* labelText) :
171      NumEntryX<uint8_t>(labelText, access)      NumEntryTemp<uint8_t>(labelText)
172  {  {
173      spinbutton.signal_input().connect(      spinbutton.signal_input().connect(
174          sigc::mem_fun(*this, &NoteEntry::on_input));          sigc::mem_fun(*this, &NoteEntry::on_input));
# Line 196  bool NoteEntry::on_output() Line 211  bool NoteEntry::on_output()
211      return true;      return true;
212  }  }
213    
214  ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(  ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(char* labelText) :
     char* labelText,  
     gig::leverage_ctrl_t gig::DimensionRegion::* param) :  
215      align(0, 0, 0, 0),      align(0, 0, 0, 0),
216      LabelWidget(labelText, align),      LabelWidget(labelText, align)
     param(param)  
217  {  {
218      for (int i = 0 ; i < 99 ; i++) {      for (int i = 0 ; i < 99 ; i++) {
219          if (controlChangeTexts[i]) {          if (controlChangeTexts[i]) {
# Line 215  ChoiceEntryLeverageCtrl::ChoiceEntryLeve Line 227  ChoiceEntryLeverageCtrl::ChoiceEntryLeve
227    
228  void ChoiceEntryLeverageCtrl::value_changed()  void ChoiceEntryLeverageCtrl::value_changed()
229  {  {
230      if (dimreg && update_gui) {      if (ptr && update_gui) {
231          int rowno = combobox.get_active_row_number();          int rowno = combobox.get_active_row_number();
232          switch (rowno)          switch (rowno)
233          {          {
234          case -1:          case -1:
235              break;              break;
236          case 0:          case 0:
237              (dimreg->*param).type = gig::leverage_ctrl_t::type_none;              ptr->type = gig::leverage_ctrl_t::type_none;
238              break;              break;
239          case 1:          case 1:
240              (dimreg->*param).type =              ptr->type = gig::leverage_ctrl_t::type_channelaftertouch;
                 gig::leverage_ctrl_t::type_channelaftertouch;  
241              break;              break;
242          case 2:          case 2:
243              (dimreg->*param).type = gig::leverage_ctrl_t::type_velocity;              ptr->type = gig::leverage_ctrl_t::type_velocity;
244              break;              break;
245          default:          default:
246              (dimreg->*param).type = gig::leverage_ctrl_t::type_controlchange;              ptr->type = gig::leverage_ctrl_t::type_controlchange;
247              int x = 3;              int x = 3;
248              for (int cc = 0 ; cc < 96 ; cc++) {              for (int cc = 0 ; cc < 96 ; cc++) {
249                  if (controlChangeTexts[cc + 3]) {                  if (controlChangeTexts[cc + 3]) {
250                      if (rowno == x) {                      if (rowno == x) {
251                          (dimreg->*param).controller_number = cc;                          ptr->controller_number = cc;
252                          break;                          break;
253                      }                      }
254                      x++;                      x++;
# Line 248  void ChoiceEntryLeverageCtrl::value_chan Line 259  void ChoiceEntryLeverageCtrl::value_chan
259      }      }
260  }  }
261    
262  void ChoiceEntryLeverageCtrl::set_dimreg(gig::DimensionRegion* dimreg)  void ChoiceEntryLeverageCtrl::set_ptr(gig::leverage_ctrl_t* ptr)
263  {  {
264      this->dimreg = 0;      this->ptr = 0;
     gig::leverage_ctrl_t c = dimreg->*param;  
265      int x;      int x;
266      switch (c.type)      switch (ptr->type)
267      {      {
268      case gig::leverage_ctrl_t::type_none:      case gig::leverage_ctrl_t::type_none:
269          x = 0;          x = 0;
# Line 269  void ChoiceEntryLeverageCtrl::set_dimreg Line 279  void ChoiceEntryLeverageCtrl::set_dimreg
279          for (int cc = 0 ; cc < 96 ; cc++) {          for (int cc = 0 ; cc < 96 ; cc++) {
280              if (controlChangeTexts[cc + 3]) {              if (controlChangeTexts[cc + 3]) {
281                  x++;                  x++;
282                  if (c.controller_number == cc) {                  if (ptr->controller_number == cc) {
283                      x += 3;                      x += 3;
284                      break;                      break;
285                  }                  }
# Line 281  void ChoiceEntryLeverageCtrl::set_dimreg Line 291  void ChoiceEntryLeverageCtrl::set_dimreg
291          break;          break;
292      }      }
293      combobox.set_active(x);      combobox.set_active(x);
294      this->dimreg = dimreg;      this->ptr = ptr;
295    }
296    
297    
298    BoolEntry::BoolEntry(char* labelText) :
299        LabelWidget(labelText, checkbutton)
300    {
301        checkbutton.signal_toggled().connect(
302            sigc::mem_fun(*this, &BoolEntry::value_changed));
303    }
304    
305    void BoolEntry::value_changed()
306    {
307        if (ptr && update_gui) {
308            *ptr = checkbutton.get_active();
309        }
310    }
311    
312    void BoolEntry::set_ptr(bool* ptr)
313    {
314        this->ptr = 0;
315        checkbutton.set_active(*ptr);
316        this->ptr = ptr;
317    }
318    
319    
320    StringEntry::StringEntry(char* labelText) :
321        LabelWidget(labelText, entry)
322    {
323        entry.signal_changed().connect(
324            sigc::mem_fun(*this, &StringEntry::value_changed));
325    }
326    
327    void StringEntry::value_changed()
328    {
329        if (ptr && update_gui) {
330            *ptr = entry.get_text();
331        }
332    }
333    
334    void StringEntry::set_ptr(gig::String* ptr)
335    {
336        this->ptr = 0;
337        entry.set_text(*ptr);
338        this->ptr = ptr;
339  }  }

Legend:
Removed from v.1117  
changed lines
  Added in v.1138

  ViewVC Help
Powered by ViewVC