/[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 2994 by schoenebeck, Sat Sep 24 23:34:37 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    
54  class PropDialog : public Gtk::Window,  class PropDialog : public ManagedWindow,
55                     public PropEditor<DLS::Info> {                     public PropEditor<DLS::Info> {
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);      void set_file(gig::File* file);
60    
61        // implementation for abstract methods of interface class "ManagedWindow"
62        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->filePropsWindowX; }
63        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->filePropsWindowY; }
64        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->filePropsWindowW; }
65        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->filePropsWindowH; }
66    
67  protected:  protected:
68      ChoiceEntry<int> eFileFormat;      ChoiceEntry<int> eFileFormat;
69      StringEntry eName;      StringEntry eName;
# Line 83  protected: Line 92  protected:
92      void onFileFormatChanged();      void onFileFormatChanged();
93  };  };
94    
95  class InstrumentProps : public Gtk::Window,  class InstrumentProps : public ManagedWindow,
96                          public PropEditor<gig::Instrument> {                          public PropEditor<gig::Instrument> {
97  public:  public:
98      InstrumentProps();      InstrumentProps();
# Line 93  public: Line 102  public:
102      sigc::signal<void>& signal_name_changed() {      sigc::signal<void>& signal_name_changed() {
103          return sig_name_changed;          return sig_name_changed;
104      }      }
105    
106        // implementation for abstract methods of interface class "ManagedWindow"
107        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->instrPropsWindowX; }
108        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->instrPropsWindowY; }
109        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->instrPropsWindowW; }
110        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->instrPropsWindowH; }
111    
112  protected:  protected:
113      void set_Name(const gig::String& name);      void set_Name(const gig::String& name);
114      void set_IsDrum(bool value);      void set_IsDrum(bool value);
# Line 118  protected: Line 134  protected:
134      NoteEntry eDimensionKeyRangeHigh;      NoteEntry eDimensionKeyRangeHigh;
135  };  };
136    
137  class LoadDialog : public Gtk::Dialog {  class ProgressDialog : public Gtk::Dialog {
138  public:  public:
139      LoadDialog(const Glib::ustring& title, Gtk::Window& parent);      ProgressDialog(const Glib::ustring& title, Gtk::Window& parent);
140      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
141  protected:  protected:
142      Gtk::ProgressBar progressBar;      Gtk::ProgressBar progressBar;
# Line 131  public: Line 147  public:
147      Loader(const char* filename);      Loader(const char* filename);
148      void launch();      void launch();
149      Glib::Dispatcher& signal_progress();      Glib::Dispatcher& signal_progress();
150      Glib::Dispatcher& signal_finished();      Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
151        Glib::Dispatcher& signal_error();
152        void progress_callback(float fraction);
153        float get_progress();
154        const Glib::ustring filename;
155        Glib::ustring error_message;
156        gig::File* gig;
157    
158    private:
159        Glib::Threads::Thread* thread;
160        void thread_function();
161        Glib::Dispatcher finished_dispatcher;
162        Glib::Dispatcher progress_dispatcher;
163        Glib::Dispatcher error_dispatcher;
164        Glib::Threads::Mutex progressMutex;
165        float progress;
166    };
167    
168    class Saver : public sigc::trackable {
169    public:
170        Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"
171        void launch();
172        Glib::Dispatcher& signal_progress();
173        Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
174        Glib::Dispatcher& signal_error();
175      void progress_callback(float fraction);      void progress_callback(float fraction);
176      float get_progress();      float get_progress();
     const char* filename;  
177      gig::File* gig;      gig::File* gig;
178        const Glib::ustring filename;
179        Glib::ustring error_message;
180    
181  private:  private:
182      Glib::Threads::Thread* thread;      Glib::Threads::Thread* thread;
183      void thread_function();      void thread_function();
184      Glib::Dispatcher finished_dispatcher;      Glib::Dispatcher finished_dispatcher;
185      Glib::Dispatcher progress_dispatcher;      Glib::Dispatcher progress_dispatcher;
186        Glib::Dispatcher error_dispatcher;
187      Glib::Threads::Mutex progressMutex;      Glib::Threads::Mutex progressMutex;
188      float progress;      float progress;
189  };  };
190    
191  class MainWindow : public Gtk::Window {  class MainWindow : public ManagedWindow {
192  public:  public:
193      MainWindow();      MainWindow();
194      virtual ~MainWindow();      virtual ~MainWindow();
# Line 170  public: Line 212  public:
212      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
213      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
214    
215        sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();
216    
217        sigc::signal<void, gig::Script*> signal_script_to_be_changed;
218        sigc::signal<void, gig::Script*> signal_script_changed;
219    
220        // implementation for abstract methods of interface class "ManagedWindow"
221        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->mainWindowX; }
222        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->mainWindowY; }
223        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->mainWindowW; }
224        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
225    
226  protected:  protected:
227      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
228      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
# Line 199  protected: Line 252  protected:
252      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
253      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
254    
255        sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;
256    
257      void on_instrument_selection_change(Gtk::RadioMenuItem* item);      void on_instrument_selection_change(Gtk::RadioMenuItem* item);
258      void on_sel_change();      void on_sel_change();
259      void region_changed();      void region_changed();
260      void dimreg_changed();      void dimreg_changed();
261        void select_instrument(gig::Instrument* instrument);
262        bool select_dimension_region(gig::DimensionRegion* dimRgn);
263        void select_sample(gig::Sample* sample);
264      void on_loader_progress();      void on_loader_progress();
265      void on_loader_finished();      void on_loader_finished();
266        void on_loader_error();
267        void on_saver_progress();
268        void on_saver_error();
269        void on_saver_finished();
270    
271      void dimreg_all_dimregs_toggled();      void dimreg_all_dimregs_toggled();
272      gig::Instrument* get_instrument();      gig::Instrument* get_instrument();
273      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 276  protected:
276      class ModelColumns : public Gtk::TreeModel::ColumnRecord {      class ModelColumns : public Gtk::TreeModel::ColumnRecord {
277      public:      public:
278          ModelColumns() {          ModelColumns() {
279              add(m_col_nr);
280            add(m_col_name);            add(m_col_name);
281            add(m_col_instr);            add(m_col_instr);
282          }          }
283    
284            Gtk::TreeModelColumn<int> m_col_nr;
285          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
286          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
287      } m_Columns;      } m_Columns;
# Line 231  protected: Line 296  protected:
296    
297      Gtk::Menu* instrument_menu;      Gtk::Menu* instrument_menu;
298    
299        std::map<gig::Sample*,int> sample_ref_count;
300    
301      class SamplesModel : public Gtk::TreeModel::ColumnRecord {      class SamplesModel : public Gtk::TreeModel::ColumnRecord {
302      public:      public:
303          SamplesModel() {          SamplesModel() {
304              add(m_col_name);              add(m_col_name);
305              add(m_col_sample);              add(m_col_sample);
306              add(m_col_group);              add(m_col_group);
307                add(m_col_refcount);
308                add(m_color);
309          }          }
310    
311          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
312          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
313          Gtk::TreeModelColumn<gig::Group*> m_col_group;          Gtk::TreeModelColumn<gig::Group*> m_col_group;
314            Gtk::TreeModelColumn<Glib::ustring> m_col_refcount;
315            Gtk::TreeModelColumn<Glib::ustring> m_color;
316      } m_SamplesModel;      } m_SamplesModel;
317    
318      class SamplesTreeStore : public Gtk::TreeStore {      class SamplesTreeStore : public Gtk::TreeStore {
# Line 314  protected: Line 385  protected:
385      void show_midi_rules();      void show_midi_rules();
386      void show_script_slots();      void show_script_slots();
387      void on_action_view_status_bar();      void on_action_view_status_bar();
388        void on_auto_restore_win_dim();
389        void on_save_with_temporary_file();
390        void on_action_refresh_all();
391      void on_action_warn_user_on_extensions();      void on_action_warn_user_on_extensions();
392        void on_action_sync_sampler_instrument_selection();
393        void on_action_move_root_note_with_region_moved();
394      void on_action_help_about();      void on_action_help_about();
395    
396      // sample right-click popup actions      // sample right-click popup actions
# Line 322  protected: Line 398  protected:
398      void on_action_sample_properties();      void on_action_sample_properties();
399      void on_action_add_group();      void on_action_add_group();
400      void on_action_add_sample();      void on_action_add_sample();
401        void on_action_replace_sample();
402      void on_action_replace_all_samples_in_all_groups();      void on_action_replace_all_samples_in_all_groups();
403      void on_action_remove_sample();      void on_action_remove_sample();
404            void on_action_remove_unused_samples();
405    
406      // script right-click popup actions      // script right-click popup actions
407      void on_script_treeview_button_release(GdkEventButton* button);      void on_script_treeview_button_release(GdkEventButton* button);
408      void on_action_add_script_group();      void on_action_add_script_group();
# Line 336  protected: Line 414  protected:
414      void on_action_duplicate_instrument();      void on_action_duplicate_instrument();
415      void on_action_remove_instrument();      void on_action_remove_instrument();
416    
417        void show_samples_tab();
418        void show_intruments_tab();
419        void show_scripts_tab();
420    
421      void add_instrument(gig::Instrument* instrument);      void add_instrument(gig::Instrument* instrument);
422      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
423                                                 int position = -1);                                                 int position = -1);
424      void remove_instrument_from_menu(int index);      void remove_instrument_from_menu(int index);
425    
426      LoadDialog* load_dialog;      ProgressDialog* progress_dialog;
427      Loader* loader;      Loader* loader;
428        Saver* saver;
429      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
430        void updateSampleRefCountMap(gig::File* gig);
431    
432      gig::File* file;      gig::File* file;
433      bool file_is_shared;      bool file_is_shared;
# Line 360  protected: Line 444  protected:
444      bool check_if_savable();      bool check_if_savable();
445    
446      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
447        void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
448        void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
449                                                   Gtk::SelectionData& selection_data, guint, guint);
450        void on_instruments_treeview_drop_drag_data_received(
451            const Glib::RefPtr<Gdk::DragContext>& context, int, int,
452            const Gtk::SelectionData& selection_data, guint, guint time
453        );
454      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
455      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
456                                             Gtk::SelectionData& selection_data, guint, guint);                                             Gtk::SelectionData& selection_data, guint, guint);
# Line 373  protected: Line 464  protected:
464    
465      void script_name_changed(const Gtk::TreeModel::Path& path,      void script_name_changed(const Gtk::TreeModel::Path& path,
466                               const Gtk::TreeModel::iterator& iter);                               const Gtk::TreeModel::iterator& iter);
467        void script_double_clicked(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
468      void sample_name_changed(const Gtk::TreeModel::Path& path,      void sample_name_changed(const Gtk::TreeModel::Path& path,
469                               const Gtk::TreeModel::iterator& iter);                               const Gtk::TreeModel::iterator& iter);
470      void instrument_name_changed(const Gtk::TreeModel::Path& path,      void instrument_name_changed(const Gtk::TreeModel::Path& path,
# Line 381  protected: Line 473  protected:
473      sigc::connection instrument_name_connection;      sigc::connection instrument_name_connection;
474    
475      void on_action_combine_instruments();      void on_action_combine_instruments();
476        void on_action_view_references();
477      void on_action_merge_files();      void on_action_merge_files();
478      void mergeFiles(const std::vector<std::string>& filenames);      void mergeFiles(const std::vector<std::string>& filenames);
479    
480        void on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample);
481        void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
482        void on_samples_to_be_removed(std::list<gig::Sample*> samples);
483    
484        void add_or_replace_sample(bool replace);
485    
486      void __import_queued_samples();      void __import_queued_samples();
487      void __clear();      void __clear();
488      void __refreshEntireGUI();      void __refreshEntireGUI();

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

  ViewVC Help
Powered by ViewVC