/[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 1853 by schoenebeck, Sun Mar 1 22:26:36 2009 UTC revision 3712 by schoenebeck, Fri Jan 10 15:22:34 2020 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006 - 2008 Andreas Persson   * Copyright (C) 2006 - 2020 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 "compat.h"
32    
33  #include <gtkmm/actiongroup.h>  #include <gtkmm/box.h>
34  #include <gtkmm/buttonbox.h>  #include <gtkmm/buttonbox.h>
35  #include <gtkmm/dialog.h>  #include <gtkmm/dialog.h>
36  #include <gtkmm/liststore.h>  #include <gtkmm/liststore.h>
37    #include <gtkmm/menu.h>
38  #include <gtkmm/paned.h>  #include <gtkmm/paned.h>
39  #include <gtkmm/progressbar.h>  #include <gtkmm/progressbar.h>
40    #include <gtkmm/radiomenuitem.h>
41  #include <gtkmm/scrolledwindow.h>  #include <gtkmm/scrolledwindow.h>
42  #include <gtkmm/treestore.h>  #include <gtkmm/treestore.h>
43  #include <gtkmm/uimanager.h>  #include <gtkmm/treemodelfilter.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    #if USE_GTKMM_BUILDER
51    # include <gtkmm/builder.h>
52    #else
53    # include <gtkmm/uimanager.h> // deprecated in gtkmm >= 3.21.4
54    #endif
55    
56  #include <sstream>  #include <sstream>
57    
58  #include "regionchooser.h"  #include "regionchooser.h"
59  #include "dimregionchooser.h"  #include "dimregionchooser.h"
60  #include "dimregionedit.h"  #include "dimregionedit.h"
61    #include "midirules.h"
62    #ifdef GLIB_THREADS
63    #ifndef OLD_THREADS
64    #include <glibmm/threads.h>
65    #endif
66    #else
67    #include <thread>
68    #include <mutex>
69    #endif
70    #include "ManagedWindow.h"
71    
72  class MainWindow;  class MainWindow;
73    
74  class Table : public Gtk::Table  class FilePropDialog : public ManagedWindow,
75  {                         public PropEditor<DLS::Info> {
76  public:  public:
77      Table(int x, int y);      FilePropDialog();
78      void add(BoolEntry& boolentry);      void set_file(gig::File* file);
79      void add(BoolEntryPlus6& boolentry);  
80      void add(LabelWidget& labelwidget);      // implementation for abstract methods of interface class "ManagedWindow"
81  private:      virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->filePropsWindowX; }
82      int rowno;      virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->filePropsWindowY; }
83  };      virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->filePropsWindowW; }
84        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->filePropsWindowH; }
85    
 class PropDialog : public Gtk::Window {  
 public:  
     PropDialog();  
     void set_info(DLS::Info* info);  
     sigc::signal<void>& signal_info_changed();  
86  protected:  protected:
87      sigc::signal<void> info_changed;      ChoiceEntry<int> eFileFormat;
88      StringEntry eName;      StringEntry eName;
89      StringEntry eCreationDate;      StringEntry eCreationDate;
90      StringEntryMultiLine eComments;      StringEntryMultiLine eComments;
# Line 77  protected: Line 101  protected:
101      StringEntry eSourceForm;      StringEntry eSourceForm;
102      StringEntry eCommissioned;      StringEntry eCommissioned;
103      StringEntry eSubject;      StringEntry eSubject;
104      Gtk::VBox vbox;      VBox vbox;
105      Gtk::HButtonBox buttonBox;      HButtonBox buttonBox;
106      Gtk::Button quitButton;      Gtk::Button quitButton;
107      Table table;      Table table;
     int update_model;  
     DLS::Info* info;  
108    
109      template<typename T>      gig::File* m_file;
     void set_member(T value, T DLS::Info::* member) {  
         if (update_model == 0) {  
             info->*member = value;  
             info_changed();  
         }  
     }  
110    
111      template<typename C, typename T>      void set_FileFormat(int value);
     void connect(C& widget, T DLS::Info::* member) {  
         widget.signal_value_changed().connect(  
             sigc::compose(  
                 sigc::bind(sigc::mem_fun(*this, &PropDialog::set_member<T>), member),  
                 sigc::mem_fun(widget, &C::get_value)));  
     }  
112  };  };
113    
114  class InstrumentProps : public Gtk::Window {  class InstrumentProps : public ManagedWindow,
115                            public PropEditor<gig::Instrument> {
116  public:  public:
117      InstrumentProps();      InstrumentProps();
118      void set_instrument(gig::Instrument* instrument);      void set_instrument(gig::Instrument* instrument);
119      sigc::signal<void>& signal_instrument_changed();      gig::Instrument* get_instrument() { return m; }
120  protected:      void update_name();
121      gig::Instrument* instrument;      sigc::signal<void>& signal_name_changed() {
122      int update_model;          return sig_name_changed;
   
     template<typename T>  
     void set_value(T value, sigc::slot<void, InstrumentProps*, T> setter) {  
         if (update_model == 0) {  
             setter(this, value);  
             instrument_changed();  
         }  
123      }      }
124    
125      template<typename C, typename T>      // implementation for abstract methods of interface class "ManagedWindow"
126      void connect(C& widget, T gig::Instrument::* member) {      virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->instrPropsWindowX; }
127          widget.signal_value_changed().connect(      virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->instrPropsWindowY; }
128              sigc::compose(      virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->instrPropsWindowW; }
129                  sigc::bind(sigc::mem_fun(*this, &InstrumentProps::set_value<T>),      virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->instrPropsWindowH; }
                            sigc::bind(sigc::mem_fun(&InstrumentProps::set_member<T>), member)),  
                 sigc::mem_fun(widget, &C::get_value)));  
     }  
   
     template<typename C, typename T>  
     void connect(C& widget, void (InstrumentProps::*setter)(T)) {  
         widget.signal_value_changed().connect(  
             sigc::compose(  
                 sigc::bind(sigc::mem_fun(*this, &InstrumentProps::set_value<T>),  
                            sigc::mem_fun(setter)),  
                 sigc::mem_fun(widget, &C::get_value)));  
     }  
   
     template<typename T>  
     void set_member(T value, T gig::Instrument::* member) {  
         instrument->*member = value;  
     }  
130    
131    protected:
132        void set_Name(const gig::String& name);
133      void set_IsDrum(bool value);      void set_IsDrum(bool value);
134      void set_MIDIBank(uint16_t value);      void set_MIDIBank(uint16_t value);
135      void set_MIDIProgram(uint32_t value);      void set_MIDIProgram(uint32_t value);
     void set_DimensionKeyRange_low(uint8_t value);  
     void set_DimensionKeyRange_high(uint8_t value);  
136    
137      Gtk::VBox vbox;      sigc::signal<void> sig_name_changed;
138      Gtk::HButtonBox buttonBox;      Gtk::Notebook tabs;
139        VBox vbox[3];
140        HButtonBox buttonBox;
141      Gtk::Button quitButton;      Gtk::Button quitButton;
142    
143        // tab 1
144      Table table;      Table table;
145      StringEntry eName;      StringEntry eName;
146      BoolEntry eIsDrum;      BoolEntry eIsDrum;
147      NumEntryTemp<uint16_t> eMIDIBank;      NumEntryTemp<uint16_t> eMIDIBank;
148      NumEntryTemp<uint32_t> eMIDIProgram;      NumEntryTemp<uint32_t> eMIDIProgram;
149      NumEntryGain eAttenuation;      NumEntryGain eAttenuation;
     BoolEntryPlus6 eGainPlus6;  
150      NumEntryTemp<uint16_t> eEffectSend;      NumEntryTemp<uint16_t> eEffectSend;
151      NumEntryTemp<int16_t> eFineTune;      NumEntryTemp<int16_t> eFineTune;
152      NumEntryTemp<uint16_t> ePitchbendRange;      NumEntryTemp<uint16_t> ePitchbendRange;
153      BoolEntry ePianoReleaseMode;      BoolEntry ePianoReleaseMode;
154      NoteEntry eDimensionKeyRangeLow;      NoteEntry eDimensionKeyRangeLow;
155      NoteEntry eDimensionKeyRangeHigh;      NoteEntry eDimensionKeyRangeHigh;
156      sigc::signal<void> instrument_changed;  
157        // tab 2
158        Table table2;
159        StringEntry eName2;
160        StringEntry eCreationDate;
161        StringEntryMultiLine eComments;
162        StringEntry eProduct;
163        StringEntry eCopyright;
164        StringEntry eArtists;
165        StringEntry eGenre;
166        StringEntry eKeywords;
167        StringEntry eEngineer;
168        StringEntry eTechnician;
169        StringEntry eSoftware;
170        StringEntry eMedium;
171        StringEntry eSource;
172        StringEntry eSourceForm;
173        StringEntry eCommissioned;
174        StringEntry eSubject;
175    };
176    
177    class SampleProps : public ManagedWindow,
178                        public PropEditor<gig::Sample> {
179    public:
180        SampleProps();
181        void set_sample(gig::Sample* sample);
182        gig::Sample* get_sample() { return m; }
183        void update_name();
184        sigc::signal<void>& signal_name_changed() {
185            return sig_name_changed;
186        }
187    
188        // implementation for abstract methods of interface class "ManagedWindow"
189        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->samplePropsWindowX; }
190        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->samplePropsWindowY; }
191        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->samplePropsWindowW; }
192        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->samplePropsWindowH; }
193    
194    protected:
195        void set_Name(const gig::String& name);
196    
197        sigc::signal<void> sig_name_changed;
198        Gtk::Notebook tabs;
199        VBox vbox[3];
200        HButtonBox buttonBox;
201        Gtk::Button quitButton;
202    
203        // tab 1
204        Table table;
205        StringEntry eName;
206        NoteEntry eUnityNote;
207        ReadOnlyLabelWidget eSampleGroup;
208        ReadOnlyLabelWidget eSampleFormatInfo;
209        ReadOnlyLabelWidget eSampleID;
210        ReadOnlyLabelWidget eChecksum;
211        NumEntryTemp<uint32_t> eLoopsCount;
212        NumEntryTemp<uint32_t> eLoopStart;
213        NumEntryTemp<uint32_t> eLoopLength;
214        ChoiceEntry<gig::loop_type_t> eLoopType;
215        NumEntryTemp<uint32_t> eLoopPlayCount;
216        // tab 2
217        Table table2;
218        StringEntry eName2;
219        StringEntry eCreationDate;
220        StringEntryMultiLine eComments;
221        StringEntry eProduct;
222        StringEntry eCopyright;
223        StringEntry eArtists;
224        StringEntry eGenre;
225        StringEntry eKeywords;
226        StringEntry eEngineer;
227        StringEntry eTechnician;
228        StringEntry eSoftware;
229        StringEntry eMedium;
230        StringEntry eSource;
231        StringEntry eSourceForm;
232        StringEntry eCommissioned;
233        StringEntry eSubject;
234  };  };
235    
236  class LoadDialog : public Gtk::Dialog {  class ProgressDialog : public Gtk::Dialog {
237  public:  public:
238      LoadDialog(const Glib::ustring& title, Gtk::Window& parent);      ProgressDialog(const Glib::ustring& title, Gtk::Window& parent);
239      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }      void set_fraction(float fraction) { progressBar.set_fraction(fraction); }
240  protected:  protected:
241      Gtk::ProgressBar progressBar;      Gtk::ProgressBar progressBar;
242  };  };
243    
244  class Loader : public sigc::trackable {  class LoaderSaverBase {
245  public:  public:
     Loader(const char* filename);  
246      void launch();      void launch();
247      Glib::Dispatcher& signal_progress();      Glib::Dispatcher& signal_progress();
248      Glib::Dispatcher& signal_finished();      Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
249        Glib::Dispatcher& signal_error();
250      void progress_callback(float fraction);      void progress_callback(float fraction);
251      float get_progress();      float get_progress();
252      const char* filename;      void join();
253        const Glib::ustring filename;
254        Glib::ustring error_message;
255      gig::File* gig;      gig::File* gig;
256    
257    protected:
258        LoaderSaverBase(const Glib::ustring filename, gig::File* gig);
259    
260  private:  private:
261      Glib::Thread* thread;  #ifdef GLIB_THREADS
262        Glib::Threads::Thread* thread;
263        Glib::Threads::Mutex progressMutex;
264    #else
265        std::thread thread;
266        std::mutex progressMutex;
267    #endif
268      void thread_function();      void thread_function();
269        virtual void thread_function_sub(gig::progress_t& progress) = 0;
270      Glib::Dispatcher finished_dispatcher;      Glib::Dispatcher finished_dispatcher;
271      Glib::Dispatcher progress_dispatcher;      Glib::Dispatcher progress_dispatcher;
272      Glib::Mutex progressMutex;      Glib::Dispatcher error_dispatcher;
273      float progress;      float progress;
274  };  };
275    
276  class MainWindow : public Gtk::Window {  class Loader : public LoaderSaverBase {
277    public:
278        Loader(const char* filename);
279    
280    private:
281        void thread_function_sub(gig::progress_t& progress);
282    };
283    
284    class Saver : public LoaderSaverBase {
285    public:
286        Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"
287    
288    private:
289        void thread_function_sub(gig::progress_t& progress);
290    };
291    
292    class MainWindow : public ManagedWindow {
293  public:  public:
294      MainWindow();      MainWindow();
295      virtual ~MainWindow();      virtual ~MainWindow();
# Line 218  public: Line 313  public:
313      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_hit();
314      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();      sigc::signal<void, int/*key*/, int/*velocity*/>& signal_keyboard_key_released();
315    
316        sigc::signal<void, gig::Instrument*>& signal_switch_sampler_instrument();
317    
318        sigc::signal<void, gig::Script*> signal_script_to_be_changed;
319        sigc::signal<void, gig::Script*> signal_script_changed;
320    
321        // implementation for abstract methods of interface class "ManagedWindow"
322        virtual Settings::Property<int>* windowSettingX() { return &Settings::singleton()->mainWindowX; }
323        virtual Settings::Property<int>* windowSettingY() { return &Settings::singleton()->mainWindowY; }
324        virtual Settings::Property<int>* windowSettingWidth() { return &Settings::singleton()->mainWindowW; }
325        virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
326    
327  protected:  protected:
328    #if USE_GTKMM_BUILDER
329        Glib::RefPtr<Gio::SimpleActionGroup> m_actionGroup;
330        Glib::RefPtr<Gtk::Builder> m_uiManager;
331    #else
332      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
333      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
334    #endif
335    
336    #if USE_GLIB_ACTION
337        Glib::RefPtr<Gio::SimpleAction> m_actionMIDIRules;
338    
339        Glib::RefPtr<Gio::SimpleAction> m_actionCopyDimRgn;
340        Glib::RefPtr<Gio::SimpleAction> m_actionPasteDimRgn;
341        Glib::RefPtr<Gio::SimpleAction> m_actionAdjustClipboard;
342    
343        Glib::RefPtr<Gio::SimpleAction> m_actionSampleProperties;
344        Glib::RefPtr<Gio::SimpleAction> m_actionAddSample;
345        Glib::RefPtr<Gio::SimpleAction> m_actionRemoveSample;
346        Glib::RefPtr<Gio::SimpleAction> m_actionViewSampleRefs;
347        Glib::RefPtr<Gio::SimpleAction> m_actionReplaceSample;
348        Glib::RefPtr<Gio::SimpleAction> m_actionAddSampleGroup;
349    
350        Glib::RefPtr<Gio::SimpleAction> m_actionAddScriptGroup;
351        Glib::RefPtr<Gio::SimpleAction> m_actionAddScript;
352        Glib::RefPtr<Gio::SimpleAction> m_actionEditScript;
353        Glib::RefPtr<Gio::SimpleAction> m_actionRemoveScript;
354    
355        Glib::RefPtr<Gio::SimpleAction> m_actionInstrDoubleClickOpensProps;
356    
357        Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleUnity;
358        Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleTune;
359        Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleLoop;
360        Glib::RefPtr<Gio::SimpleAction> m_actionToggleStatusBar;
361        Glib::RefPtr<Gio::SimpleAction> m_actionToggleRestoreWinDim;
362        Glib::RefPtr<Gio::SimpleAction> m_actionToggleSaveWithTempFile;
363        Glib::RefPtr<Gio::SimpleAction> m_actionToggleWarnOnExtensions;
364        Glib::RefPtr<Gio::SimpleAction> m_actionToggleShowTooltips;
365        Glib::RefPtr<Gio::SimpleAction> m_actionToggleSyncSamplerSelection;
366        Glib::RefPtr<Gio::SimpleAction> m_actionToggleMoveRootNoteWithRegion;
367    #endif
368    
369      Gtk::Statusbar m_StatusBar;      Gtk::Statusbar m_StatusBar;
370      Gtk::Label     m_AttachedStateLabel;      Gtk::Label     m_AttachedStateLabel;
# Line 229  protected: Line 373  protected:
373      RegionChooser m_RegionChooser;      RegionChooser m_RegionChooser;
374      DimRegionChooser m_DimRegionChooser;      DimRegionChooser m_DimRegionChooser;
375    
376      PropDialog propDialog;      FilePropDialog fileProps;
377      InstrumentProps instrumentProps;      InstrumentProps instrumentProps;
378        SampleProps sampleProps;
379        MidiRules midiRules;
380    
381        /**
382         * Ensures that the 2 signals MainWindow::dimreg_to_be_changed_signal and
383         * MainWindowv::dimreg_changed_signal are always triggered correctly as a
384         * pair. It behaves similar to a "mutex lock guard" design pattern.
385         */
386        class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> {
387        public:
388            DimRegionChangeGuard(MainWindow* w, gig::DimensionRegion* pDimReg) :
389            SignalGuard<gig::DimensionRegion*>(w->dimreg_to_be_changed_signal, w->dimreg_changed_signal, pDimReg)
390            {
391            }
392        };
393    
394      sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;      sigc::signal<void, gig::File*> file_structure_to_be_changed_signal;
395      sigc::signal<void, gig::File*> file_structure_changed_signal;      sigc::signal<void, gig::File*> file_structure_changed_signal;
# Line 246  protected: Line 405  protected:
405      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_on_signal;
406      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;      sigc::signal<void, int/*key*/, int/*velocity*/> note_off_signal;
407    
408      void on_instrument_selection_change(int index);      sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;
409    
410    #if !USE_GTKMM_BUILDER
411        void on_instrument_selection_change(Gtk::RadioMenuItem* item);
412    #endif
413        void on_action_move_instr();
414      void on_sel_change();      void on_sel_change();
415      void region_changed();      void region_changed();
416      void dimreg_changed();      void dimreg_changed();
417        void select_instrument(gig::Instrument* instrument);
418        bool select_dimension_region(gig::DimensionRegion* dimRgn);
419        void select_sample(gig::Sample* sample);
420      void on_loader_progress();      void on_loader_progress();
421      void on_loader_finished();      void on_loader_finished();
422        void on_loader_error();
423        void on_saver_progress();
424        void on_saver_error();
425        void on_saver_finished();
426        void updateMacroMenu();
427        void onMacroSelected(int iMacro);
428        void setupMacros();
429        void onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros);
430        void applyMacro(Serialization::Archive& macro);
431        void onScriptSlotsModified(gig::Instrument* pInstrument);
432        void bringToFront();
433    
434      void dimreg_all_dimregs_toggled();      void dimreg_all_dimregs_toggled();
435      gig::Instrument* get_instrument();      gig::Instrument* get_instrument();
436      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 260  protected: Line 439  protected:
439      class ModelColumns : public Gtk::TreeModel::ColumnRecord {      class ModelColumns : public Gtk::TreeModel::ColumnRecord {
440      public:      public:
441          ModelColumns() {          ModelColumns() {
442              add(m_col_nr);
443            add(m_col_name);            add(m_col_name);
444            add(m_col_instr);            add(m_col_instr);
445              add(m_col_scripts);
446              add(m_col_tooltip);
447          }          }
448    
449            Gtk::TreeModelColumn<int> m_col_nr;
450          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
451          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
452            Gtk::TreeModelColumn<Glib::ustring> m_col_scripts;
453            Gtk::TreeModelColumn<Glib::ustring> m_col_tooltip;
454      } m_Columns;      } m_Columns;
455    
456      Gtk::VBox m_VBox;      VBox m_VBox;
457      Gtk::HPaned m_HPaned;      Gtk::HPaned m_HPaned;
458    
459      Gtk::ScrolledWindow m_ScrolledWindow;      Gtk::ScrolledWindow m_ScrolledWindow;
460    
461      Gtk::TreeView m_TreeView;      Gtk::TreeView m_TreeView;
462      Glib::RefPtr<Gtk::ListStore> m_refTreeModel;      Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
463        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.
464    
465    #if USE_GTKMM_BUILDER
466        Gtk::Menu* menuMacro;
467    #else
468        Gtk::Menu* instrument_menu; // kept for GTKMM 2 version only, will be completely removed in future
469    #endif
470        Gtk::Menu* assign_scripts_menu;
471    
472        std::map<gig::Sample*,int> sample_ref_count;
473    
474      class SamplesModel : public Gtk::TreeModel::ColumnRecord {      class SamplesModel : public Gtk::TreeModel::ColumnRecord {
475      public:      public:
# Line 282  protected: Line 477  protected:
477              add(m_col_name);              add(m_col_name);
478              add(m_col_sample);              add(m_col_sample);
479              add(m_col_group);              add(m_col_group);
480                add(m_col_refcount);
481                add(m_color);
482          }          }
483    
484          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
485          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;          Gtk::TreeModelColumn<gig::Sample*> m_col_sample;
486          Gtk::TreeModelColumn<gig::Group*> m_col_group;          Gtk::TreeModelColumn<gig::Group*> m_col_group;
487            Gtk::TreeModelColumn<Glib::ustring> m_col_refcount;
488            Gtk::TreeModelColumn<Glib::ustring> m_color;
489      } m_SamplesModel;      } m_SamplesModel;
490    
491      class SamplesTreeStore : public Gtk::TreeStore {      class SamplesTreeStore : public Gtk::TreeStore {
# Line 302  protected: Line 501  protected:
501      Gtk::TreeView m_TreeViewSamples;      Gtk::TreeView m_TreeViewSamples;
502      Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;      Glib::RefPtr<SamplesTreeStore> m_refSamplesTreeModel;
503    
504      Gtk::VBox dimreg_vbox;      class ScriptsModel : public Gtk::TreeModel::ColumnRecord {
505      Gtk::HBox dimreg_hbox;      public:
506            ScriptsModel() {
507                add(m_col_name);
508                add(m_col_script);
509                add(m_col_group);
510            }
511    
512            Gtk::TreeModelColumn<Glib::ustring> m_col_name;
513            Gtk::TreeModelColumn<gig::Script*> m_col_script;
514            Gtk::TreeModelColumn<gig::ScriptGroup*> m_col_group;
515        } m_ScriptsModel;
516    
517        class ScriptsTreeStore : public Gtk::TreeStore {
518        public:
519            static Glib::RefPtr<ScriptsTreeStore> create(const ScriptsModel& columns) {
520                return Glib::RefPtr<ScriptsTreeStore>( new ScriptsTreeStore(columns) );
521            }
522        protected:
523            ScriptsTreeStore(const ScriptsModel& columns) : Gtk::TreeStore(columns) {}
524        };
525    
526        Gtk::ScrolledWindow m_ScrolledWindowScripts;
527        Gtk::TreeView m_TreeViewScripts;
528        Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel;
529    
530        VBox dimreg_vbox;
531        HBox dimreg_hbox;
532      Gtk::Label dimreg_label;      Gtk::Label dimreg_label;
533      Gtk::CheckButton dimreg_all_regions;      Gtk::CheckButton dimreg_all_regions;
534      Gtk::CheckButton dimreg_all_dimregs;      Gtk::CheckButton dimreg_all_dimregs;
535      Gtk::CheckButton dimreg_stereo;      Gtk::CheckButton dimreg_stereo;
536    
537        HBox legend_hbox;
538        Gtk::Label labelLegend;
539        Gtk::Image imageNoSample;
540        Gtk::Label labelNoSample;
541        Gtk::Image imageMissingSample;
542        Gtk::Label labelMissingSample;
543        Gtk::Image imageLooped;
544        Gtk::Label labelLooped;
545        Gtk::Image imageSomeLoops;
546        Gtk::Label labelSomeLoops;
547      DimRegionEdit dimreg_edit;      DimRegionEdit dimreg_edit;
548    
549      Gtk::Notebook m_Notebook;      VBox m_left_vbox;
550      Gtk::Notebook m_TreeViewNotebook;      Gtk::Notebook m_TreeViewNotebook;
551        HBox m_searchField;
552        Gtk::Label m_searchLabel;
553        Gtk::Entry m_searchText;
554    
555      struct SampleImportItem {      struct SampleImportItem {
556          gig::Sample*  gig_sample;  // pointer to the gig::Sample to          gig::Sample*  gig_sample;  // pointer to the gig::Sample to
# Line 320  protected: Line 559  protected:
559          Glib::ustring sample_path; // file name of the sample to be          Glib::ustring sample_path; // file name of the sample to be
560                                     // imported                                     // imported
561      };      };
562      std::list<SampleImportItem> m_SampleImportQueue;      std::map<gig::Sample*, SampleImportItem> m_SampleImportQueue;
563    
564    
565      void on_action_file_new();      void on_action_file_new();
# Line 330  protected: Line 569  protected:
569      void on_action_file_properties();      void on_action_file_properties();
570      void on_action_quit();      void on_action_quit();
571      void show_instr_props();      void show_instr_props();
572        bool instr_props_set_instrument();
573        void show_sample_props();
574        bool sample_props_set_sample();
575        void sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it);
576        void show_midi_rules();
577        void show_script_slots();
578      void on_action_view_status_bar();      void on_action_view_status_bar();
579        void on_auto_restore_win_dim();
580        void on_instr_double_click_opens_props();
581        void on_save_with_temporary_file();
582        void on_action_refresh_all();
583        void on_action_warn_user_on_extensions();
584        void on_action_show_tooltips();
585        void on_show_tooltips_changed();
586        void on_action_sync_sampler_instrument_selection();
587        void on_action_move_root_note_with_region_moved();
588      void on_action_help_about();      void on_action_help_about();
589    
590        void on_notebook_tab_switched(void* page, guint page_num);
591    
592      // sample right-click popup actions      // sample right-click popup actions
593    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
594        bool on_sample_treeview_button_release(Gdk::EventButton& button);
595    #else
596      void on_sample_treeview_button_release(GdkEventButton* button);      void on_sample_treeview_button_release(GdkEventButton* button);
597    #endif
598      void on_action_sample_properties();      void on_action_sample_properties();
599      void on_action_add_group();      void on_action_add_group();
600      void on_action_add_sample();      void on_action_add_sample();
601        void on_action_replace_sample();
602      void on_action_replace_all_samples_in_all_groups();      void on_action_replace_all_samples_in_all_groups();
603      void on_action_remove_sample();      void on_action_remove_sample();
604        void on_action_remove_unused_samples();
605    
606        // script right-click popup actions
607    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
608        bool on_script_treeview_button_release(Gdk::EventButton& button);
609    #else
610        void on_script_treeview_button_release(GdkEventButton* button);
611    #endif
612        void on_action_add_script_group();
613        void on_action_add_script();
614        void on_action_edit_script();
615        void on_action_remove_script();
616    
617      void on_action_add_instrument();      void on_action_add_instrument();
618        void on_action_duplicate_instrument();
619      void on_action_remove_instrument();      void on_action_remove_instrument();
620    
621      LoadDialog* load_dialog;      void show_samples_tab();
622        void show_intruments_tab();
623        void show_scripts_tab();
624    
625        void select_prev_instrument();
626        void select_next_instrument();
627        void select_instrument_by_dir(int dir);
628    
629        void select_prev_region();
630        void select_next_region();
631    
632        void select_next_dim_rgn_zone();
633        void select_prev_dim_rgn_zone();
634        void select_add_next_dim_rgn_zone();
635        void select_add_prev_dim_rgn_zone();
636        void select_prev_dimension();
637        void select_next_dimension();
638    
639        Serialization::Archive m_serializationArchive; ///< Clipboard content.
640        std::vector<Serialization::Archive> m_macros; ///< User configured list of macros.
641    
642        void copy_selected_dimrgn();
643        void paste_copied_dimrgn();
644        void adjust_clipboard_content();
645        void updateClipboardCopyAvailable();
646        void updateClipboardPasteAvailable();
647    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
648        void on_clipboard_owner_change(Gdk::EventOwnerChange& event);
649    #else
650        void on_clipboard_owner_change(GdkEventOwnerChange* event);
651    #endif
652        void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);
653        void on_clipboard_clear();
654        void on_clipboard_received(const Gtk::SelectionData& selection_data);
655        void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);
656    
657        void add_instrument(gig::Instrument* instrument);
658    #if !USE_GTKMM_BUILDER
659        Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
660                                                   int position = -1);
661        void remove_instrument_from_menu(int index);
662    #endif
663        bool onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
664    
665        ProgressDialog* progress_dialog;
666      Loader* loader;      Loader* loader;
667        Saver* saver;
668      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);      void load_gig(gig::File* gig, const char* filename, bool isSharedInstrument = false);
669        void updateSampleRefCountMap(gig::File* gig);
670    
671      gig::File* file;      gig::File* file;
672      bool file_is_shared;      bool file_is_shared;
# Line 362  protected: Line 682  protected:
682      bool file_save_as();      bool file_save_as();
683      bool check_if_savable();      bool check_if_savable();
684    
685    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
686        bool on_button_release(Gdk::EventButton& button);
687    #else
688      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
689    #endif
690        void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
691        void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
692                                                   Gtk::SelectionData& selection_data, guint, guint);
693        void on_instruments_treeview_drop_drag_data_received(
694            const Glib::RefPtr<Gdk::DragContext>& context, int, int,
695            const Gtk::SelectionData& selection_data, guint, guint time
696        );
697        void on_scripts_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
698        void on_scripts_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
699                                               Gtk::SelectionData& selection_data, guint, guint);
700      void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_sample_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
701      void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_sample_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
702                                            Gtk::SelectionData& selection_data, guint, guint);                                            Gtk::SelectionData& selection_data, guint, guint);
# Line 371  protected: Line 705  protected:
705                                                   const Gtk::SelectionData& selection_data,                                                   const Gtk::SelectionData& selection_data,
706                                                   guint, guint time);                                                   guint, guint time);
707    
708        void script_name_changed(const Gtk::TreeModel::Path& path,
709                                 const Gtk::TreeModel::iterator& iter);
710        void script_double_clicked(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
711      void sample_name_changed(const Gtk::TreeModel::Path& path,      void sample_name_changed(const Gtk::TreeModel::Path& path,
712                               const Gtk::TreeModel::iterator& iter);                               const Gtk::TreeModel::iterator& iter);
713      void instrument_name_changed(const Gtk::TreeModel::Path& path,      void instrument_name_changed(const Gtk::TreeModel::Path& path,
714                                   const Gtk::TreeModel::iterator& iter);                                   const Gtk::TreeModel::iterator& iter);
715        void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it);
716        bool instrument_row_visible(const Gtk::TreeModel::const_iterator& iter);
717        sigc::connection instrument_name_connection;
718    
719        void on_action_combine_instruments();
720        void on_action_view_references();
721        void on_action_merge_files();
722        void mergeFiles(const std::vector<std::string>& filenames);
723    
724        void on_sample_ref_changed(gig::Sample* oldSample, gig::Sample* newSample);
725        void on_sample_ref_count_incremented(gig::Sample* sample, int offset);
726        void on_samples_to_be_removed(std::list<gig::Sample*> samples);
727    
728        void add_or_replace_sample(bool replace);
729    
730      void __import_queued_samples();      void __import_queued_samples();
731      void __clear();      void __clear();
732        void __refreshEntireGUI();
733        void updateScriptListOfMenu();
734        void assignScript(gig::Script* pScript);
735        void dropAllScriptSlots();
736    
737      bool close_confirmation_dialog();      bool close_confirmation_dialog();
738      bool leaving_shared_mode_dialog();      bool leaving_shared_mode_dialog();
739    
740      Gtk::Menu* popup_menu;      Gtk::Menu* popup_menu;
741    #if USE_GTKMM_BUILDER
742        Gtk::Menu* sample_popup;
743        Gtk::Menu* script_popup;
744    #endif
745    
746      bool on_delete_event(GdkEventAny* event);      bool on_delete_event(GdkEventAny* event);
747    
748      bool first_call_to_drag_data_get;      bool first_call_to_drag_data_get;
749    
750        bool is_copy_samples_unity_note_enabled() const;
751        bool is_copy_samples_fine_tune_enabled() const;
752        bool is_copy_samples_loop_enabled() const;
753  };  };
754    
755  #endif  #endif

Legend:
Removed from v.1853  
changed lines
  Added in v.3712

  ViewVC Help
Powered by ViewVC