/[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 2610 by schoenebeck, Sun Jun 8 19:09:26 2014 UTC revision 3151 by schoenebeck, Fri May 5 18:44:59 2017 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006 - 2014 Andreas Persson   * Copyright (C) 2006 - 2017 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 20  Line 20 
20  #ifndef GIGEDIT_MAINWINDOW_H  #ifndef GIGEDIT_MAINWINDOW_H
21  #define GIGEDIT_MAINWINDOW_H  #define GIGEDIT_MAINWINDOW_H
22    
23  #include <gig.h>  #ifdef LIBGIG_HEADER_FILE
24    # include LIBGIG_HEADER_FILE(gig.h)
25    # include LIBGIG_HEADER_FILE(Serialization.h)
26    #else
27    # include <gig.h>
28    # include <Serialization.h>
29    #endif
30    
31    #include <gtkmm/box.h>
32  #include <gtkmm/actiongroup.h>  #include <gtkmm/actiongroup.h>
33  #include <gtkmm/buttonbox.h>  #include <gtkmm/buttonbox.h>
34  #include <gtkmm/dialog.h>  #include <gtkmm/dialog.h>
# Line 46  Line 53 
53  #ifndef OLD_THREADS  #ifndef OLD_THREADS
54  #include <glibmm/threads.h>  #include <glibmm/threads.h>
55  #endif  #endif
56    #include "ManagedWindow.h"
57    
58  class MainWindow;  class MainWindow;
59    
60  class PropDialog : public Gtk::Window,  class PropDialog : public ManagedWindow,
61                     public PropEditor<DLS::Info> {                     public PropEditor<DLS::Info> {
62  public:  public:
63      PropDialog();      PropDialog();
64      void set_info(DLS::Info* info);      void set_info(DLS::Info* info);
65      void set_file(gig::File* file);      void set_file(gig::File* file);
66    
67        // implementation for abstract methods of interface class "ManagedWindow"
68        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->filePropsWindowX; }
69        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->filePropsWindowY; }
70        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->filePropsWindowW; }
71        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->filePropsWindowH; }
72    
73  protected:  protected:
74      ChoiceEntry<int> eFileFormat;      ChoiceEntry<int> eFileFormat;
75      StringEntry eName;      StringEntry eName;
# Line 83  protected: Line 98  protected:
98      void onFileFormatChanged();      void onFileFormatChanged();
99  };  };
100    
101  class InstrumentProps : public Gtk::Window,  class InstrumentProps : public ManagedWindow,
102                          public PropEditor<gig::Instrument> {                          public PropEditor<gig::Instrument> {
103  public:  public:
104      InstrumentProps();      InstrumentProps();
# Line 93  public: Line 108  public:
108      sigc::signal<void>& signal_name_changed() {      sigc::signal<void>& signal_name_changed() {
109          return sig_name_changed;          return sig_name_changed;
110      }      }
111    
112        // implementation for abstract methods of interface class "ManagedWindow"
113        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->instrPropsWindowX; }
114        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->instrPropsWindowY; }
115        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->instrPropsWindowW; }
116        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->instrPropsWindowH; }
117    
118  protected:  protected:
119      void set_Name(const gig::String& name);      void set_Name(const gig::String& name);
120      void set_IsDrum(bool value);      void set_IsDrum(bool value);
# Line 118  protected: Line 140  protected:
140      NoteEntry eDimensionKeyRangeHigh;      NoteEntry eDimensionKeyRangeHigh;
141  };  };
142    
143  class LoadDialog : public Gtk::Dialog {  class ProgressDialog : public Gtk::Dialog {
144  public:  public:
145      LoadDialog(const Glib::ustring& title, Gtk::Window& parent);      ProgressDialog(const Glib::ustring& title, Gtk::Window& parent);
146      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
147  protected:  protected:
148      Gtk::ProgressBar progressBar;      Gtk::ProgressBar progressBar;
# Line 131  public: Line 153  public:
153      Loader(const char* filename);      Loader(const char* filename);
154      void launch();      void launch();
155      Glib::Dispatcher& signal_progress();      Glib::Dispatcher& signal_progress();
156      Glib::Dispatcher& signal_finished();      Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
157        Glib::Dispatcher& signal_error();
158        void progress_callback(float fraction);
159        float get_progress();
160        const Glib::ustring filename;
161        Glib::ustring error_message;
162        gig::File* gig;
163    
164    private:
165        Glib::Threads::Thread* thread;
166        void thread_function();
167        Glib::Dispatcher finished_dispatcher;
168        Glib::Dispatcher progress_dispatcher;
169        Glib::Dispatcher error_dispatcher;
170        Glib::Threads::Mutex progressMutex;
171        float progress;
172    };
173    
174    class Saver : public sigc::trackable {
175    public:
176        Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"
177        void launch();
178        Glib::Dispatcher& signal_progress();
179        Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
180        Glib::Dispatcher& signal_error();
181      void progress_callback(float fraction);      void progress_callback(float fraction);
182      float get_progress();      float get_progress();
     const char* filename;  
183      gig::File* gig;      gig::File* gig;
184        const Glib::ustring filename;
185        Glib::ustring error_message;
186    
187  private:  private:
188      Glib::Threads::Thread* thread;      Glib::Threads::Thread* thread;
189      void thread_function();      void thread_function();
190      Glib::Dispatcher finished_dispatcher;      Glib::Dispatcher finished_dispatcher;
191      Glib::Dispatcher progress_dispatcher;      Glib::Dispatcher progress_dispatcher;
192        Glib::Dispatcher error_dispatcher;
193      Glib::Threads::Mutex progressMutex;      Glib::Threads::Mutex progressMutex;
194      float progress;      float progress;
195  };  };
196    
197  class MainWindow : public Gtk::Window {  class MainWindow : public ManagedWindow {
198  public:  public:
199      MainWindow();      MainWindow();
200      virtual ~MainWindow();      virtual ~MainWindow();
# Line 170  public: Line 218  public:
218      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
219      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
220    
221        sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();
222    
223        sigc::signal<void, gig::Script*> signal_script_to_be_changed;
224        sigc::signal<void, gig::Script*> signal_script_changed;
225    
226        // implementation for abstract methods of interface class "ManagedWindow"
227        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->mainWindowX; }
228        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->mainWindowY; }
229        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->mainWindowW; }
230        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
231    
232  protected:  protected:
233      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
234      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
# Line 199  protected: Line 258  protected:
258      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
259      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
260    
261        sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;
262    
263      void on_instrument_selection_change(Gtk::RadioMenuItem* item);      void on_instrument_selection_change(Gtk::RadioMenuItem* item);
264      void on_sel_change();      void on_sel_change();
265      void region_changed();      void region_changed();
266      void dimreg_changed();      void dimreg_changed();
267        void select_instrument(gig::Instrument* instrument);
268        bool select_dimension_region(gig::DimensionRegion* dimRgn);
269        void select_sample(gig::Sample* sample);
270      void on_loader_progress();      void on_loader_progress();
271      void on_loader_finished();      void on_loader_finished();
272        void on_loader_error();
273        void on_saver_progress();
274        void on_saver_error();
275        void on_saver_finished();
276    
277      void dimreg_all_dimregs_toggled();      void dimreg_all_dimregs_toggled();
278      gig::Instrument* get_instrument();      gig::Instrument* get_instrument();
279      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 213  protected: Line 282  protected:
282      class ModelColumns : public Gtk::TreeModel::ColumnRecord {      class ModelColumns : public Gtk::TreeModel::ColumnRecord {
283      public:      public:
284          ModelColumns() {          ModelColumns() {
285              add(m_col_nr);
286            add(m_col_name);            add(m_col_name);
287            add(m_col_instr);            add(m_col_instr);
288          }          }
289    
290            Gtk::TreeModelColumn<int> m_col_nr;
291          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
292          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
293      } m_Columns;      } m_Columns;
# Line 231  protected: Line 302  protected:
302    
303      Gtk::Menu* instrument_menu;      Gtk::Menu* instrument_menu;
304    
305        std::map<gig::Sample*,int> sample_ref_count;
306    
307      class SamplesModel : public Gtk::TreeModel::ColumnRecord {      class SamplesModel : public Gtk::TreeModel::ColumnRecord {
308      public:      public:
309          SamplesModel() {          SamplesModel() {
310              add(m_col_name);              add(m_col_name);
311              add(m_col_sample);              add(m_col_sample);
312              add(m_col_group);              add(m_col_group);
313                add(m_col_refcount);
314                add(m_color);
315          }          }
316    
317          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
318          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
319          Gtk::TreeModelColumn<gig::Group*> m_col_group;          Gtk::TreeModelColumn<gig::Group*> m_col_group;
320            Gtk::TreeModelColumn<Glib::ustring> m_col_refcount;
321            Gtk::TreeModelColumn<Glib::ustring> m_color;
322      } m_SamplesModel;      } m_SamplesModel;
323    
324      class SamplesTreeStore : public Gtk::TreeStore {      class SamplesTreeStore : public Gtk::TreeStore {
# Line 289  protected: Line 366  protected:
366      Gtk::CheckButton dimreg_all_regions;      Gtk::CheckButton dimreg_all_regions;
367      Gtk::CheckButton dimreg_all_dimregs;      Gtk::CheckButton dimreg_all_dimregs;
368      Gtk::CheckButton dimreg_stereo;      Gtk::CheckButton dimreg_stereo;
369    
370        Gtk::HBox legend_hbox;
371        Gtk::Label labelLegend;
372        Gtk::Image imageNoSample;
373        Gtk::Label labelNoSample;
374        Gtk::Image imageMissingSample;
375        Gtk::Label labelMissingSample;
376        Gtk::Image imageLooped;
377        Gtk::Label labelLooped;
378        Gtk::Image imageSomeLoops;
379        Gtk::Label labelSomeLoops;
380      DimRegionEdit dimreg_edit;      DimRegionEdit dimreg_edit;
381    
382      Gtk::Notebook m_TreeViewNotebook;      Gtk::Notebook m_TreeViewNotebook;
# Line 300  protected: Line 388  protected:
388          Glib::ustring sample_path; // file name of the sample to be          Glib::ustring sample_path; // file name of the sample to be
389                                     // imported                                     // imported
390      };      };
391      std::list<SampleImportItem> m_SampleImportQueue;      std::map<gig::Sample*, SampleImportItem> m_SampleImportQueue;
392    
393    
394      void on_action_file_new();      void on_action_file_new();
# Line 314  protected: Line 402  protected:
402      void show_midi_rules();      void show_midi_rules();
403      void show_script_slots();      void show_script_slots();
404      void on_action_view_status_bar();      void on_action_view_status_bar();
405        void on_auto_restore_win_dim();
406        void on_save_with_temporary_file();
407        void on_action_refresh_all();
408      void on_action_warn_user_on_extensions();      void on_action_warn_user_on_extensions();
409        void on_action_sync_sampler_instrument_selection();
410        void on_action_move_root_note_with_region_moved();
411      void on_action_help_about();      void on_action_help_about();
412    
413      // sample right-click popup actions      // sample right-click popup actions
# Line 322  protected: Line 415  protected:
415      void on_action_sample_properties();      void on_action_sample_properties();
416      void on_action_add_group();      void on_action_add_group();
417      void on_action_add_sample();      void on_action_add_sample();
418        void on_action_replace_sample();
419      void on_action_replace_all_samples_in_all_groups();      void on_action_replace_all_samples_in_all_groups();
420      void on_action_remove_sample();      void on_action_remove_sample();
421            void on_action_remove_unused_samples();
422    
423      // script right-click popup actions      // script right-click popup actions
424      void on_script_treeview_button_release(GdkEventButton* button);      void on_script_treeview_button_release(GdkEventButton* button);
425      void on_action_add_script_group();      void on_action_add_script_group();
# Line 336  protected: Line 431  protected:
431      void on_action_duplicate_instrument();      void on_action_duplicate_instrument();
432      void on_action_remove_instrument();      void on_action_remove_instrument();
433    
434        void show_samples_tab();
435        void show_intruments_tab();
436        void show_scripts_tab();
437    
438        void select_prev_region();
439        void select_next_region();
440    
441        void select_next_dim_rgn_zone();
442        void select_prev_dim_rgn_zone();
443        void select_add_next_dim_rgn_zone();
444        void select_add_prev_dim_rgn_zone();
445        void select_prev_dimension();
446        void select_next_dimension();
447    
448        Serialization::Archive m_serializationArchive;
449    
450        void copy_selected_dimrgn();
451        void paste_copied_dimrgn();
452        void adjust_clipboard_content();
453        void updateClipboardCopyAvailable();
454        void updateClipboardPasteAvailable();
455        void on_clipboard_owner_change(GdkEventOwnerChange* event);
456        void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);
457        void on_clipboard_clear();
458        void on_clipboard_received(const Gtk::SelectionData& selection_data);
459        void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);
460    
461      void add_instrument(gig::Instrument* instrument);      void add_instrument(gig::Instrument* instrument);
462      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
463                                                 int position = -1);                                                 int position = -1);
464      void remove_instrument_from_menu(int index);      void remove_instrument_from_menu(int index);
465    
466      LoadDialog* load_dialog;      ProgressDialog* progress_dialog;
467      Loader* loader;      Loader* loader;
468        Saver* saver;
469      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
470        void updateSampleRefCountMap(gig::File* gig);
471    
472      gig::File* file;      gig::File* file;
473      bool file_is_shared;      bool file_is_shared;
# Line 360  protected: Line 484  protected:
484      bool check_if_savable();      bool check_if_savable();
485    
486      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
487        void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
488        void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
489                                                   Gtk::SelectionData& selection_data, guint, guint);
490        void on_instruments_treeview_drop_drag_data_received(
491            const Glib::RefPtr<Gdk::DragContext>& context, int, int,
492            const Gtk::SelectionData& selection_data, guint, guint time
493        );
494      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
495      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
496                                             Gtk::SelectionData& selection_data, guint, guint);                                             Gtk::SelectionData& selection_data, guint, guint);
# Line 373  protected: Line 504  protected:
504    
505      void script_name_changed(const Gtk::TreeModel::Path& path,      void script_name_changed(const Gtk::TreeModel::Path& path,
506                               const Gtk::TreeModel::iterator& iter);                               const Gtk::TreeModel::iterator& iter);
507        void script_double_clicked(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
508      void sample_name_changed(const Gtk::TreeModel::Path& path,      void sample_name_changed(const Gtk::TreeModel::Path& path,
509                               const Gtk::TreeModel::iterator& iter);                               const Gtk::TreeModel::iterator& iter);
510      void instrument_name_changed(const Gtk::TreeModel::Path& path,      void instrument_name_changed(const Gtk::TreeModel::Path& path,
# Line 381  protected: Line 513  protected:
513      sigc::connection instrument_name_connection;      sigc::connection instrument_name_connection;
514    
515      void on_action_combine_instruments();      void on_action_combine_instruments();
516        void on_action_view_references();
517      void on_action_merge_files();      void on_action_merge_files();
518      void mergeFiles(const std::vector<std::string>& filenames);      void mergeFiles(const std::vector<std::string>& filenames);
519    
520        void on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample);
521        void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
522        void on_samples_to_be_removed(std::list<gig::Sample*> samples);
523    
524        void add_or_replace_sample(bool replace);
525    
526      void __import_queued_samples();      void __import_queued_samples();
527      void __clear();      void __clear();
528      void __refreshEntireGUI();      void __refreshEntireGUI();

Legend:
Removed from v.2610  
changed lines
  Added in v.3151

  ViewVC Help
Powered by ViewVC