/[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 1225 by schoenebeck, Sun Jun 10 10:56:11 2007 UTC revision 3364 by schoenebeck, Tue Nov 14 18:07:25 2017 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006, 2007 Andreas Persson   * Copyright (C) 2006-2017 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 20  Line 20 
20  #ifndef GIGEDIT_DIMREGIONEDIT_H  #ifndef GIGEDIT_DIMREGIONEDIT_H
21  #define GIGEDIT_DIMREGIONEDIT_H  #define GIGEDIT_DIMREGIONEDIT_H
22    
23  #include <gig.h>  #ifdef LIBGIG_HEADER_FILE
24    # include LIBGIG_HEADER_FILE(gig.h)
25    #else
26    # include <gig.h>
27    #endif
28    
29    #include "compat.h"
30    
31    #include <cairomm/context.h>
32    #include <gtkmm/box.h>
33    #include <gtkmm/drawingarea.h>
34  #include <gtkmm/entry.h>  #include <gtkmm/entry.h>
35  #include <gtkmm/label.h>  #include <gtkmm/label.h>
36  #include <gtkmm/notebook.h>  #include <gtkmm/notebook.h>
37  #include <gtkmm/table.h>  #if USE_GTKMM_GRID
38  #include <gtkmm/tooltips.h>  # include <gtkmm/grid.h>
39    #else
40    # include <gtkmm/table.h>
41    #endif
42    
43    #include <set>
44    
45  #include "paramedit.h"  #include "paramedit.h"
46    #include "global.h"
47    
48    class VelocityCurve : public Gtk::DrawingArea {
49    public:
50        VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t));
51        void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
52    
53    protected:
54    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
55        bool on_expose_event(GdkEventExpose* e);
56    #else
57        bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
58    #endif
59    
60    private:
61        double (gig::DimensionRegion::* const getter)(uint8_t);
62        gig::DimensionRegion* dimreg;
63    };
64    
65    class CrossfadeCurve : public Gtk::DrawingArea {
66    public:
67        CrossfadeCurve();
68        void set_dim_region(gig::DimensionRegion* d) { dimreg = d; }
69    
70    protected:
71    #if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
72        bool on_expose_event(GdkEventExpose* e);
73    #else
74        bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
75    #endif
76    
77    private:
78        gig::DimensionRegion* dimreg;
79        void draw_one_curve(const Cairo::RefPtr<Cairo::Context>& cr,
80                            const gig::DimensionRegion* d,
81                            bool sensitive);
82    };
83    
84    class EGStateOptions : public HBox {
85    public:
86        Gtk::Label label;
87        BoolBox checkBoxAttack;
88        BoolBox checkBoxAttackHold;
89        BoolBox checkBoxDecay1;
90        BoolBox checkBoxDecay2;
91        BoolBox checkBoxRelease;
92    
93        EGStateOptions();
94    };
95    
96  class DimRegionEdit : public Gtk::Notebook  class DimRegionEdit : public Gtk::Notebook
97  {  {
# Line 36  public: Line 99  public:
99      DimRegionEdit();      DimRegionEdit();
100      virtual ~DimRegionEdit();      virtual ~DimRegionEdit();
101      void set_dim_region(gig::DimensionRegion* d);      void set_dim_region(gig::DimensionRegion* d);
102        bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
103        bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
104      Gtk::Entry* wSample;      Gtk::Entry* wSample;
105        Gtk::Button* buttonNullSampleReference;
106        sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
107        sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
108        sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
109        sigc::signal<void, gig::Sample*>& signal_select_sample();
110    
111        std::set<gig::DimensionRegion*> dimregs;
112    
113  protected:  protected:
114        sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
115        sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
116        sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
117        sigc::signal<void> instrument_changed;
118        sigc::signal<void, gig::Sample*> select_sample_signal;
119    
120        /**
121         * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
122         * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
123         * pair. It behaves similar to a "mutex lock guard" design pattern.
124         */
125        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
126        public:
127            DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
128                SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
129            {
130            }
131        };
132    
133      gig::DimensionRegion* dimregion;      gig::DimensionRegion* dimregion;
134    
135    #ifdef OLD_TOOLTIPS
136      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
137    #endif
138    
139    #if USE_GTKMM_GRID
140        Gtk::Grid* table[7];
141    #else
142      Gtk::Table* table[7];      Gtk::Table* table[7];
143    #endif
144    
145      Gtk::Label* lSample;      Gtk::Label* lSample;
146    
147        VelocityCurve velocity_curve;
148        VelocityCurve release_curve;
149        VelocityCurve cutoff_curve;
150        CrossfadeCurve crossfade_curve;
151    
152      NumEntryPermille eEG1PreAttack;      NumEntryPermille eEG1PreAttack;
153      NumEntryTemp<double> eEG1Attack;      NumEntryTemp<double> eEG1Attack;
154      NumEntryTemp<double> eEG1Decay1;      NumEntryTemp<double> eEG1Decay1;
# Line 60  protected: Line 162  protected:
162      NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;      NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
163      NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;      NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
164      NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;      NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
165        EGStateOptions eEG1StateOptions;
166      NumEntryTemp<double> eLFO1Frequency;      NumEntryTemp<double> eLFO1Frequency;
167      NumEntryTemp<uint16_t> eLFO1InternalDepth;      NumEntryTemp<uint16_t> eLFO1InternalDepth;
168      NumEntryTemp<uint16_t> eLFO1ControlDepth;      NumEntryTemp<uint16_t> eLFO1ControlDepth;
# Line 78  protected: Line 181  protected:
181      NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;      NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
182      NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;      NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
183      NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;      NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
184        EGStateOptions eEG2StateOptions;
185      NumEntryTemp<double> eLFO2Frequency;      NumEntryTemp<double> eLFO2Frequency;
186      NumEntryTemp<uint16_t> eLFO2InternalDepth;      NumEntryTemp<uint16_t> eLFO2InternalDepth;
187      NumEntryTemp<uint16_t> eLFO2ControlDepth;      NumEntryTemp<uint16_t> eLFO2ControlDepth;
# Line 126  protected: Line 230  protected:
230      BoolEntry eMSDecode;      BoolEntry eMSDecode;
231      NumEntryTemp<uint16_t> eSampleStartOffset;      NumEntryTemp<uint16_t> eSampleStartOffset;
232      NoteEntry eUnityNote;      NoteEntry eUnityNote;
233        ReadOnlyLabelWidget eSampleGroup;
234        ReadOnlyLabelWidget eSampleFormatInfo;
235        ReadOnlyLabelWidget eSampleID;
236        ReadOnlyLabelWidget eChecksum;
237      NumEntryTemp<int16_t> eFineTune;      NumEntryTemp<int16_t> eFineTune;
238      NumEntryGain eGain;      NumEntryGain eGain;
239      BoolEntryPlus6 eGainPlus6;      BoolEntryPlus6 eGainPlus6;
# Line 135  protected: Line 243  protected:
243      ChoiceEntry<uint32_t> eSampleLoopType;      ChoiceEntry<uint32_t> eSampleLoopType;
244      BoolEntry eSampleLoopInfinite;      BoolEntry eSampleLoopInfinite;
245      NumEntryTemp<uint32_t> eSampleLoopPlayCount;      NumEntryTemp<uint32_t> eSampleLoopPlayCount;
246        Gtk::Label* lEG2;
247        Gtk::Label* lLFO2;
248    
249        Gtk::Button buttonSelectSample;
250    
251      int rowno;      int rowno;
252      int pageno;      int pageno;
# Line 142  protected: Line 254  protected:
254    
255    
256      void addProp(BoolEntry& boolentry);      void addProp(BoolEntry& boolentry);
257        void addProp(BoolEntryPlus6& boolentry);
258      void addProp(LabelWidget& labelwidget);      void addProp(LabelWidget& labelwidget);
259        void addLine(HBox& line);
260      void addString(const char* labelText, Gtk::Label*& label,      void addString(const char* labelText, Gtk::Label*& label,
261                     Gtk::Entry*& widget);                     Gtk::Entry*& widget);
262      void addHeader(const char* text);      void addString(const char* labelText, Gtk::Label*& label,
263                       Gtk::Entry*& widget, Gtk::Button*& button);
264        Gtk::Label* addHeader(const char* text);
265        void addRightHandSide(Gtk::Widget& widget);
266      void nextPage();      void nextPage();
267    
268      void VCFEnabled_toggled();      void VCFEnabled_toggled();
# Line 163  protected: Line 280  protected:
280      void crossfade2_changed();      void crossfade2_changed();
281      void crossfade3_changed();      void crossfade3_changed();
282      void crossfade4_changed();      void crossfade4_changed();
283      void loop_enabled_toggled();      void update_loop_elements();
284        void loop_start_changed();
285        void loop_length_changed();
286      void loop_infinite_toggled();      void loop_infinite_toggled();
287        void nullOutSampleReference();
288    
289        int update_model;
290    
291        /**
292         * Workaround for the circumstance that C++ does not allow to cast to
293         * member pointers.
294         */
295        template<typename classT, typename memberT>
296        union ClassMemberPtr {
297            memberT classT::*pmember;
298            void* pvoid;
299    
300            ClassMemberPtr(size_t s) : pvoid((void*)s) {}
301            ClassMemberPtr(void* p) : pvoid(p) {}
302        };
303    
304        // connect a widget to a setter function in DimRegionEdit
305        template<typename C, typename T>
306        void connect(C& widget,
307                     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
308            connect<C, T>(widget,
309                          sigc::mem_fun(setter));
310        }
311    
312        // connect a widget to a member variable in gig::DimensionRegion
313        template<typename C, typename T>
314        void connect(C& widget, T gig::DimensionRegion::* member) {
315            connect<C, T>(widget,
316                          sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
317        }
318    
319        // connect a widget to a setter function in gig::DimensionRegion
320        template<typename C, typename T>
321        void connect(C& widget,
322                     void (gig::DimensionRegion::*setter)(T)) {
323            connect<C, T>(widget,
324                          sigc::hide<0>(sigc::mem_fun(setter)));
325        }
326    
327        // helper function for the connect functions above
328        template<typename C, typename T>
329        void connect(C& widget,
330                     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
331            widget.signal_value_changed().connect(
332                sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
333                              sigc::mem_fun(widget, &C::get_value)));
334        }
335    
336        // loop through all dimregions being edited and set a value in
337        // each of them
338        template<typename T>
339        void set_many(T value,
340                      sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
341            if (update_model == 0) {
342                for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
343                     i != dimregs.end() ; ++i)
344                {
345                    DimRegionChangeGuard(this, *i);
346                    setter(this, *i, value);
347                }
348            }
349        }
350    
351        // set a value of a member variable in the given dimregion
352        template<typename T>
353        void set_member(gig::DimensionRegion* d, T value,
354                        T gig::DimensionRegion::* member) {
355            d->*member = value;
356        }
357    
358        // setters for specific dimregion parameters
359    
360        void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
361        void set_FineTune(gig::DimensionRegion* d, int16_t value);
362        void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
363        void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
364        void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
365        void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
366        void set_Gain(gig::DimensionRegion* d, int32_t value);
367        void set_LoopEnabled(gig::DimensionRegion* d, bool value);
368        void set_LoopType(gig::DimensionRegion* d, uint32_t value);
369        void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
370        void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
371        void set_LoopInfinite(gig::DimensionRegion* d, bool value);
372        void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
373    
374      void updateLoopElements();      void onButtonSelectSamplePressed();
375  };  };
376    
377  #endif  #endif

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

  ViewVC Help
Powered by ViewVC