--- gigedit/trunk/src/gigedit/mainwindow.h 2008/04/26 08:52:15 1725 +++ gigedit/trunk/src/gigedit/mainwindow.h 2014/06/11 20:26:26 2624 @@ -1,5 +1,5 @@ /* -*- c++ -*- - * Copyright (C) 2006 - 2008 Andreas Persson + * Copyright (C) 2006 - 2014 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 @@ -26,8 +26,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -40,27 +42,21 @@ #include "regionchooser.h" #include "dimregionchooser.h" #include "dimregionedit.h" +#include "midirules.h" +#ifndef OLD_THREADS +#include +#endif class MainWindow; -class Table : public Gtk::Table -{ -public: - Table(int x, int y); - void add(BoolEntry& boolentry); - void add(BoolEntryPlus6& boolentry); - void add(LabelWidget& labelwidget); -private: - int rowno; -}; - -class PropDialog : public Gtk::Window { +class PropDialog : public Gtk::Window, + public PropEditor { public: PropDialog(); void set_info(DLS::Info* info); - sigc::signal& signal_info_changed(); + void set_file(gig::File* file); protected: - sigc::signal info_changed; + ChoiceEntry eFileFormat; StringEntry eName; StringEntry eCreationDate; StringEntryMultiLine eComments; @@ -81,72 +77,29 @@ Gtk::HButtonBox buttonBox; Gtk::Button quitButton; Table table; - int update_model; - DLS::Info* info; - template - void set_member(T value, T DLS::Info::* member) { - if (update_model == 0) { - info->*member = value; - info_changed(); - } - } + gig::File* m_file; - template - void connect(C& widget, T DLS::Info::* member) { - widget.signal_value_changed().connect( - sigc::compose( - sigc::bind(sigc::mem_fun(*this, &PropDialog::set_member), member), - sigc::mem_fun(widget, &C::get_value))); - } + void onFileFormatChanged(); }; -class InstrumentProps : public Gtk::Window { +class InstrumentProps : public Gtk::Window, + public PropEditor { public: InstrumentProps(); void set_instrument(gig::Instrument* instrument); - sigc::signal& signal_instrument_changed(); -protected: - gig::Instrument* instrument; - int update_model; - - template - void set_value(T value, sigc::slot setter) { - if (update_model == 0) { - setter(this, value); - instrument_changed(); - } - } - - template - void connect(C& widget, T gig::Instrument::* member) { - widget.signal_value_changed().connect( - sigc::compose( - sigc::bind(sigc::mem_fun(*this, &InstrumentProps::set_value), - sigc::bind(sigc::mem_fun(&InstrumentProps::set_member), member)), - sigc::mem_fun(widget, &C::get_value))); - } - - template - void connect(C& widget, void (InstrumentProps::*setter)(T)) { - widget.signal_value_changed().connect( - sigc::compose( - sigc::bind(sigc::mem_fun(*this, &InstrumentProps::set_value), - sigc::mem_fun(setter)), - sigc::mem_fun(widget, &C::get_value))); + gig::Instrument* get_instrument() { return m; } + void update_name(); + sigc::signal& signal_name_changed() { + return sig_name_changed; } - - template - void set_member(T value, T gig::Instrument::* member) { - instrument->*member = value; - } - +protected: + void set_Name(const gig::String& name); void set_IsDrum(bool value); void set_MIDIBank(uint16_t value); void set_MIDIProgram(uint32_t value); - void set_DimensionKeyRange_low(uint8_t value); - void set_DimensionKeyRange_high(uint8_t value); + sigc::signal sig_name_changed; Gtk::VBox vbox; Gtk::HButtonBox buttonBox; Gtk::Button quitButton; @@ -163,7 +116,6 @@ BoolEntry ePianoReleaseMode; NoteEntry eDimensionKeyRangeLow; NoteEntry eDimensionKeyRangeHigh; - sigc::signal instrument_changed; }; class LoadDialog : public Gtk::Dialog { @@ -186,11 +138,11 @@ gig::File* gig; private: - Glib::Thread* thread; + Glib::Threads::Thread* thread; void thread_function(); Glib::Dispatcher finished_dispatcher; Glib::Dispatcher progress_dispatcher; - Glib::Mutex progressMutex; + Glib::Threads::Mutex progressMutex; float progress; }; @@ -209,6 +161,7 @@ sigc::signal& signal_region_changed(); sigc::signal& signal_dimreg_to_be_changed(); sigc::signal& signal_dimreg_changed(); + sigc::signal& signal_sample_changed(); sigc::signal& signal_sample_ref_changed(); sigc::signal& signal_note_on(); @@ -230,6 +183,7 @@ PropDialog propDialog; InstrumentProps instrumentProps; + MidiRules midiRules; sigc::signal file_structure_to_be_changed_signal; sigc::signal file_structure_changed_signal; @@ -239,12 +193,13 @@ sigc::signal region_changed_signal; sigc::signal dimreg_to_be_changed_signal; sigc::signal dimreg_changed_signal; + sigc::signal sample_changed_signal; sigc::signal sample_ref_changed_signal; sigc::signal note_on_signal; sigc::signal note_off_signal; - void on_instrument_selection_change(int index); + void on_instrument_selection_change(Gtk::RadioMenuItem* item); void on_sel_change(); void region_changed(); void dimreg_changed(); @@ -274,17 +229,25 @@ Gtk::TreeView m_TreeView; Glib::RefPtr m_refTreeModel; + Gtk::Menu* instrument_menu; + + std::map sample_ref_count; + class SamplesModel : public Gtk::TreeModel::ColumnRecord { public: SamplesModel() { add(m_col_name); add(m_col_sample); add(m_col_group); + add(m_col_refcount); + add(m_color); } Gtk::TreeModelColumn m_col_name; Gtk::TreeModelColumn m_col_sample; Gtk::TreeModelColumn m_col_group; + Gtk::TreeModelColumn m_col_refcount; + Gtk::TreeModelColumn m_color; } m_SamplesModel; class SamplesTreeStore : public Gtk::TreeStore { @@ -300,6 +263,32 @@ Gtk::TreeView m_TreeViewSamples; Glib::RefPtr m_refSamplesTreeModel; + class ScriptsModel : public Gtk::TreeModel::ColumnRecord { + public: + ScriptsModel() { + add(m_col_name); + add(m_col_script); + add(m_col_group); + } + + Gtk::TreeModelColumn m_col_name; + Gtk::TreeModelColumn m_col_script; + Gtk::TreeModelColumn m_col_group; + } m_ScriptsModel; + + class ScriptsTreeStore : public Gtk::TreeStore { + public: + static Glib::RefPtr create(const ScriptsModel& columns) { + return Glib::RefPtr( new ScriptsTreeStore(columns) ); + } + protected: + ScriptsTreeStore(const ScriptsModel& columns) : Gtk::TreeStore(columns) {} + }; + + Gtk::ScrolledWindow m_ScrolledWindowScripts; + Gtk::TreeView m_TreeViewScripts; + Glib::RefPtr m_refScriptsTreeModel; + Gtk::VBox dimreg_vbox; Gtk::HBox dimreg_hbox; Gtk::Label dimreg_label; @@ -308,7 +297,6 @@ Gtk::CheckButton dimreg_stereo; DimRegionEdit dimreg_edit; - Gtk::Notebook m_Notebook; Gtk::Notebook m_TreeViewNotebook; struct SampleImportItem { @@ -328,7 +316,11 @@ void on_action_file_properties(); void on_action_quit(); void show_instr_props(); + bool instr_props_set_instrument(); + void show_midi_rules(); + void show_script_slots(); void on_action_view_status_bar(); + void on_action_warn_user_on_extensions(); void on_action_help_about(); // sample right-click popup actions @@ -338,13 +330,27 @@ void on_action_add_sample(); void on_action_replace_all_samples_in_all_groups(); void on_action_remove_sample(); + + // script right-click popup actions + void on_script_treeview_button_release(GdkEventButton* button); + void on_action_add_script_group(); + void on_action_add_script(); + void on_action_edit_script(); + void on_action_remove_script(); void on_action_add_instrument(); + void on_action_duplicate_instrument(); void on_action_remove_instrument(); + void add_instrument(gig::Instrument* instrument); + Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name, + int position = -1); + void remove_instrument_from_menu(int index); + LoadDialog* load_dialog; Loader* loader; void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false); + void updateSampleRefCountMap(gig::File* gig); gig::File* file; bool file_is_shared; @@ -361,6 +367,9 @@ bool check_if_savable(); void on_button_release(GdkEventButton* button); + void on_scripts_treeview_drag_begin(const Glib::RefPtr& context); + void on_scripts_treeview_drag_data_get(const Glib::RefPtr&, + Gtk::SelectionData& selection_data, guint, guint); void on_sample_treeview_drag_begin(const Glib::RefPtr& context); void on_sample_treeview_drag_data_get(const Glib::RefPtr&, Gtk::SelectionData& selection_data, guint, guint); @@ -369,13 +378,27 @@ const Gtk::SelectionData& selection_data, guint, guint time); + void script_name_changed(const Gtk::TreeModel::Path& path, + const Gtk::TreeModel::iterator& iter); 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 instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it); + sigc::connection instrument_name_connection; + + void on_action_combine_instruments(); + void on_action_view_references(); + void on_action_merge_files(); + void mergeFiles(const std::vector& filenames); + + void on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample); + void on_sample_ref_count_incremented(gig::Sample* sample, int offset); + void on_samples_to_be_removed(std::list samples); void __import_queued_samples(); void __clear(); + void __refreshEntireGUI(); bool close_confirmation_dialog(); bool leaving_shared_mode_dialog(); @@ -385,6 +408,10 @@ bool on_delete_event(GdkEventAny* event); bool first_call_to_drag_data_get; + + bool is_copy_samples_unity_note_enabled() const; + bool is_copy_samples_fine_tune_enabled() const; + bool is_copy_samples_loop_enabled() const; }; #endif