/[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 2691 by schoenebeck, Sun Jan 4 19:46:54 2015 UTC revision 3342 by schoenebeck, Mon Jul 31 11:32:49 2017 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006 - 2015 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 32  Line 39 
39  #include <gtkmm/radiomenuitem.h>  #include <gtkmm/radiomenuitem.h>
40  #include <gtkmm/scrolledwindow.h>  #include <gtkmm/scrolledwindow.h>
41  #include <gtkmm/treestore.h>  #include <gtkmm/treestore.h>
42    #include <gtkmm/treemodelfilter.h>
43  #include <gtkmm/uimanager.h>  #include <gtkmm/uimanager.h>
44  #include <gtkmm/window.h>  #include <gtkmm/window.h>
45  #include <gtkmm/statusbar.h>  #include <gtkmm/statusbar.h>
46  #include <gtkmm/image.h>  #include <gtkmm/image.h>
47    #include <gtkmm/entry.h>
48    #include <gtkmm/notebook.h>
49    
50  #include <sstream>  #include <sstream>
51    
# Line 46  Line 56 
56  #ifndef OLD_THREADS  #ifndef OLD_THREADS
57  #include <glibmm/threads.h>  #include <glibmm/threads.h>
58  #endif  #endif
59    #include "ManagedWindow.h"
60    
61  class MainWindow;  class MainWindow;
62    
63  class PropDialog : public Gtk::Window,  class PropDialog : public ManagedWindow,
64                     public PropEditor<DLS::Info> {                     public PropEditor<DLS::Info> {
65  public:  public:
66      PropDialog();      PropDialog();
67      void set_info(DLS::Info* info);      void set_info(DLS::Info* info);
68      void set_file(gig::File* file);      void set_file(gig::File* file);
69    
70        // implementation for abstract methods of interface class "ManagedWindow"
71        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->filePropsWindowX; }
72        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->filePropsWindowY; }
73        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->filePropsWindowW; }
74        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->filePropsWindowH; }
75    
76  protected:  protected:
77      ChoiceEntry<int> eFileFormat;      ChoiceEntry<int> eFileFormat;
78      StringEntry eName;      StringEntry eName;
# Line 83  protected: Line 101  protected:
101      void onFileFormatChanged();      void onFileFormatChanged();
102  };  };
103    
104  class InstrumentProps : public Gtk::Window,  class InstrumentProps : public ManagedWindow,
105                          public PropEditor<gig::Instrument> {                          public PropEditor<gig::Instrument> {
106  public:  public:
107      InstrumentProps();      InstrumentProps();
# Line 93  public: Line 111  public:
111      sigc::signal<void>& signal_name_changed() {      sigc::signal<void>& signal_name_changed() {
112          return sig_name_changed;          return sig_name_changed;
113      }      }
114    
115        // implementation for abstract methods of interface class "ManagedWindow"
116        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->instrPropsWindowX; }
117        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->instrPropsWindowY; }
118        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->instrPropsWindowW; }
119        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->instrPropsWindowH; }
120    
121  protected:  protected:
122      void set_Name(const gig::String& name);      void set_Name(const gig::String& name);
123      void set_IsDrum(bool value);      void set_IsDrum(bool value);
# Line 172  private: Line 197  private:
197      float progress;      float progress;
198  };  };
199    
200  class MainWindow : public Gtk::Window {  class MainWindow : public ManagedWindow {
201  public:  public:
202      MainWindow();      MainWindow();
203      virtual ~MainWindow();      virtual ~MainWindow();
# Line 198  public: Line 223  public:
223    
224      sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();      sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();
225    
226        sigc::signal<void, gig::Script*> signal_script_to_be_changed;
227        sigc::signal<void, gig::Script*> signal_script_changed;
228    
229        // implementation for abstract methods of interface class "ManagedWindow"
230        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->mainWindowX; }
231        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->mainWindowY; }
232        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->mainWindowW; }
233        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
234    
235  protected:  protected:
236      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
237      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
# Line 213  protected: Line 247  protected:
247      InstrumentProps instrumentProps;      InstrumentProps instrumentProps;
248      MidiRules midiRules;      MidiRules midiRules;
249    
250        /**
251         * Ensures that the 2 signals MainWindow::dimreg_to_be_changed_signal and
252         * MainWindowv::dimreg_changed_signal are always triggered correctly as a
253         * pair. It behaves similar to a "mutex lock guard" design pattern.
254         */
255        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
256        public:
257            DimRegionChangeGuard(MainWindow* w, gig::DimensionRegion* pDimReg) :
258            SignalGuard<gig::DimensionRegion*>(w->dimreg_to_be_changed_signal, w->dimreg_changed_signal, pDimReg)
259            {
260            }
261        };
262    
263      sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;      sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
264      sigc::signal<void, gig::File*> file_structure_changed_signal;      sigc::signal<void, gig::File*> file_structure_changed_signal;
265      sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal;      sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal;
# Line 233  protected: Line 280  protected:
280      void on_sel_change();      void on_sel_change();
281      void region_changed();      void region_changed();
282      void dimreg_changed();      void dimreg_changed();
283        void select_instrument(gig::Instrument* instrument);
284        bool select_dimension_region(gig::DimensionRegion* dimRgn);
285      void select_sample(gig::Sample* sample);      void select_sample(gig::Sample* sample);
286      void on_loader_progress();      void on_loader_progress();
287      void on_loader_finished();      void on_loader_finished();
# Line 240  protected: Line 289  protected:
289      void on_saver_progress();      void on_saver_progress();
290      void on_saver_error();      void on_saver_error();
291      void on_saver_finished();      void on_saver_finished();
292        void updateMacroMenu();
293        void onMacroSelected(int iMacro);
294        void setupMacros();
295        void onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros);
296        void applyMacro(Serialization::Archive& macro);
297        void onScriptSlotsModified(gig::Instrument* pInstrument);
298        void bringToFront();
299    
300      void dimreg_all_dimregs_toggled();      void dimreg_all_dimregs_toggled();
301      gig::Instrument* get_instrument();      gig::Instrument* get_instrument();
# Line 249  protected: Line 305  protected:
305      class ModelColumns : public Gtk::TreeModel::ColumnRecord {      class ModelColumns : public Gtk::TreeModel::ColumnRecord {
306      public:      public:
307          ModelColumns() {          ModelColumns() {
308              add(m_col_nr);
309            add(m_col_name);            add(m_col_name);
310            add(m_col_instr);            add(m_col_instr);
311              add(m_col_scripts);
312          }          }
313    
314            Gtk::TreeModelColumn<int> m_col_nr;
315          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
316          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
317            Gtk::TreeModelColumn<Glib::ustring> m_col_scripts;
318      } m_Columns;      } m_Columns;
319    
320      Gtk::VBox m_VBox;      Gtk::VBox m_VBox;
# Line 264  protected: Line 324  protected:
324    
325      Gtk::TreeView m_TreeView;      Gtk::TreeView m_TreeView;
326      Glib::RefPtr<Gtk::ListStore> m_refTreeModel;      Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
327        Glib::RefPtr<Gtk::TreeModelFilter> m_refTreeModelFilter; //FIXME: I really would love to get rid of TreeModelFilter, because it causes behavior conflicts with get_model() all over the place (see the respective comments regarding get_model()), however I found no other way to filter a treeview effectively.
328    
329      Gtk::Menu* instrument_menu;      Gtk::Menu* instrument_menu;
330        Gtk::Menu* assign_scripts_menu;
331    
332      std::map<gig::Sample*,int> sample_ref_count;      std::map<gig::Sample*,int> sample_ref_count;
333    
# Line 331  protected: Line 393  protected:
393      Gtk::CheckButton dimreg_all_regions;      Gtk::CheckButton dimreg_all_regions;
394      Gtk::CheckButton dimreg_all_dimregs;      Gtk::CheckButton dimreg_all_dimregs;
395      Gtk::CheckButton dimreg_stereo;      Gtk::CheckButton dimreg_stereo;
396    
397        Gtk::HBox legend_hbox;
398        Gtk::Label labelLegend;
399        Gtk::Image imageNoSample;
400        Gtk::Label labelNoSample;
401        Gtk::Image imageMissingSample;
402        Gtk::Label labelMissingSample;
403        Gtk::Image imageLooped;
404        Gtk::Label labelLooped;
405        Gtk::Image imageSomeLoops;
406        Gtk::Label labelSomeLoops;
407      DimRegionEdit dimreg_edit;      DimRegionEdit dimreg_edit;
408    
409        Gtk::VBox m_left_vbox;
410      Gtk::Notebook m_TreeViewNotebook;      Gtk::Notebook m_TreeViewNotebook;
411        Gtk::HBox m_searchField;
412        Gtk::Label m_searchLabel;
413        Gtk::Entry m_searchText;
414    
415      struct SampleImportItem {      struct SampleImportItem {
416          gig::Sample*  gig_sample;  // pointer to the gig::Sample to          gig::Sample*  gig_sample;  // pointer to the gig::Sample to
# Line 342  protected: Line 419  protected:
419          Glib::ustring sample_path; // file name of the sample to be          Glib::ustring sample_path; // file name of the sample to be
420                                     // imported                                     // imported
421      };      };
422      std::list<SampleImportItem> m_SampleImportQueue;      std::map<gig::Sample*, SampleImportItem> m_SampleImportQueue;
423    
424    
425      void on_action_file_new();      void on_action_file_new();
# Line 356  protected: Line 433  protected:
433      void show_midi_rules();      void show_midi_rules();
434      void show_script_slots();      void show_script_slots();
435      void on_action_view_status_bar();      void on_action_view_status_bar();
436        void on_auto_restore_win_dim();
437        void on_save_with_temporary_file();
438        void on_action_refresh_all();
439      void on_action_warn_user_on_extensions();      void on_action_warn_user_on_extensions();
440      void on_action_sync_sampler_instrument_selection();      void on_action_sync_sampler_instrument_selection();
441        void on_action_move_root_note_with_region_moved();
442      void on_action_help_about();      void on_action_help_about();
443    
444        void on_notebook_tab_switched(GtkNotebookPage* page, guint page_num);
445    
446      // sample right-click popup actions      // sample right-click popup actions
447      void on_sample_treeview_button_release(GdkEventButton* button);      void on_sample_treeview_button_release(GdkEventButton* button);
448      void on_action_sample_properties();      void on_action_sample_properties();
449      void on_action_add_group();      void on_action_add_group();
450      void on_action_add_sample();      void on_action_add_sample();
451        void on_action_replace_sample();
452      void on_action_replace_all_samples_in_all_groups();      void on_action_replace_all_samples_in_all_groups();
453      void on_action_remove_sample();      void on_action_remove_sample();
454            void on_action_remove_unused_samples();
455    
456      // script right-click popup actions      // script right-click popup actions
457      void on_script_treeview_button_release(GdkEventButton* button);      void on_script_treeview_button_release(GdkEventButton* button);
458      void on_action_add_script_group();      void on_action_add_script_group();
# Line 383  protected: Line 468  protected:
468      void show_intruments_tab();      void show_intruments_tab();
469      void show_scripts_tab();      void show_scripts_tab();
470    
471        void select_prev_instrument();
472        void select_next_instrument();
473        void select_instrument_by_dir(int dir);
474    
475        void select_prev_region();
476        void select_next_region();
477    
478        void select_next_dim_rgn_zone();
479        void select_prev_dim_rgn_zone();
480        void select_add_next_dim_rgn_zone();
481        void select_add_prev_dim_rgn_zone();
482        void select_prev_dimension();
483        void select_next_dimension();
484    
485        Serialization::Archive m_serializationArchive; ///< Clipboard content.
486        std::vector<Serialization::Archive> m_macros; ///< User configured list of macros.
487    
488        void copy_selected_dimrgn();
489        void paste_copied_dimrgn();
490        void adjust_clipboard_content();
491        void updateClipboardCopyAvailable();
492        void updateClipboardPasteAvailable();
493        void on_clipboard_owner_change(GdkEventOwnerChange* event);
494        void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);
495        void on_clipboard_clear();
496        void on_clipboard_received(const Gtk::SelectionData& selection_data);
497        void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);
498    
499      void add_instrument(gig::Instrument* instrument);      void add_instrument(gig::Instrument* instrument);
500      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
501                                                 int position = -1);                                                 int position = -1);
# Line 409  protected: Line 522  protected:
522      bool check_if_savable();      bool check_if_savable();
523    
524      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
525        void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
526        void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
527                                                   Gtk::SelectionData& selection_data, guint, guint);
528        void on_instruments_treeview_drop_drag_data_received(
529            const Glib::RefPtr<Gdk::DragContext>& context, int, int,
530            const Gtk::SelectionData& selection_data, guint, guint time
531        );
532      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
533      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
534                                             Gtk::SelectionData& selection_data, guint, guint);                                             Gtk::SelectionData& selection_data, guint, guint);
# Line 428  protected: Line 548  protected:
548      void instrument_name_changed(const Gtk::TreeModel::Path& path,      void instrument_name_changed(const Gtk::TreeModel::Path& path,
549                                   const Gtk::TreeModel::iterator& iter);                                   const Gtk::TreeModel::iterator& iter);
550      void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it);      void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it);
551        bool instrument_row_visible(const Gtk::TreeModel::const_iterator& iter);
552      sigc::connection instrument_name_connection;      sigc::connection instrument_name_connection;
553    
554      void on_action_combine_instruments();      void on_action_combine_instruments();
# Line 439  protected: Line 560  protected:
560      void on_sample_ref_count_incremented(gig::Sample* sample, int offset);      void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
561      void on_samples_to_be_removed(std::list<gig::Sample*> samples);      void on_samples_to_be_removed(std::list<gig::Sample*> samples);
562    
563        void add_or_replace_sample(bool replace);
564    
565      void __import_queued_samples();      void __import_queued_samples();
566      void __clear();      void __clear();
567      void __refreshEntireGUI();      void __refreshEntireGUI();
568        void updateScriptListOfMenu();
569        void assignScript(gig::Script* pScript);
570    
571      bool close_confirmation_dialog();      bool close_confirmation_dialog();
572      bool leaving_shared_mode_dialog();      bool leaving_shared_mode_dialog();

Legend:
Removed from v.2691  
changed lines
  Added in v.3342

  ViewVC Help
Powered by ViewVC