/[svn]/gigedit/trunk/src/gigedit/dimregionedit.h
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/dimregionedit.h

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

revision 1322 by schoenebeck, Tue Sep 4 11:04:56 2007 UTC revision 2690 by schoenebeck, Sun Jan 4 18:36:42 2015 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2015 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 22  Line 22 
22    
23  #include <gig.h>  #include <gig.h>
24    
25    #include <cairomm/context.h>
26    #include <gtkmm/drawingarea.h>
27  #include <gtkmm/entry.h>  #include <gtkmm/entry.h>
28  #include <gtkmm/label.h>  #include <gtkmm/label.h>
29  #include <gtkmm/notebook.h>  #include <gtkmm/notebook.h>
30  #include <gtkmm/table.h>  #include <gtkmm/table.h>
31  #include <gtkmm/tooltips.h>  
32    #include <set>
33    
34  #include "paramedit.h"  #include "paramedit.h"
35    
36    class VelocityCurve : public Gtk::DrawingArea {
37    public:
38        VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t));
39        void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
40    
41    protected:
42    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
43        bool on_expose_event(GdkEventExpose* e);
44    #else
45        bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
46    #endif
47    
48    private:
49        double (gig::DimensionRegion::* const getter)(uint8_t);
50        gig::DimensionRegion* dimreg;
51    };
52    
53    class CrossfadeCurve : public Gtk::DrawingArea {
54    public:
55        CrossfadeCurve();
56        void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
57    
58    protected:
59    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
60        bool on_expose_event(GdkEventExpose* e);
61    #else
62        bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
63    #endif
64    
65    private:
66        gig::DimensionRegion* dimreg;
67        void draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
68                            const gig::DimensionRegion* d,
69                            bool sensitive);
70    };
71    
72  class DimRegionEdit : public Gtk::Notebook  class DimRegionEdit : public Gtk::Notebook
73  {  {
74  public:  public:
75      DimRegionEdit();      DimRegionEdit();
76      virtual ~DimRegionEdit();      virtual ~DimRegionEdit();
77      void set_dim_region(gig::DimensionRegion* d);      void set_dim_region(gig::DimensionRegion* d);
78      bool set_sample(gig::Sample* sample);      bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
79      Gtk::Entry* wSample;      Gtk::Entry* wSample;
80      sigc::signal<void, gig::DimensionRegion*> signal_dimreg_to_be_changed();      sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
81      sigc::signal<void, gig::DimensionRegion*> signal_dimreg_changed();      sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
82      sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> signal_sample_ref_changed();      sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
83    
84        std::set<gig::DimensionRegion*> dimregs;
85    
86  protected:  protected:
87      sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;      sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
# Line 50  protected: Line 91  protected:
91    
92      gig::DimensionRegion* dimregion;      gig::DimensionRegion* dimregion;
93    
94    #ifdef OLD_TOOLTIPS
95      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
96    #endif
97    
98      Gtk::Table* table[7];      Gtk::Table* table[7];
99    
100      Gtk::Label* lSample;      Gtk::Label* lSample;
101    
102        VelocityCurve velocity_curve;
103        VelocityCurve release_curve;
104        VelocityCurve cutoff_curve;
105        CrossfadeCurve crossfade_curve;
106    
107      NumEntryPermille eEG1PreAttack;      NumEntryPermille eEG1PreAttack;
108      NumEntryTemp<double> eEG1Attack;      NumEntryTemp<double> eEG1Attack;
109      NumEntryTemp<double> eEG1Decay1;      NumEntryTemp<double> eEG1Decay1;
# Line 135  protected: Line 183  protected:
183      BoolEntry eMSDecode;      BoolEntry eMSDecode;
184      NumEntryTemp<uint16_t> eSampleStartOffset;      NumEntryTemp<uint16_t> eSampleStartOffset;
185      NoteEntry eUnityNote;      NoteEntry eUnityNote;
186        ReadOnlyLabelWidget eSampleFormatInfo;
187        ReadOnlyLabelWidget eSampleID;
188      NumEntryTemp<int16_t> eFineTune;      NumEntryTemp<int16_t> eFineTune;
189      NumEntryGain eGain;      NumEntryGain eGain;
190      BoolEntryPlus6 eGainPlus6;      BoolEntryPlus6 eGainPlus6;
# Line 144  protected: Line 194  protected:
194      ChoiceEntry<uint32_t> eSampleLoopType;      ChoiceEntry<uint32_t> eSampleLoopType;
195      BoolEntry eSampleLoopInfinite;      BoolEntry eSampleLoopInfinite;
196      NumEntryTemp<uint32_t> eSampleLoopPlayCount;      NumEntryTemp<uint32_t> eSampleLoopPlayCount;
197        Gtk::Label* lEG2;
198        Gtk::Label* lLFO2;
199    
200      int rowno;      int rowno;
201      int pageno;      int pageno;
# Line 155  protected: Line 207  protected:
207      void addProp(LabelWidget& labelwidget);      void addProp(LabelWidget& labelwidget);
208      void addString(const char* labelText, Gtk::Label*& label,      void addString(const char* labelText, Gtk::Label*& label,
209                     Gtk::Entry*& widget);                     Gtk::Entry*& widget);
210      void addHeader(const char* text);      Gtk::Label* addHeader(const char* text);
211      void nextPage();      void nextPage();
212    
213      void VCFEnabled_toggled();      void VCFEnabled_toggled();
# Line 173  protected: Line 225  protected:
225      void crossfade2_changed();      void crossfade2_changed();
226      void crossfade3_changed();      void crossfade3_changed();
227      void crossfade4_changed();      void crossfade4_changed();
228      void loop_enabled_toggled();      void update_loop_elements();
229        void loop_start_changed();
230        void loop_length_changed();
231      void loop_infinite_toggled();      void loop_infinite_toggled();
232    
233      void updateLoopElements();      int update_model;
234    
235        // connect a widget to a setter function in DimRegionEdit
236        template<typename C, typename T>
237        void connect(C& widget,
238                     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
239            connect<C, T>(widget,
240                          sigc::mem_fun(setter));
241        }
242    
243        // connect a widget to a member variable in gig::DimensionRegion
244        template<typename C, typename T>
245        void connect(C& widget, T gig::DimensionRegion::* member) {
246            connect<C, T>(widget,
247                          sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
248        }
249    
250        // connect a widget to a setter function in gig::DimensionRegion
251        template<typename C, typename T>
252        void connect(C& widget,
253                     void (gig::DimensionRegion::*setter)(T)) {
254            connect<C, T>(widget,
255                          sigc::hide<0>(sigc::mem_fun(setter)));
256        }
257    
258        // helper function for the connect functions above
259        template<typename C, typename T>
260        void connect(C& widget,
261                     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
262            widget.signal_value_changed().connect(
263                sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
264                              sigc::mem_fun(widget, &C::get_value)));
265        }
266    
267        // loop through all dimregions being edited ant set a value in
268        // each of them
269        template<typename T>
270        void set_many(T value,
271                      sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
272            if (update_model == 0) {
273                for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
274                     i != dimregs.end() ; i++)
275                {
276                    dimreg_changed_signal(*i);
277                    setter(this, *i, value);
278                }
279            }
280        }
281    
282        // set a value of a member variable in the given dimregion
283        template<typename T>
284        void set_member(gig::DimensionRegion* d, T value,
285                        T gig::DimensionRegion::* member) {
286            d->*member = value;
287        }
288    
289        // setters for specific dimregion parameters
290    
291        void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
292        void set_FineTune(gig::DimensionRegion* d, int16_t value);
293        void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
294        void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
295        void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
296        void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
297        void set_Gain(gig::DimensionRegion* d, int32_t value);
298        void set_LoopEnabled(gig::DimensionRegion* d, bool value);
299        void set_LoopType(gig::DimensionRegion* d, uint32_t value);
300        void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
301        void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
302        void set_LoopInfinite(gig::DimensionRegion* d, bool value);
303        void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
304  };  };
305    
306  #endif  #endif

Legend:
Removed from v.1322  
changed lines
  Added in v.2690

  ViewVC Help
Powered by ViewVC