/[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 3343 by schoenebeck, Mon Jul 31 11:35:30 2017 UTC revision 3470 by persson, Thu Feb 14 19:10:49 2019 UTC
# Line 1  Line 1 
1  /*                                                         -*- c++ -*-  /*                                                         -*- c++ -*-
2   * Copyright (C) 2006 - 2017 Andreas Persson   * Copyright (C) 2006 - 2019 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 28  Line 28 
28  # include <Serialization.h>  # include <Serialization.h>
29  #endif  #endif
30    
31    #include "compat.h"
32    
33  #include <gtkmm/box.h>  #include <gtkmm/box.h>
 #include <gtkmm/actiongroup.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>
# Line 40  Line 41 
41  #include <gtkmm/scrolledwindow.h>  #include <gtkmm/scrolledwindow.h>
42  #include <gtkmm/treestore.h>  #include <gtkmm/treestore.h>
43  #include <gtkmm/treemodelfilter.h>  #include <gtkmm/treemodelfilter.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>  #include <gtkmm/entry.h>
 #include <gtk/gtknotebook.h>  
48  #include <gtkmm/notebook.h>  #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"
# Line 65  class PropDialog : public ManagedWindow, Line 70  class PropDialog : public ManagedWindow,
70                     public PropEditor<DLS::Info> {                     public PropEditor<DLS::Info> {
71  public:  public:
72      PropDialog();      PropDialog();
     void set_info(DLS::Info* info);  
73      void set_file(gig::File* file);      void set_file(gig::File* file);
74    
75      // implementation for abstract methods of interface class "ManagedWindow"      // implementation for abstract methods of interface class "ManagedWindow"
# Line 92  protected: Line 96  protected:
96      StringEntry eSourceForm;      StringEntry eSourceForm;
97      StringEntry eCommissioned;      StringEntry eCommissioned;
98      StringEntry eSubject;      StringEntry eSubject;
99      Gtk::VBox vbox;      VBox vbox;
100      Gtk::HButtonBox buttonBox;      HButtonBox buttonBox;
101      Gtk::Button quitButton;      Gtk::Button quitButton;
102      Table table;      Table table;
103    
104      gig::File* m_file;      gig::File* m_file;
105    
106      void onFileFormatChanged();      void set_FileFormat(int value);
107  };  };
108    
109  class InstrumentProps : public ManagedWindow,  class InstrumentProps : public ManagedWindow,
# Line 126  protected: Line 130  protected:
130      void set_MIDIProgram(uint32_t value);      void set_MIDIProgram(uint32_t value);
131    
132      sigc::signal<void> sig_name_changed;      sigc::signal<void> sig_name_changed;
133      Gtk::VBox vbox;      VBox vbox;
134      Gtk::HButtonBox buttonBox;      HButtonBox buttonBox;
135      Gtk::Button quitButton;      Gtk::Button quitButton;
136      Table table;      Table table;
137      StringEntry eName;      StringEntry eName;
# Line 152  protected: Line 156  protected:
156      Gtk::ProgressBar progressBar;      Gtk::ProgressBar progressBar;
157  };  };
158    
159  class Loader : public sigc::trackable {  class LoaderSaverBase {
160  public:  public:
     Loader(const char* filename);  
161      void launch();      void launch();
162      Glib::Dispatcher& signal_progress();      Glib::Dispatcher& signal_progress();
163      Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.      Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.
# Line 165  public: Line 168  public:
168      Glib::ustring error_message;      Glib::ustring error_message;
169      gig::File* gig;      gig::File* gig;
170    
171    protected:
172        LoaderSaverBase(const Glib::ustring filename, gig::File* gig);
173    
174  private:  private:
175      Glib::Threads::Thread* thread;      Glib::Threads::Thread* thread;
176      void thread_function();      void thread_function();
177        virtual void thread_function_sub(gig::progress_t& progress) = 0;
178      Glib::Dispatcher finished_dispatcher;      Glib::Dispatcher finished_dispatcher;
179      Glib::Dispatcher progress_dispatcher;      Glib::Dispatcher progress_dispatcher;
180      Glib::Dispatcher error_dispatcher;      Glib::Dispatcher error_dispatcher;
# Line 175  private: Line 182  private:
182      float progress;      float progress;
183  };  };
184    
185  class Saver : public sigc::trackable {  class Loader : public LoaderSaverBase {
186    public:
187        Loader(const char* filename);
188    
189    private:
190        void thread_function_sub(gig::progress_t& progress);
191    };
192    
193    class Saver : public LoaderSaverBase {
194  public:  public:
195      Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"      Saver(gig::File* file, Glib::ustring filename = ""); ///< one argument means "save", two arguments means "save as"
     void launch();  
     Glib::Dispatcher& signal_progress();  
     Glib::Dispatcher& signal_finished(); ///< Finished successfully, without error.  
     Glib::Dispatcher& signal_error();  
     void progress_callback(float fraction);  
     float get_progress();  
     gig::File* gig;  
     const Glib::ustring filename;  
     Glib::ustring error_message;  
196    
197  private:  private:
198      Glib::Threads::Thread* thread;      void thread_function_sub(gig::progress_t& progress);
     void thread_function();  
     Glib::Dispatcher finished_dispatcher;  
     Glib::Dispatcher progress_dispatcher;  
     Glib::Dispatcher error_dispatcher;  
     Glib::Threads::Mutex progressMutex;  
     float progress;  
199  };  };
200    
201  class MainWindow : public ManagedWindow {  class MainWindow : public ManagedWindow {
# Line 234  public: Line 234  public:
234      virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }      virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; }
235    
236  protected:  protected:
237    #if USE_GTKMM_BUILDER
238        Glib::RefPtr<Gio::SimpleActionGroup> m_actionGroup;
239        Glib::RefPtr<Gtk::Builder> m_uiManager;
240    #else
241      Glib::RefPtr<Gtk::ActionGroup> actionGroup;      Glib::RefPtr<Gtk::ActionGroup> actionGroup;
242      Glib::RefPtr<Gtk::UIManager> uiManager;      Glib::RefPtr<Gtk::UIManager> uiManager;
243    #endif
244    
245    #if USE_GLIB_ACTION
246        Glib::RefPtr<Gio::SimpleAction> m_actionMIDIRules;
247    
248        Glib::RefPtr<Gio::SimpleAction> m_actionCopyDimRgn;
249        Glib::RefPtr<Gio::SimpleAction> m_actionPasteDimRgn;
250        Glib::RefPtr<Gio::SimpleAction> m_actionAdjustClipboard;
251    
252        Glib::RefPtr<Gio::SimpleAction> m_actionSampleProperties;
253        Glib::RefPtr<Gio::SimpleAction> m_actionAddSample;
254        Glib::RefPtr<Gio::SimpleAction> m_actionRemoveSample;
255        Glib::RefPtr<Gio::SimpleAction> m_actionViewSampleRefs;
256        Glib::RefPtr<Gio::SimpleAction> m_actionReplaceSample;
257        Glib::RefPtr<Gio::SimpleAction> m_actionAddSampleGroup;
258    
259        Glib::RefPtr<Gio::SimpleAction> m_actionAddScriptGroup;
260        Glib::RefPtr<Gio::SimpleAction> m_actionAddScript;
261        Glib::RefPtr<Gio::SimpleAction> m_actionEditScript;
262        Glib::RefPtr<Gio::SimpleAction> m_actionRemoveScript;
263    
264        Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleUnity;
265        Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleTune;
266        Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleLoop;
267        Glib::RefPtr<Gio::SimpleAction> m_actionToggleStatusBar;
268        Glib::RefPtr<Gio::SimpleAction> m_actionToggleRestoreWinDim;
269        Glib::RefPtr<Gio::SimpleAction> m_actionToggleSaveWithTempFile;
270        Glib::RefPtr<Gio::SimpleAction> m_actionToggleWarnOnExtensions;
271        Glib::RefPtr<Gio::SimpleAction> m_actionToggleShowTooltips;
272        Glib::RefPtr<Gio::SimpleAction> m_actionToggleSyncSamplerSelection;
273        Glib::RefPtr<Gio::SimpleAction> m_actionToggleMoveRootNoteWithRegion;
274    #endif
275    
276      Gtk::Statusbar m_StatusBar;      Gtk::Statusbar m_StatusBar;
277      Gtk::Label     m_AttachedStateLabel;      Gtk::Label     m_AttachedStateLabel;
# Line 277  protected: Line 313  protected:
313    
314      sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;      sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal;
315    
316    #if !USE_GTKMM_BUILDER
317      void on_instrument_selection_change(Gtk::RadioMenuItem* item);      void on_instrument_selection_change(Gtk::RadioMenuItem* item);
318    #endif
319      void on_sel_change();      void on_sel_change();
320      void region_changed();      void region_changed();
321      void dimreg_changed();      void dimreg_changed();
# Line 310  protected: Line 348  protected:
348            add(m_col_name);            add(m_col_name);
349            add(m_col_instr);            add(m_col_instr);
350            add(m_col_scripts);            add(m_col_scripts);
351              add(m_col_tooltip);
352          }          }
353    
354          Gtk::TreeModelColumn<int> m_col_nr;          Gtk::TreeModelColumn<int> m_col_nr;
355          Gtk::TreeModelColumn<Glib::ustring> m_col_name;          Gtk::TreeModelColumn<Glib::ustring> m_col_name;
356          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;          Gtk::TreeModelColumn<gig::Instrument*> m_col_instr;
357          Gtk::TreeModelColumn<Glib::ustring> m_col_scripts;          Gtk::TreeModelColumn<Glib::ustring> m_col_scripts;
358            Gtk::TreeModelColumn<Glib::ustring> m_col_tooltip;
359      } m_Columns;      } m_Columns;
360    
361      Gtk::VBox m_VBox;      VBox m_VBox;
362      Gtk::HPaned m_HPaned;      Gtk::HPaned m_HPaned;
363    
364      Gtk::ScrolledWindow m_ScrolledWindow;      Gtk::ScrolledWindow m_ScrolledWindow;
# Line 327  protected: Line 367  protected:
367      Glib::RefPtr<Gtk::ListStore> m_refTreeModel;      Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
368      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.      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.
369    
370      Gtk::Menu* instrument_menu;  #if USE_GTKMM_BUILDER
371        Gtk::Menu* menuMacro;
372    #else
373        Gtk::Menu* instrument_menu; // kept for GTKMM 2 version only, will be completely removed in future
374    #endif
375      Gtk::Menu* assign_scripts_menu;      Gtk::Menu* assign_scripts_menu;
376    
377      std::map<gig::Sample*,int> sample_ref_count;      std::map<gig::Sample*,int> sample_ref_count;
# Line 388  protected: Line 432  protected:
432      Gtk::TreeView m_TreeViewScripts;      Gtk::TreeView m_TreeViewScripts;
433      Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel;      Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel;
434    
435      Gtk::VBox dimreg_vbox;      VBox dimreg_vbox;
436      Gtk::HBox dimreg_hbox;      HBox dimreg_hbox;
437      Gtk::Label dimreg_label;      Gtk::Label dimreg_label;
438      Gtk::CheckButton dimreg_all_regions;      Gtk::CheckButton dimreg_all_regions;
439      Gtk::CheckButton dimreg_all_dimregs;      Gtk::CheckButton dimreg_all_dimregs;
440      Gtk::CheckButton dimreg_stereo;      Gtk::CheckButton dimreg_stereo;
441    
442      Gtk::HBox legend_hbox;      HBox legend_hbox;
443      Gtk::Label labelLegend;      Gtk::Label labelLegend;
444      Gtk::Image imageNoSample;      Gtk::Image imageNoSample;
445      Gtk::Label labelNoSample;      Gtk::Label labelNoSample;
# Line 407  protected: Line 451  protected:
451      Gtk::Label labelSomeLoops;      Gtk::Label labelSomeLoops;
452      DimRegionEdit dimreg_edit;      DimRegionEdit dimreg_edit;
453    
454      Gtk::VBox m_left_vbox;      VBox m_left_vbox;
455      Gtk::Notebook m_TreeViewNotebook;      Gtk::Notebook m_TreeViewNotebook;
456      Gtk::HBox m_searchField;      HBox m_searchField;
457      Gtk::Label m_searchLabel;      Gtk::Label m_searchLabel;
458      Gtk::Entry m_searchText;      Gtk::Entry m_searchText;
459    
# Line 438  protected: Line 482  protected:
482      void on_save_with_temporary_file();      void on_save_with_temporary_file();
483      void on_action_refresh_all();      void on_action_refresh_all();
484      void on_action_warn_user_on_extensions();      void on_action_warn_user_on_extensions();
485        void on_action_show_tooltips();
486        void on_show_tooltips_changed();
487      void on_action_sync_sampler_instrument_selection();      void on_action_sync_sampler_instrument_selection();
488      void on_action_move_root_note_with_region_moved();      void on_action_move_root_note_with_region_moved();
489      void on_action_help_about();      void on_action_help_about();
490    
491      void on_notebook_tab_switched(GtkNotebookPage* page, guint page_num);      void on_notebook_tab_switched(void* page, guint page_num);
492    
493      // sample right-click popup actions      // sample right-click popup actions
494    #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
495        bool on_sample_treeview_button_release(Gdk::EventButton& button);
496    #else
497      void on_sample_treeview_button_release(GdkEventButton* button);      void on_sample_treeview_button_release(GdkEventButton* button);
498    #endif
499      void on_action_sample_properties();      void on_action_sample_properties();
500      void on_action_add_group();      void on_action_add_group();
501      void on_action_add_sample();      void on_action_add_sample();
# Line 455  protected: Line 505  protected:
505      void on_action_remove_unused_samples();      void on_action_remove_unused_samples();
506    
507      // script right-click popup actions      // script right-click popup actions
508    #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
509        bool on_script_treeview_button_release(Gdk::EventButton& button);
510    #else
511      void on_script_treeview_button_release(GdkEventButton* button);      void on_script_treeview_button_release(GdkEventButton* button);
512    #endif
513      void on_action_add_script_group();      void on_action_add_script_group();
514      void on_action_add_script();      void on_action_add_script();
515      void on_action_edit_script();      void on_action_edit_script();
# Line 491  protected: Line 545  protected:
545      void adjust_clipboard_content();      void adjust_clipboard_content();
546      void updateClipboardCopyAvailable();      void updateClipboardCopyAvailable();
547      void updateClipboardPasteAvailable();      void updateClipboardPasteAvailable();
548    #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
549        void on_clipboard_owner_change(Gdk::EventOwnerChange& event);
550    #else
551      void on_clipboard_owner_change(GdkEventOwnerChange* event);      void on_clipboard_owner_change(GdkEventOwnerChange* event);
552    #endif
553      void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);      void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);
554      void on_clipboard_clear();      void on_clipboard_clear();
555      void on_clipboard_received(const Gtk::SelectionData& selection_data);      void on_clipboard_received(const Gtk::SelectionData& selection_data);
556      void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);      void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);
557    
558      void add_instrument(gig::Instrument* instrument);      void add_instrument(gig::Instrument* instrument);
559    #if !USE_GTKMM_BUILDER
560      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,      Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name,
561                                                 int position = -1);                                                 int position = -1);
562      void remove_instrument_from_menu(int index);      void remove_instrument_from_menu(int index);
563    #endif
564        bool onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
565    
566      ProgressDialog* progress_dialog;      ProgressDialog* progress_dialog;
567      Loader* loader;      Loader* loader;
# Line 522  protected: Line 583  protected:
583      bool file_save_as();      bool file_save_as();
584      bool check_if_savable();      bool check_if_savable();
585    
586    #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
587        bool on_button_release(Gdk::EventButton& button);
588    #else
589      void on_button_release(GdkEventButton* button);      void on_button_release(GdkEventButton* button);
590    #endif
591      void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);      void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context);
592      void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,      void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&,
593                                                 Gtk::SelectionData& selection_data, guint, guint);                                                 Gtk::SelectionData& selection_data, guint, guint);
# Line 568  protected: Line 633  protected:
633      void __refreshEntireGUI();      void __refreshEntireGUI();
634      void updateScriptListOfMenu();      void updateScriptListOfMenu();
635      void assignScript(gig::Script* pScript);      void assignScript(gig::Script* pScript);
636        void dropAllScriptSlots();
637    
638      bool close_confirmation_dialog();      bool close_confirmation_dialog();
639      bool leaving_shared_mode_dialog();      bool leaving_shared_mode_dialog();
640    
641      Gtk::Menu* popup_menu;      Gtk::Menu* popup_menu;
642    #if USE_GTKMM_BUILDER
643        Gtk::Menu* sample_popup;
644        Gtk::Menu* script_popup;
645    #endif
646    
647      bool on_delete_event(GdkEventAny* event);      bool on_delete_event(GdkEventAny* event);
648    
649      bool first_call_to_drag_data_get;      bool first_call_to_drag_data_get;
650        
651      bool is_copy_samples_unity_note_enabled() const;      bool is_copy_samples_unity_note_enabled() const;
652      bool is_copy_samples_fine_tune_enabled() const;      bool is_copy_samples_fine_tune_enabled() const;
653      bool is_copy_samples_loop_enabled() const;      bool is_copy_samples_loop_enabled() const;

Legend:
Removed from v.3343  
changed lines
  Added in v.3470

  ViewVC Help
Powered by ViewVC