--- gigedit/trunk/src/mainwindow.h 2007/03/15 13:57:47 1099 +++ gigedit/trunk/src/mainwindow.h 2007/03/17 09:20:19 1100 @@ -23,35 +23,21 @@ #include #include -#include -#include #include -#include -#include #include -#include -#include #include -#include #include #include -#include #include -#include -#include #include -#include #include #include -#include -#include #include #include "regionchooser.h" #include "dimregionchooser.h" - -extern bool update_gui; +#include "dimregionedit.h" class MainWindow; @@ -81,7 +67,7 @@ class LoadDialog : public Gtk::Dialog { public: - LoadDialog(); + LoadDialog(const Glib::ustring& title, Gtk::Window& parent); void set_fraction(float fraction) { progressBar.set_fraction(fraction); } protected: Gtk::ProgressBar progressBar; @@ -107,367 +93,19 @@ float progress; }; -class LabelWidget { -public: - Gtk::Label label; - Gtk::Widget& widget; - - LabelWidget(char* labelText, Gtk::Widget& widget); - void set_sensitive(bool sensitive = true); -}; - - -template -class NumEntry : public LabelWidget { -protected: - Gtk::Adjustment adjust; - Gtk::HScale scale; - Gtk::SpinButton spinbutton; - Gtk::HBox box; - T2* dimreg; -public: - NumEntry(char* labelText, double lower = 0, double upper = 127, - int decimals = 0); - void set_value(double value) { - spinbutton.set_value(value); - } - Glib::SignalProxy0 signal_value_changed() { - return spinbutton.signal_value_changed(); - } - double get_value() const { - return spinbutton.get_value(); - } -}; - -template -NumEntry::NumEntry(char* labelText, double lower, double upper, - int decimals) : - adjust(lower, lower, upper, 1, 10), - scale(adjust), - spinbutton(adjust), - LabelWidget(labelText, box) -{ - spinbutton.set_digits(decimals); - scale.set_draw_value(false); - box.pack_start(spinbutton, Gtk::PACK_SHRINK); - box.add(scale); -} - -class NumEntryGain : public NumEntry { -private: - void value_changed(); -public: - NumEntryGain(char* labelText, - double lower, double upper, int decimals); - void set_dimreg(gig::DimensionRegion* dimreg); -}; - -template -class NumEntryX : public NumEntry { -private: - T& (*access)(gig::DimensionRegion*); - void value_changed(); -public: - NumEntryX(char* labelText, T& (*access)(gig::DimensionRegion*), - double lower = 0, double upper = 127, int decimals = 0); - void set_dimreg(gig::DimensionRegion* dimreg); -}; - -template -NumEntryX::NumEntryX(char* labelText, T& (*access)(gig::DimensionRegion*), - double lower, double upper, int decimals) : - NumEntry(labelText, lower, upper, decimals), - access(access) -{ - spinbutton.signal_value_changed().connect( - sigc::mem_fun(*this, &NumEntryX::value_changed)); -} - -template -void NumEntryX::value_changed() -{ - if (dimreg && update_gui) { - access(dimreg) = T(spinbutton.get_value()); - } -} - -template -void NumEntryX::set_dimreg(gig::DimensionRegion* dimreg) -{ - this->dimreg = 0; - set_value(access(dimreg)); - this->dimreg = dimreg; -} - - -class NoteEntry : public NumEntryX { -public: - NoteEntry(char* labelText, uint8_t& (*access)(gig::DimensionRegion*)); -private: - int on_input(double* new_value); - bool on_output(); -}; - - -template -class NumEntryTemp : public NumEntry { - using NumEntry::spinbutton; - using NumEntry::dimreg; -private: - T T2::* param; - void value_changed(); -public: - NumEntryTemp(char* labelText, T T2::* param, - double lower = 0, double upper = 127, int decimals = 0); - void set_dimreg(gig::DimensionRegion* dimreg); -}; - -template -NumEntryTemp::NumEntryTemp(char* labelText, T T2::* param, - double lower, double upper, int decimals) : - NumEntry(labelText, lower, upper, decimals), - param(param) -{ - spinbutton.signal_value_changed().connect( - sigc::mem_fun(*this, &NumEntryTemp::value_changed)); -} - -template -void NumEntryTemp::value_changed() -{ - if (dimreg && update_gui) { - dimreg->*param = T(spinbutton.get_value()); - } -} - -template -void NumEntryTemp::set_dimreg(gig::DimensionRegion* dimreg) -{ - this->dimreg = 0; - set_value(dimreg->*param); - this->dimreg = dimreg; -} - - - -class NumEntryPermille : public NumEntry { -private: - uint16_t gig::DimensionRegion::* param; - void value_changed(); -public: - NumEntryPermille(char* labelText, uint16_t gig::DimensionRegion::* param, - double lower = 0, double upper = 127, int decimals = 0); - void set_dimreg(gig::DimensionRegion* dimreg); -}; - - -template -class ChoiceEntry : public LabelWidget { -private: - Gtk::ComboBoxText combobox; - Gtk::Alignment align; - T gig::DimensionRegion::* param; - gig::DimensionRegion* dimreg; - void value_changed(); - const T* values; -public: - ChoiceEntry(char* labelText, - T gig::DimensionRegion::* param); - void set_choices(char** texts, const T* values); - void set_dimreg(gig::DimensionRegion* dimreg); - int get_active_row_number() { return combobox.get_active_row_number(); } - Glib::SignalProxy0 signal_changed() { - return combobox.signal_changed(); - } -}; - -template -ChoiceEntry::ChoiceEntry(char* labelText, - T gig::DimensionRegion::* param) : - align(0, 0, 0, 0), - LabelWidget(labelText, align), - param(param) -{ - combobox.signal_changed().connect( - sigc::mem_fun(*this, &ChoiceEntry::value_changed)); - align.add(combobox); -} - -template -void ChoiceEntry::set_choices(char** texts, const T* values) -{ - for (int i = 0 ; texts[i] ; i++) { - combobox.append_text(texts[i]); - } - this->values = values; -} - -template -void ChoiceEntry::value_changed() -{ - if (dimreg && update_gui) { - int rowno = combobox.get_active_row_number(); - if (rowno != -1) dimreg->*param = values[rowno]; - } -} - -template -void ChoiceEntry::set_dimreg(gig::DimensionRegion* dimreg) -{ - this->dimreg = 0; - T value = dimreg->*param; - int row = 0; - int nb_rows = combobox.get_model()->children().size(); - for (; row < nb_rows ; row++) { - if (value == values[row]) break; - } - combobox.set_active(row == nb_rows ? -1 : row); - this->dimreg = dimreg; -} - - -class ChoiceEntryLeverageCtrl : public LabelWidget { -private: - Gtk::ComboBoxText combobox; - Gtk::Alignment align; - gig::leverage_ctrl_t gig::DimensionRegion::* param; - gig::DimensionRegion* dimreg; - void value_changed(); -public: - ChoiceEntryLeverageCtrl(char* labelText, - gig::leverage_ctrl_t gig::DimensionRegion::* param); - void set_dimreg(gig::DimensionRegion* dimreg); - int get_active_row_number() { return combobox.get_active_row_number(); } - Glib::SignalProxy0 signal_changed() { - return combobox.signal_changed(); - } -}; - - - -class BoolEntry : public LabelWidget { -private: - Gtk::CheckButton checkbutton; - bool gig::DimensionRegion::* param; - gig::DimensionRegion* dimreg; - void value_changed(); -public: - BoolEntry(char* labelText, bool gig::DimensionRegion::* param); - void set_dimreg(gig::DimensionRegion* dimreg); - bool get_active() { return checkbutton.get_active(); } - Glib::SignalProxy0 signal_toggled() { - return checkbutton.signal_toggled(); - } -}; - class MainWindow : public Gtk::Window { public: MainWindow(); virtual ~MainWindow(); - void getInfo(const char* filename); + void load_file(const char* name); protected: Glib::RefPtr actionGroup; Glib::RefPtr uiManager; - int rowno; - int pageno; - int firstRowInBlock; - - NumEntryPermille eEG1PreAttack; - NumEntryTemp eEG1Attack; - NumEntryTemp eEG1Decay1; - NumEntryTemp eEG1Decay2; - BoolEntry eEG1InfiniteSustain; - NumEntryPermille eEG1Sustain; - NumEntryTemp eEG1Release; - BoolEntry eEG1Hold; - ChoiceEntryLeverageCtrl eEG1Controller; - BoolEntry eEG1ControllerInvert; - NumEntryTemp eEG1ControllerAttackInfluence; - NumEntryTemp eEG1ControllerDecayInfluence; - NumEntryTemp eEG1ControllerReleaseInfluence; - NumEntryTemp eLFO1Frequency; - NumEntryTemp eLFO1InternalDepth; - NumEntryTemp eLFO1ControlDepth; - ChoiceEntry eLFO1Controller; - BoolEntry eLFO1FlipPhase; - BoolEntry eLFO1Sync; - NumEntryPermille eEG2PreAttack; - NumEntryTemp eEG2Attack; - NumEntryTemp eEG2Decay1; - NumEntryTemp eEG2Decay2; - BoolEntry eEG2InfiniteSustain; - NumEntryPermille eEG2Sustain; - NumEntryTemp eEG2Release; - ChoiceEntryLeverageCtrl eEG2Controller; - BoolEntry eEG2ControllerInvert; - NumEntryTemp eEG2ControllerAttackInfluence; - NumEntryTemp eEG2ControllerDecayInfluence; - NumEntryTemp eEG2ControllerReleaseInfluence; - NumEntryTemp eLFO2Frequency; - NumEntryTemp eLFO2InternalDepth; - NumEntryTemp eLFO2ControlDepth; - ChoiceEntry eLFO2Controller; - BoolEntry eLFO2FlipPhase; - BoolEntry eLFO2Sync; - NumEntryTemp eEG3Attack; - NumEntryTemp eEG3Depth; - NumEntryTemp eLFO3Frequency; - NumEntryTemp eLFO3InternalDepth; - NumEntryTemp eLFO3ControlDepth; - ChoiceEntry eLFO3Controller; - BoolEntry eLFO3Sync; - BoolEntry eVCFEnabled; - ChoiceEntry eVCFType; - ChoiceEntry eVCFCutoffController; - BoolEntry eVCFCutoffControllerInvert; - NumEntryTemp eVCFCutoff; - ChoiceEntry eVCFVelocityCurve; - NumEntryTemp eVCFVelocityScale; - NumEntryTemp eVCFVelocityDynamicRange; - NumEntryTemp eVCFResonance; - BoolEntry eVCFResonanceDynamic; - ChoiceEntry eVCFResonanceController; - BoolEntry eVCFKeyboardTracking; - NumEntryTemp eVCFKeyboardTrackingBreakpoint; - ChoiceEntry eVelocityResponseCurve; - NumEntryTemp eVelocityResponseDepth; - NumEntryTemp eVelocityResponseCurveScaling; - ChoiceEntry eReleaseVelocityResponseCurve; - NumEntryTemp eReleaseVelocityResponseDepth; - NumEntryTemp eReleaseTriggerDecay; - NumEntryX eCrossfade_in_start; - NumEntryX eCrossfade_in_end; - NumEntryX eCrossfade_out_start; - NumEntryX eCrossfade_out_end; - BoolEntry ePitchTrack; - ChoiceEntry eDimensionBypass; - NumEntryTemp ePan; - BoolEntry eSelfMask; - ChoiceEntryLeverageCtrl eAttenuationController; - BoolEntry eInvertAttenuationController; - NumEntryTemp eAttenuationControllerThreshold; - NumEntryTemp eChannelOffset; - BoolEntry eSustainDefeat; - BoolEntry eMSDecode; - NumEntryTemp eSampleStartOffset; - // NumEntryX eUnityNote; - NoteEntry eUnityNote; - NumEntryX eFineTune; - NumEntryGain eGain; - NumEntryX eSampleLoops; - - void addProp(LabelWidget& labelwidget); - void addString(char* labelText, Gtk::Label*& label, - Gtk::Entry*& widget); - void addHeader(char* text); - void nextPage(); - RegionChooser m_RegionChooser; DimRegionChooser m_DimRegionChooser; - void set_dim_region(gig::DimensionRegion* d); PropDialog propDialog; InstrumentProps instrumentProps; @@ -480,7 +118,6 @@ class ModelColumns : public Gtk::TreeModel::ColumnRecord { public: - ModelColumns() { add(m_col_name); add(m_col_instr); @@ -494,6 +131,7 @@ Gtk::HPaned m_HPaned; Gtk::ScrolledWindow m_ScrolledWindow; + Gtk::TreeView m_TreeView; Glib::RefPtr m_refTreeModel; @@ -523,43 +161,27 @@ Gtk::TreeView m_TreeViewSamples; Glib::RefPtr m_refSamplesTreeModel; + DimRegionEdit dimreg_edit; + Gtk::Notebook m_Notebook; Gtk::Notebook m_TreeViewNotebook; - Gtk::Table* table[5]; - - // dimensionregion parameter widgets - // TODO: remove: - Gtk::Label* lSample; - Gtk::Entry* wSample; - struct SampleImportItem { - gig::Sample* gig_sample; // pointer to the gig::Sample to which the sample data should be imported to - Glib::ustring sample_path; // file name of the sample to be imported + gig::Sample* gig_sample; // pointer to the gig::Sample to + // which the sample data should be + // imported to + Glib::ustring sample_path; // file name of the sample to be + // imported }; std::list m_SampleImportQueue; - void VCFEnabled_toggled(); - void VCFCutoffController_changed(); - void VCFResonanceController_changed(); - void EG1InfiniteSustain_toggled(); - void EG2InfiniteSustain_toggled(); - void EG1Controller_changed(); - void EG2Controller_changed(); - void AttenuationController_changed(); - void LFO1Controller_changed(); - void LFO2Controller_changed(); - void LFO3Controller_changed(); - void crossfade1_changed(); - void crossfade2_changed(); - void crossfade3_changed(); - void crossfade4_changed(); void on_action_file_new(); void on_action_file_open(); void on_action_file_save(); void on_action_file_save_as(); void on_action_file_properties(); + void show_instr_props(); void on_action_help_about(); // sample right-click popup actions @@ -576,14 +198,20 @@ gig::File* file; void on_button_release(GdkEventButton* button); - void on_sample_treeview_drag_data_get(const Glib::RefPtr&, Gtk::SelectionData& selection_data, guint, guint); - void on_sample_label_drop_drag_data_received(const Glib::RefPtr& context, int, int, const Gtk::SelectionData& selection_data, guint, guint time); - void sample_name_changed(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter); - void instrument_name_changed(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter); + void on_sample_treeview_drag_data_get(const Glib::RefPtr&, + Gtk::SelectionData& selection_data, guint, guint); + void on_sample_label_drop_drag_data_received(const Glib::RefPtr& context, + int, int, + const Gtk::SelectionData& selection_data, + guint, guint time); + void sample_name_changed(const Gtk::TreeModel::Path& path, + const Gtk::TreeModel::iterator& iter); + void instrument_name_changed(const Gtk::TreeModel::Path& path, + const Gtk::TreeModel::iterator& iter); void __import_queued_samples(); - Gtk::Menu* popup_menu; + Gtk::Menu* popup_menu; }; #endif