/[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 3177 by schoenebeck, Thu May 11 20:59:46 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 DimRegionEdit : public Gtk::Notebook  class DimRegionEdit : public Gtk::Notebook
79  {  {
# Line 36  public: Line 81  public:
81      DimRegionEdit();      DimRegionEdit();
82      virtual ~DimRegionEdit();      virtual ~DimRegionEdit();
83      void set_dim_region(gig::DimensionRegion* d);      void set_dim_region(gig::DimensionRegion* d);
84      bool set_sample(gig::Sample* sample);      bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
85        bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop);
86      Gtk::Entry* wSample;      Gtk::Entry* wSample;
87      sigc::signal<void, gig::DimensionRegion*> signal_dimreg_to_be_changed();      Gtk::Button* buttonNullSampleReference;
88      sigc::signal<void, gig::DimensionRegion*> signal_dimreg_changed();      sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_to_be_changed();
89      sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/> signal_sample_ref_changed();      sigc::signal<void, gig::DimensionRegion*>& signal_dimreg_changed();
90        sigc::signal<void, gig::Sample*/*old*/, gig::Sample*/*new*/>& signal_sample_ref_changed();
91        sigc::signal<void, gig::Sample*>& signal_select_sample();
92    
93        std::set<gig::DimensionRegion*> dimregs;
94    
95  protected:  protected:
96      sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;      sigc::signal<void, gig::DimensionRegion*> dimreg_to_be_changed_signal;
97      sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;      sigc::signal<void, gig::DimensionRegion*> dimreg_changed_signal;
98      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;
99      sigc::signal<void> instrument_changed;      sigc::signal<void> instrument_changed;
100        sigc::signal<void, gig::Sample*> select_sample_signal;
101    
102        /**
103         * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and
104         * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a
105         * pair. It behaves similar to a "mutex lock guard" design pattern.
106         */
107        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
108        public:
109            DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) :
110                SignalGuard<gig::DimensionRegion*>(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg)
111            {
112            }
113        };
114    
115      gig::DimensionRegion* dimregion;      gig::DimensionRegion* dimregion;
116    
117    #ifdef OLD_TOOLTIPS
118      Gtk::Tooltips tooltips;      Gtk::Tooltips tooltips;
119    #endif
120    
121      Gtk::Table* table[7];      Gtk::Table* table[7];
122    
123      Gtk::Label* lSample;      Gtk::Label* lSample;
124    
125        VelocityCurve velocity_curve;
126        VelocityCurve release_curve;
127        VelocityCurve cutoff_curve;
128        CrossfadeCurve crossfade_curve;
129    
130      NumEntryPermille eEG1PreAttack;      NumEntryPermille eEG1PreAttack;
131      NumEntryTemp<double> eEG1Attack;      NumEntryTemp<double> eEG1Attack;
132      NumEntryTemp<double> eEG1Decay1;      NumEntryTemp<double> eEG1Decay1;
# Line 135  protected: Line 206  protected:
206      BoolEntry eMSDecode;      BoolEntry eMSDecode;
207      NumEntryTemp<uint16_t> eSampleStartOffset;      NumEntryTemp<uint16_t> eSampleStartOffset;
208      NoteEntry eUnityNote;      NoteEntry eUnityNote;
209        ReadOnlyLabelWidget eSampleGroup;
210        ReadOnlyLabelWidget eSampleFormatInfo;
211        ReadOnlyLabelWidget eSampleID;
212        ReadOnlyLabelWidget eChecksum;
213      NumEntryTemp<int16_t> eFineTune;      NumEntryTemp<int16_t> eFineTune;
214      NumEntryGain eGain;      NumEntryGain eGain;
215      BoolEntryPlus6 eGainPlus6;      BoolEntryPlus6 eGainPlus6;
# Line 144  protected: Line 219  protected:
219      ChoiceEntry<uint32_t> eSampleLoopType;      ChoiceEntry<uint32_t> eSampleLoopType;
220      BoolEntry eSampleLoopInfinite;      BoolEntry eSampleLoopInfinite;
221      NumEntryTemp<uint32_t> eSampleLoopPlayCount;      NumEntryTemp<uint32_t> eSampleLoopPlayCount;
222        Gtk::Label* lEG2;
223        Gtk::Label* lLFO2;
224    
225        Gtk::Button buttonSelectSample;
226    
227      int rowno;      int rowno;
228      int pageno;      int pageno;
# Line 155  protected: Line 234  protected:
234      void addProp(LabelWidget& labelwidget);      void addProp(LabelWidget& labelwidget);
235      void addString(const char* labelText, Gtk::Label*& label,      void addString(const char* labelText, Gtk::Label*& label,
236                     Gtk::Entry*& widget);                     Gtk::Entry*& widget);
237      void addHeader(const char* text);      void addString(const char* labelText, Gtk::Label*& label,
238                       Gtk::Entry*& widget, Gtk::Button*& button);
239        Gtk::Label* addHeader(const char* text);
240        void addRightHandSide(Gtk::Widget& widget);
241      void nextPage();      void nextPage();
242    
243      void VCFEnabled_toggled();      void VCFEnabled_toggled();
# Line 173  protected: Line 255  protected:
255      void crossfade2_changed();      void crossfade2_changed();
256      void crossfade3_changed();      void crossfade3_changed();
257      void crossfade4_changed();      void crossfade4_changed();
258      void loop_enabled_toggled();      void update_loop_elements();
259        void loop_start_changed();
260        void loop_length_changed();
261      void loop_infinite_toggled();      void loop_infinite_toggled();
262        void nullOutSampleReference();
263    
264        int update_model;
265    
266        // connect a widget to a setter function in DimRegionEdit
267        template<typename C, typename T>
268        void connect(C& widget,
269                     void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) {
270            connect<C, T>(widget,
271                          sigc::mem_fun(setter));
272        }
273    
274        // connect a widget to a member variable in gig::DimensionRegion
275        template<typename C, typename T>
276        void connect(C& widget, T gig::DimensionRegion::* member) {
277            connect<C, T>(widget,
278                          sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member<T>), member));
279        }
280    
281        // connect a widget to a setter function in gig::DimensionRegion
282        template<typename C, typename T>
283        void connect(C& widget,
284                     void (gig::DimensionRegion::*setter)(T)) {
285            connect<C, T>(widget,
286                          sigc::hide<0>(sigc::mem_fun(setter)));
287        }
288    
289        // helper function for the connect functions above
290        template<typename C, typename T>
291        void connect(C& widget,
292                     sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
293            widget.signal_value_changed().connect(
294                sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many<T>), setter),
295                              sigc::mem_fun(widget, &C::get_value)));
296        }
297    
298        // loop through all dimregions being edited and set a value in
299        // each of them
300        template<typename T>
301        void set_many(T value,
302                      sigc::slot<void, DimRegionEdit*, gig::DimensionRegion*, T> setter) {
303            if (update_model == 0) {
304                for (std::set<gig::DimensionRegion*>::iterator i = dimregs.begin() ;
305                     i != dimregs.end() ; ++i)
306                {
307                    DimRegionChangeGuard(this, *i);
308                    setter(this, *i, value);
309                }
310            }
311        }
312    
313        // set a value of a member variable in the given dimregion
314        template<typename T>
315        void set_member(gig::DimensionRegion* d, T value,
316                        T gig::DimensionRegion::* member) {
317            d->*member = value;
318        }
319    
320        // setters for specific dimregion parameters
321    
322        void set_UnityNote(gig::DimensionRegion* d, uint8_t value);
323        void set_FineTune(gig::DimensionRegion* d, int16_t value);
324        void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value);
325        void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value);
326        void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value);
327        void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value);
328        void set_Gain(gig::DimensionRegion* d, int32_t value);
329        void set_LoopEnabled(gig::DimensionRegion* d, bool value);
330        void set_LoopType(gig::DimensionRegion* d, uint32_t value);
331        void set_LoopStart(gig::DimensionRegion* d, uint32_t value);
332        void set_LoopLength(gig::DimensionRegion* d, uint32_t value);
333        void set_LoopInfinite(gig::DimensionRegion* d, bool value);
334        void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value);
335    
336      void updateLoopElements();      void onButtonSelectSamplePressed();
337  };  };
338    
339  #endif  #endif

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

  ViewVC Help
Powered by ViewVC