1 |
/* -*- c++ -*- |
/* -*- c++ -*- |
2 |
* Copyright (C) 2006 - 2016 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 |
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/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> |
40 |
#include <gtkmm/radiomenuitem.h> |
#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 |
|
|
97 |
StringEntry eSourceForm; |
StringEntry eSourceForm; |
98 |
StringEntry eCommissioned; |
StringEntry eCommissioned; |
99 |
StringEntry eSubject; |
StringEntry eSubject; |
100 |
Gtk::VBox vbox; |
VBox vbox; |
101 |
Gtk::HButtonBox buttonBox; |
HButtonBox buttonBox; |
102 |
Gtk::Button quitButton; |
Gtk::Button quitButton; |
103 |
Table table; |
Table table; |
104 |
|
|
131 |
void set_MIDIProgram(uint32_t value); |
void set_MIDIProgram(uint32_t value); |
132 |
|
|
133 |
sigc::signal<void> sig_name_changed; |
sigc::signal<void> sig_name_changed; |
134 |
Gtk::VBox vbox; |
VBox vbox; |
135 |
Gtk::HButtonBox buttonBox; |
HButtonBox buttonBox; |
136 |
Gtk::Button quitButton; |
Gtk::Button quitButton; |
137 |
Table table; |
Table table; |
138 |
StringEntry eName; |
StringEntry eName; |
239 |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; } |
virtual Settings::Property<int>* windowSettingHeight() { return &Settings::singleton()->mainWindowH; } |
240 |
|
|
241 |
protected: |
protected: |
242 |
|
#if USE_GTKMM_BUILDER |
243 |
|
Glib::RefPtr<Gio::SimpleActionGroup> m_actionGroup; |
244 |
|
Glib::RefPtr<Gtk::Builder> m_uiManager; |
245 |
|
#else |
246 |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
Glib::RefPtr<Gtk::ActionGroup> actionGroup; |
247 |
Glib::RefPtr<Gtk::UIManager> uiManager; |
Glib::RefPtr<Gtk::UIManager> uiManager; |
248 |
|
#endif |
249 |
|
|
250 |
|
#if USE_GLIB_ACTION |
251 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionMIDIRules; |
252 |
|
|
253 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionCopyDimRgn; |
254 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionPasteDimRgn; |
255 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAdjustClipboard; |
256 |
|
|
257 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionSampleProperties; |
258 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddSample; |
259 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionRemoveSample; |
260 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionViewSampleRefs; |
261 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionReplaceSample; |
262 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddSampleGroup; |
263 |
|
|
264 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddScriptGroup; |
265 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionAddScript; |
266 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionEditScript; |
267 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionRemoveScript; |
268 |
|
|
269 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleUnity; |
270 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleTune; |
271 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleCopySampleLoop; |
272 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleStatusBar; |
273 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleRestoreWinDim; |
274 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleSaveWithTempFile; |
275 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleWarnOnExtensions; |
276 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleShowTooltips; |
277 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleSyncSamplerSelection; |
278 |
|
Glib::RefPtr<Gio::SimpleAction> m_actionToggleMoveRootNoteWithRegion; |
279 |
|
#endif |
280 |
|
|
281 |
Gtk::Statusbar m_StatusBar; |
Gtk::Statusbar m_StatusBar; |
282 |
Gtk::Label m_AttachedStateLabel; |
Gtk::Label m_AttachedStateLabel; |
289 |
InstrumentProps instrumentProps; |
InstrumentProps instrumentProps; |
290 |
MidiRules midiRules; |
MidiRules midiRules; |
291 |
|
|
292 |
|
/** |
293 |
|
* Ensures that the 2 signals MainWindow::dimreg_to_be_changed_signal and |
294 |
|
* MainWindowv::dimreg_changed_signal are always triggered correctly as a |
295 |
|
* pair. It behaves similar to a "mutex lock guard" design pattern. |
296 |
|
*/ |
297 |
|
class DimRegionChangeGuard : public SignalGuard<gig::DimensionRegion*> { |
298 |
|
public: |
299 |
|
DimRegionChangeGuard(MainWindow* w, gig::DimensionRegion* pDimReg) : |
300 |
|
SignalGuard<gig::DimensionRegion*>(w->dimreg_to_be_changed_signal, w->dimreg_changed_signal, pDimReg) |
301 |
|
{ |
302 |
|
} |
303 |
|
}; |
304 |
|
|
305 |
sigc::signal<void, gig::File*> file_structure_to_be_changed_signal; |
sigc::signal<void, gig::File*> file_structure_to_be_changed_signal; |
306 |
sigc::signal<void, gig::File*> file_structure_changed_signal; |
sigc::signal<void, gig::File*> file_structure_changed_signal; |
307 |
sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal; |
sigc::signal<void, std::list<gig::Sample*> > samples_to_be_removed_signal; |
318 |
|
|
319 |
sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal; |
sigc::signal<void, gig::Instrument*> switch_sampler_instrument_signal; |
320 |
|
|
321 |
|
#if !USE_GTKMM_BUILDER |
322 |
void on_instrument_selection_change(Gtk::RadioMenuItem* item); |
void on_instrument_selection_change(Gtk::RadioMenuItem* item); |
323 |
|
#endif |
324 |
void on_sel_change(); |
void on_sel_change(); |
325 |
void region_changed(); |
void region_changed(); |
326 |
void dimreg_changed(); |
void dimreg_changed(); |
333 |
void on_saver_progress(); |
void on_saver_progress(); |
334 |
void on_saver_error(); |
void on_saver_error(); |
335 |
void on_saver_finished(); |
void on_saver_finished(); |
336 |
|
void updateMacroMenu(); |
337 |
|
void onMacroSelected(int iMacro); |
338 |
|
void setupMacros(); |
339 |
|
void onMacrosSetupChanged(const std::vector<Serialization::Archive>& macros); |
340 |
|
void applyMacro(Serialization::Archive& macro); |
341 |
|
void onScriptSlotsModified(gig::Instrument* pInstrument); |
342 |
|
void bringToFront(); |
343 |
|
|
344 |
void dimreg_all_dimregs_toggled(); |
void dimreg_all_dimregs_toggled(); |
345 |
gig::Instrument* get_instrument(); |
gig::Instrument* get_instrument(); |
349 |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
class ModelColumns : public Gtk::TreeModel::ColumnRecord { |
350 |
public: |
public: |
351 |
ModelColumns() { |
ModelColumns() { |
352 |
|
add(m_col_nr); |
353 |
add(m_col_name); |
add(m_col_name); |
354 |
add(m_col_instr); |
add(m_col_instr); |
355 |
|
add(m_col_scripts); |
356 |
} |
} |
357 |
|
|
358 |
|
Gtk::TreeModelColumn<int> m_col_nr; |
359 |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
Gtk::TreeModelColumn<Glib::ustring> m_col_name; |
360 |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
Gtk::TreeModelColumn<gig::Instrument*> m_col_instr; |
361 |
|
Gtk::TreeModelColumn<Glib::ustring> m_col_scripts; |
362 |
} m_Columns; |
} m_Columns; |
363 |
|
|
364 |
Gtk::VBox m_VBox; |
VBox m_VBox; |
365 |
Gtk::HPaned m_HPaned; |
Gtk::HPaned m_HPaned; |
366 |
|
|
367 |
Gtk::ScrolledWindow m_ScrolledWindow; |
Gtk::ScrolledWindow m_ScrolledWindow; |
368 |
|
|
369 |
Gtk::TreeView m_TreeView; |
Gtk::TreeView m_TreeView; |
370 |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
Glib::RefPtr<Gtk::ListStore> m_refTreeModel; |
371 |
|
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. |
372 |
|
|
373 |
Gtk::Menu* instrument_menu; |
#if USE_GTKMM_BUILDER |
374 |
|
Gtk::Menu* menuMacro; |
375 |
|
#else |
376 |
|
Gtk::Menu* instrument_menu; // kept for GTKMM 2 version only, will be completely removed in future |
377 |
|
#endif |
378 |
|
Gtk::Menu* assign_scripts_menu; |
379 |
|
|
380 |
std::map<gig::Sample*,int> sample_ref_count; |
std::map<gig::Sample*,int> sample_ref_count; |
381 |
|
|
435 |
Gtk::TreeView m_TreeViewScripts; |
Gtk::TreeView m_TreeViewScripts; |
436 |
Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel; |
Glib::RefPtr<ScriptsTreeStore> m_refScriptsTreeModel; |
437 |
|
|
438 |
Gtk::VBox dimreg_vbox; |
VBox dimreg_vbox; |
439 |
Gtk::HBox dimreg_hbox; |
HBox dimreg_hbox; |
440 |
Gtk::Label dimreg_label; |
Gtk::Label dimreg_label; |
441 |
Gtk::CheckButton dimreg_all_regions; |
Gtk::CheckButton dimreg_all_regions; |
442 |
Gtk::CheckButton dimreg_all_dimregs; |
Gtk::CheckButton dimreg_all_dimregs; |
443 |
Gtk::CheckButton dimreg_stereo; |
Gtk::CheckButton dimreg_stereo; |
444 |
|
|
445 |
|
HBox legend_hbox; |
446 |
|
Gtk::Label labelLegend; |
447 |
|
Gtk::Image imageNoSample; |
448 |
|
Gtk::Label labelNoSample; |
449 |
|
Gtk::Image imageMissingSample; |
450 |
|
Gtk::Label labelMissingSample; |
451 |
|
Gtk::Image imageLooped; |
452 |
|
Gtk::Label labelLooped; |
453 |
|
Gtk::Image imageSomeLoops; |
454 |
|
Gtk::Label labelSomeLoops; |
455 |
DimRegionEdit dimreg_edit; |
DimRegionEdit dimreg_edit; |
456 |
|
|
457 |
|
VBox m_left_vbox; |
458 |
Gtk::Notebook m_TreeViewNotebook; |
Gtk::Notebook m_TreeViewNotebook; |
459 |
|
HBox m_searchField; |
460 |
|
Gtk::Label m_searchLabel; |
461 |
|
Gtk::Entry m_searchText; |
462 |
|
|
463 |
struct SampleImportItem { |
struct SampleImportItem { |
464 |
gig::Sample* gig_sample; // pointer to the gig::Sample to |
gig::Sample* gig_sample; // pointer to the gig::Sample to |
467 |
Glib::ustring sample_path; // file name of the sample to be |
Glib::ustring sample_path; // file name of the sample to be |
468 |
// imported |
// imported |
469 |
}; |
}; |
470 |
std::list<SampleImportItem> m_SampleImportQueue; |
std::map<gig::Sample*, SampleImportItem> m_SampleImportQueue; |
471 |
|
|
472 |
|
|
473 |
void on_action_file_new(); |
void on_action_file_new(); |
482 |
void show_script_slots(); |
void show_script_slots(); |
483 |
void on_action_view_status_bar(); |
void on_action_view_status_bar(); |
484 |
void on_auto_restore_win_dim(); |
void on_auto_restore_win_dim(); |
485 |
|
void on_save_with_temporary_file(); |
486 |
void on_action_refresh_all(); |
void on_action_refresh_all(); |
487 |
void on_action_warn_user_on_extensions(); |
void on_action_warn_user_on_extensions(); |
488 |
|
void on_action_show_tooltips(); |
489 |
|
void on_show_tooltips_changed(); |
490 |
void on_action_sync_sampler_instrument_selection(); |
void on_action_sync_sampler_instrument_selection(); |
491 |
void on_action_move_root_note_with_region_moved(); |
void on_action_move_root_note_with_region_moved(); |
492 |
void on_action_help_about(); |
void on_action_help_about(); |
493 |
|
|
494 |
|
void on_notebook_tab_switched(void* page, guint page_num); |
495 |
|
|
496 |
// sample right-click popup actions |
// sample right-click popup actions |
497 |
|
#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 |
498 |
|
bool on_sample_treeview_button_release(Gdk::EventButton& button); |
499 |
|
#else |
500 |
void on_sample_treeview_button_release(GdkEventButton* button); |
void on_sample_treeview_button_release(GdkEventButton* button); |
501 |
|
#endif |
502 |
void on_action_sample_properties(); |
void on_action_sample_properties(); |
503 |
void on_action_add_group(); |
void on_action_add_group(); |
504 |
void on_action_add_sample(); |
void on_action_add_sample(); |
508 |
void on_action_remove_unused_samples(); |
void on_action_remove_unused_samples(); |
509 |
|
|
510 |
// script right-click popup actions |
// script right-click popup actions |
511 |
|
#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 |
512 |
|
bool on_script_treeview_button_release(Gdk::EventButton& button); |
513 |
|
#else |
514 |
void on_script_treeview_button_release(GdkEventButton* button); |
void on_script_treeview_button_release(GdkEventButton* button); |
515 |
|
#endif |
516 |
void on_action_add_script_group(); |
void on_action_add_script_group(); |
517 |
void on_action_add_script(); |
void on_action_add_script(); |
518 |
void on_action_edit_script(); |
void on_action_edit_script(); |
526 |
void show_intruments_tab(); |
void show_intruments_tab(); |
527 |
void show_scripts_tab(); |
void show_scripts_tab(); |
528 |
|
|
529 |
|
void select_prev_instrument(); |
530 |
|
void select_next_instrument(); |
531 |
|
void select_instrument_by_dir(int dir); |
532 |
|
|
533 |
|
void select_prev_region(); |
534 |
|
void select_next_region(); |
535 |
|
|
536 |
|
void select_next_dim_rgn_zone(); |
537 |
|
void select_prev_dim_rgn_zone(); |
538 |
|
void select_add_next_dim_rgn_zone(); |
539 |
|
void select_add_prev_dim_rgn_zone(); |
540 |
|
void select_prev_dimension(); |
541 |
|
void select_next_dimension(); |
542 |
|
|
543 |
|
Serialization::Archive m_serializationArchive; ///< Clipboard content. |
544 |
|
std::vector<Serialization::Archive> m_macros; ///< User configured list of macros. |
545 |
|
|
546 |
|
void copy_selected_dimrgn(); |
547 |
|
void paste_copied_dimrgn(); |
548 |
|
void adjust_clipboard_content(); |
549 |
|
void updateClipboardCopyAvailable(); |
550 |
|
void updateClipboardPasteAvailable(); |
551 |
|
#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 |
552 |
|
void on_clipboard_owner_change(Gdk::EventOwnerChange& event); |
553 |
|
#else |
554 |
|
void on_clipboard_owner_change(GdkEventOwnerChange* event); |
555 |
|
#endif |
556 |
|
void on_clipboard_get(Gtk::SelectionData& selection_data, guint info); |
557 |
|
void on_clipboard_clear(); |
558 |
|
void on_clipboard_received(const Gtk::SelectionData& selection_data); |
559 |
|
void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets); |
560 |
|
|
561 |
void add_instrument(gig::Instrument* instrument); |
void add_instrument(gig::Instrument* instrument); |
562 |
|
#if !USE_GTKMM_BUILDER |
563 |
Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name, |
Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name, |
564 |
int position = -1); |
int position = -1); |
565 |
void remove_instrument_from_menu(int index); |
void remove_instrument_from_menu(int index); |
566 |
|
#endif |
567 |
|
|
568 |
ProgressDialog* progress_dialog; |
ProgressDialog* progress_dialog; |
569 |
Loader* loader; |
Loader* loader; |
585 |
bool file_save_as(); |
bool file_save_as(); |
586 |
bool check_if_savable(); |
bool check_if_savable(); |
587 |
|
|
588 |
|
#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 |
589 |
|
bool on_button_release(Gdk::EventButton& button); |
590 |
|
#else |
591 |
void on_button_release(GdkEventButton* button); |
void on_button_release(GdkEventButton* button); |
592 |
|
#endif |
593 |
void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context); |
void on_instruments_treeview_drag_begin(const Glib::RefPtr<Gdk::DragContext>& context); |
594 |
void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
void on_instruments_treeview_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, |
595 |
Gtk::SelectionData& selection_data, guint, guint); |
Gtk::SelectionData& selection_data, guint, guint); |
616 |
void instrument_name_changed(const Gtk::TreeModel::Path& path, |
void instrument_name_changed(const Gtk::TreeModel::Path& path, |
617 |
const Gtk::TreeModel::iterator& iter); |
const Gtk::TreeModel::iterator& iter); |
618 |
void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it); |
void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it); |
619 |
|
bool instrument_row_visible(const Gtk::TreeModel::const_iterator& iter); |
620 |
sigc::connection instrument_name_connection; |
sigc::connection instrument_name_connection; |
621 |
|
|
622 |
void on_action_combine_instruments(); |
void on_action_combine_instruments(); |
633 |
void __import_queued_samples(); |
void __import_queued_samples(); |
634 |
void __clear(); |
void __clear(); |
635 |
void __refreshEntireGUI(); |
void __refreshEntireGUI(); |
636 |
|
void updateScriptListOfMenu(); |
637 |
|
void assignScript(gig::Script* pScript); |
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 |
|
|