/[svn]/gigedit/trunk/src/gigedit/mainwindow.h
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/mainwindow.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2541 by schoenebeck, Wed Apr 23 16:49:05 2014 UTC revision 2893 by schoenebeck, Fri Apr 29 14:19:53 2016 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006 - 2014 Andreas Persson   * Copyright (C) 2006 - 2016 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 22  Line 22 
22    
23  #include <gig.h>  #include <gig.h>
24    
25    #include <gtkmm/box.h>
26  #include <gtkmm/actiongroup.h>  #include <gtkmm/actiongroup.h>
27  #include <gtkmm/buttonbox.h>  #include <gtkmm/buttonbox.h>
28  #include <gtkmm/dialog.h>  #include <gtkmm/dialog.h>
# Line 46  Line 47 
47  #ifndef OLD_THREADS  #ifndef OLD_THREADS
48  #include <glibmm/threads.h>  #include <glibmm/threads.h>
49  #endif  #endif
50    #include "ManagedWindow.h"
51    
52  class MainWindow;  class MainWindow;
53    
# Line 54  class PropDialog : public Gtk::Window, Line 56  class PropDialog : public Gtk::Window,
56  public:  public:
57      PropDialog();      PropDialog();
58      void set_info(DLS::Info* info);      void set_info(DLS::Info* info);
59        void set_file(gig::File* file);
60  protected:  protected:
61        ChoiceEntry<int> eFileFormat;
62      StringEntry eName;      StringEntry eName;
63      StringEntry eCreationDate;      StringEntry eCreationDate;
64      StringEntryMultiLine eComments;      StringEntryMultiLine eComments;
# Line 75  protected: Line 79  protected:
79      Gtk::HButtonBox buttonBox;      Gtk::HButtonBox buttonBox;
80      Gtk::Button quitButton;      Gtk::Button quitButton;
81      Table table;      Table table;
82    
83        gig::File* m_file;
84    
85        void onFileFormatChanged();
86  };  };
87    
88  class InstrumentProps : public Gtk::Window,  class InstrumentProps : public Gtk::Window,
# Line 112  protected: Line 120  protected:
120      NoteEntry eDimensionKeyRangeHigh;      NoteEntry eDimensionKeyRangeHigh;
121  };  };
122    
123  class LoadDialog : public Gtk::Dialog {  class ProgressDialog : public Gtk::Dialog {
124  public:  public:
125      LoadDialog(const Glib::ustring& title, Gtk::Window& parent);      ProgressDialog(const Glib::ustring& title, Gtk::Window& parent);
126      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
127  protected:  protected:
128      Gtk::ProgressBar progressBar;      Gtk::ProgressBar progressBar;
# Line 125  public: Line 133  public:
133      Loader(const char* filename);      Loader(const char* filename);
134      void launch();      void launch();
135      Glib::Dispatcher& signal_progress();      Glib::Dispatcher& signal_progress();
136      Glib::Dispatcher& signal_finished();      Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
137        Glib::Dispatcher& signal_error();
138        void progress_callback(float fraction);
139        float get_progress();
140        const Glib::ustring filename;
141        Glib::ustring error_message;
142        gig::File* gig;
143    
144    private:
145        Glib::Threads::Thread* thread;
146        void thread_function();
147        Glib::Dispatcher finished_dispatcher;
148        Glib::Dispatcher progress_dispatcher;
149        Glib::Dispatcher error_dispatcher;
150        Glib::Threads::Mutex progressMutex;
151        float progress;
152    };
153    
154    class Saver : public sigc::trackable {
155    public:
156        Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"
157        void launch();
158        Glib::Dispatcher& signal_progress();
159        Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
160        Glib::Dispatcher& signal_error();
161      void progress_callback(float fraction);      void progress_callback(float fraction);
162      float get_progress();      float get_progress();
     const char* filename;  
163      gig::File* gig;      gig::File* gig;
164        const Glib::ustring filename;
165        Glib::ustring error_message;
166    
167  private:  private:
168      Glib::Threads::Thread* thread;      Glib::Threads::Thread* thread;
169      void thread_function();      void thread_function();
170      Glib::Dispatcher finished_dispatcher;      Glib::Dispatcher finished_dispatcher;
171      Glib::Dispatcher progress_dispatcher;      Glib::Dispatcher progress_dispatcher;
172        Glib::Dispatcher error_dispatcher;
173      Glib::Threads::Mutex progressMutex;      Glib::Threads::Mutex progressMutex;
174      float progress;      float progress;
175  };  };
176    
177  class MainWindow : public Gtk::Window {  class MainWindow : public ManagedWindow {
178  public:  public:
179      MainWindow();      MainWindow();
180      virtual ~MainWindow();      virtual ~MainWindow();
# Line 164  public: Line 198  public:
198      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
199      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
200    
201        sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();
202        
203        // implementation for abstract methods of interface class "ManagedWindow"
204        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->mainWindowX; }
205        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->mainWindowY; }
206        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->mainWindowW; }
207        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
208    
209  protected:  protected:
210      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
211      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
# Line 193  protected: Line 235  protected:
235      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
236      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
237    
238        sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;
239    
240      void on_instrument_selection_change(Gtk::RadioMenuItem* item);      void on_instrument_selection_change(Gtk::RadioMenuItem* item);
241      void on_sel_change();      void on_sel_change();
242      void region_changed();      void region_changed();
243      void dimreg_changed();      void dimreg_changed();
244        void select_instrument(gig::Instrument* instrument);
245        bool select_dimension_region(gig::DimensionRegion* dimRgn);
246        void select_sample(gig::Sample* sample);
247      void on_loader_progress();      void on_loader_progress();
248      void on_loader_finished();      void on_loader_finished();
249        void on_loader_error();
250        void on_saver_progress();
251        void on_saver_error();
252        void on_saver_finished();
253    
254      void dimreg_all_dimregs_toggled();      void dimreg_all_dimregs_toggled();
255      gig::Instrument* get_instrument();      gig::Instrument* get_instrument();
256      void add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs);      void add_region_to_dimregs(gig::Region* region, bool stereo, bool all_dimregs);
# Line 225  protected: Line 277  protected:
277    
278      Gtk::Menu* instrument_menu;      Gtk::Menu* instrument_menu;
279    
280        std::map<gig::Sample*,int> sample_ref_count;
281    
282      class SamplesModel : public Gtk::TreeModel::ColumnRecord {      class SamplesModel : public Gtk::TreeModel::ColumnRecord {
283      public:      public:
284          SamplesModel() {          SamplesModel() {
285              add(m_col_name);              add(m_col_name);
286              add(m_col_sample);              add(m_col_sample);
287              add(m_col_group);              add(m_col_group);
288                add(m_col_refcount);
289                add(m_color);
290          }          }
291    
292          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
293          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
294          Gtk::TreeModelColumn<gig::Group*> m_col_group;          Gtk::TreeModelColumn<gig::Group*> m_col_group;
295            Gtk::TreeModelColumn<Glib::ustring> m_col_refcount;
296            Gtk::TreeModelColumn<Glib::ustring> m_color;
297      } m_SamplesModel;      } m_SamplesModel;
298    
299      class SamplesTreeStore : public Gtk::TreeStore {      class SamplesTreeStore : public Gtk::TreeStore {
# Line 251  protected: Line 309  protected:
309      Gtk::TreeView m_TreeViewSamples;      Gtk::TreeView m_TreeViewSamples;
310      Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;      Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;
311    
312        class ScriptsModel : public Gtk::TreeModel::ColumnRecord {
313        public:
314            ScriptsModel() {
315                add(m_col_name);
316                add(m_col_script);
317                add(m_col_group);
318            }
319    
320            Gtk::TreeModelColumn<Glib::ustring> m_col_name;
321            Gtk::TreeModelColumn<gig::Script*> m_col_script;
322            Gtk::TreeModelColumn<gig::ScriptGroup*> m_col_group;
323        } m_ScriptsModel;
324    
325        class ScriptsTreeStore : public Gtk::TreeStore {
326        public:
327            static Glib::RefPtr<ScriptsTreeStore> create(const ScriptsModel& columns) {
328                return Glib::RefPtr<ScriptsTreeStore>( new ScriptsTreeStore(columns) );
329            }
330        protected:
331            ScriptsTreeStore(const ScriptsModel& columns) : Gtk::TreeStore(columns) {}
332        };
333    
334        Gtk::ScrolledWindow m_ScrolledWindowScripts;
335        Gtk::TreeView m_TreeViewScripts;
336        Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel;
337    
338      Gtk::VBox dimreg_vbox;      Gtk::VBox dimreg_vbox;
339      Gtk::HBox dimreg_hbox;      Gtk::HBox dimreg_hbox;
340      Gtk::Label dimreg_label;      Gtk::Label dimreg_label;
# Line 280  protected: Line 364  protected:
364      void show_instr_props();      void show_instr_props();
365      bool instr_props_set_instrument();      bool instr_props_set_instrument();
366      void show_midi_rules();      void show_midi_rules();
367        void show_script_slots();
368      void on_action_view_status_bar();      void on_action_view_status_bar();
369        void on_action_refresh_all();
370      void on_action_warn_user_on_extensions();      void on_action_warn_user_on_extensions();
371        void on_action_sync_sampler_instrument_selection();
372        void on_action_move_root_note_with_region_moved();
373      void on_action_help_about();      void on_action_help_about();
374    
375      // sample right-click popup actions      // sample right-click popup actions
# Line 289  protected: Line 377  protected:
377      void on_action_sample_properties();      void on_action_sample_properties();
378      void on_action_add_group();      void on_action_add_group();
379      void on_action_add_sample();      void on_action_add_sample();
380        void on_action_replace_sample();
381      void on_action_replace_all_samples_in_all_groups();      void on_action_replace_all_samples_in_all_groups();
382      void on_action_remove_sample();      void on_action_remove_sample();
383        void on_action_remove_unused_samples();
384    
385        // script right-click popup actions
386        void on_script_treeview_button_release(GdkEventButton* button);
387        void on_action_add_script_group();
388        void on_action_add_script();
389        void on_action_edit_script();
390        void on_action_remove_script();
391    
392      void on_action_add_instrument();      void on_action_add_instrument();
393      void on_action_duplicate_instrument();      void on_action_duplicate_instrument();
394      void on_action_remove_instrument();      void on_action_remove_instrument();
395    
396        void show_samples_tab();
397        void show_intruments_tab();
398        void show_scripts_tab();
399    
400      void add_instrument(gig::Instrument* instrument);      void add_instrument(gig::Instrument* instrument);
401      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
402                                                 int position = -1);                                                 int position = -1);
403      void remove_instrument_from_menu(int index);      void remove_instrument_from_menu(int index);
404    
405      LoadDialog* load_dialog;      ProgressDialog* progress_dialog;
406      Loader* loader;      Loader* loader;
407        Saver* saver;
408      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
409        void updateSampleRefCountMap(gig::File* gig);
410    
411      gig::File* file;      gig::File* file;
412      bool file_is_shared;      bool file_is_shared;
# Line 320  protected: Line 423  protected:
423      bool check_if_savable();      bool check_if_savable();
424    
425      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
426        void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
427        void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
428                                                   Gtk::SelectionData& selection_data, guint, guint);
429        void on_instruments_treeview_drop_drag_data_received(
430            const Glib::RefPtr<Gdk::DragContext>& context, int, int,
431            const Gtk::SelectionData& selection_data, guint, guint time
432        );
433        void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
434        void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
435                                               Gtk::SelectionData& selection_data, guint, guint);
436      void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
437      void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
438                                            Gtk::SelectionData& selection_data, guint, guint);                                            Gtk::SelectionData& selection_data, guint, guint);
# Line 328  protected: Line 441  protected:
441                                                   const Gtk::SelectionData& selection_data,                                                   const Gtk::SelectionData& selection_data,
442                                                   guint, guint time);                                                   guint, guint time);
443    
444        void script_name_changed(const Gtk::TreeModel::Path& path,
445                                 const Gtk::TreeModel::iterator& iter);
446        void script_double_clicked(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
447      void sample_name_changed(const Gtk::TreeModel::Path& path,      void sample_name_changed(const Gtk::TreeModel::Path& path,
448                               const Gtk::TreeModel::iterator& iter);                               const Gtk::TreeModel::iterator& iter);
449      void instrument_name_changed(const Gtk::TreeModel::Path& path,      void instrument_name_changed(const Gtk::TreeModel::Path& path,
# Line 335  protected: Line 451  protected:
451      void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it);      void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it);
452      sigc::connection instrument_name_connection;      sigc::connection instrument_name_connection;
453    
454        void on_action_combine_instruments();
455        void on_action_view_references();
456        void on_action_merge_files();
457        void mergeFiles(const std::vector<std::string>& filenames);
458    
459        void on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample);
460        void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
461        void on_samples_to_be_removed(std::list<gig::Sample*> samples);
462    
463        void add_or_replace_sample(bool replace);
464    
465      void __import_queued_samples();      void __import_queued_samples();
466      void __clear();      void __clear();
467        void __refreshEntireGUI();
468    
469      bool close_confirmation_dialog();      bool close_confirmation_dialog();
470      bool leaving_shared_mode_dialog();      bool leaving_shared_mode_dialog();

Legend:
Removed from v.2541  
changed lines
  Added in v.2893

  ViewVC Help
Powered by ViewVC