--- gigedit/trunk/src/gigedit/mainwindow.h 2017/05/30 20:17:12 3258 +++ gigedit/trunk/src/gigedit/mainwindow.h 2019/10/24 12:06:18 3636 @@ -1,5 +1,5 @@ /* -*- c++ -*- - * Copyright (C) 2006 - 2017 Andreas Persson + * Copyright (C) 2006 - 2019 Andreas Persson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -28,8 +28,9 @@ # include #endif +#include "compat.h" + #include -#include #include #include #include @@ -39,10 +40,18 @@ #include #include #include -#include +#include #include #include #include +#include +#include + +#if USE_GTKMM_BUILDER +# include +#else +# include // deprecated in gtkmm >= 3.21.4 +#endif #include @@ -50,18 +59,22 @@ #include "dimregionchooser.h" #include "dimregionedit.h" #include "midirules.h" +#ifdef GLIB_THREADS #ifndef OLD_THREADS #include #endif +#else +#include +#include +#endif #include "ManagedWindow.h" class MainWindow; -class PropDialog : public ManagedWindow, - public PropEditor { +class FilePropDialog : public ManagedWindow, + public PropEditor { public: - PropDialog(); - void set_info(DLS::Info* info); + FilePropDialog(); void set_file(gig::File* file); // implementation for abstract methods of interface class "ManagedWindow" @@ -88,14 +101,14 @@ StringEntry eSourceForm; StringEntry eCommissioned; StringEntry eSubject; - Gtk::VBox vbox; - Gtk::HButtonBox buttonBox; + VBox vbox; + HButtonBox buttonBox; Gtk::Button quitButton; Table table; gig::File* m_file; - void onFileFormatChanged(); + void set_FileFormat(int value); }; class InstrumentProps : public ManagedWindow, @@ -122,9 +135,12 @@ void set_MIDIProgram(uint32_t value); sigc::signal sig_name_changed; - Gtk::VBox vbox; - Gtk::HButtonBox buttonBox; + Gtk::Notebook tabs; + VBox vbox[3]; + HButtonBox buttonBox; Gtk::Button quitButton; + + // tab 1 Table table; StringEntry eName; BoolEntry eIsDrum; @@ -138,6 +154,25 @@ BoolEntry ePianoReleaseMode; NoteEntry eDimensionKeyRangeLow; NoteEntry eDimensionKeyRangeHigh; + + // tab 2 + Table table2; + StringEntry eName2; + StringEntry eCreationDate; + StringEntryMultiLine eComments; + StringEntry eProduct; + StringEntry eCopyright; + StringEntry eArtists; + StringEntry eGenre; + StringEntry eKeywords; + StringEntry eEngineer; + StringEntry eTechnician; + StringEntry eSoftware; + StringEntry eMedium; + StringEntry eSource; + StringEntry eSourceForm; + StringEntry eCommissioned; + StringEntry eSubject; }; class ProgressDialog : public Gtk::Dialog { @@ -148,50 +183,52 @@ Gtk::ProgressBar progressBar; }; -class Loader : public sigc::trackable { +class LoaderSaverBase { public: - Loader(const char* filename); 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(); + void join(); const Glib::ustring filename; Glib::ustring error_message; gig::File* gig; +protected: + LoaderSaverBase(const Glib::ustring filename, gig::File* gig); + private: +#ifdef GLIB_THREADS Glib::Threads::Thread* thread; + Glib::Threads::Mutex progressMutex; +#else + std::thread thread; + std::mutex progressMutex; +#endif void thread_function(); + virtual void thread_function_sub(gig::progress_t& progress) = 0; Glib::Dispatcher finished_dispatcher; Glib::Dispatcher progress_dispatcher; Glib::Dispatcher error_dispatcher; - Glib::Threads::Mutex progressMutex; float progress; }; -class Saver : public sigc::trackable { +class Loader : public LoaderSaverBase { +public: + Loader(const char* filename); + +private: + void thread_function_sub(gig::progress_t& progress); +}; + +class Saver : public LoaderSaverBase { public: 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; private: - Glib::Threads::Thread* thread; - void thread_function(); - Glib::Dispatcher finished_dispatcher; - Glib::Dispatcher progress_dispatcher; - Glib::Dispatcher error_dispatcher; - Glib::Threads::Mutex progressMutex; - float progress; + void thread_function_sub(gig::progress_t& progress); }; class MainWindow : public ManagedWindow { @@ -230,8 +267,44 @@ virtual Settings::Property* windowSettingHeight() { return &Settings::singleton()->mainWindowH; } protected: +#if USE_GTKMM_BUILDER + Glib::RefPtr m_actionGroup; + Glib::RefPtr m_uiManager; +#else Glib::RefPtr actionGroup; Glib::RefPtr uiManager; +#endif + +#if USE_GLIB_ACTION + Glib::RefPtr m_actionMIDIRules; + + Glib::RefPtr m_actionCopyDimRgn; + Glib::RefPtr m_actionPasteDimRgn; + Glib::RefPtr m_actionAdjustClipboard; + + Glib::RefPtr m_actionSampleProperties; + Glib::RefPtr m_actionAddSample; + Glib::RefPtr m_actionRemoveSample; + Glib::RefPtr m_actionViewSampleRefs; + Glib::RefPtr m_actionReplaceSample; + Glib::RefPtr m_actionAddSampleGroup; + + Glib::RefPtr m_actionAddScriptGroup; + Glib::RefPtr m_actionAddScript; + Glib::RefPtr m_actionEditScript; + Glib::RefPtr m_actionRemoveScript; + + Glib::RefPtr m_actionToggleCopySampleUnity; + Glib::RefPtr m_actionToggleCopySampleTune; + Glib::RefPtr m_actionToggleCopySampleLoop; + Glib::RefPtr m_actionToggleStatusBar; + Glib::RefPtr m_actionToggleRestoreWinDim; + Glib::RefPtr m_actionToggleSaveWithTempFile; + Glib::RefPtr m_actionToggleWarnOnExtensions; + Glib::RefPtr m_actionToggleShowTooltips; + Glib::RefPtr m_actionToggleSyncSamplerSelection; + Glib::RefPtr m_actionToggleMoveRootNoteWithRegion; +#endif Gtk::Statusbar m_StatusBar; Gtk::Label m_AttachedStateLabel; @@ -240,7 +313,7 @@ RegionChooser m_RegionChooser; DimRegionChooser m_DimRegionChooser; - PropDialog propDialog; + FilePropDialog fileProps; InstrumentProps instrumentProps; MidiRules midiRules; @@ -273,7 +346,9 @@ sigc::signal switch_sampler_instrument_signal; +#if !USE_GTKMM_BUILDER void on_instrument_selection_change(Gtk::RadioMenuItem* item); +#endif void on_sel_change(); void region_changed(); void dimreg_changed(); @@ -306,23 +381,31 @@ add(m_col_name); add(m_col_instr); add(m_col_scripts); + add(m_col_tooltip); } Gtk::TreeModelColumn m_col_nr; Gtk::TreeModelColumn m_col_name; Gtk::TreeModelColumn m_col_instr; Gtk::TreeModelColumn m_col_scripts; + Gtk::TreeModelColumn m_col_tooltip; } m_Columns; - Gtk::VBox m_VBox; + VBox m_VBox; Gtk::HPaned m_HPaned; Gtk::ScrolledWindow m_ScrolledWindow; Gtk::TreeView m_TreeView; Glib::RefPtr m_refTreeModel; + Glib::RefPtr 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. - Gtk::Menu* instrument_menu; +#if USE_GTKMM_BUILDER + Gtk::Menu* menuMacro; +#else + Gtk::Menu* instrument_menu; // kept for GTKMM 2 version only, will be completely removed in future +#endif + Gtk::Menu* assign_scripts_menu; std::map sample_ref_count; @@ -382,14 +465,14 @@ Gtk::TreeView m_TreeViewScripts; Glib::RefPtr m_refScriptsTreeModel; - Gtk::VBox dimreg_vbox; - Gtk::HBox dimreg_hbox; + VBox dimreg_vbox; + HBox dimreg_hbox; Gtk::Label dimreg_label; Gtk::CheckButton dimreg_all_regions; Gtk::CheckButton dimreg_all_dimregs; Gtk::CheckButton dimreg_stereo; - Gtk::HBox legend_hbox; + HBox legend_hbox; Gtk::Label labelLegend; Gtk::Image imageNoSample; Gtk::Label labelNoSample; @@ -401,7 +484,11 @@ Gtk::Label labelSomeLoops; DimRegionEdit dimreg_edit; + VBox m_left_vbox; Gtk::Notebook m_TreeViewNotebook; + HBox m_searchField; + Gtk::Label m_searchLabel; + Gtk::Entry m_searchText; struct SampleImportItem { gig::Sample* gig_sample; // pointer to the gig::Sample to @@ -428,12 +515,20 @@ void on_save_with_temporary_file(); void on_action_refresh_all(); void on_action_warn_user_on_extensions(); + void on_action_show_tooltips(); + void on_show_tooltips_changed(); void on_action_sync_sampler_instrument_selection(); void on_action_move_root_note_with_region_moved(); void on_action_help_about(); + void on_notebook_tab_switched(void* page, guint page_num); + // sample right-click popup actions +#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 + bool on_sample_treeview_button_release(Gdk::EventButton& button); +#else void on_sample_treeview_button_release(GdkEventButton* button); +#endif void on_action_sample_properties(); void on_action_add_group(); void on_action_add_sample(); @@ -443,7 +538,11 @@ void on_action_remove_unused_samples(); // script right-click popup actions +#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 + bool on_script_treeview_button_release(Gdk::EventButton& button); +#else void on_script_treeview_button_release(GdkEventButton* button); +#endif void on_action_add_script_group(); void on_action_add_script(); void on_action_edit_script(); @@ -457,6 +556,10 @@ void show_intruments_tab(); void show_scripts_tab(); + void select_prev_instrument(); + void select_next_instrument(); + void select_instrument_by_dir(int dir); + void select_prev_region(); void select_next_region(); @@ -475,16 +578,23 @@ void adjust_clipboard_content(); void updateClipboardCopyAvailable(); void updateClipboardPasteAvailable(); +#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 + void on_clipboard_owner_change(Gdk::EventOwnerChange& event); +#else void on_clipboard_owner_change(GdkEventOwnerChange* event); +#endif void on_clipboard_get(Gtk::SelectionData& selection_data, guint info); void on_clipboard_clear(); void on_clipboard_received(const Gtk::SelectionData& selection_data); void on_clipboard_received_targets(const std::vector& targets); void add_instrument(gig::Instrument* instrument); +#if !USE_GTKMM_BUILDER Gtk::RadioMenuItem* add_instrument_to_menu(const Glib::ustring& name, int position = -1); void remove_instrument_from_menu(int index); +#endif + bool onQueryTreeViewTooltip(int x, int y, bool keyboardTip, const Glib::RefPtr& tooltip); ProgressDialog* progress_dialog; Loader* loader; @@ -506,7 +616,11 @@ bool file_save_as(); bool check_if_savable(); +#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 + bool on_button_release(Gdk::EventButton& button); +#else void on_button_release(GdkEventButton* button); +#endif void on_instruments_treeview_drag_begin(const Glib::RefPtr& context); void on_instruments_treeview_drag_data_get(const Glib::RefPtr&, Gtk::SelectionData& selection_data, guint, guint); @@ -533,6 +647,7 @@ void instrument_name_changed(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter); void instr_name_changed_by_instr_props(Gtk::TreeModel::iterator& it); + bool instrument_row_visible(const Gtk::TreeModel::const_iterator& iter); sigc::connection instrument_name_connection; void on_action_combine_instruments(); @@ -549,16 +664,23 @@ void __import_queued_samples(); void __clear(); void __refreshEntireGUI(); + void updateScriptListOfMenu(); + void assignScript(gig::Script* pScript); + void dropAllScriptSlots(); bool close_confirmation_dialog(); bool leaving_shared_mode_dialog(); Gtk::Menu* popup_menu; +#if USE_GTKMM_BUILDER + Gtk::Menu* sample_popup; + Gtk::Menu* script_popup; +#endif bool on_delete_event(GdkEventAny* event); bool first_call_to_drag_data_get; - + bool is_copy_samples_unity_note_enabled() const; bool is_copy_samples_fine_tune_enabled() const; bool is_copy_samples_loop_enabled() const;