/[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 3258 by schoenebeck, Tue May 30 20:17:12 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 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 172  private: Line 194  private:
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 198  public: Line 220  public:
220    
221      sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();      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 213  protected: Line 244  protected:
244      InstrumentProps instrumentProps;      InstrumentProps instrumentProps;
245      MidiRules midiRules;      MidiRules midiRules;
246    
247        /**
248         * Ensures that the 2 signals MainWindow::dimreg_to_be_changed_signal and
249         * MainWindowv::dimreg_changed_signal are always triggered correctly as a
250         * pair. It behaves similar to a "mutex lock guard" design pattern.
251         */
252        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
253        public:
254            DimRegionChangeGuard(MainWindow* w, gig::DimensionRegion* pDimReg) :
255            SignalGuard<gig::DimensionRegion*>(w->dimreg_to_be_changed_signal, w->dimreg_changed_signal, pDimReg)
256            {
257            }
258        };
259    
260      sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;      sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
261      sigc::signal<void, gig::File*> file_structure_changed_signal;      sigc::signal<void, gig::File*> file_structure_changed_signal;
262      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 277  protected:
277      void on_sel_change();      void on_sel_change();
278      void region_changed();      void region_changed();
279      void dimreg_changed();      void dimreg_changed();
280        void select_instrument(gig::Instrument* instrument);
281        bool select_dimension_region(gig::DimensionRegion* dimRgn);
282      void select_sample(gig::Sample* sample);      void select_sample(gig::Sample* sample);
283      void on_loader_progress();      void on_loader_progress();
284      void on_loader_finished();      void on_loader_finished();
# Line 240  protected: Line 286  protected:
286      void on_saver_progress();      void on_saver_progress();
287      void on_saver_error();      void on_saver_error();
288      void on_saver_finished();      void on_saver_finished();
289        void updateMacroMenu();
290        void onMacroSelected(int iMacro);
291        void setupMacros();
292        void onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros);
293        void applyMacro(Serialization::Archive& macro);
294        void onScriptSlotsModified(gig::Instrument* pInstrument);
295        void bringToFront();
296    
297      void dimreg_all_dimregs_toggled();      void dimreg_all_dimregs_toggled();
298      gig::Instrument* get_instrument();      gig::Instrument* get_instrument();
# Line 249  protected: Line 302  protected:
302      class ModelColumns : public Gtk::TreeModel::ColumnRecord {      class ModelColumns : public Gtk::TreeModel::ColumnRecord {
303      public:      public:
304          ModelColumns() {          ModelColumns() {
305              add(m_col_nr);
306            add(m_col_name);            add(m_col_name);
307            add(m_col_instr);            add(m_col_instr);
308              add(m_col_scripts);
309          }          }
310    
311            Gtk::TreeModelColumn<int> m_col_nr;
312          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
313          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
314            Gtk::TreeModelColumn<Glib::ustring> m_col_scripts;
315      } m_Columns;      } m_Columns;
316    
317      Gtk::VBox m_VBox;      Gtk::VBox m_VBox;
# Line 331  protected: Line 388  protected:
388      Gtk::CheckButton dimreg_all_regions;      Gtk::CheckButton dimreg_all_regions;
389      Gtk::CheckButton dimreg_all_dimregs;      Gtk::CheckButton dimreg_all_dimregs;
390      Gtk::CheckButton dimreg_stereo;      Gtk::CheckButton dimreg_stereo;
391    
392        Gtk::HBox legend_hbox;
393        Gtk::Label labelLegend;
394        Gtk::Image imageNoSample;
395        Gtk::Label labelNoSample;
396        Gtk::Image imageMissingSample;
397        Gtk::Label labelMissingSample;
398        Gtk::Image imageLooped;
399        Gtk::Label labelLooped;
400        Gtk::Image imageSomeLoops;
401        Gtk::Label labelSomeLoops;
402      DimRegionEdit dimreg_edit;      DimRegionEdit dimreg_edit;
403    
404      Gtk::Notebook m_TreeViewNotebook;      Gtk::Notebook m_TreeViewNotebook;
# Line 342  protected: Line 410  protected:
410          Glib::ustring sample_path; // file name of the sample to be          Glib::ustring sample_path; // file name of the sample to be
411                                     // imported                                     // imported
412      };      };
413      std::list<SampleImportItem> m_SampleImportQueue;      std::map<gig::Sample*, SampleImportItem> m_SampleImportQueue;
414    
415    
416      void on_action_file_new();      void on_action_file_new();
# Line 356  protected: Line 424  protected:
424      void show_midi_rules();      void show_midi_rules();
425      void show_script_slots();      void show_script_slots();
426      void on_action_view_status_bar();      void on_action_view_status_bar();
427        void on_auto_restore_win_dim();
428        void on_save_with_temporary_file();
429        void on_action_refresh_all();
430      void on_action_warn_user_on_extensions();      void on_action_warn_user_on_extensions();
431      void on_action_sync_sampler_instrument_selection();      void on_action_sync_sampler_instrument_selection();
432        void on_action_move_root_note_with_region_moved();
433      void on_action_help_about();      void on_action_help_about();
434    
435      // sample right-click popup actions      // sample right-click popup actions
# Line 365  protected: Line 437  protected:
437      void on_action_sample_properties();      void on_action_sample_properties();
438      void on_action_add_group();      void on_action_add_group();
439      void on_action_add_sample();      void on_action_add_sample();
440        void on_action_replace_sample();
441      void on_action_replace_all_samples_in_all_groups();      void on_action_replace_all_samples_in_all_groups();
442      void on_action_remove_sample();      void on_action_remove_sample();
443            void on_action_remove_unused_samples();
444    
445      // script right-click popup actions      // script right-click popup actions
446      void on_script_treeview_button_release(GdkEventButton* button);      void on_script_treeview_button_release(GdkEventButton* button);
447      void on_action_add_script_group();      void on_action_add_script_group();
# Line 383  protected: Line 457  protected:
457      void show_intruments_tab();      void show_intruments_tab();
458      void show_scripts_tab();      void show_scripts_tab();
459    
460        void select_prev_region();
461        void select_next_region();
462    
463        void select_next_dim_rgn_zone();
464        void select_prev_dim_rgn_zone();
465        void select_add_next_dim_rgn_zone();
466        void select_add_prev_dim_rgn_zone();
467        void select_prev_dimension();
468        void select_next_dimension();
469    
470        Serialization::Archive m_serializationArchive; ///< Clipboard content.
471        std::vector<Serialization::Archive> m_macros; ///< User configured list of macros.
472    
473        void copy_selected_dimrgn();
474        void paste_copied_dimrgn();
475        void adjust_clipboard_content();
476        void updateClipboardCopyAvailable();
477        void updateClipboardPasteAvailable();
478        void on_clipboard_owner_change(GdkEventOwnerChange* event);
479        void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);
480        void on_clipboard_clear();
481        void on_clipboard_received(const Gtk::SelectionData& selection_data);
482        void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);
483    
484      void add_instrument(gig::Instrument* instrument);      void add_instrument(gig::Instrument* instrument);
485      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
486                                                 int position = -1);                                                 int position = -1);
# Line 409  protected: Line 507  protected:
507      bool check_if_savable();      bool check_if_savable();
508    
509      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
510        void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
511        void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
512                                                   Gtk::SelectionData& selection_data, guint, guint);
513        void on_instruments_treeview_drop_drag_data_received(
514            const Glib::RefPtr<Gdk::DragContext>& context, int, int,
515            const Gtk::SelectionData& selection_data, guint, guint time
516        );
517      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
518      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
519                                             Gtk::SelectionData& selection_data, guint, guint);                                             Gtk::SelectionData& selection_data, guint, guint);
# Line 439  protected: Line 544  protected:
544      void on_sample_ref_count_incremented(gig::Sample* sample, int offset);      void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
545      void on_samples_to_be_removed(std::list<gig::Sample*> samples);      void on_samples_to_be_removed(std::list<gig::Sample*> samples);
546    
547        void add_or_replace_sample(bool replace);
548    
549      void __import_queued_samples();      void __import_queued_samples();
550      void __clear();      void __clear();
551      void __refreshEntireGUI();      void __refreshEntireGUI();

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

  ViewVC Help
Powered by ViewVC