/[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 3409 by schoenebeck, Tue Jan 23 16:30:56 2018 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        void on_show_tooltips_changed();
95    };
96    
97  class DimRegionEdit : public Gtk::Notebook  class DimRegionEdit : public Gtk::Notebook
98  {  {
# Line 36  public: Line 100  public:
100      DimRegionEdit();      DimRegionEdit();
101      virtual ~DimRegionEdit();      virtual ~DimRegionEdit();
102      void set_dim_region(gig::DimensionRegion* d);      void set_dim_region(gig::DimensionRegion* d);
103        bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
104        bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
105      Gtk::Entry* wSample;      Gtk::Entry* wSample;
106        Gtk::Button* buttonNullSampleReference;
107        sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
108        sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
109        sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
110        sigc::signal<void, gig::Sample*>& signal_select_sample();
111    
112        std::set<gig::DimensionRegion*> dimregs;
113    
114  protected:  protected:
115        sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
116        sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
117        sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> sample_ref_changed_signal;
118        sigc::signal<void> instrument_changed;
119        sigc::signal<void, gig::Sample*> select_sample_signal;
120    
121        /**
122         * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
123         * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
124         * pair. It behaves similar to a "mutex lock guard" design pattern.
125         */
126        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
127        public:
128            DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
129                SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
130            {
131            }
132        };
133    
134      gig::DimensionRegion* dimregion;      gig::DimensionRegion* dimregion;
135    
136    #ifdef OLD_TOOLTIPS
137      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
138    #endif
139    
140    #if USE_GTKMM_GRID
141        Gtk::Grid* table[7];
142    #else
143      Gtk::Table* table[7];      Gtk::Table* table[7];
144    #endif
145    
146      Gtk::Label* lSample;      Gtk::Label* lSample;
147    
148        VelocityCurve velocity_curve;
149        VelocityCurve release_curve;
150        VelocityCurve cutoff_curve;
151        CrossfadeCurve crossfade_curve;
152    
153      NumEntryPermille eEG1PreAttack;      NumEntryPermille eEG1PreAttack;
154      NumEntryTemp<double> eEG1Attack;      NumEntryTemp<double> eEG1Attack;
155      NumEntryTemp<double> eEG1Decay1;      NumEntryTemp<double> eEG1Decay1;
# Line 60  protected: Line 163  protected:
163      NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;      NumEntryTemp<uint8_t> eEG1ControllerAttackInfluence;
164      NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;      NumEntryTemp<uint8_t> eEG1ControllerDecayInfluence;
165      NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;      NumEntryTemp<uint8_t> eEG1ControllerReleaseInfluence;
166        EGStateOptions eEG1StateOptions;
167      NumEntryTemp<double> eLFO1Frequency;      NumEntryTemp<double> eLFO1Frequency;
168      NumEntryTemp<uint16_t> eLFO1InternalDepth;      NumEntryTemp<uint16_t> eLFO1InternalDepth;
169      NumEntryTemp<uint16_t> eLFO1ControlDepth;      NumEntryTemp<uint16_t> eLFO1ControlDepth;
# Line 78  protected: Line 182  protected:
182      NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;      NumEntryTemp<uint8_t> eEG2ControllerAttackInfluence;
183      NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;      NumEntryTemp<uint8_t> eEG2ControllerDecayInfluence;
184      NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;      NumEntryTemp<uint8_t> eEG2ControllerReleaseInfluence;
185        EGStateOptions eEG2StateOptions;
186      NumEntryTemp<double> eLFO2Frequency;      NumEntryTemp<double> eLFO2Frequency;
187      NumEntryTemp<uint16_t> eLFO2InternalDepth;      NumEntryTemp<uint16_t> eLFO2InternalDepth;
188      NumEntryTemp<uint16_t> eLFO2ControlDepth;      NumEntryTemp<uint16_t> eLFO2ControlDepth;
# Line 126  protected: Line 231  protected:
231      BoolEntry eMSDecode;      BoolEntry eMSDecode;
232      NumEntryTemp<uint16_t> eSampleStartOffset;      NumEntryTemp<uint16_t> eSampleStartOffset;
233      NoteEntry eUnityNote;      NoteEntry eUnityNote;
234        ReadOnlyLabelWidget eSampleGroup;
235        ReadOnlyLabelWidget eSampleFormatInfo;
236        ReadOnlyLabelWidget eSampleID;
237        ReadOnlyLabelWidget eChecksum;
238      NumEntryTemp<int16_t> eFineTune;      NumEntryTemp<int16_t> eFineTune;
239      NumEntryGain eGain;      NumEntryGain eGain;
240      BoolEntryPlus6 eGainPlus6;      BoolEntryPlus6 eGainPlus6;
# Line 135  protected: Line 244  protected:
244      ChoiceEntry<uint32_t> eSampleLoopType;      ChoiceEntry<uint32_t> eSampleLoopType;
245      BoolEntry eSampleLoopInfinite;      BoolEntry eSampleLoopInfinite;
246      NumEntryTemp<uint32_t> eSampleLoopPlayCount;      NumEntryTemp<uint32_t> eSampleLoopPlayCount;
247        Gtk::Label* lEG2;
248        Gtk::Label* lLFO2;
249    
250        Gtk::Button buttonSelectSample;
251    
252      int rowno;      int rowno;
253      int pageno;      int pageno;
# Line 142  protected: Line 255  protected:
255    
256    
257      void addProp(BoolEntry& boolentry);      void addProp(BoolEntry& boolentry);
258        void addProp(BoolEntryPlus6& boolentry);
259      void addProp(LabelWidget& labelwidget);      void addProp(LabelWidget& labelwidget);
260        void addLine(HBox& line);
261      void addString(const char* labelText, Gtk::Label*& label,      void addString(const char* labelText, Gtk::Label*& label,
262                     Gtk::Entry*& widget);                     Gtk::Entry*& widget);
263      void addHeader(const char* text);      void addString(const char* labelText, Gtk::Label*& label,
264                       Gtk::Entry*& widget, Gtk::Button*& button);
265        Gtk::Label* addHeader(const char* text);
266        void addRightHandSide(Gtk::Widget& widget);
267      void nextPage();      void nextPage();
268    
269      void VCFEnabled_toggled();      void VCFEnabled_toggled();
# Line 163  protected: Line 281  protected:
281      void crossfade2_changed();      void crossfade2_changed();
282      void crossfade3_changed();      void crossfade3_changed();
283      void crossfade4_changed();      void crossfade4_changed();
284      void loop_enabled_toggled();      void update_loop_elements();
285        void loop_start_changed();
286        void loop_length_changed();
287      void loop_infinite_toggled();      void loop_infinite_toggled();
288        void nullOutSampleReference();
289        void on_show_tooltips_changed();
290    
291        int update_model;
292    
293        /**
294         * Workaround for the circumstance that C++ does not allow to cast to
295         * member pointers.
296         */
297        template<typename classT, typename memberT>
298        union ClassMemberPtr {
299            memberT classT::*pmember;
300            void* pvoid;
301    
302            ClassMemberPtr(size_t s) : pvoid((void*)s) {}
303            ClassMemberPtr(void* p) : pvoid(p) {}
304        };
305    
306        // connect a widget to a setter function in DimRegionEdit
307        template<typename C, typename T>
308        void connect(C& widget,
309                     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
310            connect<C, T>(widget,
311                          sigc::mem_fun(setter));
312        }
313    
314        // connect a widget to a member variable in gig::DimensionRegion
315        template<typename C, typename T>
316        void connect(C& widget, T gig::DimensionRegion::* member) {
317            connect<C, T>(widget,
318                          sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
319        }
320    
321        // connect a widget to a setter function in gig::DimensionRegion
322        template<typename C, typename T>
323        void connect(C& widget,
324                     void (gig::DimensionRegion::*setter)(T)) {
325            connect<C, T>(widget,
326                          sigc::hide<0>(sigc::mem_fun(setter)));
327        }
328    
329        // helper function for the connect functions above
330        template<typename C, typename T>
331        void connect(C& widget,
332                     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
333            widget.signal_value_changed().connect(
334                sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
335                              sigc::mem_fun(widget, &C::get_value)));
336        }
337    
338        // loop through all dimregions being edited and set a value in
339        // each of them
340        template<typename T>
341        void set_many(T value,
342                      sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
343            if (update_model == 0) {
344                for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
345                     i != dimregs.end() ; ++i)
346                {
347                    DimRegionChangeGuard(this, *i);
348                    setter(this, *i, value);
349                }
350            }
351        }
352    
353        // set a value of a member variable in the given dimregion
354        template<typename T>
355        void set_member(gig::DimensionRegion* d, T value,
356                        T gig::DimensionRegion::* member) {
357            d->*member = value;
358        }
359    
360        // setters for specific dimregion parameters
361    
362        void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
363        void set_FineTune(gig::DimensionRegion* d, int16_t value);
364        void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
365        void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
366        void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
367        void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
368        void set_Gain(gig::DimensionRegion* d, int32_t value);
369        void set_LoopEnabled(gig::DimensionRegion* d, bool value);
370        void set_LoopType(gig::DimensionRegion* d, uint32_t value);
371        void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
372        void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
373        void set_LoopInfinite(gig::DimensionRegion* d, bool value);
374        void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
375    
376      void updateLoopElements();      void onButtonSelectSamplePressed();
377  };  };
378    
379  #endif  #endif

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

  ViewVC Help
Powered by ViewVC