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

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

  ViewVC Help
Powered by ViewVC