--- gigedit/trunk/src/gigedit/mainwindow.h 2007/08/26 09:29:52 1303 +++ gigedit/trunk/src/gigedit/mainwindow.h 2012/03/04 09:01:40 2325 @@ -1,5 +1,5 @@ /* -*- c++ -*- - * Copyright (C) 2006, 2007 Andreas Persson + * Copyright (C) 2006 - 2008 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 @@ -32,35 +32,128 @@ #include #include #include +#include +#include #include #include "regionchooser.h" #include "dimregionchooser.h" #include "dimregionedit.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 { public: PropDialog(); void set_info(DLS::Info* info); + sigc::signal& signal_info_changed(); protected: - Gtk::Table table; - Gtk::Label label[16]; - Gtk::Entry entry[16]; + sigc::signal info_changed; + StringEntry eName; + StringEntry eCreationDate; + StringEntryMultiLine eComments; + StringEntry eProduct; + StringEntry eCopyright; + StringEntry eArtists; + StringEntry eGenre; + StringEntry eKeywords; + StringEntry eEngineer; + StringEntry eTechnician; + StringEntry eSoftware; + StringEntry eMedium; + StringEntry eSource; + StringEntry eSourceForm; + StringEntry eCommissioned; + StringEntry eSubject; + Gtk::VBox vbox; + 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(); + } + } + + 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))); + } }; class InstrumentProps : public Gtk::Window { public: InstrumentProps(); void set_instrument(gig::Instrument* instrument); - sigc::signal signal_instrument_changed(); + 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))); + } + + template + void set_member(T value, T gig::Instrument::* member) { + instrument->*member = value; + } + + 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); + Gtk::VBox vbox; Gtk::HButtonBox buttonBox; Gtk::Button quitButton; - Gtk::Table table; + Table table; StringEntry eName; BoolEntry eIsDrum; NumEntryTemp eMIDIBank; @@ -73,12 +166,6 @@ BoolEntry ePianoReleaseMode; NoteEntry eDimensionKeyRangeLow; NoteEntry eDimensionKeyRangeHigh; - int rowno; - void add_prop(BoolEntry& prop); - void add_prop(BoolEntryPlus6& prop); - void add_prop(LabelWidget& prop); - void key_range_low_changed(); - void key_range_high_changed(); sigc::signal instrument_changed; }; @@ -102,11 +189,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; }; @@ -117,23 +204,61 @@ void load_file(const char* name); void load_instrument(gig::Instrument* instr); void file_changed(); + sigc::signal& signal_file_structure_to_be_changed(); + sigc::signal& signal_file_structure_changed(); + sigc::signal >& signal_samples_to_be_removed(); + sigc::signal& signal_samples_removed(); + sigc::signal& signal_region_to_be_changed(); + 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(); + sigc::signal& signal_note_off(); + + sigc::signal& signal_keyboard_key_hit(); + sigc::signal& signal_keyboard_key_released(); protected: Glib::RefPtr actionGroup; Glib::RefPtr uiManager; + Gtk::Statusbar m_StatusBar; + Gtk::Label m_AttachedStateLabel; + Gtk::Image m_AttachedStateImage; + RegionChooser m_RegionChooser; DimRegionChooser m_DimRegionChooser; PropDialog propDialog; InstrumentProps instrumentProps; + sigc::signal file_structure_to_be_changed_signal; + sigc::signal file_structure_changed_signal; + sigc::signal > samples_to_be_removed_signal; + sigc::signal samples_removed_signal; + sigc::signal region_to_be_changed_signal; + 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_sel_change(); void region_changed(); void dimreg_changed(); void on_loader_progress(); void on_loader_finished(); + void dimreg_all_dimregs_toggled(); + gig::Instrument* get_instrument(); + void add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs); + void update_dimregs(); class ModelColumns : public Gtk::TreeModel::ColumnRecord { public: @@ -180,6 +305,12 @@ Gtk::TreeView m_TreeViewSamples; Glib::RefPtr m_refSamplesTreeModel; + Gtk::VBox dimreg_vbox; + Gtk::HBox dimreg_hbox; + Gtk::Label dimreg_label; + Gtk::CheckButton dimreg_all_regions; + Gtk::CheckButton dimreg_all_dimregs; + Gtk::CheckButton dimreg_stereo; DimRegionEdit dimreg_edit; Gtk::Notebook m_Notebook; @@ -202,6 +333,7 @@ void on_action_file_properties(); void on_action_quit(); void show_instr_props(); + void on_action_view_status_bar(); void on_action_help_about(); // sample right-click popup actions @@ -209,6 +341,7 @@ void on_action_sample_properties(); void on_action_add_group(); void on_action_add_sample(); + void on_action_replace_all_samples_in_all_groups(); void on_action_remove_sample(); void on_action_add_instrument(); @@ -216,13 +349,17 @@ LoadDialog* load_dialog; Loader* loader; - void load_gig(gig::File* gig, const char* filename); + void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false); gig::File* file; + bool file_is_shared; bool file_has_name; bool file_is_changed; std::string filename; - std::string current_dir; + std::string current_gig_dir; + std::string current_sample_dir; + + void set_file_is_shared(bool); bool file_save(); bool file_save_as(); @@ -246,6 +383,7 @@ void __clear(); bool close_confirmation_dialog(); + bool leaving_shared_mode_dialog(); Gtk::Menu* popup_menu;