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 |
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> |
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" |
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" |
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, |
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; |
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. |
164 |
Glib::Dispatcher& signal_error(); |
Glib::Dispatcher& signal_error(); |
165 |
void progress_callback(float fraction); |
void progress_callback(float fraction); |
166 |
float get_progress(); |
float get_progress(); |
167 |
|
void join(); |
168 |
const Glib::ustring filename; |
const Glib::ustring filename; |
169 |
Glib::ustring error_message; |
Glib::ustring error_message; |
170 |
gig::File* gig; |
gig::File* gig; |
171 |
|
|
172 |
|
protected: |
173 |
|
LoaderSaverBase(const Glib::ustring filename, gig::File* gig); |
174 |
|
|
175 |
private: |
private: |
176 |
Glib::Threads::Thread* thread; |
Glib::Threads::Thread* thread; |
177 |
void thread_function(); |
void thread_function(); |
178 |
|
virtual void thread_function_sub(gig::progress_t& progress) = 0; |
179 |
Glib::Dispatcher finished_dispatcher; |
Glib::Dispatcher finished_dispatcher; |
180 |
Glib::Dispatcher progress_dispatcher; |
Glib::Dispatcher progress_dispatcher; |
181 |
Glib::Dispatcher error_dispatcher; |
Glib::Dispatcher error_dispatcher; |
183 |
float progress; |
float progress; |
184 |
}; |
}; |
185 |
|
|
186 |
class Saver : public sigc::trackable { |
class Loader : public LoaderSaverBase { |
187 |
|
public: |
188 |
|
Loader(const char* filename); |
189 |
|
|
190 |
|
private: |
191 |
|
void thread_function_sub(gig::progress_t& progress); |
192 |
|
}; |
193 |
|
|
194 |
|
class Saver : public LoaderSaverBase { |
195 |
public: |
public: |
196 |
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; |
|
197 |
|
|
198 |
private: |
private: |
199 |
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; |
|
200 |
}; |
}; |
201 |
|
|
202 |
class MainWindow : public ManagedWindow { |
class MainWindow : public ManagedWindow { |
235 |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; } |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; } |
236 |
|
|
237 |
protected: |
protected: |
238 |
|
#if USE_GTKMM_BUILDER |
239 |
|
Glib::RefPtr<Gio::SimpleActionGroup> m_actionGroup; |
240 |
|
Glib::RefPtr<Gtk::Builder> m_uiManager; |
241 |
|
#else |
242 |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
243 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
Glib::RefPtr<Gtk::UIManager> uiManager; |
244 |
|
#endif |
245 |
|
|
246 |
|
#if USE_GLIB_ACTION |
247 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionMIDIRules; |
248 |
|
|
249 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionCopyDimRgn; |
250 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionPasteDimRgn; |
251 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAdjustClipboard; |
252 |
|
|
253 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionSampleProperties; |
254 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddSample; |
255 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionRemoveSample; |
256 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionViewSampleRefs; |
257 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionReplaceSample; |
258 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddSampleGroup; |
259 |
|
|
260 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddScriptGroup; |
261 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddScript; |
262 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionEditScript; |
263 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionRemoveScript; |
264 |
|
|
265 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleUnity; |
266 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleTune; |
267 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleLoop; |
268 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleStatusBar; |
269 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleRestoreWinDim; |
270 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleSaveWithTempFile; |
271 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleWarnOnExtensions; |
272 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleShowTooltips; |
273 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleSyncSamplerSelection; |
274 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleMoveRootNoteWithRegion; |
275 |
|
#endif |
276 |
|
|
277 |
Gtk::Statusbar m_StatusBar; |
Gtk::Statusbar m_StatusBar; |
278 |
Gtk::Label m_AttachedStateLabel; |
Gtk::Label m_AttachedStateLabel; |
314 |
|
|
315 |
sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal; |
sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal; |
316 |
|
|
317 |
|
#if !USE_GTKMM_BUILDER |
318 |
void on_instrument_selection_change(Gtk::RadioMenuItem* item); |
void on_instrument_selection_change(Gtk::RadioMenuItem* item); |
319 |
|
#endif |
320 |
void on_sel_change(); |
void on_sel_change(); |
321 |
void region_changed(); |
void region_changed(); |
322 |
void dimreg_changed(); |
void dimreg_changed(); |
349 |
add(m_col_name); |
add(m_col_name); |
350 |
add(m_col_instr); |
add(m_col_instr); |
351 |
add(m_col_scripts); |
add(m_col_scripts); |
352 |
|
add(m_col_tooltip); |
353 |
} |
} |
354 |
|
|
355 |
Gtk::TreeModelColumn<int> m_col_nr; |
Gtk::TreeModelColumn<int> m_col_nr; |
356 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
357 |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
358 |
Gtk::TreeModelColumn<Glib::ustring> m_col_scripts; |
Gtk::TreeModelColumn<Glib::ustring> m_col_scripts; |
359 |
|
Gtk::TreeModelColumn<Glib::ustring> m_col_tooltip; |
360 |
} m_Columns; |
} m_Columns; |
361 |
|
|
362 |
Gtk::VBox m_VBox; |
VBox m_VBox; |
363 |
Gtk::HPaned m_HPaned; |
Gtk::HPaned m_HPaned; |
364 |
|
|
365 |
Gtk::ScrolledWindow m_ScrolledWindow; |
Gtk::ScrolledWindow m_ScrolledWindow; |
368 |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
369 |
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. |
370 |
|
|
371 |
Gtk::Menu* instrument_menu; |
#if USE_GTKMM_BUILDER |
372 |
|
Gtk::Menu* menuMacro; |
373 |
|
#else |
374 |
|
Gtk::Menu* instrument_menu; // kept for GTKMM 2 version only, will be completely removed in future |
375 |
|
#endif |
376 |
Gtk::Menu* assign_scripts_menu; |
Gtk::Menu* assign_scripts_menu; |
377 |
|
|
378 |
std::map<gig::Sample*,int> sample_ref_count; |
std::map<gig::Sample*,int> sample_ref_count; |
433 |
Gtk::TreeView m_TreeViewScripts; |
Gtk::TreeView m_TreeViewScripts; |
434 |
Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel; |
Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel; |
435 |
|
|
436 |
Gtk::VBox dimreg_vbox; |
VBox dimreg_vbox; |
437 |
Gtk::HBox dimreg_hbox; |
HBox dimreg_hbox; |
438 |
Gtk::Label dimreg_label; |
Gtk::Label dimreg_label; |
439 |
Gtk::CheckButton dimreg_all_regions; |
Gtk::CheckButton dimreg_all_regions; |
440 |
Gtk::CheckButton dimreg_all_dimregs; |
Gtk::CheckButton dimreg_all_dimregs; |
441 |
Gtk::CheckButton dimreg_stereo; |
Gtk::CheckButton dimreg_stereo; |
442 |
|
|
443 |
Gtk::HBox legend_hbox; |
HBox legend_hbox; |
444 |
Gtk::Label labelLegend; |
Gtk::Label labelLegend; |
445 |
Gtk::Image imageNoSample; |
Gtk::Image imageNoSample; |
446 |
Gtk::Label labelNoSample; |
Gtk::Label labelNoSample; |
452 |
Gtk::Label labelSomeLoops; |
Gtk::Label labelSomeLoops; |
453 |
DimRegionEdit dimreg_edit; |
DimRegionEdit dimreg_edit; |
454 |
|
|
455 |
Gtk::VBox m_left_vbox; |
VBox m_left_vbox; |
456 |
Gtk::Notebook m_TreeViewNotebook; |
Gtk::Notebook m_TreeViewNotebook; |
457 |
Gtk::HBox m_searchField; |
HBox m_searchField; |
458 |
Gtk::Label m_searchLabel; |
Gtk::Label m_searchLabel; |
459 |
Gtk::Entry m_searchText; |
Gtk::Entry m_searchText; |
460 |
|
|
483 |
void on_save_with_temporary_file(); |
void on_save_with_temporary_file(); |
484 |
void on_action_refresh_all(); |
void on_action_refresh_all(); |
485 |
void on_action_warn_user_on_extensions(); |
void on_action_warn_user_on_extensions(); |
486 |
|
void on_action_show_tooltips(); |
487 |
|
void on_show_tooltips_changed(); |
488 |
void on_action_sync_sampler_instrument_selection(); |
void on_action_sync_sampler_instrument_selection(); |
489 |
void on_action_move_root_note_with_region_moved(); |
void on_action_move_root_note_with_region_moved(); |
490 |
void on_action_help_about(); |
void on_action_help_about(); |
491 |
|
|
492 |
void on_notebook_tab_switched(GtkNotebookPage* page, guint page_num); |
void on_notebook_tab_switched(void* page, guint page_num); |
493 |
|
|
494 |
// sample right-click popup actions |
// sample right-click popup actions |
495 |
|
#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 |
496 |
|
bool on_sample_treeview_button_release(Gdk::EventButton& button); |
497 |
|
#else |
498 |
void on_sample_treeview_button_release(GdkEventButton* button); |
void on_sample_treeview_button_release(GdkEventButton* button); |
499 |
|
#endif |
500 |
void on_action_sample_properties(); |
void on_action_sample_properties(); |
501 |
void on_action_add_group(); |
void on_action_add_group(); |
502 |
void on_action_add_sample(); |
void on_action_add_sample(); |
506 |
void on_action_remove_unused_samples(); |
void on_action_remove_unused_samples(); |
507 |
|
|
508 |
// script right-click popup actions |
// script right-click popup actions |
509 |
|
#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 |
510 |
|
bool on_script_treeview_button_release(Gdk::EventButton& button); |
511 |
|
#else |
512 |
void on_script_treeview_button_release(GdkEventButton* button); |
void on_script_treeview_button_release(GdkEventButton* button); |
513 |
|
#endif |
514 |
void on_action_add_script_group(); |
void on_action_add_script_group(); |
515 |
void on_action_add_script(); |
void on_action_add_script(); |
516 |
void on_action_edit_script(); |
void on_action_edit_script(); |
546 |
void adjust_clipboard_content(); |
void adjust_clipboard_content(); |
547 |
void updateClipboardCopyAvailable(); |
void updateClipboardCopyAvailable(); |
548 |
void updateClipboardPasteAvailable(); |
void updateClipboardPasteAvailable(); |
549 |
|
#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 |
550 |
|
void on_clipboard_owner_change(Gdk::EventOwnerChange& event); |
551 |
|
#else |
552 |
void on_clipboard_owner_change(GdkEventOwnerChange* event); |
void on_clipboard_owner_change(GdkEventOwnerChange* event); |
553 |
|
#endif |
554 |
void on_clipboard_get(Gtk::SelectionData& selection_data, guint info); |
void on_clipboard_get(Gtk::SelectionData& selection_data, guint info); |
555 |
void on_clipboard_clear(); |
void on_clipboard_clear(); |
556 |
void on_clipboard_received(const Gtk::SelectionData& selection_data); |
void on_clipboard_received(const Gtk::SelectionData& selection_data); |
557 |
void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets); |
void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets); |
558 |
|
|
559 |
void add_instrument(gig::Instrument* instrument); |
void add_instrument(gig::Instrument* instrument); |
560 |
|
#if !USE_GTKMM_BUILDER |
561 |
Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name, |
Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name, |
562 |
int position = -1); |
int position = -1); |
563 |
void remove_instrument_from_menu(int index); |
void remove_instrument_from_menu(int index); |
564 |
|
#endif |
565 |
|
bool onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr<Gtk::Tooltip>& tooltip); |
566 |
|
|
567 |
ProgressDialog* progress_dialog; |
ProgressDialog* progress_dialog; |
568 |
Loader* loader; |
Loader* loader; |
584 |
bool file_save_as(); |
bool file_save_as(); |
585 |
bool check_if_savable(); |
bool check_if_savable(); |
586 |
|
|
587 |
|
#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 |
588 |
|
bool on_button_release(Gdk::EventButton& button); |
589 |
|
#else |
590 |
void on_button_release(GdkEventButton* button); |
void on_button_release(GdkEventButton* button); |
591 |
|
#endif |
592 |
void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context); |
void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context); |
593 |
void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
594 |
Gtk::SelectionData& selection_data, guint, guint); |
Gtk::SelectionData& selection_data, guint, guint); |
634 |
void __refreshEntireGUI(); |
void __refreshEntireGUI(); |
635 |
void updateScriptListOfMenu(); |
void updateScriptListOfMenu(); |
636 |
void assignScript(gig::Script* pScript); |
void assignScript(gig::Script* pScript); |
637 |
|
void dropAllScriptSlots(); |
638 |
|
|
639 |
bool close_confirmation_dialog(); |
bool close_confirmation_dialog(); |
640 |
bool leaving_shared_mode_dialog(); |
bool leaving_shared_mode_dialog(); |
641 |
|
|
642 |
Gtk::Menu* popup_menu; |
Gtk::Menu* popup_menu; |
643 |
|
#if USE_GTKMM_BUILDER |
644 |
|
Gtk::Menu* sample_popup; |
645 |
|
Gtk::Menu* script_popup; |
646 |
|
#endif |
647 |
|
|
648 |
bool on_delete_event(GdkEventAny* event); |
bool on_delete_event(GdkEventAny* event); |
649 |
|
|
650 |
bool first_call_to_drag_data_get; |
bool first_call_to_drag_data_get; |
651 |
|
|
652 |
bool is_copy_samples_unity_note_enabled() const; |
bool is_copy_samples_unity_note_enabled() const; |
653 |
bool is_copy_samples_fine_tune_enabled() const; |
bool is_copy_samples_fine_tune_enabled() const; |
654 |
bool is_copy_samples_loop_enabled() const; |
bool is_copy_samples_loop_enabled() const; |