--- gigedit/trunk/src/gigedit/dimregionedit.h 2007/07/22 15:07:08 1262 +++ gigedit/trunk/src/gigedit/dimregionedit.h 2019/01/31 18:43:09 3458 @@ -1,5 +1,5 @@ /* -*- c++ -*- - * Copyright (C) 2006, 2007 Andreas Persson + * Copyright (C) 2006-2019 Andreas Persson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -20,15 +20,79 @@ #ifndef GIGEDIT_DIMREGIONEDIT_H #define GIGEDIT_DIMREGIONEDIT_H -#include +#ifdef LIBGIG_HEADER_FILE +# include LIBGIG_HEADER_FILE(gig.h) +#else +# include +#endif + +#include "compat.h" +#include +#include +#include #include #include #include -#include -#include +#if USE_GTKMM_GRID +# include +#else +# include +#endif + +#include #include "paramedit.h" +#include "global.h" + +class VelocityCurve : public Gtk::DrawingArea { +public: + VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)); + void set_dim_region(gig::DimensionRegion* d) { dimreg = d; } + +protected: +#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 + bool on_expose_event(GdkEventExpose* e); +#else + bool on_draw(const Cairo::RefPtr& cr); +#endif + +private: + double (gig::DimensionRegion::* const getter)(uint8_t); + gig::DimensionRegion* dimreg; +}; + +class CrossfadeCurve : public Gtk::DrawingArea { +public: + CrossfadeCurve(); + void set_dim_region(gig::DimensionRegion* d) { dimreg = d; } + +protected: +#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 + bool on_expose_event(GdkEventExpose* e); +#else + bool on_draw(const Cairo::RefPtr& cr); +#endif + +private: + gig::DimensionRegion* dimreg; + void draw_one_curve(const Cairo::RefPtr& cr, + const gig::DimensionRegion* d, + bool sensitive); +}; + +class EGStateOptions : public HBox { +public: + Gtk::Label label; + BoolBox checkBoxAttack; + BoolBox checkBoxAttackHold; + BoolBox checkBoxDecay1; + BoolBox checkBoxDecay2; + BoolBox checkBoxRelease; + + EGStateOptions(); + void on_show_tooltips_changed(); +}; class DimRegionEdit : public Gtk::Notebook { @@ -36,23 +100,56 @@ DimRegionEdit(); virtual ~DimRegionEdit(); void set_dim_region(gig::DimensionRegion* d); + bool set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop); + bool set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop); Gtk::Entry* wSample; - sigc::signal signal_dimreg_changed() { - return dimreg_changed_signal; - } + Gtk::Button* buttonNullSampleReference; + sigc::signal& signal_dimreg_to_be_changed(); + sigc::signal& signal_dimreg_changed(); + sigc::signal& signal_sample_ref_changed(); + sigc::signal& signal_select_sample(); + + std::set dimregs; protected: - sigc::signal dimreg_changed_signal; + sigc::signal dimreg_to_be_changed_signal; + sigc::signal dimreg_changed_signal; + sigc::signal sample_ref_changed_signal; sigc::signal instrument_changed; + sigc::signal select_sample_signal; + + /** + * Ensures that the 2 signals DimRegionEdit::dimreg_to_be_changed_signal and + * DimRegionEdit::dimreg_changed_signal are always triggered correctly as a + * pair. It behaves similar to a "mutex lock guard" design pattern. + */ + class DimRegionChangeGuard : public SignalGuard { + public: + DimRegionChangeGuard(DimRegionEdit* edit, gig::DimensionRegion* pDimReg) : + SignalGuard(edit->dimreg_to_be_changed_signal, edit->dimreg_changed_signal, pDimReg) + { + } + }; gig::DimensionRegion* dimregion; +#ifdef OLD_TOOLTIPS Gtk::Tooltips tooltips; +#endif +#if USE_GTKMM_GRID + Gtk::Grid* table[7]; +#else Gtk::Table* table[7]; +#endif Gtk::Label* lSample; + VelocityCurve velocity_curve; + VelocityCurve release_curve; + VelocityCurve cutoff_curve; + CrossfadeCurve crossfade_curve; + NumEntryPermille eEG1PreAttack; NumEntryTemp eEG1Attack; NumEntryTemp eEG1Decay1; @@ -66,6 +163,7 @@ NumEntryTemp eEG1ControllerAttackInfluence; NumEntryTemp eEG1ControllerDecayInfluence; NumEntryTemp eEG1ControllerReleaseInfluence; + EGStateOptions eEG1StateOptions; NumEntryTemp eLFO1Frequency; NumEntryTemp eLFO1InternalDepth; NumEntryTemp eLFO1ControlDepth; @@ -84,6 +182,7 @@ NumEntryTemp eEG2ControllerAttackInfluence; NumEntryTemp eEG2ControllerDecayInfluence; NumEntryTemp eEG2ControllerReleaseInfluence; + EGStateOptions eEG2StateOptions; NumEntryTemp eLFO2Frequency; NumEntryTemp eLFO2InternalDepth; NumEntryTemp eLFO2ControlDepth; @@ -121,6 +220,8 @@ NumEntryTemp eCrossfade_out_start; NumEntryTemp eCrossfade_out_end; BoolEntry ePitchTrack; + ChoiceEntry eSustainReleaseTrigger; + BoolEntry eNoNoteOffReleaseTrigger; ChoiceEntry eDimensionBypass; NumEntryTemp ePan; BoolEntry eSelfMask; @@ -132,6 +233,10 @@ BoolEntry eMSDecode; NumEntryTemp eSampleStartOffset; NoteEntry eUnityNote; + ReadOnlyLabelWidget eSampleGroup; + ReadOnlyLabelWidget eSampleFormatInfo; + ReadOnlyLabelWidget eSampleID; + ReadOnlyLabelWidget eChecksum; NumEntryTemp eFineTune; NumEntryGain eGain; BoolEntryPlus6 eGainPlus6; @@ -141,6 +246,10 @@ ChoiceEntry eSampleLoopType; BoolEntry eSampleLoopInfinite; NumEntryTemp eSampleLoopPlayCount; + Gtk::Label* lEG2; + Gtk::Label* lLFO2; + + Gtk::Button buttonSelectSample; int rowno; int pageno; @@ -150,9 +259,13 @@ void addProp(BoolEntry& boolentry); void addProp(BoolEntryPlus6& boolentry); void addProp(LabelWidget& labelwidget); + void addLine(HBox& line); void addString(const char* labelText, Gtk::Label*& label, Gtk::Entry*& widget); - void addHeader(const char* text); + void addString(const char* labelText, Gtk::Label*& label, + Gtk::Entry*& widget, Gtk::Button*& button); + Gtk::Label* addHeader(const char* text); + void addRightHandSide(Gtk::Widget& widget); void nextPage(); void VCFEnabled_toggled(); @@ -170,10 +283,100 @@ void crossfade2_changed(); void crossfade3_changed(); void crossfade4_changed(); - void loop_enabled_toggled(); + void update_loop_elements(); + void loop_start_changed(); + void loop_length_changed(); void loop_infinite_toggled(); + void nullOutSampleReference(); + void on_show_tooltips_changed(); + + int update_model; + + // connect a widget to a setter function in DimRegionEdit + template + void connect(C& widget, + void (DimRegionEdit::*setter)(gig::DimensionRegion*, T)) { + connect(widget, + sigc::mem_fun(setter)); + } + + // connect a widget to a member variable in gig::DimensionRegion + template + void connect(C& widget, T gig::DimensionRegion::* member) { + connect(widget, + sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member), member)); + } + + // connect a widget to a member of a struct member in gig::DimensionRegion + template + void connect(C& widget, S gig::DimensionRegion::* member, T S::* member2) { + connect(widget, + sigc::bind(sigc::mem_fun(&DimRegionEdit::set_member), member, member2)); + } + + // connect a widget to a setter function in gig::DimensionRegion + template + void connect(C& widget, + void (gig::DimensionRegion::*setter)(T)) { + connect(widget, + sigc::hide<0>(sigc::mem_fun(setter))); + } + + // helper function for the connect functions above + template + void connect(C& widget, + sigc::slot setter) { + widget.signal_value_changed().connect( + sigc::compose(sigc::bind(sigc::mem_fun(*this, &DimRegionEdit::set_many), setter), + sigc::mem_fun(widget, &C::get_value))); + } + + // loop through all dimregions being edited and set a value in + // each of them + template + void set_many(T value, + sigc::slot setter) { + if (update_model == 0) { + for (std::set::iterator i = dimregs.begin() ; + i != dimregs.end() ; ++i) + { + DimRegionChangeGuard(this, *i); + setter(this, *i, value); + } + } + } + + // set a value of a member variable in the given dimregion + template + void set_member(gig::DimensionRegion* d, T value, + T gig::DimensionRegion::* member) { + d->*member = value; + } + + // set a value of a member of a struct member variable in the given dimregion + template + void set_member(gig::DimensionRegion* d, T value, + S gig::DimensionRegion::* member, T S::* member2) { + d->*member.*member2 = value; + } + + // setters for specific dimregion parameters + + void set_UnityNote(gig::DimensionRegion* d, uint8_t value); + void set_FineTune(gig::DimensionRegion* d, int16_t value); + void set_Crossfade_in_start(gig::DimensionRegion* d, uint8_t value); + void set_Crossfade_in_end(gig::DimensionRegion* d, uint8_t value); + void set_Crossfade_out_start(gig::DimensionRegion* d, uint8_t value); + void set_Crossfade_out_end(gig::DimensionRegion* d, uint8_t value); + void set_Gain(gig::DimensionRegion* d, int32_t value); + void set_LoopEnabled(gig::DimensionRegion* d, bool value); + void set_LoopType(gig::DimensionRegion* d, uint32_t value); + void set_LoopStart(gig::DimensionRegion* d, uint32_t value); + void set_LoopLength(gig::DimensionRegion* d, uint32_t value); + void set_LoopInfinite(gig::DimensionRegion* d, bool value); + void set_LoopPlayCount(gig::DimensionRegion* d, uint32_t value); - void updateLoopElements(); + void onButtonSelectSamplePressed(); }; #endif