diff --git a/meson.build b/meson.build index 7be6e1a..c5dd71a 100755 --- a/meson.build +++ b/meson.build @@ -21,12 +21,25 @@ project('SampleHive', 'cpp', version : 'v0.9.0_alpha.1', license : 'GPL v3', + meson_version: '>= 0.58.0', default_options : ['warning_level=1', 'cpp_std=c++11']) meson_src_root = meson.current_source_dir() meson_build_root = meson.current_build_dir() +# Create configuration data +config_data = configuration_data() + +# Save project information +project_name = meson.project_name() +project_license = meson.project_license() +project_version = meson.project_version() + +config_data.set_quoted('NAME', project_name) +config_data.set_quoted('LICENSE', project_license) +config_data.set_quoted('VERSION', project_version) + # Save important directories prefix = get_option('prefix') bindir = prefix / get_option('bindir') @@ -34,8 +47,6 @@ libdir = prefix / get_option('libdir') datadir = prefix / get_option('datadir') samplehive_datadir = datadir / 'SampleHive' -# Create configuration data -config_data = configuration_data() config_data.set_quoted('PREFIX', prefix) config_data.set_quoted('BINDIR', bindir) config_data.set_quoted('LIBDIR', libdir) @@ -76,6 +87,28 @@ taglib_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON', 'CMAKE_BUILD_TYPE': 'Release', 'CMAKE_CXX_COMPILER': 'g++'}) +yaml_opts = cmake.subproject_options() +yaml_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON', + 'CMAKE_INSTALL_PREFIX': prefix, + 'CMAKE_BUILD_TYPE': 'Release', + 'CMAKE_CXX_COMPILER': 'g++', + 'YAML_BUILD_SHARED_LIBS': 'ON', + 'YAML_CPP_BUILD_TESTS': 'OFF', + 'YAML_CPP_BUILD_CONTRIB': 'ON', + 'YAML_CPP_BUILD_TOOLS': 'ON'}) + +snd_opts = cmake.subproject_options() +snd_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON', + 'CMAKE_INSTALL_PREFIX': prefix, + 'CMAKE_BUILD_TYPE': 'Release', + 'CMAKE_CXX_COMPILER': 'g++', + 'BUILD_SHARED_LIBS': 'ON', + 'BUILD_PROGRAMS': 'OFF', + 'BUILD_EXAMPLES': 'OFF', + 'BUILD_TESTING': 'OFF', + 'ENABLE_EXTERNAL_LIBS': 'ON', + 'ENABLE_MPEG': 'ON'}) + # Source files to be compiled src = [ @@ -128,9 +161,27 @@ else config_data.set('USE_SYSTEM_INCLUDE_PATH', 1) endif -sqlite3 = dependency('sqlite3', required: true) -yaml = dependency('yaml-cpp', required: true) -snd = dependency('sndfile', required: true) +sqlite3 = dependency('sqlite3', version: '>=3.31.1', required: false) + +if not sqlite3.found() + sqlite3_subproject = subproject('sqlite3') + libsqlite3 = sqlite3_subproject.get_variable('libsqlite3') + sqlite3 = declare_dependency(link_with: libsqlite3) +endif + +yaml = dependency('yaml-cpp', version: '>=0.6.2', required: false) + +if not yaml.found() + yaml_subproject = cmake.subproject('yaml-cpp', options: yaml_opts) + yaml = yaml_subproject.dependency('yaml-cpp') +endif + +snd = dependency('sndfile', version: '>=1.0.28', required: false) + +if not snd.found() + snd_subproject = cmake.subproject('libsndfile', options: snd_opts) + snd = snd_subproject.dependency('sndfile') +endif # Create samplehive-config.h based on configuration config_h = configure_file(output: 'SampleHiveConfig.hpp', @@ -138,7 +189,8 @@ config_h = configure_file(output: 'SampleHiveConfig.hpp', install_subdir('assets', install_dir: samplehive_datadir, - exclude_directories: 'screenshots') + exclude_directories: 'screenshots', + strip_directory: true) if wx_found executable('SampleHive', diff --git a/src/App.cpp b/src/App.cpp index 98be309..de21a93 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -26,7 +26,7 @@ #include #include -#define SPLASH_LOGO SAMPLEHIVE_DATADIR "/assets/logo/logo-samplehive_768x432.png" +#define SPLASH_LOGO SAMPLEHIVE_DATADIR "/logo/logo-samplehive_768x432.png" wxIMPLEMENT_APP(App); @@ -79,7 +79,7 @@ bool App::OnCmdLineParsed(wxCmdLineParser& parser) if (parser.Found("version")) { - std::cout << "SampleHive v0.9.0_alpha.1" << std::endl; + std::cout << NAME << ' ' << VERSION << std::endl; return false; } diff --git a/src/App.hpp b/src/App.hpp index 045d61c..a10ce3c 100644 --- a/src/App.hpp +++ b/src/App.hpp @@ -20,11 +20,11 @@ #pragma once +#include "MainFrame.hpp" + #include #include -#include "MainFrame.hpp" - class App : public wxApp { public: diff --git a/src/Database.cpp b/src/Database.cpp index bd0b1bc..726bfc5 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -18,6 +18,8 @@ * along with this program. If not, see . */ +#include "Database.hpp" + #include #include @@ -29,8 +31,6 @@ #include #include -#include "Database.hpp" - Database::Database(wxInfoBar& infoBar) : m_InfoBar(infoBar) { diff --git a/src/Database.hpp b/src/Database.hpp index 59fb834..0736db8 100644 --- a/src/Database.hpp +++ b/src/Database.hpp @@ -18,6 +18,8 @@ * along with this program. If not, see . */ +#include "Sample.hpp" + #include #include #include @@ -31,8 +33,6 @@ #include -#include "Sample.hpp" - class Database { public: diff --git a/src/MainFrame.cpp b/src/MainFrame.cpp index f6f8f9f..292ded2 100644 --- a/src/MainFrame.cpp +++ b/src/MainFrame.cpp @@ -41,9 +41,8 @@ #include // #include #include -#include -#include -#include +#include +#include #include #include #include @@ -68,24 +67,24 @@ #include "SampleHiveConfig.hpp" // Path to all the assets -#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-hive_16x16.png" -#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/assets/icons/icon-hive_24x24.png" -#define ICON_HIVE_32px SAMPLEHIVE_DATADIR "/assets/icons/icon-hive_32x32.png" -#define ICON_HIVE_64px SAMPLEHIVE_DATADIR "/assets/icons/icon-hive_64x64.png" -#define ICON_HIVE_128px SAMPLEHIVE_DATADIR "/assets/icons/icon-hive_128x128.png" -#define ICON_HIVE_256px SAMPLEHIVE_DATADIR "/assets/icons/icon-hive_256x256.png" -#define ICON_STAR_FILLED_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-star_filled_16x16.png" -#define ICON_STAR_EMPTY_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-star_empty_16x16.png" -#define ICON_PLAY_DARK_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-play-dark_16x16.png" -#define ICON_STOP_DARK_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-stop-dark_16x16.png" -#define ICON_AB_DARK_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-ab-dark_16x16.png" -#define ICON_LOOP_DARK_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-loop-dark_16x16.png" -#define ICON_MUTE_DARK_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-mute-dark_16x16.png" -#define ICON_PLAY_LIGHT_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-play-light_16x16.png" -#define ICON_STOP_LIGHT_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-stop-light_16x16.png" -#define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-ab-light_16x16.png" -#define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-loop-light_16x16.png" -#define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/assets/icons/icon-mute-light_16x16.png" +#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png" +#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png" +#define ICON_HIVE_32px SAMPLEHIVE_DATADIR "/icons/icon-hive_32x32.png" +#define ICON_HIVE_64px SAMPLEHIVE_DATADIR "/icons/icon-hive_64x64.png" +#define ICON_HIVE_128px SAMPLEHIVE_DATADIR "/icons/icon-hive_128x128.png" +#define ICON_HIVE_256px SAMPLEHIVE_DATADIR "/icons/icon-hive_256x256.png" +#define ICON_STAR_FILLED_16px SAMPLEHIVE_DATADIR "/icons/icon-star_filled_16x16.png" +#define ICON_STAR_EMPTY_16px SAMPLEHIVE_DATADIR "/icons/icon-star_empty_16x16.png" +#define ICON_PLAY_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-play-dark_16x16.png" +#define ICON_STOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-dark_16x16.png" +#define ICON_AB_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-dark_16x16.png" +#define ICON_LOOP_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-dark_16x16.png" +#define ICON_MUTE_DARK_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-dark_16x16.png" +#define ICON_PLAY_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-play-light_16x16.png" +#define ICON_STOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-stop-light_16x16.png" +#define ICON_AB_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-ab-light_16x16.png" +#define ICON_LOOP_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-loop-light_16x16.png" +#define ICON_MUTE_LIGHT_16px SAMPLEHIVE_DATADIR "/icons/icon-mute-light_16x16.png" #define APP_CONFIG_DIR wxGetHomeDir() + "/.config/SampleHive" #define APP_DATA_DIR wxGetHomeDir() + "/.local/share/SampleHive" #define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml" @@ -200,10 +199,10 @@ MainFrame::MainFrame() m_Notebook = new wxNotebook(m_BottomLeftPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP); // Initializing wxGenericDirCtrl as one of the wxNotebook page. - m_DirCtrl = new wxDirCtrl(m_Notebook, BC_DirCtrl, wxDirDialogDefaultFolderStr, wxDefaultPosition, - wxDefaultSize, wxDIRCTRL_SHOW_FILTERS, - _("All files|*|Ogg files (*.ogg)|*.ogg|Wav files (*.wav)|*.wav|" - "Flac files (*.flac)|*.flac"), 0); + m_DirCtrl = new wxGenericDirCtrl(m_Notebook, BC_DirCtrl, wxDirDialogDefaultFolderStr, wxDefaultPosition, + wxDefaultSize, wxDIRCTRL_SHOW_FILTERS, + _("All files|*|Ogg files (*.ogg)|*.ogg|Wav files (*.wav)|*.wav|" + "Flac files (*.flac)|*.flac"), 0); wxString path = wxGetHomeDir(); m_DirCtrl->SetPath(path); @@ -2641,8 +2640,8 @@ void MainFrame::LoadConfigFile() this->SetMinSize(wxSize(width, height)); this->CenterOnScreen(wxBOTH); this->SetIcon(wxIcon(ICON_HIVE_256px, wxICON_DEFAULT_TYPE, -1, -1)); - this->SetTitle("SampleHive"); - this->SetStatusText("SampleHive v0.9.0_alpha.1", 3); + this->SetTitle(NAME); + this->SetStatusText(wxString::Format("%s %s", NAME, VERSION), 3); this->SetStatusText(_("Stopped"), 1); } @@ -2884,31 +2883,31 @@ void MainFrame::OnSelectAbout(wxCommandEvent& event) { wxAboutDialogInfo aboutInfo; - aboutInfo.SetName("SampleHive"); + aboutInfo.SetName(NAME); aboutInfo.SetIcon(wxIcon(ICON_HIVE_64px)); aboutInfo.AddArtist("Apoorv"); - aboutInfo.SetVersion("v0.9.0_alpha.1", _("Version 0.9.0_alpha.1")); + aboutInfo.SetVersion(VERSION, _("Version 0.9.0_alpha.1")); aboutInfo.SetDescription(_("A simple, modern audio sample browser/manager for GNU/Linux.")); aboutInfo.SetCopyright("(C) 2020-2021"); aboutInfo.SetWebSite("http://samplehive.gitlab.io"); aboutInfo.AddDeveloper("Apoorv"); - aboutInfo.SetLicence(wxString::FromAscii( - "SampleHive v0.9.0_alpha.1\n" + aboutInfo.SetLicence(wxString::Format(wxString::FromAscii( + "%s %s\n" "Copyright (C) 2021 Apoorv Singh\n" "\n" - "SampleHive is free software: you can redistribute it and/or modify\n" + "%s is free software: you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License as published by\n" "the Free Software Foundation, either version 3 of the License, or\n" "(at your option) any later version.\n" "\n" - "SampleHive is distributed in the hope that it will be useful,\n" + "%s is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" "GNU General Public License for more details.\n" "\n" "You should have received a copy of the GNU General Public License\n" "along with this program. If not, see .\n" - )); + ), NAME, VERSION, NAME, NAME)); wxAboutBox(aboutInfo); } diff --git a/src/MainFrame.hpp b/src/MainFrame.hpp index 5e18559..509318a 100644 --- a/src/MainFrame.hpp +++ b/src/MainFrame.hpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -146,7 +145,7 @@ class MainFrame : public wxFrame wxBoxSizer* m_TrashMainSizer; wxBoxSizer* m_TrashItemSizer; wxBoxSizer* m_TrashButtonSizer; - wxDirCtrl* m_DirCtrl; + wxGenericDirCtrl* m_DirCtrl; wxDataViewTreeCtrl* m_Hives; wxDataViewItem favorites_hive; wxTreeItemId trash_root; diff --git a/src/Serialize.cpp b/src/Serialize.cpp index 93568a8..3752fbf 100644 --- a/src/Serialize.cpp +++ b/src/Serialize.cpp @@ -18,6 +18,8 @@ * along with this program. If not, see . */ +#include "Serialize.hpp" + #include #include @@ -29,8 +31,6 @@ #include #include -#include "Serialize.hpp" - Serializer::Serializer(const std::string& filepath) : m_Filepath(filepath) { diff --git a/src/SettingsDialog.cpp b/src/SettingsDialog.cpp index c8a7f0e..a182e03 100644 --- a/src/SettingsDialog.cpp +++ b/src/SettingsDialog.cpp @@ -18,16 +18,15 @@ * along with this program. If not, see . */ -#include -#include -#include -// #include -#include - #include "ControlID_Enums.hpp" #include "SettingsDialog.hpp" #include "Serialize.hpp" +#include +#include +#include +#include + Settings::Settings(const std::string& configFilepath, const std::string& databaseFilepath) : m_ConfigFilepath(configFilepath), m_DatabaseFilepath(databaseFilepath) { diff --git a/src/TagEditorDialog.cpp b/src/TagEditorDialog.cpp index 6641a98..8145e1f 100644 --- a/src/TagEditorDialog.cpp +++ b/src/TagEditorDialog.cpp @@ -18,6 +18,10 @@ * along with this program. If not, see . */ +#include "ControlID_Enums.hpp" +#include "Database.hpp" +#include "TagEditorDialog.hpp" + #include #include #include @@ -25,10 +29,6 @@ #include #include -#include "ControlID_Enums.hpp" -#include "Database.hpp" -#include "TagEditorDialog.hpp" - TagEditor::TagEditor(wxWindow* window, const std::string& dbPath, const std::string& filename, wxInfoBar& info_bar) : wxDialog(window, wxID_ANY, "Edit tags", wxDefaultPosition, wxSize(640, 360), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP), diff --git a/src/TagEditorDialog.hpp b/src/TagEditorDialog.hpp index 2c25aa1..a20c139 100644 --- a/src/TagEditorDialog.hpp +++ b/src/TagEditorDialog.hpp @@ -20,6 +20,8 @@ #pragma once +#include "Tags.hpp" + #include #include @@ -34,8 +36,6 @@ #include #include -#include "Tags.hpp" - class TagEditor : public wxDialog { public: diff --git a/src/WaveformViewer.cpp b/src/WaveformViewer.cpp index f50342f..d69ed10 100644 --- a/src/WaveformViewer.cpp +++ b/src/WaveformViewer.cpp @@ -18,6 +18,13 @@ * along with this program. If not, see . */ +#include "WaveformViewer.hpp" +#include "Database.hpp" +#include "SettingsDialog.hpp" +#include "Serialize.hpp" +#include "Tags.hpp" +#include "SH_Event.hpp" + #include #include @@ -31,13 +38,6 @@ #include -#include "WaveformViewer.hpp" -#include "Database.hpp" -#include "SettingsDialog.hpp" -#include "Serialize.hpp" -#include "Tags.hpp" -#include "SH_Event.hpp" - WaveformViewer::WaveformViewer(wxWindow* parentFrame, wxWindow* window, wxDataViewListCtrl& library, wxMediaCtrl& mediaCtrl, wxInfoBar& infoBar, const std::string& configFilepath, const std::string& databaseFilepath) diff --git a/subprojects/libsndfile.wrap b/subprojects/libsndfile.wrap new file mode 100644 index 0000000..5f0f64d --- /dev/null +++ b/subprojects/libsndfile.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/libsndfile/libsndfile.git +revision = master diff --git a/subprojects/sqlite3.wrap b/subprojects/sqlite3.wrap new file mode 100644 index 0000000..5588580 --- /dev/null +++ b/subprojects/sqlite3.wrap @@ -0,0 +1,12 @@ +[wrap-file] +directory = sqlite-amalgamation-3340100 +source_url = https://www.sqlite.org/2021/sqlite-amalgamation-3340100.zip +source_filename = sqlite-amalgamation-3340100.zip +source_hash = e0b1c0345fe4338b936e17da8e1bd88366cd210e576834546977f040c12a8f68 +patch_url = https://wrapdb.mesonbuild.com/v2/sqlite3_3.34.1-1/get_patch +patch_filename = sqlite3-3.34.1-1-wrap.zip +patch_hash = cba9e47bdb4c02f88fadaae8deab357218d32562c6b86ce7ba0c72f107044360 + +[provide] +sqlite3 = sqlite3_dep + diff --git a/subprojects/yaml-cpp.wrap b/subprojects/yaml-cpp.wrap new file mode 100644 index 0000000..99eb5b4 --- /dev/null +++ b/subprojects/yaml-cpp.wrap @@ -0,0 +1,3 @@ +[wrap-git] +url = https://github.com/jbeder/yaml-cpp.git +revision = master