Merge branch 'experimental-encapsulation' into testing
This commit is contained in:
commit
c9d3ab8295
|
|
@ -1,6 +1,35 @@
|
||||||
|
;;; Directory Local Variables
|
||||||
|
;;; For more information see (info "(emacs) Directory Variables")
|
||||||
|
|
||||||
|
;; (concat (cdr (project-current))
|
||||||
|
|
||||||
((nil . ((cmake-ide-project-dir . "~/repos/sample-hive")
|
((nil . ((cmake-ide-project-dir . "~/repos/sample-hive")
|
||||||
(cmake-ide-build-dir . "~/repos/sample-hive/build")
|
(cmake-ide-build-dir . "~/repos/sample-hive/build")
|
||||||
(cmake-ide-cmake-opts . "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DPORTABLE=1 -DCMAKE_CXX_COMPILER='/usr/bin/g++'")
|
(cmake-ide-cmake-opts . "-DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DPORTABLE=1 -DCMAKE_CXX_COMPILER='/usr/bin/g++'")
|
||||||
|
;; (projectile-project-root . "~/repos/sample-hive")
|
||||||
(projectile-project-name . "SampleHive")
|
(projectile-project-name . "SampleHive")
|
||||||
(projectile-project-run-cmd . "~/repos/sample-hive/build/SampleHive")
|
(projectile-project-run-cmd . "~/repos/sample-hive/build/SampleHive")
|
||||||
(projectile-project-test-cmd . "./test.sh"))))
|
;; (projectile-project-run-cmd . "/tmp/SampleHive/bin/SampleHive")
|
||||||
|
(compile-command . "cd .. && ninja -C build install")
|
||||||
|
(fill-column . 110)
|
||||||
|
;; Setup dap debugging template for the project
|
||||||
|
(setq dap-debug-template-configurations
|
||||||
|
'(("SampleHive::Core::Debug"
|
||||||
|
:type "gdb"
|
||||||
|
:request "launch"
|
||||||
|
:name "SampleHive::Core::Debug"
|
||||||
|
:target "${workspaceFolder}/build/SampleHive"
|
||||||
|
;; :target "/tmp/SampleHive/bin/SampleHive"
|
||||||
|
:cwd "${workspaceFolder}"
|
||||||
|
:symbolLoadInfo "loadAll"
|
||||||
|
:additionalSOLibSearchPath "/tmp/SampleHive/bin/"))))))
|
||||||
|
|
||||||
|
;; ((c++-mode . ((dap-debug-template-configurations . '(("SampleHive::Core::Debug"
|
||||||
|
;; :type "gdb"
|
||||||
|
;; :request "launch"
|
||||||
|
;; :name "SampleHive::Core::Debug"
|
||||||
|
;; :target "${workspaceFolder}/build/SampleHive"
|
||||||
|
;; ;; :target "/tmp/SampleHive/bin/SampleHive"
|
||||||
|
;; :cwd "${workspaceFolder}"
|
||||||
|
;; :symbolLoadInfo "loadAll"
|
||||||
|
;; :additionalSOLibSearchPath "/tmp/SampleHive/bin/"))))))
|
||||||
|
|
|
||||||
80
meson.build
80
meson.build
|
|
@ -80,6 +80,15 @@ config_data.set_quoted('SAMPLEHIVE_DATADIR', samplehive_datadir)
|
||||||
# Import CMake
|
# Import CMake
|
||||||
cmake = import('cmake')
|
cmake = import('cmake')
|
||||||
|
|
||||||
|
# Check which platform the build is for and set the appropriate GUI toolkit
|
||||||
|
wx_toolkit = ''
|
||||||
|
|
||||||
|
if host_sys == 'linux'
|
||||||
|
wx_toolkit = 'gtk3'
|
||||||
|
elif host_sys == 'windows'
|
||||||
|
wx_toolkit = 'msw'
|
||||||
|
endif
|
||||||
|
|
||||||
wx_opts = cmake.subproject_options()
|
wx_opts = cmake.subproject_options()
|
||||||
wx_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
wx_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
||||||
'CMAKE_INSTALL_PREFIX': prefix,
|
'CMAKE_INSTALL_PREFIX': prefix,
|
||||||
|
|
@ -93,7 +102,7 @@ wx_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
|
||||||
'wxBUILD_SAMPLES': 'OFF',
|
'wxBUILD_SAMPLES': 'OFF',
|
||||||
'wxBUILD_DEMOS': 'OFF',
|
'wxBUILD_DEMOS': 'OFF',
|
||||||
'wxBUILD_COMPATIBILITY': '3.0',
|
'wxBUILD_COMPATIBILITY': '3.0',
|
||||||
'wxBUILD_TOOLKIT': 'gtk3',
|
'wxBUILD_TOOLKIT': wx_toolkit,
|
||||||
'wxUSE_UNICODE': 'ON',
|
'wxUSE_UNICODE': 'ON',
|
||||||
'wxUSE_AUI': 'OFF',
|
'wxUSE_AUI': 'OFF',
|
||||||
'wxUSE_XML': 'OFF',
|
'wxUSE_XML': 'OFF',
|
||||||
|
|
@ -144,7 +153,16 @@ src = [
|
||||||
'src/App.cpp',
|
'src/App.cpp',
|
||||||
|
|
||||||
'src/GUI/MainFrame.cpp',
|
'src/GUI/MainFrame.cpp',
|
||||||
|
'src/GUI/TransportControls.cpp',
|
||||||
'src/GUI/WaveformViewer.cpp',
|
'src/GUI/WaveformViewer.cpp',
|
||||||
|
'src/GUI/Notebook.cpp',
|
||||||
|
'src/GUI/DirectoryBrowser.cpp',
|
||||||
|
'src/GUI/Hives.cpp',
|
||||||
|
'src/GUI/Trash.cpp',
|
||||||
|
'src/GUI/ListCtrl.cpp',
|
||||||
|
'src/GUI/SearchBar.cpp',
|
||||||
|
'src/GUI/InfoBar.cpp',
|
||||||
|
'src/GUI/Library.cpp',
|
||||||
|
|
||||||
'src/GUI/Dialogs/Settings.cpp',
|
'src/GUI/Dialogs/Settings.cpp',
|
||||||
'src/GUI/Dialogs/TagEditor.cpp',
|
'src/GUI/Dialogs/TagEditor.cpp',
|
||||||
|
|
@ -154,8 +172,10 @@ src = [
|
||||||
'src/Utility/Sample.cpp',
|
'src/Utility/Sample.cpp',
|
||||||
'src/Utility/Serialize.cpp',
|
'src/Utility/Serialize.cpp',
|
||||||
'src/Utility/Tags.cpp',
|
'src/Utility/Tags.cpp',
|
||||||
'src/Utility/SH_Event.cpp',
|
'src/Utility/Event.cpp',
|
||||||
|
'src/Utility/Signal.cpp',
|
||||||
'src/Utility/Log.cpp',
|
'src/Utility/Log.cpp',
|
||||||
|
'src/Utility/Utils.cpp',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -164,23 +184,18 @@ include_dirs = include_directories('src')
|
||||||
# Dependencies
|
# Dependencies
|
||||||
wx = dependency('wxwidgets', version: '>=3.1.5', required: false)
|
wx = dependency('wxwidgets', version: '>=3.1.5', required: false)
|
||||||
|
|
||||||
wx_found = false
|
wx_cxx_flags = []
|
||||||
|
wx_libs = []
|
||||||
|
|
||||||
if not wx.found()
|
if not wx.found()
|
||||||
wx_found = false
|
|
||||||
|
|
||||||
wx_subproject = cmake.subproject('wxwidgets', options: wx_opts)
|
wx_subproject = cmake.subproject('wxwidgets', options: wx_opts)
|
||||||
wx_base = wx_subproject.dependency('wxbase')
|
wx_base = wx_subproject.dependency('wxbase')
|
||||||
wx_core = wx_subproject.dependency('wxcore')
|
wx_core = wx_subproject.dependency('wxcore')
|
||||||
wx_media = wx_subproject.dependency('wxmedia')
|
wx_media = wx_subproject.dependency('wxmedia')
|
||||||
wx = [wx_core, wx_base, wx_media]
|
wx = [wx_core, wx_base, wx_media]
|
||||||
else
|
else
|
||||||
wx_found = true
|
wxconfig = find_program(['wx-config', 'wx-config-gtk3'])
|
||||||
|
|
||||||
wxconfig = find_program(['wx-config-gtk3', 'wx-config'])
|
|
||||||
wx_modules = ['media', 'std']
|
wx_modules = ['media', 'std']
|
||||||
wx_cxx_flags = []
|
|
||||||
wx_libs = []
|
|
||||||
|
|
||||||
foreach module : wx_modules
|
foreach module : wx_modules
|
||||||
wx_cxx_flags += run_command(wxconfig, '--cxxflags', module).stdout().strip().split()
|
wx_cxx_flags += run_command(wxconfig, '--cxxflags', module).stdout().strip().split()
|
||||||
|
|
@ -212,50 +227,37 @@ if not yaml.found()
|
||||||
yaml = yaml_subproject.dependency('yaml-cpp')
|
yaml = yaml_subproject.dependency('yaml-cpp')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
snd = dependency('sndfile', version: '>=1.0.28', required: false)
|
snd_subproject = cmake.subproject('libsndfile', options: snd_opts)
|
||||||
|
snd = snd_subproject.dependency('sndfile')
|
||||||
if not snd.found()
|
|
||||||
snd_subproject = cmake.subproject('libsndfile', options: snd_opts)
|
|
||||||
snd = snd_subproject.dependency('sndfile')
|
|
||||||
endif
|
|
||||||
|
|
||||||
spdlog = dependency('spdlog', version: '>=1.8.5', required: false)
|
spdlog = dependency('spdlog', version: '>=1.8.5', required: false)
|
||||||
|
|
||||||
if not spdlog.found()
|
if not spdlog.found()
|
||||||
spdlog_subproject = subproject('spdlog',
|
spdlog_subproject = subproject('spdlog',
|
||||||
default_options: [
|
default_options: [
|
||||||
'default_library=static',
|
'default_library=static',
|
||||||
'compile_library=true',])
|
'compile_library=true',])
|
||||||
|
|
||||||
spdlog = spdlog_subproject.get_variable('spdlog_dep')
|
spdlog = spdlog_subproject.get_variable('spdlog_dep')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Create samplehive-config.h based on configuration
|
# Create SampleHiveConfig.hpp based on configuration
|
||||||
config_h = configure_file(output: 'SampleHiveConfig.hpp',
|
config = configure_file(output: 'SampleHiveConfig.hpp',
|
||||||
configuration: config_data,)
|
configuration: config_data,)
|
||||||
|
|
||||||
install_subdir('assets',
|
install_subdir('assets',
|
||||||
install_dir: samplehive_datadir,
|
install_dir: samplehive_datadir,
|
||||||
exclude_directories: 'screenshots',
|
exclude_directories: 'screenshots',
|
||||||
strip_directory: true)
|
strip_directory: true)
|
||||||
|
|
||||||
if wx_found
|
executable('SampleHive',
|
||||||
executable('SampleHive',
|
sources: src,
|
||||||
sources: src,
|
cpp_args: [wx_cxx_flags],
|
||||||
cpp_args: [wx_cxx_flags],
|
link_args: [wx_libs],
|
||||||
link_args: [wx_libs],
|
include_directories : include_dirs,
|
||||||
include_directories : include_dirs,
|
dependencies: [wx, taglib, sqlite3, yaml, snd, spdlog],
|
||||||
dependencies: [wx, taglib, sqlite3, yaml, snd, spdlog],
|
install: true,
|
||||||
install: true,
|
install_rpath: prefix / 'lib')
|
||||||
install_rpath: prefix / 'lib')
|
|
||||||
else
|
|
||||||
executable('SampleHive',
|
|
||||||
sources: src,
|
|
||||||
include_directories : include_dirs,
|
|
||||||
dependencies: [wx, taglib, sqlite3, yaml, snd, spdlog],
|
|
||||||
install: true,
|
|
||||||
install_rpath: prefix / 'lib')
|
|
||||||
endif
|
|
||||||
|
|
||||||
summary(
|
summary(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
18
src/App.cpp
18
src/App.cpp
|
|
@ -29,20 +29,20 @@
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
#include <wx/splash.h>
|
#include <wx/splash.h>
|
||||||
|
|
||||||
wxIMPLEMENT_APP(App);
|
wxIMPLEMENT_APP(cApp);
|
||||||
|
|
||||||
App::App()
|
cApp::cApp()
|
||||||
{
|
{
|
||||||
// Initialize the logger
|
// Initialize the logger
|
||||||
SampleHive::Log::InitLogger("SampleHive");
|
SampleHive::cLog::InitLogger("SampleHive");
|
||||||
}
|
}
|
||||||
|
|
||||||
App::~App()
|
cApp::~cApp()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::OnInit()
|
bool cApp::OnInit()
|
||||||
{
|
{
|
||||||
if (!wxApp::OnInit())
|
if (!wxApp::OnInit())
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -50,7 +50,7 @@ bool App::OnInit()
|
||||||
wxLog::AddTraceMask("EventSource");
|
wxLog::AddTraceMask("EventSource");
|
||||||
wxLog::AddTraceMask(wxTRACE_FSWATCHER);
|
wxLog::AddTraceMask(wxTRACE_FSWATCHER);
|
||||||
|
|
||||||
m_Frame = new MainFrame();
|
m_Frame = new cMainFrame();
|
||||||
|
|
||||||
wxBitmap bitmap;
|
wxBitmap bitmap;
|
||||||
wxSplashScreen* splash;
|
wxSplashScreen* splash;
|
||||||
|
|
@ -69,7 +69,7 @@ bool App::OnInit()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnInitCmdLine(wxCmdLineParser& parser)
|
void cApp::OnInitCmdLine(wxCmdLineParser& parser)
|
||||||
{
|
{
|
||||||
wxApp::OnInitCmdLine(parser);
|
wxApp::OnInitCmdLine(parser);
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ void App::OnInitCmdLine(wxCmdLineParser& parser)
|
||||||
parser.Parse(true);
|
parser.Parse(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::OnCmdLineParsed(wxCmdLineParser& parser)
|
bool cApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||||
{
|
{
|
||||||
if (!wxApp::OnCmdLineParsed(parser))
|
if (!wxApp::OnCmdLineParsed(parser))
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -142,7 +142,7 @@ bool App::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnEventLoopEnter(wxEventLoopBase* event)
|
void cApp::OnEventLoopEnter(wxEventLoopBase* event)
|
||||||
{
|
{
|
||||||
if (m_Frame->CreateWatcherIfNecessary())
|
if (m_Frame->CreateWatcherIfNecessary())
|
||||||
SH_LOG_INFO("Filesystem watcher created sucessfully");
|
SH_LOG_INFO("Filesystem watcher created sucessfully");
|
||||||
|
|
|
||||||
12
src/App.hpp
12
src/App.hpp
|
|
@ -25,18 +25,18 @@
|
||||||
#include <wx/app.h>
|
#include <wx/app.h>
|
||||||
#include <wx/cmdline.h>
|
#include <wx/cmdline.h>
|
||||||
|
|
||||||
class App : public wxApp
|
class cApp : public wxApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
App();
|
cApp();
|
||||||
~App();
|
~cApp();
|
||||||
|
|
||||||
private:
|
|
||||||
MainFrame* m_Frame = nullptr;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
virtual void OnEventLoopEnter(wxEventLoopBase* event);
|
virtual void OnEventLoopEnter(wxEventLoopBase* event);
|
||||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||||
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||||
|
|
||||||
|
private:
|
||||||
|
cMainFrame* m_Frame = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
#include <wx/dataview.h>
|
#include <wx/dataview.h>
|
||||||
#include <wx/dvrenderers.h>
|
#include <wx/dvrenderers.h>
|
||||||
#include <wx/msgdlg.h>
|
#include <wx/msgdlg.h>
|
||||||
|
|
@ -49,11 +50,10 @@ void debug_log_on_error(int rc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_modal_dialog_and_log(const std::string &message, const std::string &title,
|
void show_modal_dialog_and_log(const std::string &message, const std::string &title, const std::string &error_msg)
|
||||||
const std::string &error_msg)
|
|
||||||
{
|
{
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << message << error_msg;
|
ss << message << " : " << error_msg;
|
||||||
|
|
||||||
const auto msg = ss.str();
|
const auto msg = ss.str();
|
||||||
|
|
||||||
|
|
@ -78,17 +78,17 @@ class Sqlite3Statement
|
||||||
sqlite3_stmt* stmt = nullptr;
|
sqlite3_stmt* stmt = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
Database::Database()
|
cDatabase::cDatabase()
|
||||||
{
|
{
|
||||||
OpenDatabase();
|
OpenDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
Database::~Database()
|
cDatabase::~cDatabase()
|
||||||
{
|
{
|
||||||
CloseDatabase();
|
CloseDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::CreateTableSamples()
|
void cDatabase::CreateTableSamples()
|
||||||
{
|
{
|
||||||
/* Create SQL statement */
|
/* Create SQL statement */
|
||||||
const auto samples = "CREATE TABLE IF NOT EXISTS SAMPLES("
|
const auto samples = "CREATE TABLE IF NOT EXISTS SAMPLES("
|
||||||
|
|
@ -107,7 +107,7 @@ void Database::CreateTableSamples()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_exec(m_Database, samples, NULL, 0, &m_ErrMsg));
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, samples, NULL, 0, &m_pErrMsg));
|
||||||
SH_LOG_INFO("SAMPLES table created successfully.");
|
SH_LOG_INFO("SAMPLES table created successfully.");
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
|
|
@ -116,14 +116,14 @@ void Database::CreateTableSamples()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::CreateTableHives()
|
void cDatabase::CreateTableHives()
|
||||||
{
|
{
|
||||||
/* Create SQL statement */
|
/* Create SQL statement */
|
||||||
const auto hives = "CREATE TABLE IF NOT EXISTS HIVES(HIVE TEXT NOT NULL);";
|
const auto hives = "CREATE TABLE IF NOT EXISTS HIVES(HIVE TEXT NOT NULL);";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_exec(m_Database, hives, NULL, 0, &m_ErrMsg));
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, hives, NULL, 0, &m_pErrMsg));
|
||||||
SH_LOG_INFO("HIVES table created successfully.");
|
SH_LOG_INFO("HIVES table created successfully.");
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
|
|
@ -133,7 +133,7 @@ void Database::CreateTableHives()
|
||||||
}
|
}
|
||||||
|
|
||||||
//Loops through a Sample array and adds them to the database
|
//Loops through a Sample array and adds them to the database
|
||||||
void Database::InsertIntoSamples(const std::vector<Sample> &samples)
|
void cDatabase::InsertIntoSamples(const std::vector<Sample> &samples)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -142,9 +142,9 @@ void Database::InsertIntoSamples(const std::vector<Sample> &samples)
|
||||||
SAMPLERATE, BITRATE, PATH, TRASHED, HIVE) \
|
SAMPLERATE, BITRATE, PATH, TRASHED, HIVE) \
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_exec(m_Database, "BEGIN TRANSACTION", NULL, NULL, &m_ErrMsg));
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, "BEGIN TRANSACTION", NULL, NULL, &m_pErrMsg));
|
||||||
|
|
||||||
Sample sample;
|
Sample sample;
|
||||||
|
|
||||||
|
|
@ -167,30 +167,25 @@ void Database::InsertIntoSamples(const std::vector<Sample> &samples)
|
||||||
std::string hive = "Favorites";
|
std::string hive = "Favorites";
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite()));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite()));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 3, file_extension.c_str(), file_extension.size(), SQLITE_STATIC));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 3, file_extension.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 4, sample_pack.c_str(), sample_pack.size(), SQLITE_STATIC));
|
||||||
file_extension.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 5, type.c_str(), type.size(), SQLITE_STATIC));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 4, sample_pack.c_str(),
|
|
||||||
sample_pack.size(), SQLITE_STATIC));
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 5, type.c_str(),
|
|
||||||
type.size(), SQLITE_STATIC));
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 6, sample.GetChannels()));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 6, sample.GetChannels()));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 7, sample.GetLength()));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 7, sample.GetLength()));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 8, sample.GetSampleRate()));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 8, sample.GetSampleRate()));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 9, sample.GetBitrate()));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 9, sample.GetBitrate()));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 10, path.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 10, path.c_str(), path.size(), SQLITE_STATIC));
|
||||||
path.size(), SQLITE_STATIC));
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 11, sample.GetTrashed()));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 11, sample.GetTrashed()));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 12, hive.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 12, hive.c_str(), hive.size(), SQLITE_STATIC));
|
||||||
hive.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
sqlite3_step(statement.stmt);
|
sqlite3_step(statement.stmt);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_clear_bindings(statement.stmt));
|
throw_on_sqlite3_error(sqlite3_clear_bindings(statement.stmt));
|
||||||
throw_on_sqlite3_error(sqlite3_reset(statement.stmt));
|
throw_on_sqlite3_error(sqlite3_reset(statement.stmt));
|
||||||
}
|
}
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_exec(m_Database, "END TRANSACTION", NULL, NULL, &m_ErrMsg));
|
throw_on_sqlite3_error(sqlite3_exec(m_pDatabase, "END TRANSACTION", NULL, NULL, &m_pErrMsg));
|
||||||
|
|
||||||
SH_LOG_INFO("Data inserted successfully into SAMPLES.");
|
SH_LOG_INFO("Data inserted successfully into SAMPLES.");
|
||||||
}
|
}
|
||||||
|
|
@ -200,67 +195,36 @@ void Database::InsertIntoSamples(const std::vector<Sample> &samples)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::InsertIntoHives(const std::string &hiveName)
|
void cDatabase::InsertIntoHives(const std::string &hiveName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "INSERT INTO HIVES(HIVE) VALUES(?);";
|
const auto sql = "INSERT INTO HIVES(HIVE) VALUES(?);";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
// rc = sqlite3_exec(m_Database, "BEGIN TRANSACTION", NULL, NULL, &m_ErrMsg);
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
|
|
||||||
// Sample sample;
|
|
||||||
|
|
||||||
// std::string filename;
|
|
||||||
// std::string file_extension;
|
|
||||||
// std::string sample_pack;
|
|
||||||
// std::string type;
|
|
||||||
// std::string path;
|
|
||||||
|
|
||||||
// for(unsigned int i = 0; i < samples.size(); i++)
|
|
||||||
// {
|
|
||||||
// sample = samples[i];
|
|
||||||
|
|
||||||
// filename = sample.GetFilename();
|
|
||||||
// file_extension = sample.GetFileExtension();
|
|
||||||
// sample_pack = sample.GetSamplePack();
|
|
||||||
// type = sample.GetType();
|
|
||||||
// path = sample.GetPath();
|
|
||||||
|
|
||||||
// std::string hive = "Favourites";
|
|
||||||
|
|
||||||
// rc = sqlite3_bind_int(statement.stmt, 1, sample.GetFavorite());
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
|
|
||||||
hiveName.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_step(statement.stmt));
|
throw_on_sqlite3_error(sqlite3_step(statement.stmt));
|
||||||
// rc = sqlite3_clear_bindings(statement.stmt);
|
|
||||||
// rc = sqlite3_reset(statement.stmt);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// rc = sqlite3_exec(m_Database, "END TRANSACTION", NULL, NULL, &m_ErrMsg);
|
|
||||||
|
|
||||||
SH_LOG_INFO("Data inserted successfully into HIVES.");
|
SH_LOG_INFO("Data inserted successfully into HIVES.");
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
show_modal_dialog_and_log("Error! Cannot insert data into HIVES", "Error", e.what());
|
show_modal_dialog_and_log("Error! Cannot insert data into HIVES", "Error", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateHive(const std::string &hiveOldName, const std::string &hiveNewName)
|
void cDatabase::UpdateHive(const std::string &hiveOldName, const std::string &hiveNewName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE HIVES SET HIVE = ? WHERE HIVE = ?;";
|
const auto sql = "UPDATE HIVES SET HIVE = ? WHERE HIVE = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveNewName.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveNewName.c_str(), hiveNewName.size(), SQLITE_STATIC));
|
||||||
hiveNewName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, hiveOldName.c_str(), hiveOldName.size(), SQLITE_STATIC));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, hiveOldName.c_str(),
|
|
||||||
hiveOldName.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) != SQLITE_DONE)
|
if (sqlite3_step(statement.stmt) != SQLITE_DONE)
|
||||||
{
|
{
|
||||||
|
|
@ -277,18 +241,16 @@ void Database::UpdateHive(const std::string &hiveOldName, const std::string &hiv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateHiveName(const std::string &filename, const std::string &hiveName)
|
void cDatabase::UpdateHiveName(const std::string &filename, const std::string &hiveName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET HIVE = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET HIVE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
hiveName.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
|
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -303,17 +265,16 @@ void Database::UpdateHiveName(const std::string &filename, const std::string &hi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateFavoriteColumn(const std::string &filename, int value)
|
void cDatabase::UpdateFavoriteColumn(const std::string &filename, int value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET FAVORITE = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET FAVORITE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -328,18 +289,16 @@ void Database::UpdateFavoriteColumn(const std::string &filename, int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateSamplePack(const std::string &filename, const std::string &samplePack)
|
void cDatabase::UpdateSamplePack(const std::string &filename, const std::string &samplePack)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET SAMPLEPACK = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET SAMPLEPACK = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, samplePack.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, samplePack.c_str(), samplePack.size(), SQLITE_STATIC));
|
||||||
samplePack.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
|
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -354,17 +313,16 @@ void Database::UpdateSamplePack(const std::string &filename, const std::string &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateSampleType(const std::string &filename, const std::string &type)
|
void cDatabase::UpdateSampleType(const std::string &filename, const std::string &type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET TYPE = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET TYPE = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, type.c_str(), type.size(), SQLITE_STATIC));
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, type.c_str(), type.size(), SQLITE_STATIC));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -379,7 +337,7 @@ void Database::UpdateSampleType(const std::string &filename, const std::string &
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Database::GetSampleType(const std::string &filename)
|
std::string cDatabase::GetSampleType(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string type;
|
std::string type;
|
||||||
|
|
||||||
|
|
@ -387,16 +345,15 @@ std::string Database::GetSampleType(const std::string &filename)
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT TYPE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT TYPE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Record found, fetching sample type for {}", filename);
|
SH_LOG_INFO("Record found, fetching sample type for {}", filename);
|
||||||
|
|
||||||
type = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
|
type = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_LOG_INFO("Selected sample type from table successfully.");
|
SH_LOG_INFO("Selected sample type from table successfully.");
|
||||||
|
|
@ -409,7 +366,7 @@ std::string Database::GetSampleType(const std::string &filename)
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Database::GetFavoriteColumnValueByFilename(const std::string &filename)
|
int cDatabase::GetFavoriteColumnValueByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
|
|
@ -417,10 +374,9 @@ int Database::GetFavoriteColumnValueByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT FAVORITE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT FAVORITE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -438,7 +394,7 @@ int Database::GetFavoriteColumnValueByFilename(const std::string &filename)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Database::GetHiveByFilename(const std::string &filename)
|
std::string cDatabase::GetHiveByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string hive;
|
std::string hive;
|
||||||
|
|
||||||
|
|
@ -446,14 +402,13 @@ std::string Database::GetHiveByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
hive = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
|
hive = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 0)));
|
||||||
SH_LOG_INFO("Record found, fetching hive for {}", filename);
|
SH_LOG_INFO("Record found, fetching hive for {}", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -467,16 +422,15 @@ std::string Database::GetHiveByFilename(const std::string &filename)
|
||||||
return hive;
|
return hive;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::RemoveSampleFromDatabase(const std::string &filename)
|
void cDatabase::RemoveSampleFromDatabase(const std::string &filename)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "DELETE FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "DELETE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_DONE)
|
if (sqlite3_step(statement.stmt) == SQLITE_DONE)
|
||||||
{
|
{
|
||||||
|
|
@ -491,16 +445,15 @@ void Database::RemoveSampleFromDatabase(const std::string &filename)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::RemoveHiveFromDatabase(const std::string &hiveName)
|
void cDatabase::RemoveHiveFromDatabase(const std::string &hiveName)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "DELETE FROM HIVES WHERE HIVE = ?;";
|
const auto sql = "DELETE FROM HIVES WHERE HIVE = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
hiveName.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_DONE)
|
if (sqlite3_step(statement.stmt) == SQLITE_DONE)
|
||||||
{
|
{
|
||||||
|
|
@ -515,7 +468,7 @@ void Database::RemoveHiveFromDatabase(const std::string &hiveName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Database::GetSamplePathByFilename(const std::string &filename)
|
std::string cDatabase::GetSamplePathByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
||||||
|
|
@ -523,14 +476,13 @@ std::string Database::GetSamplePathByFilename(const std::string &filename)
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT PATH FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT PATH FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
path = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
|
path = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 0)));
|
||||||
SH_LOG_INFO("Record found, fetching sample path for {}", filename);
|
SH_LOG_INFO("Record found, fetching sample path for {}", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -544,7 +496,7 @@ std::string Database::GetSamplePathByFilename(const std::string &filename)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Database::GetSampleFileExtension(const std::string &filename)
|
std::string cDatabase::GetSampleFileExtension(const std::string &filename)
|
||||||
{
|
{
|
||||||
std::string extension;
|
std::string extension;
|
||||||
|
|
||||||
|
|
@ -552,14 +504,13 @@ std::string Database::GetSampleFileExtension(const std::string &filename)
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT EXTENSION FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT EXTENSION FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
extension = std::string(reinterpret_cast<const char *>(sqlite3_column_text(statement.stmt, 0)));
|
extension = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 0)));
|
||||||
SH_LOG_INFO("Record found, fetching file extension for {}", filename);
|
SH_LOG_INFO("Record found, fetching file extension for {}", filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -573,7 +524,7 @@ std::string Database::GetSampleFileExtension(const std::string &filename)
|
||||||
return extension;
|
return extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &favorite_tree,
|
wxVector<wxVector<wxVariant>> cDatabase::LoadSamplesDatabase(wxDataViewTreeCtrl &favorite_tree,
|
||||||
wxDataViewItem &favorite_item,
|
wxDataViewItem &favorite_item,
|
||||||
wxTreeCtrl &trash_tree, wxTreeItemId &trash_item,
|
wxTreeCtrl &trash_tree, wxTreeItemId &trash_item,
|
||||||
bool show_extension,
|
bool show_extension,
|
||||||
|
|
@ -590,7 +541,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
|
||||||
{
|
{
|
||||||
int num_rows = 0;
|
int num_rows = 0;
|
||||||
|
|
||||||
Sqlite3Statement statement1(m_Database, "SELECT Count(*) FROM SAMPLES;");
|
Sqlite3Statement statement1(m_pDatabase, "SELECT Count(*) FROM SAMPLES;");
|
||||||
|
|
||||||
if (SQLITE_ROW == sqlite3_step(statement1.stmt))
|
if (SQLITE_ROW == sqlite3_step(statement1.stmt))
|
||||||
{
|
{
|
||||||
|
|
@ -601,7 +552,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
|
||||||
vecSet.reserve(num_rows);
|
vecSet.reserve(num_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
Sqlite3Statement statement(m_pDatabase, "SELECT FAVORITE, FILENAME, EXTENSION, SAMPLEPACK, \
|
||||||
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
||||||
TRASHED, HIVE FROM SAMPLES;");
|
TRASHED, HIVE FROM SAMPLES;");
|
||||||
|
|
||||||
|
|
@ -610,23 +561,17 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
|
||||||
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
||||||
{
|
{
|
||||||
int favorite = sqlite3_column_int(statement.stmt, 0);
|
int favorite = sqlite3_column_int(statement.stmt, 0);
|
||||||
wxString filename = std::string(reinterpret_cast<const char *>
|
wxString filename = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 1)));
|
||||||
(sqlite3_column_text(statement.stmt, 1)));
|
wxString file_extension = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 2)));
|
||||||
wxString file_extension = std::string(reinterpret_cast<const char *>
|
wxString sample_pack = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 3)));
|
||||||
(sqlite3_column_text(statement.stmt, 2)));
|
wxString sample_type = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 4)));
|
||||||
wxString sample_pack = std::string(reinterpret_cast<const char *>
|
|
||||||
(sqlite3_column_text(statement.stmt, 3)));
|
|
||||||
wxString sample_type = std::string(reinterpret_cast<const char *>
|
|
||||||
(sqlite3_column_text(statement.stmt, 4)));
|
|
||||||
int channels = sqlite3_column_int(statement.stmt, 5);
|
int channels = sqlite3_column_int(statement.stmt, 5);
|
||||||
int length = sqlite3_column_int(statement.stmt, 6);
|
int length = sqlite3_column_int(statement.stmt, 6);
|
||||||
int sample_rate = sqlite3_column_int(statement.stmt, 7);
|
int sample_rate = sqlite3_column_int(statement.stmt, 7);
|
||||||
int bitrate = sqlite3_column_int(statement.stmt, 8);
|
int bitrate = sqlite3_column_int(statement.stmt, 8);
|
||||||
wxString path = std::string(reinterpret_cast<const char *>
|
wxString path = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 9)));
|
||||||
(sqlite3_column_text(statement.stmt, 9)));
|
|
||||||
int trashed = sqlite3_column_int(statement.stmt, 10);
|
int trashed = sqlite3_column_int(statement.stmt, 10);
|
||||||
wxString hive_name = std::string(reinterpret_cast<const char *>
|
wxString hive_name = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 11)));
|
||||||
(sqlite3_column_text(statement.stmt, 11)));
|
|
||||||
|
|
||||||
wxLongLong llLength = length;
|
wxLongLong llLength = length;
|
||||||
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
||||||
|
|
@ -683,8 +628,7 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
|
||||||
if (found_item.IsOk())
|
if (found_item.IsOk())
|
||||||
{
|
{
|
||||||
if (show_extension)
|
if (show_extension)
|
||||||
favorite_tree.AppendItem(found_item,
|
favorite_tree.AppendItem(found_item, wxString::Format("%s.%s", filename, file_extension));
|
||||||
wxString::Format("%s.%s", filename, file_extension));
|
|
||||||
else
|
else
|
||||||
favorite_tree.AppendItem(found_item, filename);
|
favorite_tree.AppendItem(found_item, filename);
|
||||||
}
|
}
|
||||||
|
|
@ -723,9 +667,9 @@ wxVector<wxVector<wxVariant>> Database::LoadSamplesDatabase(wxDataViewTreeCtrl &
|
||||||
return vecSet;
|
return vecSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>cDatabase::FilterDatabaseBySampleName(const std::string &sampleName, bool show_extension,
|
||||||
Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_extension,
|
const std::string &icon_star_filled,
|
||||||
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
const std::string &icon_star_empty)
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> sampleVec;
|
wxVector<wxVector<wxVariant>> sampleVec;
|
||||||
|
|
||||||
|
|
@ -735,12 +679,11 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
Sqlite3Statement statement(m_pDatabase, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
||||||
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
||||||
FROM SAMPLES WHERE FILENAME LIKE '%' || ? || '%' ;");
|
FROM SAMPLES WHERE FILENAME LIKE '%' || ? || '%' ;");
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, sampleName.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, sampleName.c_str(), sampleName.size(), SQLITE_STATIC));
|
||||||
sampleName.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
|
|
@ -749,18 +692,14 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex
|
||||||
SH_LOG_INFO("Record found, filtering db by {}", sampleName);
|
SH_LOG_INFO("Record found, filtering db by {}", sampleName);
|
||||||
|
|
||||||
int favorite = sqlite3_column_int(statement.stmt, 0);
|
int favorite = sqlite3_column_int(statement.stmt, 0);
|
||||||
wxString filename = wxString(std::string(reinterpret_cast<const char *>
|
wxString filename = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 1))));
|
||||||
(sqlite3_column_text(statement.stmt, 1))));
|
wxString sample_pack = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 2))));
|
||||||
wxString sample_pack = wxString(std::string(reinterpret_cast<const char *>
|
wxString sample_type = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 3)));
|
||||||
(sqlite3_column_text(statement.stmt, 2))));
|
|
||||||
wxString sample_type = std::string(reinterpret_cast<const char *>
|
|
||||||
(sqlite3_column_text(statement.stmt, 3)));
|
|
||||||
int channels = sqlite3_column_int(statement.stmt, 4);
|
int channels = sqlite3_column_int(statement.stmt, 4);
|
||||||
int length = sqlite3_column_int(statement.stmt, 5);
|
int length = sqlite3_column_int(statement.stmt, 5);
|
||||||
int sample_rate = sqlite3_column_int(statement.stmt, 6);
|
int sample_rate = sqlite3_column_int(statement.stmt, 6);
|
||||||
int bitrate = sqlite3_column_int(statement.stmt, 7);
|
int bitrate = sqlite3_column_int(statement.stmt, 7);
|
||||||
wxString path = wxString(std::string(reinterpret_cast<const char *>
|
wxString path = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 8))));
|
||||||
(sqlite3_column_text(statement.stmt, 8))));
|
|
||||||
|
|
||||||
wxLongLong llLength = length;
|
wxLongLong llLength = length;
|
||||||
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
||||||
|
|
@ -803,9 +742,9 @@ Database::FilterDatabaseBySampleName(const std::string &sampleName, bool show_ex
|
||||||
return sampleVec;
|
return sampleVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>cDatabase::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extension,
|
||||||
Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extension,
|
const std::string &icon_star_filled,
|
||||||
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
const std::string &icon_star_empty)
|
||||||
{
|
{
|
||||||
wxVector<wxVector<wxVariant>> sampleVec;
|
wxVector<wxVector<wxVariant>> sampleVec;
|
||||||
|
|
||||||
|
|
@ -815,12 +754,11 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Sqlite3Statement statement(m_Database, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
Sqlite3Statement statement(m_pDatabase, "SELECT FAVORITE, FILENAME, SAMPLEPACK, TYPE, \
|
||||||
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH \
|
||||||
FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;");
|
FROM SAMPLES WHERE HIVE = ? AND FAVORITE = 1;");
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, hiveName.c_str(), hiveName.size(), SQLITE_STATIC));
|
||||||
hiveName.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
|
|
@ -829,18 +767,14 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
|
||||||
SH_LOG_INFO("Record found, filtering db by {}", hiveName);
|
SH_LOG_INFO("Record found, filtering db by {}", hiveName);
|
||||||
|
|
||||||
int favorite = sqlite3_column_int(statement.stmt, 0);
|
int favorite = sqlite3_column_int(statement.stmt, 0);
|
||||||
wxString filename = wxString(std::string(reinterpret_cast<const char *>
|
wxString filename = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 1))));
|
||||||
(sqlite3_column_text(statement.stmt, 1))));
|
wxString sample_pack = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 2))));
|
||||||
wxString sample_pack = wxString(std::string(reinterpret_cast<const char *>
|
wxString sample_type = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 3)));
|
||||||
(sqlite3_column_text(statement.stmt, 2))));
|
|
||||||
wxString sample_type = std::string(reinterpret_cast<const char *>
|
|
||||||
(sqlite3_column_text(statement.stmt, 3)));
|
|
||||||
int channels = sqlite3_column_int(statement.stmt, 4);
|
int channels = sqlite3_column_int(statement.stmt, 4);
|
||||||
int length = sqlite3_column_int(statement.stmt, 5);
|
int length = sqlite3_column_int(statement.stmt, 5);
|
||||||
int sample_rate = sqlite3_column_int(statement.stmt, 6);
|
int sample_rate = sqlite3_column_int(statement.stmt, 6);
|
||||||
int bitrate = sqlite3_column_int(statement.stmt, 7);
|
int bitrate = sqlite3_column_int(statement.stmt, 7);
|
||||||
wxString path = wxString(std::string(reinterpret_cast<const char *>
|
wxString path = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 8))));
|
||||||
(sqlite3_column_text(statement.stmt, 8))));
|
|
||||||
|
|
||||||
wxLongLong llLength = length;
|
wxLongLong llLength = length;
|
||||||
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
||||||
|
|
@ -879,32 +813,31 @@ Database::FilterDatabaseByHiveName(const std::string &hiveName, bool show_extens
|
||||||
return sampleVec;
|
return sampleVec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl)
|
void cDatabase::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT HIVE FROM HIVES;";
|
const auto sql = "SELECT HIVE FROM HIVES;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Loading hives..");
|
SH_LOG_INFO("Loading hives..");
|
||||||
|
|
||||||
const auto hive = wxString(std::string(reinterpret_cast<const char *>
|
const auto hive = wxString(std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 0))));
|
||||||
(sqlite3_column_text(statement.stmt, 0))));
|
|
||||||
|
|
||||||
treeCtrl.AppendContainer(wxDataViewItem(wxNullPtr), hive);
|
treeCtrl.AppendContainer(wxDataViewItem(wxNullPtr), hive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception &e)
|
catch (const std::exception &e)
|
||||||
{
|
{
|
||||||
show_modal_dialog_and_log("Error! Cannot load hive from hives table", "Error", e.what());
|
show_modal_dialog_and_log("Error! Cannot load data from HIVES", "Error", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Compares the input array with the database and removes duplicates.
|
// Compares the input array with the database and removes duplicates.
|
||||||
wxArrayString Database::CheckDuplicates(const wxArrayString &files)
|
wxArrayString cDatabase::CheckDuplicates(const wxArrayString &files)
|
||||||
{
|
{
|
||||||
wxArrayString sorted_files;
|
wxArrayString sorted_files;
|
||||||
|
|
||||||
|
|
@ -915,7 +848,7 @@ wxArrayString Database::CheckDuplicates(const wxArrayString &files)
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT * FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT * FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < files.size(); i++)
|
for (unsigned int i = 0; i < files.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -940,16 +873,15 @@ wxArrayString Database::CheckDuplicates(const wxArrayString &files)
|
||||||
return sorted_files;
|
return sorted_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Database::IsTrashed(const std::string &filename)
|
bool cDatabase::IsTrashed(const std::string &filename)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "SELECT TRASHED FROM SAMPLES WHERE FILENAME = ?;";
|
const auto sql = "SELECT TRASHED FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -969,17 +901,16 @@ bool Database::IsTrashed(const std::string &filename)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateTrashColumn(const std::string &filename, int value)
|
void cDatabase::UpdateTrashColumn(const std::string &filename, int value)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const auto sql = "UPDATE SAMPLES SET TRASHED = ? WHERE FILENAME = ?;";
|
const auto sql = "UPDATE SAMPLES SET TRASHED = ? WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
throw_on_sqlite3_error(sqlite3_bind_int(statement.stmt, 1, value));
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 2, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
if (sqlite3_step(statement.stmt) == SQLITE_ROW)
|
||||||
{
|
{
|
||||||
|
|
@ -994,10 +925,10 @@ void Database::UpdateTrashColumn(const std::string &filename, int value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVector<wxVector<wxVariant>>
|
wxVector<wxVector<wxVariant>>cDatabase::RestoreFromTrashByFilename(const std::string &filename,
|
||||||
Database::RestoreFromTrashByFilename(const std::string &filename,
|
wxVector<wxVector<wxVariant>> &vecSet, bool show_extension,
|
||||||
wxVector<wxVector<wxVariant>> &vecSet, bool show_extension,
|
const std::string &icon_star_filled,
|
||||||
const std::string &icon_star_filled, const std::string &icon_star_empty)
|
const std::string &icon_star_empty)
|
||||||
{
|
{
|
||||||
wxVariant icon_filled, icon_empty;
|
wxVariant icon_filled, icon_empty;
|
||||||
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
icon_filled = wxVariant(wxBitmap(icon_star_filled));
|
||||||
|
|
@ -1009,31 +940,24 @@ Database::RestoreFromTrashByFilename(const std::string &filename,
|
||||||
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
TYPE, CHANNELS, LENGTH, SAMPLERATE, BITRATE, PATH, \
|
||||||
TRASHED, HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
TRASHED, HIVE FROM SAMPLES WHERE FILENAME = ?;";
|
||||||
|
|
||||||
Sqlite3Statement statement(m_Database, sql);
|
Sqlite3Statement statement(m_pDatabase, sql);
|
||||||
|
|
||||||
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(),
|
throw_on_sqlite3_error(sqlite3_bind_text(statement.stmt, 1, filename.c_str(), filename.size(), SQLITE_STATIC));
|
||||||
filename.size(), SQLITE_STATIC));
|
|
||||||
|
|
||||||
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
while (SQLITE_ROW == sqlite3_step(statement.stmt))
|
||||||
{
|
{
|
||||||
int favorite = sqlite3_column_int(statement.stmt, 0);
|
int favorite = sqlite3_column_int(statement.stmt, 0);
|
||||||
wxString filename = std::string(reinterpret_cast<const char *>
|
wxString filename = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 1)));
|
||||||
(sqlite3_column_text(statement.stmt, 1)));
|
wxString file_extension = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 2)));
|
||||||
wxString file_extension = std::string(reinterpret_cast<const char *>
|
wxString sample_pack = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 3)));
|
||||||
(sqlite3_column_text(statement.stmt, 2)));
|
wxString sample_type = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 4)));
|
||||||
wxString sample_pack = std::string(reinterpret_cast<const char *>
|
|
||||||
(sqlite3_column_text(statement.stmt, 3)));
|
|
||||||
wxString sample_type = std::string(reinterpret_cast<const char *>
|
|
||||||
(sqlite3_column_text(statement.stmt, 4)));
|
|
||||||
int channels = sqlite3_column_int(statement.stmt, 5);
|
int channels = sqlite3_column_int(statement.stmt, 5);
|
||||||
int length = sqlite3_column_int(statement.stmt, 6);
|
int length = sqlite3_column_int(statement.stmt, 6);
|
||||||
int sample_rate = sqlite3_column_int(statement.stmt, 7);
|
int sample_rate = sqlite3_column_int(statement.stmt, 7);
|
||||||
int bitrate = sqlite3_column_int(statement.stmt, 8);
|
int bitrate = sqlite3_column_int(statement.stmt, 8);
|
||||||
wxString path = std::string(reinterpret_cast<const char *>
|
wxString path = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 9)));
|
||||||
(sqlite3_column_text(statement.stmt, 9)));
|
|
||||||
int trashed = sqlite3_column_int(statement.stmt, 10);
|
int trashed = sqlite3_column_int(statement.stmt, 10);
|
||||||
wxString hive_name = std::string(reinterpret_cast<const char *>
|
wxString hive_name = std::string(reinterpret_cast<const char*>(sqlite3_column_text(statement.stmt, 11)));
|
||||||
(sqlite3_column_text(statement.stmt, 11)));
|
|
||||||
|
|
||||||
wxLongLong llLength = length;
|
wxLongLong llLength = length;
|
||||||
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
||||||
|
|
@ -1073,12 +997,12 @@ Database::RestoreFromTrashByFilename(const std::string &filename,
|
||||||
return vecSet;
|
return vecSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::OpenDatabase()
|
void cDatabase::OpenDatabase()
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_open(static_cast<std::string>(DATABASE_FILEPATH).c_str(), &m_Database));
|
throw_on_sqlite3_error(sqlite3_open(static_cast<std::string>(DATABASE_FILEPATH).c_str(), &m_pDatabase));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::CloseDatabase()
|
void cDatabase::CloseDatabase()
|
||||||
{
|
{
|
||||||
throw_on_sqlite3_error(sqlite3_close(m_Database));
|
throw_on_sqlite3_error(sqlite3_close(m_pDatabase));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,17 +34,17 @@
|
||||||
|
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
|
|
||||||
class Database
|
class cDatabase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Database();
|
cDatabase();
|
||||||
~Database();
|
~cDatabase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
sqlite3* m_Database;
|
sqlite3* m_pDatabase = nullptr;
|
||||||
int rc;
|
int rc;
|
||||||
char* m_ErrMsg;
|
char* m_pErrMsg = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -19,190 +19,188 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GUI/Dialogs/Settings.hpp"
|
#include "GUI/Dialogs/Settings.hpp"
|
||||||
#include "Utility/ControlID_Enums.hpp"
|
#include "Utility/ControlIDs.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
#include <wx/stringimpl.h>
|
#include <wx/stringimpl.h>
|
||||||
|
|
||||||
Settings::Settings(wxWindow *window)
|
cSettings::cSettings(wxWindow *window)
|
||||||
: wxDialog(window, wxID_ANY, "Settings", wxDefaultPosition,
|
: wxDialog(window, wxID_ANY, "cSettings", wxDefaultPosition,
|
||||||
wxSize(720, 270), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
|
wxSize(720, 270), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
|
||||||
m_Window(window)
|
m_pWindow(window)
|
||||||
{
|
{
|
||||||
m_Panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
m_pPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
m_MainSizer = new wxBoxSizer(wxVERTICAL);
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_NotebookSizer = new wxBoxSizer(wxVERTICAL);
|
m_pNotebookSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
m_Notebook = new wxNotebook(m_Panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("NOTEBOOK"));
|
m_pNotebook = new wxNotebook(m_pPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, _T("NOTEBOOK"));
|
||||||
|
|
||||||
m_DisplaySettingPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
m_pDisplaySettingPanel = new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
m_DisplayTopSizer = new wxBoxSizer(wxVERTICAL);
|
m_pDisplayTopSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_DisplayFontSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_pDisplayFontSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_WaveformColourSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_pWaveformColourSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
wxString fontChoices[] = { "System default" };
|
wxString fontChoices[] = { "System default" };
|
||||||
|
|
||||||
m_FontTypeText = new wxStaticText(m_DisplaySettingPanel, wxID_ANY, "Font",
|
m_pFontTypeText = new wxStaticText(m_pDisplaySettingPanel, wxID_ANY, "Font", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
m_pFontType = new wxChoice(m_pDisplaySettingPanel, SampleHive::ID::SD_FontType,
|
||||||
m_FontType = new wxChoice(m_DisplaySettingPanel, SD_FontType,
|
wxDefaultPosition, wxDefaultSize, 1, fontChoices, 0);
|
||||||
wxDefaultPosition, wxDefaultSize, 1, fontChoices, 0);
|
m_pFontType->SetSelection(0);
|
||||||
m_FontType->SetSelection(0);
|
m_pFontSize = new wxSpinCtrl(m_pDisplaySettingPanel, SampleHive::ID::SD_FontSize, "Default", wxDefaultPosition, wxDefaultSize);
|
||||||
m_FontSize = new wxSpinCtrl(m_DisplaySettingPanel, SD_FontSize, "Default",
|
m_pFontSize->SetValue(window->GetFont().GetPointSize());
|
||||||
wxDefaultPosition, wxDefaultSize);
|
m_pFontBrowseButton = new wxButton(m_pDisplaySettingPanel, SampleHive::ID::SD_FontBrowseButton, "Select font",
|
||||||
m_FontSize->SetValue(window->GetFont().GetPointSize());
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_FontBrowseButton = new wxButton(m_DisplaySettingPanel, SD_FontBrowseButton, "Select font",
|
m_pWaveformColourLabel = new wxStaticText(m_pDisplaySettingPanel, wxID_ANY, "Waveform colour",
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_WaveformColourLabel = new wxStaticText(m_DisplaySettingPanel, wxID_ANY, "Waveform colour",
|
m_pWaveformColourPickerCtrl = new wxColourPickerCtrl(m_pDisplaySettingPanel, SampleHive::ID::SD_WaveformColourPickerCtrl,
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
serializer.DeserializeWaveformColour(),
|
||||||
m_WaveformColourPickerCtrl = new wxColourPickerCtrl(m_DisplaySettingPanel, SD_WaveformColourPickerCtrl,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
serializer.DeserializeWaveformColour(),
|
wxCLRP_DEFAULT_STYLE);
|
||||||
wxDefaultPosition, wxDefaultSize,
|
|
||||||
wxCLRP_DEFAULT_STYLE);
|
|
||||||
|
|
||||||
m_CollectionSettingPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
m_pCollectionSettingPanel = new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
m_CollectionMainSizer = new wxBoxSizer(wxVERTICAL);
|
m_pCollectionMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_CollectionImportDirSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_pCollectionImportDirSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_CollectionImportOptionsSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_pCollectionImportOptionsSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_CollectionShowExtensionSizer = new wxBoxSizer(wxVERTICAL);
|
m_pCollectionShowExtensionSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
wxString defaultDir = wxGetHomeDir();
|
wxString defaultDir = wxGetHomeDir();
|
||||||
|
|
||||||
m_AutoImportCheck = new wxCheckBox(m_CollectionSettingPanel, SD_AutoImport, "Auto import",
|
m_pAutoImportCheck = new wxCheckBox(m_pCollectionSettingPanel, SampleHive::ID::SD_AutoImport, "Auto import",
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_ImportDirLocation = new wxTextCtrl(m_CollectionSettingPanel, wxID_ANY, defaultDir,
|
m_pImportDirLocation = new wxTextCtrl(m_pCollectionSettingPanel, wxID_ANY, defaultDir,
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_ImportDirLocation->Disable();
|
m_pImportDirLocation->Disable();
|
||||||
m_BrowseAutoImportDirButton = new wxButton(m_CollectionSettingPanel, SD_BrowseAutoImportDir, "Browse",
|
m_pBrowseAutoImportDirButton = new wxButton(m_pCollectionSettingPanel, SampleHive::ID::SD_BrowseAutoImportDir, "Browse",
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_BrowseAutoImportDirButton->Disable();
|
m_pBrowseAutoImportDirButton->Disable();
|
||||||
m_FollowSymLinksCheck = new wxCheckBox(m_CollectionSettingPanel, SD_FollowSymLinks,
|
m_pFollowSymLinksCheck = new wxCheckBox(m_pCollectionSettingPanel, SampleHive::ID::SD_FollowSymLinks,
|
||||||
"Follow symbolic links", wxDefaultPosition, wxDefaultSize, 0);
|
"Follow symbolic links", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_FollowSymLinksCheck->SetToolTip("Wheather to follow symbolic links");
|
m_pFollowSymLinksCheck->SetToolTip("Wheather to follow symbolic links");
|
||||||
m_FollowSymLinksCheck->Disable();
|
m_pFollowSymLinksCheck->Disable();
|
||||||
m_RecursiveImportCheck = new wxCheckBox(m_CollectionSettingPanel, SD_RecursiveImport,
|
m_pRecursiveImportCheck = new wxCheckBox(m_pCollectionSettingPanel, SampleHive::ID::SD_RecursiveImport,
|
||||||
"Recursive search", wxDefaultPosition, wxDefaultSize, 0);
|
"Recursive search", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_RecursiveImportCheck->SetToolTip("Recursively search for samples in the directory");
|
m_pRecursiveImportCheck->SetToolTip("Recursively search for samples in the directory");
|
||||||
m_RecursiveImportCheck->Disable();
|
m_pRecursiveImportCheck->Disable();
|
||||||
m_ShowFileExtensionCheck = new wxCheckBox(m_CollectionSettingPanel, SD_ShowFileExtension,
|
m_pShowFileExtensionCheck = new wxCheckBox(m_pCollectionSettingPanel, SampleHive::ID::SD_ShowFileExtension,
|
||||||
"Show file extension", wxDefaultPosition, wxDefaultSize, 0);
|
"Show file extension", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_ShowFileExtensionCheck->SetToolTip("Weather to show file extension");
|
m_pShowFileExtensionCheck->SetToolTip("Weather to show file extension");
|
||||||
|
|
||||||
m_ConfigurationSettingPanel = new wxPanel(m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
m_pConfigurationSettingPanel = new wxPanel(m_pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
m_GeneralMainSizer = new wxFlexGridSizer(2, 3, 0, 0);
|
m_pGeneralMainSizer = new wxFlexGridSizer(2, 3, 0, 0);
|
||||||
m_GeneralMainSizer->AddGrowableCol(1);
|
m_pGeneralMainSizer->AddGrowableCol(1);
|
||||||
m_GeneralMainSizer->SetFlexibleDirection(wxBOTH);
|
m_pGeneralMainSizer->SetFlexibleDirection(wxBOTH);
|
||||||
m_GeneralMainSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
m_pGeneralMainSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||||
|
|
||||||
m_ConfigLabel = new wxStaticText(m_ConfigurationSettingPanel, wxID_ANY,
|
m_pConfigLabel = new wxStaticText(m_pConfigurationSettingPanel, wxID_ANY,
|
||||||
"Default configuration file location", wxDefaultPosition, wxDefaultSize);
|
"Default configuration file location", wxDefaultPosition, wxDefaultSize);
|
||||||
m_ConfigText = new wxTextCtrl(m_ConfigurationSettingPanel, wxID_ANY, CONFIG_FILEPATH,
|
m_pConfigText = new wxTextCtrl(m_pConfigurationSettingPanel, wxID_ANY, CONFIG_FILEPATH,
|
||||||
wxDefaultPosition, wxDefaultSize);
|
wxDefaultPosition, wxDefaultSize);
|
||||||
m_ConfigBrowse = new wxButton(m_ConfigurationSettingPanel, SD_BrowseConfigDir, "Browse",
|
m_pConfigBrowse = new wxButton(m_pConfigurationSettingPanel, SampleHive::ID::SD_BrowseConfigDir, "Browse",
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
m_DatabaseLabel = new wxStaticText(m_ConfigurationSettingPanel, wxID_ANY, "Default database location",
|
m_pDatabaseLabel = new wxStaticText(m_pConfigurationSettingPanel, wxID_ANY, "Default database location",
|
||||||
wxDefaultPosition, wxDefaultSize);
|
wxDefaultPosition, wxDefaultSize);
|
||||||
m_DatabaseText = new wxTextCtrl(m_ConfigurationSettingPanel, wxID_ANY, DATABASE_FILEPATH,
|
m_pDatabaseText = new wxTextCtrl(m_pConfigurationSettingPanel, wxID_ANY, DATABASE_FILEPATH,
|
||||||
wxDefaultPosition, wxDefaultSize);
|
wxDefaultPosition, wxDefaultSize);
|
||||||
m_DatabaseBrowse = new wxButton(m_ConfigurationSettingPanel, SD_BrowseDatabaseDir, "Browse",
|
m_pDatabaseBrowse = new wxButton(m_pConfigurationSettingPanel, SampleHive::ID::SD_BrowseDatabaseDir, "Browse",
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
|
||||||
m_Notebook->AddPage(m_DisplaySettingPanel, "Display");
|
m_pNotebook->AddPage(m_pDisplaySettingPanel, "Display");
|
||||||
m_Notebook->AddPage(m_CollectionSettingPanel, "Collection");
|
m_pNotebook->AddPage(m_pCollectionSettingPanel, "Collection");
|
||||||
m_Notebook->AddPage(m_ConfigurationSettingPanel, "General");
|
m_pNotebook->AddPage(m_pConfigurationSettingPanel, "General");
|
||||||
|
|
||||||
m_OkButton = new wxButton(m_Panel, wxID_OK, "OK", wxDefaultPosition, wxDefaultSize);
|
m_pOkButton = new wxButton(m_pPanel, wxID_OK, "OK", wxDefaultPosition, wxDefaultSize);
|
||||||
m_CancelButton = new wxButton(m_Panel, wxID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize);
|
m_pCancelButton = new wxButton(m_pPanel, wxID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
LoadDefaultConfig();
|
LoadDefaultConfig();
|
||||||
|
|
||||||
// Bind events
|
// Bind events
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckAutoImport, this, SD_AutoImport);
|
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckAutoImport, this, SampleHive::ID::SD_AutoImport);
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckFollowSymLinks, this, SD_FollowSymLinks);
|
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckFollowSymLinks, this, SampleHive::ID::SD_FollowSymLinks);
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckRecursiveImport, this, SD_RecursiveImport);
|
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckRecursiveImport, this, SampleHive::ID::SD_RecursiveImport);
|
||||||
Bind(wxEVT_CHECKBOX, &Settings::OnCheckShowFileExtension, this, SD_ShowFileExtension);
|
Bind(wxEVT_CHECKBOX, &cSettings::OnCheckShowFileExtension, this, SampleHive::ID::SD_ShowFileExtension);
|
||||||
Bind(wxEVT_SPINCTRL, &Settings::OnChangeFontSize, this, SD_FontSize);
|
Bind(wxEVT_SPINCTRL, &cSettings::OnChangeFontSize, this, SampleHive::ID::SD_FontSize);
|
||||||
Bind(wxEVT_BUTTON, &Settings::OnSelectFont, this, SD_FontBrowseButton);
|
Bind(wxEVT_BUTTON, &cSettings::OnSelectFont, this, SampleHive::ID::SD_FontBrowseButton);
|
||||||
Bind(wxEVT_BUTTON, &Settings::OnClickBrowseAutoImportDir, this, SD_BrowseAutoImportDir);
|
Bind(wxEVT_BUTTON, &cSettings::OnClickBrowseAutoImportDir, this, SampleHive::ID::SD_BrowseAutoImportDir);
|
||||||
Bind(wxEVT_BUTTON, &Settings::OnClickConfigBrowse, this, SD_BrowseConfigDir);
|
Bind(wxEVT_BUTTON, &cSettings::OnClickConfigBrowse, this, SampleHive::ID::SD_BrowseConfigDir);
|
||||||
Bind(wxEVT_BUTTON, &Settings::OnClickDatabaseBrowse, this, SD_BrowseDatabaseDir);
|
Bind(wxEVT_BUTTON, &cSettings::OnClickDatabaseBrowse, this, SampleHive::ID::SD_BrowseDatabaseDir);
|
||||||
Bind(wxEVT_COLOURPICKER_CHANGED, &Settings::OnChangeWaveformColour, this, SD_WaveformColourPickerCtrl);
|
Bind(wxEVT_COLOURPICKER_CHANGED, &cSettings::OnChangeWaveformColour, this, SampleHive::ID::SD_WaveformColourPickerCtrl);
|
||||||
|
|
||||||
// Adding controls to sizers
|
// Adding controls to sizers
|
||||||
m_NotebookSizer->Add(m_Notebook, 1, wxALL | wxEXPAND, 2);
|
m_pNotebookSizer->Add(m_pNotebook, 1, wxALL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_GeneralMainSizer->Add(m_ConfigLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pGeneralMainSizer->Add(m_pConfigLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_GeneralMainSizer->Add(m_ConfigText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pGeneralMainSizer->Add(m_pConfigText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
m_GeneralMainSizer->Add(m_ConfigBrowse, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pGeneralMainSizer->Add(m_pConfigBrowse, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
m_GeneralMainSizer->Add(m_DatabaseLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pGeneralMainSizer->Add(m_pDatabaseLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_GeneralMainSizer->Add(m_DatabaseText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pGeneralMainSizer->Add(m_pDatabaseText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
m_GeneralMainSizer->Add(m_DatabaseBrowse, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pGeneralMainSizer->Add(m_pDatabaseBrowse, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
m_DisplayFontSizer->Add(m_FontTypeText, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pDisplayFontSizer->Add(m_pFontTypeText, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_DisplayFontSizer->Add(m_FontType, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pDisplayFontSizer->Add(m_pFontType, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_DisplayFontSizer->Add(m_FontSize, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pDisplayFontSizer->Add(m_pFontSize, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_DisplayFontSizer->Add(m_FontBrowseButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pDisplayFontSizer->Add(m_pFontBrowseButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_WaveformColourSizer->Add(m_WaveformColourLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pWaveformColourSizer->Add(m_pWaveformColourLabel, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_WaveformColourSizer->Add(m_WaveformColourPickerCtrl, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pWaveformColourSizer->Add(m_pWaveformColourPickerCtrl, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
m_DisplayTopSizer->Add(m_DisplayFontSizer, 0, wxALL | wxEXPAND, 2);
|
m_pDisplayTopSizer->Add(m_pDisplayFontSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
m_DisplayTopSizer->Add(m_WaveformColourSizer, 0, wxALL | wxEXPAND, 2);
|
m_pDisplayTopSizer->Add(m_pWaveformColourSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_CollectionImportDirSizer->Add(m_AutoImportCheck, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pCollectionImportDirSizer->Add(m_pAutoImportCheck, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_CollectionImportDirSizer->Add(m_ImportDirLocation, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pCollectionImportDirSizer->Add(m_pImportDirLocation, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_CollectionImportDirSizer->Add(m_BrowseAutoImportDirButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
m_pCollectionImportDirSizer->Add(m_pBrowseAutoImportDirButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
m_CollectionImportOptionsSizer->Add(m_FollowSymLinksCheck, 0, wxALL, 2);
|
m_pCollectionImportOptionsSizer->Add(m_pFollowSymLinksCheck, 0, wxALL, 2);
|
||||||
m_CollectionImportOptionsSizer->Add(m_RecursiveImportCheck, 0, wxALL, 2);
|
m_pCollectionImportOptionsSizer->Add(m_pRecursiveImportCheck, 0, wxALL, 2);
|
||||||
m_CollectionShowExtensionSizer->Add(m_ShowFileExtensionCheck, 0, wxALL, 2);
|
m_pCollectionShowExtensionSizer->Add(m_pShowFileExtensionCheck, 0, wxALL, 2);
|
||||||
|
|
||||||
m_CollectionMainSizer->Add(m_CollectionImportDirSizer, 0, wxALL | wxEXPAND, 2);
|
m_pCollectionMainSizer->Add(m_pCollectionImportDirSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
m_CollectionMainSizer->Add(m_CollectionImportOptionsSizer, 0, wxALL | wxEXPAND, 2);
|
m_pCollectionMainSizer->Add(m_pCollectionImportOptionsSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
m_CollectionMainSizer->Add(m_CollectionShowExtensionSizer, 0, wxALL | wxEXPAND, 2);
|
m_pCollectionMainSizer->Add(m_pCollectionShowExtensionSizer, 0, wxALL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_ButtonSizer->Add(m_OkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_pButtonSizer->Add(m_pOkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
m_ButtonSizer->Add(m_CancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_pButtonSizer->Add(m_pCancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
|
|
||||||
m_MainSizer->Add(m_NotebookSizer, 1, wxALL | wxEXPAND, 2);
|
m_pMainSizer->Add(m_pNotebookSizer, 1, wxALL | wxEXPAND, 2);
|
||||||
m_MainSizer->Add(m_ButtonSizer, 0, wxALL | wxALIGN_RIGHT, 2);
|
m_pMainSizer->Add(m_pButtonSizer, 0, wxALL | wxALIGN_RIGHT, 2);
|
||||||
|
|
||||||
// Top panel layout
|
// Top panel layout
|
||||||
m_Panel->SetSizer(m_MainSizer);
|
m_pPanel->SetSizer(m_pMainSizer);
|
||||||
m_MainSizer->Fit(m_Panel);
|
m_pMainSizer->Fit(m_pPanel);
|
||||||
m_MainSizer->SetSizeHints(m_Panel);
|
m_pMainSizer->SetSizeHints(m_pPanel);
|
||||||
m_MainSizer->Layout();
|
m_pMainSizer->Layout();
|
||||||
|
|
||||||
// Display panel layout
|
// Display panel layout
|
||||||
m_DisplaySettingPanel->SetSizer(m_DisplayTopSizer);
|
m_pDisplaySettingPanel->SetSizer(m_pDisplayTopSizer);
|
||||||
m_DisplayTopSizer->Fit(m_DisplaySettingPanel);
|
m_pDisplayTopSizer->Fit(m_pDisplaySettingPanel);
|
||||||
m_DisplayTopSizer->SetSizeHints(m_DisplaySettingPanel);
|
m_pDisplayTopSizer->SetSizeHints(m_pDisplaySettingPanel);
|
||||||
m_DisplayTopSizer->Layout();
|
m_pDisplayTopSizer->Layout();
|
||||||
|
|
||||||
// Collection panel layout
|
// Collection panel layout
|
||||||
m_CollectionSettingPanel->SetSizer(m_CollectionMainSizer);
|
m_pCollectionSettingPanel->SetSizer(m_pCollectionMainSizer);
|
||||||
m_CollectionMainSizer->Fit(m_CollectionSettingPanel);
|
m_pCollectionMainSizer->Fit(m_pCollectionSettingPanel);
|
||||||
m_CollectionMainSizer->SetSizeHints(m_CollectionSettingPanel);
|
m_pCollectionMainSizer->SetSizeHints(m_pCollectionSettingPanel);
|
||||||
m_CollectionMainSizer->Layout();
|
m_pCollectionMainSizer->Layout();
|
||||||
|
|
||||||
// Configuration panel layout
|
// Configuration panel layout
|
||||||
m_ConfigurationSettingPanel->SetSizer(m_GeneralMainSizer);
|
m_pConfigurationSettingPanel->SetSizer(m_pGeneralMainSizer);
|
||||||
m_GeneralMainSizer->Fit(m_ConfigurationSettingPanel);
|
m_pGeneralMainSizer->Fit(m_pConfigurationSettingPanel);
|
||||||
m_GeneralMainSizer->SetSizeHints(m_ConfigurationSettingPanel);
|
m_pGeneralMainSizer->SetSizeHints(m_pConfigurationSettingPanel);
|
||||||
m_GeneralMainSizer->Layout();
|
m_pGeneralMainSizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnClickConfigBrowse(wxCommandEvent& event)
|
void cSettings::OnClickConfigBrowse(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxString initial_dir = wxGetHomeDir();
|
wxString initial_dir = wxGetHomeDir();
|
||||||
|
|
||||||
|
|
@ -217,7 +215,7 @@ void Settings::OnClickConfigBrowse(wxCommandEvent& event)
|
||||||
case wxID_OK:
|
case wxID_OK:
|
||||||
{
|
{
|
||||||
wxString path = dir_dialog.GetPath();
|
wxString path = dir_dialog.GetPath();
|
||||||
m_ConfigText->SetValue(path + "/config.yaml");
|
m_pConfigText->SetValue(path + "/config.yaml");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -225,7 +223,7 @@ void Settings::OnClickConfigBrowse(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnClickDatabaseBrowse(wxCommandEvent& event)
|
void cSettings::OnClickDatabaseBrowse(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxString initial_dir = wxGetHomeDir();
|
wxString initial_dir = wxGetHomeDir();
|
||||||
|
|
||||||
|
|
@ -240,7 +238,7 @@ void Settings::OnClickDatabaseBrowse(wxCommandEvent& event)
|
||||||
case wxID_OK:
|
case wxID_OK:
|
||||||
{
|
{
|
||||||
wxString path = dir_dialog.GetPath();
|
wxString path = dir_dialog.GetPath();
|
||||||
m_DatabaseText->SetValue(path + "/config.yaml");
|
m_pDatabaseText->SetValue(path + "/config.yaml");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -248,56 +246,56 @@ void Settings::OnClickDatabaseBrowse(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnCheckAutoImport(wxCommandEvent& event)
|
void cSettings::OnCheckAutoImport(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
if (!m_AutoImportCheck->GetValue())
|
if (!m_pAutoImportCheck->GetValue())
|
||||||
{
|
{
|
||||||
bAutoImport = false;
|
m_bAutoImport = false;
|
||||||
m_ImportDirLocation->Disable();
|
m_pImportDirLocation->Disable();
|
||||||
m_BrowseAutoImportDirButton->Disable();
|
m_pBrowseAutoImportDirButton->Disable();
|
||||||
m_FollowSymLinksCheck->Disable();
|
m_pFollowSymLinksCheck->Disable();
|
||||||
m_RecursiveImportCheck->Disable();
|
m_pRecursiveImportCheck->Disable();
|
||||||
|
|
||||||
serializer.SerializeAutoImport(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
serializer.SerializeAutoImport(m_bAutoImport, m_pImportDirLocation->GetValue().ToStdString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bAutoImport = true;
|
m_bAutoImport = true;
|
||||||
m_ImportDirLocation->Enable();
|
m_pImportDirLocation->Enable();
|
||||||
m_BrowseAutoImportDirButton->Enable();
|
m_pBrowseAutoImportDirButton->Enable();
|
||||||
m_FollowSymLinksCheck->Enable();
|
m_pFollowSymLinksCheck->Enable();
|
||||||
m_RecursiveImportCheck->Enable();
|
m_pRecursiveImportCheck->Enable();
|
||||||
|
|
||||||
serializer.SerializeAutoImport(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
serializer.SerializeAutoImport(m_bAutoImport, m_pImportDirLocation->GetValue().ToStdString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnCheckFollowSymLinks(wxCommandEvent& event)
|
void cSettings::OnCheckFollowSymLinks(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
serializer.SerializeFollowSymLink(m_FollowSymLinksCheck->GetValue());
|
serializer.SerializeFollowSymLink(m_pFollowSymLinksCheck->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnCheckRecursiveImport(wxCommandEvent& event)
|
void cSettings::OnCheckRecursiveImport(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
serializer.SerializeRecursiveImport(m_RecursiveImportCheck->GetValue());
|
serializer.SerializeRecursiveImport(m_pRecursiveImportCheck->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnCheckShowFileExtension(wxCommandEvent& event)
|
void cSettings::OnCheckShowFileExtension(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
serializer.SerializeShowFileExtension(m_ShowFileExtensionCheck->GetValue());
|
serializer.SerializeShowFileExtension(m_pShowFileExtensionCheck->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
void cSettings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
wxString initial_dir = wxGetHomeDir();
|
wxString initial_dir = wxGetHomeDir();
|
||||||
|
|
||||||
|
|
@ -312,9 +310,9 @@ void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
||||||
case wxID_OK:
|
case wxID_OK:
|
||||||
{
|
{
|
||||||
wxString path = dir_dialog.GetPath();
|
wxString path = dir_dialog.GetPath();
|
||||||
m_ImportDirLocation->SetValue(path);
|
m_pImportDirLocation->SetValue(path);
|
||||||
|
|
||||||
serializer.SerializeAutoImport(bAutoImport, m_ImportDirLocation->GetValue().ToStdString());
|
serializer.SerializeAutoImport(m_bAutoImport, m_pImportDirLocation->GetValue().ToStdString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
@ -322,7 +320,7 @@ void Settings::OnClickBrowseAutoImportDir(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnSelectFont(wxCommandEvent& event)
|
void cSettings::OnSelectFont(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxFontDialog font_dialog(this);
|
wxFontDialog font_dialog(this);
|
||||||
|
|
||||||
|
|
@ -333,16 +331,16 @@ void Settings::OnSelectFont(wxCommandEvent& event)
|
||||||
wxFontData fontData = font_dialog.GetFontData();
|
wxFontData fontData = font_dialog.GetFontData();
|
||||||
m_Font = fontData.GetChosenFont();
|
m_Font = fontData.GetChosenFont();
|
||||||
|
|
||||||
if (m_FontType->GetCount() > 1)
|
if (m_pFontType->GetCount() > 1)
|
||||||
{
|
{
|
||||||
m_FontType->Delete(1);
|
m_pFontType->Delete(1);
|
||||||
m_FontType->AppendString(m_Font.GetFaceName());
|
m_pFontType->AppendString(m_Font.GetFaceName());
|
||||||
m_FontType->SetSelection(1);
|
m_pFontType->SetSelection(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_FontType->AppendString(m_Font.GetFaceName());
|
m_pFontType->AppendString(m_Font.GetFaceName());
|
||||||
m_FontType->SetSelection(1);
|
m_pFontType->SetSelection(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCustomFont();
|
SetCustomFont();
|
||||||
|
|
@ -354,29 +352,29 @@ void Settings::OnSelectFont(wxCommandEvent& event)
|
||||||
PrintFont();
|
PrintFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnChangeFontSize(wxSpinEvent& event)
|
void cSettings::OnChangeFontSize(wxSpinEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
int font_size = m_FontSize->GetValue();
|
int font_size = m_pFontSize->GetValue();
|
||||||
|
|
||||||
if (m_FontType->GetStringSelection() == "System default")
|
if (m_pFontType->GetStringSelection() == "System default")
|
||||||
m_Font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
m_Font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
||||||
|
|
||||||
m_Font.SetPointSize(font_size);
|
m_Font.SetPointSize(font_size);
|
||||||
|
|
||||||
serializer.SerializeFontSettings(m_Font);
|
serializer.SerializeFontSettings(m_Font);
|
||||||
|
|
||||||
m_Window->SetFont(m_Font);
|
m_pWindow->SetFont(m_Font);
|
||||||
this->SetFont(m_Font);
|
this->SetFont(m_Font);
|
||||||
|
|
||||||
SH_LOG_DEBUG("Font size: {}", font_size);
|
SH_LOG_DEBUG("Font size: {}", font_size);
|
||||||
SH_LOG_DEBUG("Font size: {}", m_Font.GetPointSize());
|
SH_LOG_DEBUG("Font size: {}", m_Font.GetPointSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::LoadDefaultConfig()
|
void cSettings::LoadDefaultConfig()
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
wxFont sys_font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
wxFont sys_font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
||||||
wxString system_font = sys_font.GetFaceName();
|
wxString system_font = sys_font.GetFaceName();
|
||||||
|
|
@ -387,54 +385,54 @@ void Settings::LoadDefaultConfig()
|
||||||
|
|
||||||
if (system_font != font_face)
|
if (system_font != font_face)
|
||||||
{
|
{
|
||||||
if (m_FontType->GetCount() > 1)
|
if (m_pFontType->GetCount() > 1)
|
||||||
{
|
{
|
||||||
m_FontType->Delete(1);
|
m_pFontType->Delete(1);
|
||||||
m_FontType->AppendString(font_face);
|
m_pFontType->AppendString(font_face);
|
||||||
m_FontType->SetSelection(1);
|
m_pFontType->SetSelection(1);
|
||||||
|
|
||||||
m_Font.SetFaceName(font_face);
|
m_Font.SetFaceName(font_face);
|
||||||
m_Font.SetPointSize(font_size);
|
m_Font.SetPointSize(font_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_FontType->AppendString(font_face);
|
m_pFontType->AppendString(font_face);
|
||||||
m_FontType->SetSelection(1);
|
m_pFontType->SetSelection(1);
|
||||||
|
|
||||||
m_Font.SetFaceName(font_face);
|
m_Font.SetFaceName(font_face);
|
||||||
m_Font.SetPointSize(font_size);
|
m_Font.SetPointSize(font_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_FontSize->SetValue(font_size);
|
m_pFontSize->SetValue(font_size);
|
||||||
SetCustomFont();
|
SetCustomFont();
|
||||||
|
|
||||||
bAutoImport = serializer.DeserializeAutoImport().first;
|
m_bAutoImport = serializer.DeserializeAutoImport().first;
|
||||||
|
|
||||||
m_AutoImportCheck->SetValue(bAutoImport);
|
m_pAutoImportCheck->SetValue(m_bAutoImport);
|
||||||
m_ImportDirLocation->SetValue(serializer.DeserializeAutoImport().second);
|
m_pImportDirLocation->SetValue(serializer.DeserializeAutoImport().second);
|
||||||
m_ShowFileExtensionCheck->SetValue(serializer.DeserializeShowFileExtension());
|
m_pShowFileExtensionCheck->SetValue(serializer.DeserializeShowFileExtension());
|
||||||
m_FollowSymLinksCheck->SetValue(serializer.DeserializeFollowSymLink());
|
m_pFollowSymLinksCheck->SetValue(serializer.DeserializeFollowSymLink());
|
||||||
m_RecursiveImportCheck->SetValue(serializer.DeserializeRecursiveImport());
|
m_pRecursiveImportCheck->SetValue(serializer.DeserializeRecursiveImport());
|
||||||
|
|
||||||
if (bAutoImport)
|
if (m_bAutoImport)
|
||||||
{
|
{
|
||||||
m_ImportDirLocation->Enable();
|
m_pImportDirLocation->Enable();
|
||||||
m_BrowseAutoImportDirButton->Enable();
|
m_pBrowseAutoImportDirButton->Enable();
|
||||||
m_FollowSymLinksCheck->Enable();
|
m_pFollowSymLinksCheck->Enable();
|
||||||
m_RecursiveImportCheck->Enable();
|
m_pRecursiveImportCheck->Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::SetShowExtension(bool value)
|
void cSettings::SetShowExtension(bool value)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
m_ShowFileExtensionCheck->SetValue(value);
|
m_pShowFileExtensionCheck->SetValue(value);
|
||||||
serializer.SerializeShowFileExtension(value);
|
serializer.SerializeShowFileExtension(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::PrintFont()
|
void cSettings::PrintFont()
|
||||||
{
|
{
|
||||||
SH_LOG_DEBUG("Font face: {}", m_Font.GetFaceName());
|
SH_LOG_DEBUG("Font face: {}", m_Font.GetFaceName());
|
||||||
SH_LOG_DEBUG("Font size: {}", m_Font.GetPointSize());
|
SH_LOG_DEBUG("Font size: {}", m_Font.GetPointSize());
|
||||||
|
|
@ -443,9 +441,9 @@ void Settings::PrintFont()
|
||||||
SH_LOG_DEBUG("Font weight: {}", m_Font.GetWeightString());
|
SH_LOG_DEBUG("Font weight: {}", m_Font.GetWeightString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::SetCustomFont()
|
void cSettings::SetCustomFont()
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
wxFont sys_font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
wxFont sys_font = wxSystemSettings::GetFont(wxSYS_SYSTEM_FONT);
|
||||||
std::string system_font = sys_font.GetFaceName().ToStdString();
|
std::string system_font = sys_font.GetFaceName().ToStdString();
|
||||||
|
|
@ -454,53 +452,56 @@ void Settings::SetCustomFont()
|
||||||
wxString font_face = serializer.DeserializeFontSettings().GetFaceName();
|
wxString font_face = serializer.DeserializeFontSettings().GetFaceName();
|
||||||
int font_size = serializer.DeserializeFontSettings().GetPointSize();
|
int font_size = serializer.DeserializeFontSettings().GetPointSize();
|
||||||
|
|
||||||
if (m_FontType->GetStringSelection() == "System default")
|
if (m_pFontType->GetStringSelection() == "System default")
|
||||||
{
|
{
|
||||||
m_Window->SetFont(sys_font);
|
m_pWindow->SetFont(sys_font);
|
||||||
this->SetFont(sys_font);
|
this->SetFont(sys_font);
|
||||||
|
|
||||||
serializer.SerializeFontSettings(sys_font);
|
serializer.SerializeFontSettings(sys_font);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Window->SetFont(m_Font);
|
m_pWindow->SetFont(m_Font);
|
||||||
this->SetFont(m_Font);
|
this->SetFont(m_Font);
|
||||||
|
|
||||||
serializer.SerializeFontSettings(m_Font);
|
serializer.SerializeFontSettings(m_Font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Settings::GetImportDirPath()
|
wxString cSettings::GetImportDirPath()
|
||||||
{
|
{
|
||||||
wxString dir = wxEmptyString;
|
wxString dir = wxEmptyString;
|
||||||
|
|
||||||
if (m_AutoImportCheck->GetValue())
|
if (m_pAutoImportCheck->GetValue())
|
||||||
dir = m_ImportDirLocation->GetValue();
|
dir = m_pImportDirLocation->GetValue();
|
||||||
|
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::OnChangeWaveformColour(wxColourPickerEvent& event)
|
void cSettings::OnChangeWaveformColour(wxColourPickerEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
wxColour colour = m_WaveformColourPickerCtrl->GetColour();
|
wxColour colour = m_pWaveformColourPickerCtrl->GetColour();
|
||||||
|
|
||||||
wxColour wave_colour = serializer.DeserializeWaveformColour();
|
wxColour wave_colour = serializer.DeserializeWaveformColour();
|
||||||
|
|
||||||
if (colour != wave_colour)
|
if (colour != wave_colour)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Waveform colour changed.");
|
SH_LOG_INFO("Waveform colour changed.");
|
||||||
bWaveformColourChanged = true;
|
m_bWaveformColourChanged = true;
|
||||||
|
|
||||||
serializer.SerializeWaveformColour(colour);
|
serializer.SerializeWaveformColour(colour);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Waveform colour not changed.");
|
SH_LOG_INFO("Waveform colour not changed.");
|
||||||
bWaveformColourChanged = false;
|
m_bWaveformColourChanged = false;
|
||||||
|
|
||||||
serializer.SerializeWaveformColour(colour);
|
serializer.SerializeWaveformColour(colour);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::~Settings(){}
|
cSettings::~cSettings()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,89 +40,11 @@
|
||||||
#include <wx/toplevel.h>
|
#include <wx/toplevel.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
class Settings : public wxDialog
|
class cSettings : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Settings(wxWindow* window);
|
cSettings(wxWindow* window);
|
||||||
~Settings();
|
~cSettings();
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
wxWindow* m_Window;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Top panel for wxDialog
|
|
||||||
wxPanel* m_Panel;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Notebook page panels
|
|
||||||
wxPanel* m_DisplaySettingPanel;
|
|
||||||
wxPanel* m_CollectionSettingPanel;
|
|
||||||
wxPanel* m_ConfigurationSettingPanel;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Top panel sizers
|
|
||||||
wxBoxSizer* m_MainSizer;
|
|
||||||
wxBoxSizer* m_NotebookSizer;
|
|
||||||
wxBoxSizer* m_ButtonSizer;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Notebook
|
|
||||||
wxNotebook* m_Notebook;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Display page
|
|
||||||
wxBoxSizer* m_DisplayTopSizer;
|
|
||||||
wxBoxSizer* m_DisplayFontSizer;
|
|
||||||
wxStaticText* m_RowHeightText;
|
|
||||||
wxStaticText* m_FontTypeText;
|
|
||||||
wxChoice* m_RowHeight;
|
|
||||||
wxChoice* m_FontType;
|
|
||||||
wxButton* m_FontBrowseButton;
|
|
||||||
wxSpinCtrl* m_FontSize;
|
|
||||||
wxBoxSizer* m_WaveformColourSizer;
|
|
||||||
wxStaticText* m_WaveformColourLabel;
|
|
||||||
wxColourPickerCtrl* m_WaveformColourPickerCtrl;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Collection page
|
|
||||||
wxBoxSizer* m_CollectionMainSizer;
|
|
||||||
wxBoxSizer* m_CollectionImportDirSizer;
|
|
||||||
wxBoxSizer* m_CollectionImportOptionsSizer;
|
|
||||||
wxBoxSizer* m_CollectionShowExtensionSizer;
|
|
||||||
wxCheckBox* m_AutoImportCheck;
|
|
||||||
wxCheckBox* m_FollowSymLinksCheck;
|
|
||||||
wxCheckBox* m_RecursiveImportCheck;
|
|
||||||
wxCheckBox* m_ShowFileExtensionCheck;
|
|
||||||
wxTextCtrl* m_ImportDirLocation;
|
|
||||||
wxButton* m_BrowseAutoImportDirButton;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// General configuration page
|
|
||||||
wxFlexGridSizer* m_GeneralMainSizer;
|
|
||||||
wxStaticText* m_ConfigLabel;
|
|
||||||
wxStaticText* m_DatabaseLabel;
|
|
||||||
wxTextCtrl* m_ConfigText;
|
|
||||||
wxTextCtrl* m_DatabaseText;
|
|
||||||
wxButton* m_ConfigBrowse;
|
|
||||||
wxButton* m_DatabaseBrowse;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Common buttons for wxDialog
|
|
||||||
wxButton* m_OkButton;
|
|
||||||
wxButton* m_CancelButton;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
wxFont m_Font;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
bool bAutoImport = false;
|
|
||||||
// bool bFollowSymLinks = false;
|
|
||||||
// bool bShowExtension = true;
|
|
||||||
bool bWaveformColourChanged = false;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -150,13 +72,88 @@ class Settings : public wxDialog
|
||||||
wxString GetImportDirPath();
|
wxString GetImportDirPath();
|
||||||
|
|
||||||
// inline wxFont GetFontType() { return m_Font; };
|
// inline wxFont GetFontType() { return m_Font; };
|
||||||
inline bool CanAutoImport() { return bAutoImport; };
|
inline bool CanAutoImport() { return m_bAutoImport; };
|
||||||
// inline bool ShouldFollowSymLinks() { return bFollowSymLinks; };
|
inline bool IsWaveformColourChanged() { return m_bWaveformColourChanged; }
|
||||||
// inline bool ShouldShowFileExtension() { return bShowExtension; };
|
|
||||||
inline bool IsWaveformColourChanged() { return bWaveformColourChanged; }
|
|
||||||
// inline wxColour GetWaveformColour() { return m_WaveformColourPickerCtrl->GetColour(); }
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Setters
|
// Setters
|
||||||
void SetShowExtension(bool value);
|
void SetShowExtension(bool value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Top panel for wxDialog
|
||||||
|
wxPanel* m_pPanel = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Notebook page panels
|
||||||
|
wxPanel* m_pDisplaySettingPanel = nullptr;
|
||||||
|
wxPanel* m_pCollectionSettingPanel = nullptr;
|
||||||
|
wxPanel* m_pConfigurationSettingPanel = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Top panel sizers
|
||||||
|
wxBoxSizer* m_pMainSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pNotebookSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pButtonSizer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Notebook
|
||||||
|
wxNotebook* m_pNotebook = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Display page
|
||||||
|
wxBoxSizer* m_pDisplayTopSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pDisplayFontSizer = nullptr;
|
||||||
|
wxStaticText* m_pRowHeightText = nullptr;
|
||||||
|
wxStaticText* m_pFontTypeText = nullptr;
|
||||||
|
wxChoice* m_pRowHeight = nullptr;
|
||||||
|
wxChoice* m_pFontType = nullptr;
|
||||||
|
wxButton* m_pFontBrowseButton = nullptr;
|
||||||
|
wxSpinCtrl* m_pFontSize = nullptr;
|
||||||
|
wxBoxSizer* m_pWaveformColourSizer = nullptr;
|
||||||
|
wxStaticText* m_pWaveformColourLabel = nullptr;
|
||||||
|
wxColourPickerCtrl* m_pWaveformColourPickerCtrl = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Collection page
|
||||||
|
wxBoxSizer* m_pCollectionMainSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pCollectionImportDirSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pCollectionImportOptionsSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pCollectionShowExtensionSizer = nullptr;
|
||||||
|
wxCheckBox* m_pAutoImportCheck = nullptr;
|
||||||
|
wxCheckBox* m_pFollowSymLinksCheck = nullptr;
|
||||||
|
wxCheckBox* m_pRecursiveImportCheck = nullptr;
|
||||||
|
wxCheckBox* m_pShowFileExtensionCheck = nullptr;
|
||||||
|
wxTextCtrl* m_pImportDirLocation = nullptr;
|
||||||
|
wxButton* m_pBrowseAutoImportDirButton = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// General configuration page
|
||||||
|
wxFlexGridSizer* m_pGeneralMainSizer = nullptr;
|
||||||
|
wxStaticText* m_pConfigLabel = nullptr;
|
||||||
|
wxStaticText* m_pDatabaseLabel = nullptr;
|
||||||
|
wxTextCtrl* m_pConfigText = nullptr;
|
||||||
|
wxTextCtrl* m_pDatabaseText = nullptr;
|
||||||
|
wxButton* m_pConfigBrowse = nullptr;
|
||||||
|
wxButton* m_pDatabaseBrowse = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Common buttons for wxDialog
|
||||||
|
wxButton* m_pOkButton = nullptr;
|
||||||
|
wxButton* m_pCancelButton = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxFont m_Font;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
bool m_bAutoImport = false;
|
||||||
|
// bool bFollowSymLinks = false;
|
||||||
|
// bool bShowExtension = true;
|
||||||
|
bool m_bWaveformColourChanged = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,13 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Utility/ControlID_Enums.hpp"
|
#include "GUI/Dialogs/TagEditor.hpp"
|
||||||
#include "Utility/SH_Event.hpp"
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
#include "Database/Database.hpp"
|
#include "Utility/Event.hpp"
|
||||||
#include "GUI/Dialogs/TagEditor.hpp"
|
#include "Utility/Signal.hpp"
|
||||||
|
|
||||||
#include <wx/defs.h>
|
#include <wx/defs.h>
|
||||||
#include <wx/gdicmn.h>
|
#include <wx/gdicmn.h>
|
||||||
|
|
@ -31,179 +32,179 @@
|
||||||
#include <wx/stringimpl.h>
|
#include <wx/stringimpl.h>
|
||||||
#include <wx/textdlg.h>
|
#include <wx/textdlg.h>
|
||||||
|
|
||||||
TagEditor::TagEditor(wxWindow* window, const std::string& filename)
|
cTagEditor::cTagEditor(wxWindow* window, const std::string& filename)
|
||||||
: wxDialog(window, wxID_ANY, "Edit tags", wxDefaultPosition,
|
: wxDialog(window, wxID_ANY, "Edit tags", wxDefaultPosition,
|
||||||
wxSize(640, 360), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
|
wxSize(640, 360), wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP),
|
||||||
m_Window(window), m_Filename(filename), tags(filename)
|
m_pWindow(window), m_Filename(filename), tags(filename)
|
||||||
{
|
{
|
||||||
m_Panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
m_pPanel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
m_MainSizer = new wxBoxSizer(wxVERTICAL);
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
m_ButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
m_pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
m_EditTagSizer = new wxFlexGridSizer(6, 2, 0, 0);
|
m_pEditTagSizer = new wxFlexGridSizer(6, 2, 0, 0);
|
||||||
m_EditTagSizer->AddGrowableCol(1);
|
m_pEditTagSizer->AddGrowableCol(1);
|
||||||
m_EditTagSizer->SetFlexibleDirection(wxBOTH);
|
m_pEditTagSizer->SetFlexibleDirection(wxBOTH);
|
||||||
m_EditTagSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
m_pEditTagSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||||
m_SampleTypeSizer = new wxFlexGridSizer(1, 3, 0, 0);
|
m_pSampleTypeSizer = new wxFlexGridSizer(1, 3, 0, 0);
|
||||||
m_SampleTypeSizer->AddGrowableCol(1);
|
m_pSampleTypeSizer->AddGrowableCol(1);
|
||||||
m_SampleTypeSizer->SetFlexibleDirection(wxBOTH);
|
m_pSampleTypeSizer->SetFlexibleDirection(wxBOTH);
|
||||||
m_SampleTypeSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
m_pSampleTypeSizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
|
||||||
m_StaticEditTagSizer = new wxStaticBoxSizer(wxVERTICAL, m_Panel, "Edit tags");
|
m_pStaticEditTagSizer = new wxStaticBoxSizer(wxVERTICAL, m_pPanel, "Edit tags");
|
||||||
m_StaticSampleTypeSizer = new wxStaticBoxSizer(wxVERTICAL, m_Panel, "Sample type");
|
m_pStaticSampleTypeSizer = new wxStaticBoxSizer(wxVERTICAL, m_pPanel, "Sample type");
|
||||||
|
|
||||||
wxString choices[] = {"Kick", "Snare", "Clap", "HiHat", "Cymbal", "Cowbell", "Ride", "Tom", "Shaker", "Percussion"};
|
wxString choices[] = {"Kick", "Snare", "Clap", "HiHat", "Cymbal", "Cowbell", "Ride", "Tom", "Shaker", "Percussion"};
|
||||||
|
|
||||||
m_TitleCheck = new wxCheckBox(m_Panel, ET_TitleCheck, "Title", wxDefaultPosition, wxDefaultSize);
|
m_pTitleCheck = new wxCheckBox(m_pPanel, SampleHive::ID::ET_TitleCheck, "Title", wxDefaultPosition, wxDefaultSize);
|
||||||
m_ArtistCheck = new wxCheckBox(m_Panel, ET_ArtistCheck, "Artist", wxDefaultPosition, wxDefaultSize);
|
m_pArtistCheck = new wxCheckBox(m_pPanel, SampleHive::ID::ET_ArtistCheck, "Artist", wxDefaultPosition, wxDefaultSize);
|
||||||
m_AlbumCheck = new wxCheckBox(m_Panel, ET_AlbumCheck, "Album", wxDefaultPosition, wxDefaultSize);
|
m_pAlbumCheck = new wxCheckBox(m_pPanel, SampleHive::ID::ET_AlbumCheck, "Album", wxDefaultPosition, wxDefaultSize);
|
||||||
m_GenreCheck = new wxCheckBox(m_Panel, ET_GenreCheck, "Genre", wxDefaultPosition, wxDefaultSize);
|
m_pGenreCheck = new wxCheckBox(m_pPanel, SampleHive::ID::ET_GenreCheck, "Genre", wxDefaultPosition, wxDefaultSize);
|
||||||
m_CommentCheck = new wxCheckBox(m_Panel, ET_CommentsCheck, "Comments", wxDefaultPosition, wxDefaultSize);
|
m_pCommentCheck = new wxCheckBox(m_pPanel, SampleHive::ID::ET_CommentsCheck, "Comments", wxDefaultPosition, wxDefaultSize);
|
||||||
m_SampleTypeCheck = new wxCheckBox(m_Panel, ET_TypeCheck, "Type", wxDefaultPosition, wxDefaultSize);
|
m_pSampleTypeCheck = new wxCheckBox(m_pPanel, SampleHive::ID::ET_TypeCheck, "Type", wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
m_TitleText = new wxTextCtrl(m_Panel, wxID_ANY, tags.GetAudioInfo().title, wxDefaultPosition, wxDefaultSize);
|
m_pTitleText = new wxTextCtrl(m_pPanel, wxID_ANY, tags.GetAudioInfo().title, wxDefaultPosition, wxDefaultSize);
|
||||||
m_TitleText->Disable();
|
m_pTitleText->Disable();
|
||||||
m_ArtistText = new wxTextCtrl(m_Panel, wxID_ANY, tags.GetAudioInfo().artist, wxDefaultPosition, wxDefaultSize);
|
m_pArtistText = new wxTextCtrl(m_pPanel, wxID_ANY, tags.GetAudioInfo().artist, wxDefaultPosition, wxDefaultSize);
|
||||||
m_ArtistText->Disable();
|
m_pArtistText->Disable();
|
||||||
m_AlbumText = new wxTextCtrl(m_Panel, wxID_ANY, tags.GetAudioInfo().album, wxDefaultPosition, wxDefaultSize);
|
m_pAlbumText = new wxTextCtrl(m_pPanel, wxID_ANY, tags.GetAudioInfo().album, wxDefaultPosition, wxDefaultSize);
|
||||||
m_AlbumText->Disable();
|
m_pAlbumText->Disable();
|
||||||
m_GenreText = new wxTextCtrl(m_Panel, wxID_ANY, tags.GetAudioInfo().genre, wxDefaultPosition, wxDefaultSize);
|
m_pGenreText = new wxTextCtrl(m_pPanel, wxID_ANY, tags.GetAudioInfo().genre, wxDefaultPosition, wxDefaultSize);
|
||||||
m_GenreText->Disable();
|
m_pGenreText->Disable();
|
||||||
m_CommentText = new wxTextCtrl(m_Panel, wxID_ANY, tags.GetAudioInfo().comment, wxDefaultPosition, wxDefaultSize);
|
m_pCommentText = new wxTextCtrl(m_pPanel, wxID_ANY, tags.GetAudioInfo().comment, wxDefaultPosition, wxDefaultSize);
|
||||||
m_CommentText->Disable();
|
m_pCommentText->Disable();
|
||||||
m_SampleTypeChoice = new wxChoice(m_Panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 10, choices, wxCB_SORT);
|
m_pSampleTypeChoice = new wxChoice(m_pPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 10, choices, wxCB_SORT);
|
||||||
m_SampleTypeChoice->Disable();
|
m_pSampleTypeChoice->Disable();
|
||||||
|
|
||||||
m_SampleTypeButton = new wxButton(m_Panel, ET_CustomTag, "Custom", wxDefaultPosition, wxDefaultSize);
|
m_pSampleTypeButton = new wxButton(m_pPanel, SampleHive::ID::ET_CustomTag, "Custom", wxDefaultPosition, wxDefaultSize);
|
||||||
m_SampleTypeButton->Disable();
|
m_pSampleTypeButton->Disable();
|
||||||
|
|
||||||
m_OkButton = new wxButton(m_Panel, wxID_OK, "OK", wxDefaultPosition, wxDefaultSize);
|
m_pOkButton = new wxButton(m_pPanel, wxID_OK, "OK", wxDefaultPosition, wxDefaultSize);
|
||||||
m_ApplyButton = new wxButton(m_Panel, wxID_APPLY, "Apply", wxDefaultPosition, wxDefaultSize);
|
m_pApplyButton = new wxButton(m_pPanel, wxID_APPLY, "Apply", wxDefaultPosition, wxDefaultSize);
|
||||||
m_CancelButton = new wxButton(m_Panel, wxID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize);
|
m_pCancelButton = new wxButton(m_pPanel, wxID_CANCEL, "Cancel", wxDefaultPosition, wxDefaultSize);
|
||||||
|
|
||||||
// Binding events
|
// Binding events
|
||||||
Bind(wxEVT_CHECKBOX, &TagEditor::OnCheckTitle, this, ET_TitleCheck);
|
Bind(wxEVT_CHECKBOX, &cTagEditor::OnCheckTitle, this, SampleHive::ID::ET_TitleCheck);
|
||||||
Bind(wxEVT_CHECKBOX, &TagEditor::OnCheckArtist, this, ET_ArtistCheck);
|
Bind(wxEVT_CHECKBOX, &cTagEditor::OnCheckArtist, this, SampleHive::ID::ET_ArtistCheck);
|
||||||
Bind(wxEVT_CHECKBOX, &TagEditor::OnCheckAlbum, this, ET_AlbumCheck);
|
Bind(wxEVT_CHECKBOX, &cTagEditor::OnCheckAlbum, this, SampleHive::ID::ET_AlbumCheck);
|
||||||
Bind(wxEVT_CHECKBOX, &TagEditor::OnCheckGenre, this, ET_GenreCheck);
|
Bind(wxEVT_CHECKBOX, &cTagEditor::OnCheckGenre, this, SampleHive::ID::ET_GenreCheck);
|
||||||
Bind(wxEVT_CHECKBOX, &TagEditor::OnCheckComments, this, ET_CommentsCheck);
|
Bind(wxEVT_CHECKBOX, &cTagEditor::OnCheckComments, this, SampleHive::ID::ET_CommentsCheck);
|
||||||
Bind(wxEVT_CHECKBOX, &TagEditor::OnCheckType, this, ET_TypeCheck);
|
Bind(wxEVT_CHECKBOX, &cTagEditor::OnCheckType, this, SampleHive::ID::ET_TypeCheck);
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &TagEditor::OnClickCustomTagButton, this, ET_CustomTag);
|
Bind(wxEVT_BUTTON, &cTagEditor::OnClickCustomTagButton, this, SampleHive::ID::ET_CustomTag);
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &TagEditor::OnClickApply, this, wxID_APPLY);
|
Bind(wxEVT_BUTTON, &cTagEditor::OnClickApply, this, wxID_APPLY);
|
||||||
|
|
||||||
m_EditTagSizer->Add(m_TitleCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pEditTagSizer->Add(m_pTitleCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_EditTagSizer->Add(m_TitleText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pEditTagSizer->Add(m_pTitleText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_EditTagSizer->Add(m_ArtistCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pEditTagSizer->Add(m_pArtistCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_EditTagSizer->Add(m_ArtistText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pEditTagSizer->Add(m_pArtistText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_EditTagSizer->Add(m_AlbumCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pEditTagSizer->Add(m_pAlbumCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_EditTagSizer->Add(m_AlbumText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pEditTagSizer->Add(m_pAlbumText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_EditTagSizer->Add(m_GenreCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pEditTagSizer->Add(m_pGenreCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_EditTagSizer->Add(m_GenreText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pEditTagSizer->Add(m_pGenreText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_EditTagSizer->Add(m_CommentCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pEditTagSizer->Add(m_pCommentCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_EditTagSizer->Add(m_CommentText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pEditTagSizer->Add(m_pCommentText, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_SampleTypeSizer->Add(m_SampleTypeCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pSampleTypeSizer->Add(m_pSampleTypeCheck, 0, wxALL | wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
m_SampleTypeSizer->Add(m_SampleTypeChoice, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
m_pSampleTypeSizer->Add(m_pSampleTypeChoice, 1, wxALL | wxALIGN_CENTER_VERTICAL | wxEXPAND, 2);
|
||||||
m_SampleTypeSizer->Add(m_SampleTypeButton, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 2);
|
m_pSampleTypeSizer->Add(m_pSampleTypeButton, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
m_StaticEditTagSizer->Add(m_EditTagSizer, 1, wxALL | wxEXPAND, 2);
|
m_pStaticEditTagSizer->Add(m_pEditTagSizer, 1, wxALL | wxEXPAND, 2);
|
||||||
m_StaticSampleTypeSizer->Add(m_SampleTypeSizer, 1, wxALL | wxEXPAND, 2);
|
m_pStaticSampleTypeSizer->Add(m_pSampleTypeSizer, 1, wxALL | wxEXPAND, 2);
|
||||||
|
|
||||||
m_ButtonSizer->Add(m_OkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_pButtonSizer->Add(m_pOkButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
m_ButtonSizer->Add(m_ApplyButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_pButtonSizer->Add(m_pApplyButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
m_ButtonSizer->Add(m_CancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
m_pButtonSizer->Add(m_pCancelButton, 0, wxALL | wxALIGN_BOTTOM, 2);
|
||||||
|
|
||||||
m_MainSizer->Add(m_StaticEditTagSizer, 1, wxALL | wxEXPAND, 2);
|
m_pMainSizer->Add(m_pStaticEditTagSizer, 1, wxALL | wxEXPAND, 2);
|
||||||
m_MainSizer->Add(m_StaticSampleTypeSizer, 1, wxALL | wxEXPAND, 2);
|
m_pMainSizer->Add(m_pStaticSampleTypeSizer, 1, wxALL | wxEXPAND, 2);
|
||||||
m_MainSizer->Add(m_ButtonSizer, 0, wxALL | wxALIGN_RIGHT, 2);
|
m_pMainSizer->Add(m_pButtonSizer, 0, wxALL | wxALIGN_RIGHT, 2);
|
||||||
|
|
||||||
// Top panel layout
|
// Top panel layout
|
||||||
m_Panel->SetSizer(m_MainSizer);
|
m_pPanel->SetSizer(m_pMainSizer);
|
||||||
m_MainSizer->Fit(m_Panel);
|
m_pMainSizer->Fit(m_pPanel);
|
||||||
m_MainSizer->SetSizeHints(m_Panel);
|
m_pMainSizer->SetSizeHints(m_pPanel);
|
||||||
m_MainSizer->Layout();
|
m_pMainSizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnCheckTitle(wxCommandEvent &event)
|
void cTagEditor::OnCheckTitle(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
if (m_TitleCheck->GetValue())
|
if (m_pTitleCheck->GetValue())
|
||||||
{
|
{
|
||||||
m_TitleText->Enable();
|
m_pTitleText->Enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_TitleText->Disable();
|
m_pTitleText->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnCheckArtist(wxCommandEvent &event)
|
void cTagEditor::OnCheckArtist(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
if (m_ArtistCheck->GetValue())
|
if (m_pArtistCheck->GetValue())
|
||||||
{
|
{
|
||||||
m_ArtistText->Enable();
|
m_pArtistText->Enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ArtistText->Disable();
|
m_pArtistText->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnCheckAlbum(wxCommandEvent &event)
|
void cTagEditor::OnCheckAlbum(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
if (m_AlbumCheck->GetValue())
|
if (m_pAlbumCheck->GetValue())
|
||||||
{
|
{
|
||||||
m_AlbumText->Enable();
|
m_pAlbumText->Enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_AlbumText->Disable();
|
m_pAlbumText->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnCheckGenre(wxCommandEvent &event)
|
void cTagEditor::OnCheckGenre(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
if (m_GenreCheck->GetValue())
|
if (m_pGenreCheck->GetValue())
|
||||||
{
|
{
|
||||||
m_GenreText->Enable();
|
m_pGenreText->Enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_GenreText->Disable();
|
m_pGenreText->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnCheckComments(wxCommandEvent &event)
|
void cTagEditor::OnCheckComments(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
if (m_CommentCheck->GetValue())
|
if (m_pCommentCheck->GetValue())
|
||||||
{
|
{
|
||||||
m_CommentText->Enable();
|
m_pCommentText->Enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_CommentText->Disable();
|
m_pCommentText->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnCheckType(wxCommandEvent &event)
|
void cTagEditor::OnCheckType(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
if (m_SampleTypeCheck->GetValue())
|
if (m_pSampleTypeCheck->GetValue())
|
||||||
{
|
{
|
||||||
m_SampleTypeChoice->Enable();
|
m_pSampleTypeChoice->Enable();
|
||||||
m_SampleTypeButton->Enable();
|
m_pSampleTypeButton->Enable();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_SampleTypeChoice->Disable();
|
m_pSampleTypeChoice->Disable();
|
||||||
m_SampleTypeButton->Disable();
|
m_pSampleTypeButton->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnClickCustomTagButton(wxCommandEvent& event)
|
void cTagEditor::OnClickCustomTagButton(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxTextEntryDialog* customTag;
|
wxTextEntryDialog* customTag;
|
||||||
customTag = new wxTextEntryDialog(this, "Enter a custom tag",
|
customTag = new wxTextEntryDialog(this, "Enter a custom tag",
|
||||||
|
|
@ -215,8 +216,8 @@ void TagEditor::OnClickCustomTagButton(wxCommandEvent& event)
|
||||||
case wxID_OK:
|
case wxID_OK:
|
||||||
{
|
{
|
||||||
wxString tag = customTag->GetValue();
|
wxString tag = customTag->GetValue();
|
||||||
m_SampleTypeChoice->AppendString(tag);
|
m_pSampleTypeChoice->AppendString(tag);
|
||||||
m_SampleTypeChoice->SetStringSelection(tag);
|
m_pSampleTypeChoice->SetStringSelection(tag);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxID_CANCEL:
|
case wxID_CANCEL:
|
||||||
|
|
@ -226,16 +227,16 @@ void TagEditor::OnClickCustomTagButton(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::OnClickApply(wxCommandEvent& event)
|
void cTagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Database db;
|
cDatabase db;
|
||||||
|
|
||||||
wxString title = m_TitleText->GetValue();
|
wxString title = m_pTitleText->GetValue();
|
||||||
wxString artist = m_ArtistText->GetValue();
|
wxString artist = m_pArtistText->GetValue();
|
||||||
wxString album = m_AlbumText->GetValue();
|
wxString album = m_pAlbumText->GetValue();
|
||||||
wxString genre = m_GenreText->GetValue();
|
wxString genre = m_pGenreText->GetValue();
|
||||||
wxString comment = m_CommentText->GetValue();
|
wxString comment = m_pCommentText->GetValue();
|
||||||
wxString type = m_SampleTypeChoice->GetStringSelection();
|
wxString type = m_pSampleTypeChoice->GetStringSelection();
|
||||||
|
|
||||||
std::string sampleType = db.GetSampleType(m_Filename);
|
std::string sampleType = db.GetSampleType(m_Filename);
|
||||||
|
|
||||||
|
|
@ -254,7 +255,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
switch (msgDialog->ShowModal())
|
switch (msgDialog->ShowModal())
|
||||||
{
|
{
|
||||||
case wxID_YES:
|
case wxID_YES:
|
||||||
if (m_TitleCheck->GetValue() && m_TitleText->GetValue() != tags.GetAudioInfo().title)
|
if (m_pTitleCheck->GetValue() && m_pTitleText->GetValue() != tags.GetAudioInfo().title)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Changing title tag..");
|
SH_LOG_INFO("Changing title tag..");
|
||||||
tags.SetTitle(title.ToStdString());
|
tags.SetTitle(title.ToStdString());
|
||||||
|
|
@ -262,7 +263,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = wxString::Format("Successfully changed title tag to %s", title);
|
info_msg = wxString::Format("Successfully changed title tag to %s", title);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ArtistCheck->GetValue() && m_ArtistText->GetValue() != tags.GetAudioInfo().artist)
|
if (m_pArtistCheck->GetValue() && m_pArtistText->GetValue() != tags.GetAudioInfo().artist)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Changing artist tag..");
|
SH_LOG_INFO("Changing artist tag..");
|
||||||
tags.SetArtist(artist.ToStdString());
|
tags.SetArtist(artist.ToStdString());
|
||||||
|
|
@ -274,7 +275,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = wxString::Format("Successfully changed artist tag to %s", artist);
|
info_msg = wxString::Format("Successfully changed artist tag to %s", artist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_AlbumCheck->GetValue() && m_AlbumText->GetValue() != tags.GetAudioInfo().album)
|
if (m_pAlbumCheck->GetValue() && m_pAlbumText->GetValue() != tags.GetAudioInfo().album)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Changing album tag..");
|
SH_LOG_INFO("Changing album tag..");
|
||||||
tags.SetAlbum(album.ToStdString());
|
tags.SetAlbum(album.ToStdString());
|
||||||
|
|
@ -282,7 +283,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = wxString::Format("Successfully changed album tag to %s", album);
|
info_msg = wxString::Format("Successfully changed album tag to %s", album);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_GenreCheck->GetValue() && m_GenreText->GetValue() != tags.GetAudioInfo().genre)
|
if (m_pGenreCheck->GetValue() && m_pGenreText->GetValue() != tags.GetAudioInfo().genre)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Changing genre tag..");
|
SH_LOG_INFO("Changing genre tag..");
|
||||||
tags.SetGenre(genre.ToStdString());
|
tags.SetGenre(genre.ToStdString());
|
||||||
|
|
@ -290,7 +291,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = wxString::Format("Successfully changed genre tag to %s", genre);
|
info_msg = wxString::Format("Successfully changed genre tag to %s", genre);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_CommentCheck->GetValue() && m_CommentText->GetValue() != tags.GetAudioInfo().comment)
|
if (m_pCommentCheck->GetValue() && m_pCommentText->GetValue() != tags.GetAudioInfo().comment)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Changing comment tag..");
|
SH_LOG_INFO("Changing comment tag..");
|
||||||
tags.SetComment(comment.ToStdString());
|
tags.SetComment(comment.ToStdString());
|
||||||
|
|
@ -298,7 +299,7 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = wxString::Format("Successfully changed comment tag to %s", comment);
|
info_msg = wxString::Format("Successfully changed comment tag to %s", comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_SampleTypeCheck->GetValue() && m_SampleTypeChoice->GetStringSelection() != sampleType)
|
if (m_pSampleTypeCheck->GetValue() && m_pSampleTypeChoice->GetStringSelection() != sampleType)
|
||||||
{
|
{
|
||||||
SH_LOG_INFO("Changing type tag..");
|
SH_LOG_INFO("Changing type tag..");
|
||||||
db.UpdateSampleType(filename, type.ToStdString());
|
db.UpdateSampleType(filename, type.ToStdString());
|
||||||
|
|
@ -312,22 +313,22 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = "Error, cannot change tag!";
|
info_msg = "Error, cannot change tag!";
|
||||||
}
|
}
|
||||||
|
|
||||||
SendInfoBarMessage(info_msg, wxICON_INFORMATION);
|
SampleHive::cSignal::SendInfoBarMessage(info_msg, wxICON_INFORMATION, *this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::SendInfoBarMessage(const wxString& msg, int mode)
|
// void cTagEditor::SendInfoBarMessage(const wxString& msg, int mode)
|
||||||
{
|
// {
|
||||||
SH_LOG_INFO("{} called..", __FUNCTION__);
|
// SH_LOG_INFO("{} called..", __FUNCTION__);
|
||||||
|
|
||||||
SampleHive::SH_InfoBarMessageEvent event(SampleHive::SH_EVT_INFOBAR_MESSAGE_SHOW, this->GetId());
|
// SampleHive::SH_InfoBarMessageEvent event(SampleHive::SH_EVT_INFOBAR_MESSAGE_SHOW, this->GetId());
|
||||||
event.SetEventObject(this);
|
// event.SetEventObject(this);
|
||||||
|
|
||||||
event.SetInfoBarMessage({ msg, mode });
|
// event.SetInfoBarMessage({ msg, mode });
|
||||||
|
|
||||||
GetParent()->GetEventHandler()->ProcessEvent(event);
|
// GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
}
|
// }
|
||||||
|
|
||||||
TagEditor::~TagEditor()
|
cTagEditor::~cTagEditor()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,58 +36,11 @@
|
||||||
#include <wx/toplevel.h>
|
#include <wx/toplevel.h>
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
class TagEditor : public wxDialog
|
class cTagEditor : public wxDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TagEditor(wxWindow* window, const std::string& filename);
|
cTagEditor(wxWindow* window, const std::string& filename);
|
||||||
~TagEditor();
|
~cTagEditor();
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
wxWindow* m_Window;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
const std::string m_Filename;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Top panel for wxDialog
|
|
||||||
wxPanel* m_Panel;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Top panel sizers
|
|
||||||
wxBoxSizer* m_MainSizer;
|
|
||||||
wxFlexGridSizer* m_EditTagSizer;
|
|
||||||
wxFlexGridSizer* m_SampleTypeSizer;
|
|
||||||
wxBoxSizer* m_ButtonSizer;
|
|
||||||
wxStaticBoxSizer* m_StaticEditTagSizer;
|
|
||||||
wxStaticBoxSizer* m_StaticSampleTypeSizer;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Dialog controls
|
|
||||||
wxCheckBox* m_TitleCheck;
|
|
||||||
wxCheckBox* m_ArtistCheck;
|
|
||||||
wxCheckBox* m_AlbumCheck;
|
|
||||||
wxCheckBox* m_GenreCheck;
|
|
||||||
wxCheckBox* m_CommentCheck;
|
|
||||||
wxCheckBox* m_SampleTypeCheck;
|
|
||||||
wxTextCtrl* m_TitleText;
|
|
||||||
wxTextCtrl* m_ArtistText;
|
|
||||||
wxTextCtrl* m_AlbumText;
|
|
||||||
wxTextCtrl* m_GenreText;
|
|
||||||
wxTextCtrl* m_CommentText;
|
|
||||||
wxChoice* m_SampleTypeChoice;
|
|
||||||
wxButton* m_SampleTypeButton;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Common buttons for wxDialog
|
|
||||||
wxButton* m_OkButton;
|
|
||||||
wxButton* m_ApplyButton;
|
|
||||||
wxButton* m_CancelButton;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
Tags tags;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -105,6 +58,50 @@ class TagEditor : public wxDialog
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void OnClickApply(wxCommandEvent& event);
|
void OnClickApply(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void SendInfoBarMessage(const wxString& msg, int mode);
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
const std::string& m_Filename;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Top panel for wxDialog
|
||||||
|
wxPanel* m_pPanel = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Top panel sizers
|
||||||
|
wxBoxSizer* m_pMainSizer = nullptr;
|
||||||
|
wxFlexGridSizer* m_pEditTagSizer = nullptr;
|
||||||
|
wxFlexGridSizer* m_pSampleTypeSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pButtonSizer = nullptr;
|
||||||
|
wxStaticBoxSizer* m_pStaticEditTagSizer = nullptr;
|
||||||
|
wxStaticBoxSizer* m_pStaticSampleTypeSizer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Dialog controls
|
||||||
|
wxCheckBox* m_pTitleCheck = nullptr;
|
||||||
|
wxCheckBox* m_pArtistCheck = nullptr;
|
||||||
|
wxCheckBox* m_pAlbumCheck = nullptr;
|
||||||
|
wxCheckBox* m_pGenreCheck = nullptr;
|
||||||
|
wxCheckBox* m_pCommentCheck = nullptr;
|
||||||
|
wxCheckBox* m_pSampleTypeCheck = nullptr;
|
||||||
|
wxTextCtrl* m_pTitleText = nullptr;
|
||||||
|
wxTextCtrl* m_pArtistText = nullptr;
|
||||||
|
wxTextCtrl* m_pAlbumText = nullptr;
|
||||||
|
wxTextCtrl* m_pGenreText = nullptr;
|
||||||
|
wxTextCtrl* m_pCommentText = nullptr;
|
||||||
|
wxChoice* m_pSampleTypeChoice = nullptr;
|
||||||
|
wxButton* m_pSampleTypeButton = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Common buttons for wxDialog
|
||||||
|
wxButton* m_pOkButton = nullptr;
|
||||||
|
wxButton* m_pApplyButton = nullptr;
|
||||||
|
wxButton* m_pCancelButton = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
SampleHive::cTags tags;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/DirectoryBrowser.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Utils.hpp"
|
||||||
|
|
||||||
|
#include <wx/dataobj.h>
|
||||||
|
#include <wx/dnd.h>
|
||||||
|
|
||||||
|
cDirectoryBrowser::cDirectoryBrowser(wxWindow* window)
|
||||||
|
: wxGenericDirCtrl(window, SampleHive::ID::BC_DirCtrl, wxDirDialogDefaultFolderStr, wxDefaultPosition,
|
||||||
|
wxDefaultSize, wxDIRCTRL_SHOW_FILTERS,
|
||||||
|
_("All files|*|Ogg files (*.ogg)|*.ogg|Wav files (*.wav)|*.wav|"
|
||||||
|
"Flac files (*.flac)|*.flac"), 0),
|
||||||
|
m_pWindow(window)
|
||||||
|
{
|
||||||
|
SetPath(USER_HOME_DIR);
|
||||||
|
|
||||||
|
Bind(wxEVT_DIRCTRL_FILEACTIVATED, &cDirectoryBrowser::OnClickDirCtrl, this, SampleHive::ID::BC_DirCtrl);
|
||||||
|
Bind(wxEVT_TREE_BEGIN_DRAG, &cDirectoryBrowser::OnDragFromDirCtrl, this, this->GetTreeCtrl()->GetId());
|
||||||
|
}
|
||||||
|
|
||||||
|
void cDirectoryBrowser::OnClickDirCtrl(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
wxArrayString path;
|
||||||
|
path.push_back(this->GetFilePath());
|
||||||
|
|
||||||
|
SampleHive::cUtils::Get().AddSamples(path, m_pWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporary function to check drag and drop result
|
||||||
|
void LogDragResult(wxDragResult result)
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
switch (result)
|
||||||
|
{
|
||||||
|
case wxDragError: msg = "Error!"; break;
|
||||||
|
case wxDragNone: msg = "Nothing"; break;
|
||||||
|
case wxDragCopy: msg = "Copied"; break;
|
||||||
|
case wxDragMove: msg = "Moved"; break;
|
||||||
|
case wxDragCancel: msg = "Cancelled"; break;
|
||||||
|
default: msg = "Huh?"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("Drag result: {}", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cDirectoryBrowser::OnDragFromDirCtrl(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
file_data.AddFile(this->GetPath(event.GetItem()));
|
||||||
|
|
||||||
|
wxDropSource drop_source(this);
|
||||||
|
drop_source.SetData(file_data);
|
||||||
|
|
||||||
|
LogDragResult(drop_source.DoDragDrop());
|
||||||
|
}
|
||||||
|
|
||||||
|
cDirectoryBrowser::~cDirectoryBrowser()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/control.h>
|
||||||
|
#include <wx/dirctrl.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cDirectoryBrowser : public wxGenericDirCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cDirectoryBrowser(wxWindow* window);
|
||||||
|
~cDirectoryBrowser();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// DirCtrl event handlers
|
||||||
|
void OnClickDirCtrl(wxCommandEvent& event);
|
||||||
|
void OnDragFromDirCtrl(wxTreeEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,736 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/Hives.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
#include <wx/textdlg.h>
|
||||||
|
#include <wx/menu.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
cHivesPanel::cHivesPanel(wxWindow* window)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
|
||||||
|
m_pWindow(window)
|
||||||
|
{
|
||||||
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pHivesSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
m_pAddHiveButton = new wxButton(this, SampleHive::ID::BC_HiveAdd, "+", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pAddHiveButton->SetToolTip(_("Create new hive"));
|
||||||
|
|
||||||
|
m_pButtonSizer->Add(m_pAddHiveButton, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
m_pRemoveHiveButton = new wxButton(this, SampleHive::ID::BC_HiveRemove, "-", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pRemoveHiveButton->SetToolTip(_("Delete selected hive"));
|
||||||
|
|
||||||
|
m_pButtonSizer->Add(m_pRemoveHiveButton, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
// Initializing wxDataViewTreeCtrl as another page of wxNotebook
|
||||||
|
m_pHives = new wxDataViewTreeCtrl(this, SampleHive::ID::BC_Hives, wxDefaultPosition, wxDefaultSize, wxDV_NO_HEADER | wxDV_SINGLE);
|
||||||
|
|
||||||
|
m_pHivesSizer->Add(m_pHives, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
// Adding default hive
|
||||||
|
m_FavoritesHive = m_pHives->AppendContainer(wxDataViewItem(wxNullPtr), _("Favorites"));
|
||||||
|
|
||||||
|
// Setting m_Hives to accept files to be dragged and dropped on it
|
||||||
|
m_pHives->DragAcceptFiles(true);
|
||||||
|
|
||||||
|
m_pHives->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(cHivesPanel::OnDragAndDropToHives), NULL, this);
|
||||||
|
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &cHivesPanel::OnShowHivesContextMenu, this, SampleHive::ID::BC_Hives);
|
||||||
|
Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, &cHivesPanel::OnHiveStartEditing, this, SampleHive::ID::BC_Hives);
|
||||||
|
Bind(wxEVT_BUTTON, &cHivesPanel::OnClickAddHive, this, SampleHive::ID::BC_HiveAdd);
|
||||||
|
Bind(wxEVT_BUTTON, &cHivesPanel::OnClickRemoveHive, this, SampleHive::ID::BC_HiveRemove);
|
||||||
|
|
||||||
|
m_pMainSizer->Add(m_pHivesSizer, wxSizerFlags(1).Expand());
|
||||||
|
m_pMainSizer->Add(m_pButtonSizer, wxSizerFlags(0).Expand());
|
||||||
|
|
||||||
|
// Sizer for Hives page for wxNotebook
|
||||||
|
this->SetSizer(m_pMainSizer);
|
||||||
|
m_pMainSizer->Fit(this);
|
||||||
|
m_pMainSizer->SetSizeHints(this);
|
||||||
|
m_pMainSizer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnDragAndDropToHives(wxDropFilesEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
if (event.GetNumberOfFiles() > 0)
|
||||||
|
{
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
wxDataViewItemArray items;
|
||||||
|
int rows = SampleHive::cHiveData::Get().GetListCtrlSelections(items);
|
||||||
|
|
||||||
|
wxDataViewItem drop_target;;
|
||||||
|
wxDataViewColumn* column;
|
||||||
|
wxPoint position = event.GetPosition();
|
||||||
|
|
||||||
|
m_pHives->HitTest(position, drop_target, column);
|
||||||
|
|
||||||
|
wxString hive_name = m_pHives->GetItemText(drop_target);
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
int row = SampleHive::cHiveData::Get().GetListCtrlRowFromItem(items, i);
|
||||||
|
|
||||||
|
wxString name = SampleHive::cHiveData::Get().GetListCtrlTextValue(row, 1);
|
||||||
|
|
||||||
|
file_data.AddFile(name);
|
||||||
|
|
||||||
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
|
wxString file_name = serializer.DeserializeShowFileExtension() ?
|
||||||
|
files[i].BeforeLast('.') : files[i];
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("Dropping {} file(s) {} on {}", rows - i, files[i], m_pHives->GetItemText(drop_target));
|
||||||
|
|
||||||
|
if (drop_target.IsOk() && m_pHives->IsContainer(drop_target) &&
|
||||||
|
db.GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 0)
|
||||||
|
{
|
||||||
|
m_pHives->AppendItem(drop_target, files[i]);
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlSetVariant(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(file_name.ToStdString(), 1);
|
||||||
|
db.UpdateHiveName(file_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s added to %s."), files[i], hive_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(file_name.ToStdString()) == 1)
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("%s is already added to %s hive"), files[i],
|
||||||
|
db.GetHiveByFilename(file_name.ToStdString())),
|
||||||
|
_("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_pHives->GetItemText(drop_target) == "")
|
||||||
|
wxMessageBox(_("Cannot drop item outside of a hive, try dropping on a hive."),
|
||||||
|
_("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
else
|
||||||
|
wxMessageBox(wxString::Format(_("%s is not a hive, try dropping on a hive."),
|
||||||
|
m_pHives->GetItemText(drop_target)), _("Error!"),
|
||||||
|
wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_ERROR, *this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxDataViewItem selected_hive = event.GetItem();
|
||||||
|
|
||||||
|
wxString hive_name = m_pHives->GetItemText(selected_hive);
|
||||||
|
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
if (m_pHives->IsContainer(selected_hive))
|
||||||
|
{
|
||||||
|
// Container menu items
|
||||||
|
menu.Append(SampleHive::ID::MN_RenameHive, _("Rename hive"), _("Rename selected hive"));
|
||||||
|
menu.Append(SampleHive::ID::MN_DeleteHive, _("Delete hive"), _("Delete selected hive"));
|
||||||
|
|
||||||
|
if (!m_bFiltered)
|
||||||
|
menu.Append(SampleHive::ID::MN_FilterLibrary, _("Filter library"), _("Show only samples from current hive in library"));
|
||||||
|
else
|
||||||
|
menu.Append(SampleHive::ID::MN_FilterLibrary, _("Clear filter"), _("Clear the filter"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Child menu items
|
||||||
|
menu.Append(SampleHive::ID::MN_RemoveSample, _("Remove sample"), _("Remove the selected sample(s)"));
|
||||||
|
menu.Append(SampleHive::ID::MN_ShowInLibrary, _("Show sample in library"), _("Show the selected in library"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected_hive.IsOk() && m_pHives->IsContainer(selected_hive))
|
||||||
|
{
|
||||||
|
switch (m_pHives->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
|
{
|
||||||
|
case SampleHive::ID::MN_RenameHive:
|
||||||
|
{
|
||||||
|
std::deque<wxDataViewItem> nodes;
|
||||||
|
nodes.push_back(m_pHives->GetNthChild(wxDataViewItem(wxNullPtr), 0));
|
||||||
|
|
||||||
|
wxDataViewItem current_item, found_item;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
int hive_count = m_pHives->GetChildCount(wxDataViewItem(wxNullPtr));
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxTextEntryDialog renameEntry(this, _("Enter new name"), wxGetTextFromUserPromptStr,
|
||||||
|
wxEmptyString, wxTextEntryDialogStyle, wxDefaultPosition);
|
||||||
|
|
||||||
|
renameEntry.SetTextValidator(wxFILTER_EMPTY);
|
||||||
|
|
||||||
|
switch (renameEntry.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_OK:
|
||||||
|
{
|
||||||
|
wxString hive_name = renameEntry.GetValue();
|
||||||
|
|
||||||
|
while(!nodes.empty())
|
||||||
|
{
|
||||||
|
current_item = nodes.front();
|
||||||
|
nodes.pop_front();
|
||||||
|
|
||||||
|
if (m_pHives->GetItemText(current_item) == hive_name)
|
||||||
|
{
|
||||||
|
found_item = current_item;
|
||||||
|
SH_LOG_DEBUG("Found item: {}", m_pHives->GetItemText(current_item));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDataViewItem child = m_pHives->GetNthChild(wxDataViewItem(wxNullPtr), 0);
|
||||||
|
|
||||||
|
while (row < (hive_count - 1))
|
||||||
|
{
|
||||||
|
row ++;
|
||||||
|
|
||||||
|
child = m_pHives->GetNthChild(wxDataViewItem(wxNullPtr), row);
|
||||||
|
nodes.push_back(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes.clear();
|
||||||
|
|
||||||
|
if (found_item.IsOk())
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Another hive by the name %s already exist. "
|
||||||
|
"Please try with a different name."), hive_name),
|
||||||
|
_("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString selected_hive_name = m_pHives->GetItemText(selected_hive);
|
||||||
|
|
||||||
|
int sample_count = m_pHives->GetChildCount(selected_hive);
|
||||||
|
|
||||||
|
if (sample_count <= 0)
|
||||||
|
{
|
||||||
|
m_pHives->SetItemText(selected_hive, hive_name);
|
||||||
|
db.UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < sample_count; i++)
|
||||||
|
{
|
||||||
|
wxDataViewItem sample_item = m_pHives->GetNthChild(selected_hive, i);
|
||||||
|
|
||||||
|
wxString sample_name = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_pHives->GetItemText(sample_item).BeforeLast('.') :
|
||||||
|
m_pHives->GetItemText(sample_item);
|
||||||
|
|
||||||
|
db.UpdateHiveName(sample_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
db.UpdateHive(selected_hive_name.ToStdString(), hive_name.ToStdString());
|
||||||
|
|
||||||
|
m_pHives->SetItemText(selected_hive, hive_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Successfully changed hive name to %s."), hive_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_CANCEL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_DeleteHive:
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format(_("Are you sure you want to delete %s from hives?"),
|
||||||
|
hive_name),
|
||||||
|
wxMessageBoxCaptionStr,
|
||||||
|
wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP);
|
||||||
|
|
||||||
|
wxMessageDialog deleteFilledHiveDialog(this, wxString::Format(_("Are you sure you want to delete %s and all samples "
|
||||||
|
"inside %s from hives?"), hive_name, hive_name),
|
||||||
|
wxMessageBoxCaptionStr,
|
||||||
|
wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP);
|
||||||
|
|
||||||
|
if (hive_name == m_pHives->GetItemText(m_FavoritesHive))
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Error! Default hive %s cannot be deleted."), hive_name),
|
||||||
|
_("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!selected_hive.IsOk())
|
||||||
|
{
|
||||||
|
wxMessageBox(_("No hive selected, try selecting a hive first"), _("Error!"),
|
||||||
|
wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (selected_hive.IsOk() && !m_pHives->IsContainer(selected_hive))
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Error! %s is not a hive, cannot delete from hives."), hive_name),
|
||||||
|
_("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pHives->GetChildCount(selected_hive) <= 0)
|
||||||
|
{
|
||||||
|
switch (deleteEmptyHiveDialog.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_YES:
|
||||||
|
if (selected_hive.IsOk() && m_pHives->IsContainer(selected_hive) &&
|
||||||
|
hive_name != m_pHives->GetItemText(m_FavoritesHive))
|
||||||
|
{
|
||||||
|
m_pHives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
|
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s deleted from hives successfully."), hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (deleteFilledHiveDialog.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_YES:
|
||||||
|
if (selected_hive.IsOk() && m_pHives->IsContainer(selected_hive) &&
|
||||||
|
hive_name != m_pHives->GetItemText(m_FavoritesHive))
|
||||||
|
{
|
||||||
|
wxDataViewItem child_item;
|
||||||
|
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetListCtrlItemCount(); i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1);
|
||||||
|
|
||||||
|
for (int j = 0; j < m_pHives->GetChildCount(selected_hive); j++)
|
||||||
|
{
|
||||||
|
child_item = m_pHives->GetNthChild(selected_hive, j);
|
||||||
|
|
||||||
|
wxString child_name =
|
||||||
|
serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_pHives->GetItemText(child_item).BeforeLast('.') :
|
||||||
|
m_pHives->GetItemText(child_item);
|
||||||
|
|
||||||
|
if (child_name == matched_sample)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlSetVariant(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)),
|
||||||
|
i, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
|
db.UpdateHiveName(matched_sample.ToStdString(),
|
||||||
|
m_pHives->GetItemText(m_FavoritesHive).ToStdString());
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SH_LOG_DEBUG("No match found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pHives->DeleteChildren(selected_hive);
|
||||||
|
m_pHives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
|
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s and all samples inside %s have been deleted from hives successfully."),
|
||||||
|
hive_name, hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_FilterLibrary:
|
||||||
|
{
|
||||||
|
if (!m_bFiltered)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto dataset = db.FilterDatabaseByHiveName(hive_name.ToStdString(),
|
||||||
|
serializer.DeserializeShowFileExtension(),
|
||||||
|
ICON_STAR_FILLED_16px,
|
||||||
|
ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
|
if (dataset.empty())
|
||||||
|
{
|
||||||
|
wxMessageBox(_("Error! Database is empty."), _("Error!"),
|
||||||
|
wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlDeleteAllItems();
|
||||||
|
|
||||||
|
for (auto data : dataset)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Error loading data, cannot filter sample view. Error: %s"), e.what()),
|
||||||
|
_("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bFiltered = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto dataset = db.FilterDatabaseBySampleName("", serializer.DeserializeShowFileExtension(),
|
||||||
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
|
if (dataset.empty())
|
||||||
|
{
|
||||||
|
wxMessageBox(_("Error! Database is empty."), _("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlDeleteAllItems();
|
||||||
|
|
||||||
|
for (auto data : dataset)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Error loading data, cannot filter sample view. Error: %s"), e.what()),
|
||||||
|
_("Error!"), wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bFiltered = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (selected_hive.IsOk() && !m_pHives->IsContainer(selected_hive))
|
||||||
|
{
|
||||||
|
switch (m_pHives->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
|
{
|
||||||
|
case SampleHive::ID::MN_RemoveSample:
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetListCtrlItemCount(); i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1);
|
||||||
|
|
||||||
|
wxString selected_sample_name = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_pHives->GetItemText(event.GetItem()).BeforeLast('.') :
|
||||||
|
m_pHives->GetItemText(event.GetItem());
|
||||||
|
|
||||||
|
if (selected_sample_name == matched_sample)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlSetVariant(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
|
db.UpdateHiveName(matched_sample.ToStdString(), m_pHives->GetItemText(m_FavoritesHive).ToStdString());
|
||||||
|
|
||||||
|
m_pHives->DeleteItem(selected_hive);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString msg = wxString::Format(_("Removed %s from %s"), m_pHives->GetItemText(event.GetItem()),
|
||||||
|
db.GetHiveByFilename(matched_sample.ToStdString()));
|
||||||
|
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ShowInLibrary:
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetListCtrlItemCount(); i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1);
|
||||||
|
|
||||||
|
wxString selected_sample_name = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_pHives->GetItemText(event.GetItem()).BeforeLast('.') :
|
||||||
|
m_pHives->GetItemText(event.GetItem());
|
||||||
|
|
||||||
|
if (selected_sample_name == matched_sample)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
wxDataViewItem matched_item = SampleHive::cHiveData::Get().GetListCtrlItemFromRow(i);
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlUnselectAllItems();
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlSelectRow(i);
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlEnsureVisible(matched_item);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnHiveStartEditing(wxDataViewEvent &event)
|
||||||
|
{
|
||||||
|
SH_LOG_INFO("Right click on a hive and select rename to rename it..");
|
||||||
|
event.Veto();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnClickAddHive(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
std::deque<wxDataViewItem> nodes;
|
||||||
|
nodes.push_back(m_pHives->GetNthChild(wxDataViewItem(wxNullPtr), 0));
|
||||||
|
|
||||||
|
wxDataViewItem current_item, found_item;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
int hive_count = m_pHives->GetChildCount(wxDataViewItem(wxNullPtr));
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxTextEntryDialog hiveEntry(this, _("Enter hive name"), _("Create new hive"), wxEmptyString,
|
||||||
|
wxTextEntryDialogStyle, wxDefaultPosition);
|
||||||
|
|
||||||
|
hiveEntry.SetTextValidator(wxFILTER_EMPTY);
|
||||||
|
|
||||||
|
switch (hiveEntry.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_OK:
|
||||||
|
{
|
||||||
|
wxString hive_name = hiveEntry.GetValue();
|
||||||
|
|
||||||
|
while (!nodes.empty())
|
||||||
|
{
|
||||||
|
current_item = nodes.front();
|
||||||
|
nodes.pop_front();
|
||||||
|
|
||||||
|
if (m_pHives->GetItemText(current_item) == hive_name)
|
||||||
|
{
|
||||||
|
found_item = current_item;
|
||||||
|
SH_LOG_DEBUG("Found item: {}", m_pHives->GetItemText(current_item));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDataViewItem child = m_pHives->GetNthChild(wxDataViewItem(wxNullPtr), 0);
|
||||||
|
|
||||||
|
while (row < (hive_count - 1))
|
||||||
|
{
|
||||||
|
row ++;
|
||||||
|
|
||||||
|
child = m_pHives->GetNthChild(wxDataViewItem(wxNullPtr), row);
|
||||||
|
nodes.push_back(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes.clear();
|
||||||
|
|
||||||
|
if (found_item.IsOk())
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Another hive by the name %s already exist. Please try with a different name."),
|
||||||
|
hive_name), _("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pHives->AppendContainer(wxDataViewItem(wxNullPtr), hive_name);
|
||||||
|
db.InsertIntoHives(hive_name.ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s added to Hives."), hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case wxID_CANCEL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxDataViewItem selected_item = m_pHives->GetSelection();
|
||||||
|
wxString hive_name = m_pHives->GetItemText(selected_item);
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format(_("Are you sure you want to delete %s from hives?"), hive_name),
|
||||||
|
wxMessageBoxCaptionStr, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP);
|
||||||
|
|
||||||
|
wxMessageDialog deleteFilledHiveDialog(this, wxString::Format(_("Are you sure you want to delete "
|
||||||
|
"%s and all sample inside %s from hives?"), hive_name, hive_name),
|
||||||
|
wxMessageBoxCaptionStr, wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP);
|
||||||
|
|
||||||
|
if (hive_name == m_pHives->GetItemText(m_FavoritesHive))
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Error! Default hive %s cannot be deleted."), hive_name), _("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!selected_item.IsOk())
|
||||||
|
{
|
||||||
|
wxMessageBox(_("No hive selected, try selecting a hive first"), _("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (selected_item.IsOk() && !m_pHives->IsContainer(selected_item))
|
||||||
|
{
|
||||||
|
wxMessageBox(wxString::Format(_("Error! %s is not a hive, cannot delete from hives."), hive_name),
|
||||||
|
_("Error!"), wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_pHives->GetChildCount(selected_item) <= 0)
|
||||||
|
{
|
||||||
|
switch (deleteEmptyHiveDialog.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_YES:
|
||||||
|
if (selected_item.IsOk() && m_pHives->IsContainer(selected_item) &&
|
||||||
|
hive_name != m_pHives->GetItemText(m_FavoritesHive))
|
||||||
|
{
|
||||||
|
m_pHives->DeleteItem(selected_item);
|
||||||
|
|
||||||
|
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
msg = wxString::Format(_("%s deleted from hives successfully."), hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (deleteFilledHiveDialog.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_YES:
|
||||||
|
if (selected_item.IsOk() && m_pHives->IsContainer(selected_item) &&
|
||||||
|
hive_name != m_pHives->GetItemText(m_FavoritesHive))
|
||||||
|
{
|
||||||
|
wxDataViewItem child_item;
|
||||||
|
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetListCtrlItemCount(); i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(i, 1);
|
||||||
|
|
||||||
|
for (int j = 0; j < m_pHives->GetChildCount(selected_item); j++)
|
||||||
|
{
|
||||||
|
child_item = m_pHives->GetNthChild(selected_item, j);
|
||||||
|
|
||||||
|
wxString child_name = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_pHives->GetItemText(child_item).BeforeLast('.') :
|
||||||
|
m_pHives->GetItemText(child_item);
|
||||||
|
|
||||||
|
if (child_name == matched_sample)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlSetVariant(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), i, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(matched_sample.ToStdString(), 0);
|
||||||
|
db.UpdateHiveName(matched_sample.ToStdString(), m_pHives->GetItemText(m_FavoritesHive).ToStdString());
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SH_LOG_DEBUG("No match found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pHives->DeleteChildren(selected_item);
|
||||||
|
m_pHives->DeleteItem(selected_item);
|
||||||
|
|
||||||
|
db.RemoveHiveFromDatabase(hive_name.ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s and all samples inside %s have been deleted from hives successfully."),
|
||||||
|
hive_name, hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
cHivesPanel::~cHivesPanel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cHivesPanel : public wxPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cHivesPanel(wxWindow* window);
|
||||||
|
~cHivesPanel();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxDataViewTreeCtrl* GetHivesObject() { return m_pHives; }
|
||||||
|
wxDataViewItem& GetFavoritesHive() { return m_FavoritesHive; }
|
||||||
|
|
||||||
|
bool IsLibraryFiltered() { return m_bFiltered; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Hives panel button event handlers
|
||||||
|
void OnDragAndDropToHives(wxDropFilesEvent& event);
|
||||||
|
void OnClickAddHive(wxCommandEvent& event);
|
||||||
|
void OnClickRemoveHive(wxCommandEvent& event);
|
||||||
|
void OnShowHivesContextMenu(wxDataViewEvent& event);
|
||||||
|
void OnHiveStartEditing(wxDataViewEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxDataViewItem m_FavoritesHive;
|
||||||
|
|
||||||
|
wxDataViewTreeCtrl* m_pHives = nullptr;
|
||||||
|
wxButton* m_pAddHiveButton = nullptr;
|
||||||
|
wxButton* m_pRemoveHiveButton = nullptr;
|
||||||
|
wxBoxSizer* m_pMainSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pHivesSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pButtonSizer = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
bool m_bFiltered = false;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "InfoBar.hpp"
|
||||||
|
|
||||||
|
cInfoBar::cInfoBar(wxWindow* window)
|
||||||
|
: wxInfoBar(window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cInfoBar::~cInfoBar()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/infobar.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cInfoBar : public wxInfoBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cInfoBar(wxWindow* window);
|
||||||
|
~cInfoBar();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxInfoBar* GetInfoBarObject() { return this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxWindow* m_pWindow;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/Library.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
|
||||||
|
cLibrary::cLibrary(wxWindow* window)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
|
||||||
|
{
|
||||||
|
m_pSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
m_pSearchBar = new cSearchBar(this);
|
||||||
|
m_pInfoBar = new cInfoBar(this);
|
||||||
|
m_pListCtrl = new cListCtrl(this);
|
||||||
|
|
||||||
|
m_pSizer->Add(m_pSearchBar, wxSizerFlags(1).Expand());
|
||||||
|
m_pSizer->Add(m_pInfoBar, wxSizerFlags(0).Expand());
|
||||||
|
m_pSizer->Add(m_pListCtrl, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
// Sizer for bottom right panel
|
||||||
|
this->SetSizer(m_pSizer);
|
||||||
|
m_pSizer->Fit(this);
|
||||||
|
m_pSizer->SetSizeHints(this);
|
||||||
|
m_pSizer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
cLibrary::~cLibrary()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GUI/InfoBar.hpp"
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
#include "GUI/SearchBar.hpp"
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cLibrary : public wxPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cLibrary(wxWindow* window);
|
||||||
|
~cLibrary();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxSearchCtrl* GetSearchCtrlObject() const { return m_pSearchBar; }
|
||||||
|
wxInfoBar* GetInfoBarObject() const { return m_pInfoBar; }
|
||||||
|
wxDataViewListCtrl* GetListCtrlObject() const { return m_pListCtrl; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
cSearchBar* m_pSearchBar = nullptr;
|
||||||
|
cInfoBar* m_pInfoBar = nullptr;
|
||||||
|
cListCtrl* m_pListCtrl = nullptr;
|
||||||
|
wxBoxSizer* m_pSizer = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,742 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
#include "GUI/Dialogs/TagEditor.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Event.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Utils.hpp"
|
||||||
|
|
||||||
|
#include <wx/dir.h>
|
||||||
|
#include <wx/menu.h>
|
||||||
|
#include <wx/progdlg.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
cListCtrl::cListCtrl(wxWindow* window)
|
||||||
|
: wxDataViewListCtrl(window, SampleHive::ID::BC_Library, wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxDV_MULTIPLE | wxDV_HORIZ_RULES | wxDV_VERT_RULES | wxDV_ROW_LINES),
|
||||||
|
m_pWindow(window)
|
||||||
|
{
|
||||||
|
// Adding columns to wxDataViewListCtrl.
|
||||||
|
AppendBitmapColumn(wxBitmap(ICON_STAR_FILLED_16px),
|
||||||
|
0,
|
||||||
|
wxDATAVIEW_CELL_ACTIVATABLE,
|
||||||
|
30,
|
||||||
|
wxALIGN_CENTER,
|
||||||
|
!wxDATAVIEW_COL_RESIZABLE);
|
||||||
|
AppendTextColumn(_("Filename"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
250,
|
||||||
|
wxALIGN_LEFT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Sample Pack"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
180,
|
||||||
|
wxALIGN_LEFT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Type"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
120,
|
||||||
|
wxALIGN_LEFT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Channels"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
90,
|
||||||
|
wxALIGN_RIGHT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Length"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
80,
|
||||||
|
wxALIGN_RIGHT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Sample Rate"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
120,
|
||||||
|
wxALIGN_RIGHT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Bitrate"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
80,
|
||||||
|
wxALIGN_RIGHT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
AppendTextColumn(_("Path"),
|
||||||
|
wxDATAVIEW_CELL_INERT,
|
||||||
|
250,
|
||||||
|
wxALIGN_LEFT,
|
||||||
|
wxDATAVIEW_COL_RESIZABLE |
|
||||||
|
wxDATAVIEW_COL_SORTABLE |
|
||||||
|
wxDATAVIEW_COL_REORDERABLE);
|
||||||
|
|
||||||
|
// Enable cListCtrl to accept files to be dropped on it
|
||||||
|
this->DragAcceptFiles(true);
|
||||||
|
|
||||||
|
// Enable dragging a file from cListCtrl
|
||||||
|
this->EnableDragSource(wxDF_FILENAME);
|
||||||
|
|
||||||
|
Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &cListCtrl::OnClickLibrary, this, SampleHive::ID::BC_Library);
|
||||||
|
Bind(wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, &cListCtrl::OnDragFromLibrary, this);
|
||||||
|
this->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(cListCtrl::OnDragAndDropToLibrary), NULL, this);
|
||||||
|
Bind(wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &cListCtrl::OnShowLibraryContextMenu, this, SampleHive::ID::BC_Library);
|
||||||
|
Bind(wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, &cListCtrl::OnShowLibraryColumnHeaderContextMenu, this, SampleHive::ID::BC_Library);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::OnClickLibrary(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
int selected_row = this->ItemToRow(event.GetItem());
|
||||||
|
int current_row = this->ItemToRow(this->GetCurrentItem());
|
||||||
|
|
||||||
|
if (selected_row < 0 || !event.GetItem().IsOk())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (selected_row != current_row)
|
||||||
|
{
|
||||||
|
this->SetCurrentItem(event.GetItem());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the waveform bitmap
|
||||||
|
SampleHive::cSignal::SendWaveformUpdateStatus(*this);
|
||||||
|
|
||||||
|
// Update LoopAB button value
|
||||||
|
SampleHive::cSignal::SendLoopABButtonValueChange(*this);
|
||||||
|
|
||||||
|
// Stop the timer
|
||||||
|
SampleHive::cSignal::SendTimerStopStatus(*this);
|
||||||
|
|
||||||
|
wxString selection = this->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
// Get curremt column
|
||||||
|
wxDataViewColumn* CurrentColumn = this->GetCurrentColumn();
|
||||||
|
|
||||||
|
// Get favorite column
|
||||||
|
wxDataViewColumn* FavoriteColumn = this->GetColumn(0);
|
||||||
|
|
||||||
|
if (!CurrentColumn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString sample_path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Path;
|
||||||
|
std::string filename = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Filename;
|
||||||
|
std::string extension = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Extension;
|
||||||
|
|
||||||
|
if (CurrentColumn != FavoriteColumn)
|
||||||
|
{
|
||||||
|
// ClearLoopPoints();
|
||||||
|
SampleHive::cSignal::SendClearLoopPointsStatus(*this);
|
||||||
|
|
||||||
|
// Play the sample
|
||||||
|
SampleHive::cSignal::SendCallFunctionPlay(selection, true, *this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
// Get hive name and location
|
||||||
|
std::string hive_name = SampleHive::cHiveData::Get().GetHiveItemText(true).ToStdString();
|
||||||
|
wxDataViewItem hive_selection = SampleHive::cHiveData::Get().GetHiveItemSelection();
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("HIVE NAME: {}", hive_name);
|
||||||
|
|
||||||
|
if (hive_selection.IsOk() && SampleHive::cHiveData::Get().IsHiveItemContainer(hive_selection))
|
||||||
|
hive_name = SampleHive::cHiveData::Get().GetHiveItemText(false, hive_selection);
|
||||||
|
|
||||||
|
wxString name = this->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
// Get root
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container;
|
||||||
|
wxDataViewItem child;
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(filename) == 0)
|
||||||
|
{
|
||||||
|
this->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), selected_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(filename, 1);
|
||||||
|
db.UpdateHiveName(filename, hive_name);
|
||||||
|
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetHiveChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, i);
|
||||||
|
|
||||||
|
if (SampleHive::cHiveData::Get().GetHiveItemText(false, container) == hive_name)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveAppendItem(container, name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Added %s to %s"), name, hive_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), selected_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(filename, 0);
|
||||||
|
db.UpdateHiveName(filename, SampleHive::cHiveData::Get().GetHiveItemText(true).ToStdString());
|
||||||
|
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetHiveChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, i);
|
||||||
|
|
||||||
|
for (int j = 0; j < SampleHive::cHiveData::Get().GetHiveChildCount(container); j++)
|
||||||
|
{
|
||||||
|
child = SampleHive::cHiveData::Get().GetHiveNthChild(container, j);
|
||||||
|
|
||||||
|
if (SampleHive::cHiveData::Get().GetHiveItemText(false, child) == name)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveDeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Removed %s from %s"), name, hive_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::OnDragAndDropToLibrary(wxDropFilesEvent& event)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Start Inserting Samples");
|
||||||
|
|
||||||
|
if (event.GetNumberOfFiles() > 0)
|
||||||
|
{
|
||||||
|
wxString* dropped = event.GetFiles();
|
||||||
|
wxASSERT(dropped);
|
||||||
|
|
||||||
|
wxBusyCursor busy_cursor;
|
||||||
|
wxWindowDisabler window_disabler;
|
||||||
|
|
||||||
|
wxString name;
|
||||||
|
wxString filepath;
|
||||||
|
wxArrayString filepath_array;
|
||||||
|
|
||||||
|
wxProgressDialog* progressDialog = new wxProgressDialog(_("Reading files.."),
|
||||||
|
_("Reading files, please wait..."),
|
||||||
|
event.GetNumberOfFiles(), this,
|
||||||
|
wxPD_APP_MODAL | wxPD_SMOOTH |
|
||||||
|
wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
|
||||||
|
|
||||||
|
progressDialog->CenterOnParent(wxBOTH);
|
||||||
|
|
||||||
|
wxYield();
|
||||||
|
|
||||||
|
for (int i = 0; i < event.GetNumberOfFiles(); i++)
|
||||||
|
{
|
||||||
|
filepath = dropped[i];
|
||||||
|
|
||||||
|
if (wxFileExists(filepath))
|
||||||
|
{
|
||||||
|
filepath_array.push_back(filepath);
|
||||||
|
}
|
||||||
|
else if (wxDirExists(filepath))
|
||||||
|
{
|
||||||
|
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->Pulse(_("Reading Samples"), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->Destroy();
|
||||||
|
|
||||||
|
SampleHive::cUtils::Get().AddSamples(filepath_array, m_pWindow);
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("Done Inserting Samples");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::OnDragFromLibrary(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
int selected_row = this->ItemToRow(event.GetItem());
|
||||||
|
|
||||||
|
if (selected_row < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString selection = this->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
wxString sample_path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Path;
|
||||||
|
|
||||||
|
wxFileDataObject* fileData = new wxFileDataObject();
|
||||||
|
|
||||||
|
fileData->AddFile(sample_path);
|
||||||
|
event.SetDataObject(fileData);
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("Started dragging '{}'.", sample_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::OnShowLibraryContextMenu(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
cTagEditor* tagEditor;
|
||||||
|
cDatabase db;
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxDataViewItem item = event.GetItem();
|
||||||
|
int selected_row;
|
||||||
|
|
||||||
|
if (item.IsOk())
|
||||||
|
selected_row = this->ItemToRow(item);
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString selection = this->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
wxString sample_path = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Path;
|
||||||
|
std::string filename = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Filename;
|
||||||
|
std::string extension = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selection).Extension;
|
||||||
|
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
//true = add false = remove
|
||||||
|
bool favorite_add = false;
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(filename) == 1)
|
||||||
|
menu.Append(SampleHive::ID::MN_FavoriteSample, _("Remove from hive"), _("Remove the selected sample(s) from hive"));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.Append(SampleHive::ID::MN_FavoriteSample, _("Add to hive"), _("Add selected sample(s) to hive"));
|
||||||
|
favorite_add = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.Append(SampleHive::ID::MN_DeleteSample, _("Delete"), _("Delete the selected sample(s) from database"));
|
||||||
|
menu.Append(SampleHive::ID::MN_TrashSample, _("Trash"), _("Send the selected sample(s) to trash"));
|
||||||
|
|
||||||
|
if (this->GetSelectedItemsCount() <= 1)
|
||||||
|
{
|
||||||
|
menu.Append(SampleHive::ID::MN_EditTagSample, _("Edit tags"),
|
||||||
|
_("Edit the tags for the selected sample"))->Enable(true);
|
||||||
|
menu.Append(SampleHive::ID::MN_OpenFile, _("Open in file manager"),
|
||||||
|
_("Open the selected sample in system's file manager"))->Enable(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.Append(SampleHive::ID::MN_EditTagSample, _("Edit tags"),
|
||||||
|
_("Edit the tags for the selected sample"))->Enable(false);
|
||||||
|
menu.Append(SampleHive::ID::MN_OpenFile, _("Open in file manager"),
|
||||||
|
_("Open the selected sample in system's file manager"))->Enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (this->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
|
{
|
||||||
|
case SampleHive::ID::MN_FavoriteSample:
|
||||||
|
{
|
||||||
|
std::string hive_name = SampleHive::cHiveData::Get().GetHiveItemText(true).ToStdString();
|
||||||
|
|
||||||
|
wxDataViewItem hive_selection = SampleHive::cHiveData::Get().GetHiveItemSelection();
|
||||||
|
|
||||||
|
if (hive_selection.IsOk() && SampleHive::cHiveData::Get().IsHiveItemContainer(hive_selection))
|
||||||
|
hive_name = SampleHive::cHiveData::Get().GetHiveItemText(false, hive_selection);
|
||||||
|
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container;
|
||||||
|
wxDataViewItem child;
|
||||||
|
|
||||||
|
wxDataViewItemArray samples;
|
||||||
|
int sample_count = this->GetSelections(samples);
|
||||||
|
int selected_row = 0;
|
||||||
|
int db_status = 0;
|
||||||
|
|
||||||
|
for (int k = 0; k < sample_count; k++)
|
||||||
|
{
|
||||||
|
selected_row = this->ItemToRow(samples[k]);
|
||||||
|
|
||||||
|
if (selected_row < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
wxString name = this->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
filename = serializer.DeserializeShowFileExtension() ?
|
||||||
|
name.BeforeLast('.').ToStdString() : name.ToStdString();
|
||||||
|
|
||||||
|
db_status = db.GetFavoriteColumnValueByFilename(filename);
|
||||||
|
|
||||||
|
// Aleady Added, Do Nothing
|
||||||
|
if (favorite_add && db_status == 1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Already Removed, Do Nothing
|
||||||
|
if (!favorite_add && db_status == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Add To Favorites
|
||||||
|
if (favorite_add && db_status == 0)
|
||||||
|
{
|
||||||
|
this->SetValue(wxVariant(wxBitmap(ICON_STAR_FILLED_16px)), selected_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(filename, 1);
|
||||||
|
db.UpdateHiveName(filename, hive_name);
|
||||||
|
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetHiveChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, i);
|
||||||
|
|
||||||
|
if (SampleHive::cHiveData::Get().GetHiveItemText(false, container) == hive_name)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveAppendItem(container, name);
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Added %s to %s"), name, hive_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Remove From Favorites
|
||||||
|
this->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), selected_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(filename, 0);
|
||||||
|
db.UpdateHiveName(filename, SampleHive::cHiveData::Get().GetHiveItemText(true).ToStdString());
|
||||||
|
|
||||||
|
for (int i = 0; i < SampleHive::cHiveData::Get().GetHiveChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, i);
|
||||||
|
|
||||||
|
for (int j = 0; j < SampleHive::cHiveData::Get().GetHiveChildCount(container); j++)
|
||||||
|
{
|
||||||
|
child = SampleHive::cHiveData::Get().GetHiveNthChild(container, j);
|
||||||
|
|
||||||
|
if (SampleHive::cHiveData::Get().GetHiveItemText(false, child) == name)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveDeleteItem(child);
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Removed %s from %s"), name, hive_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SampleHive::ID::MN_DeleteSample:
|
||||||
|
{
|
||||||
|
wxDataViewItemArray items;
|
||||||
|
int rows = this->GetSelections(items);
|
||||||
|
|
||||||
|
wxMessageDialog singleMsgDialog(this, wxString::Format(_("Are you sure you want to delete %s from database? "
|
||||||
|
"Warning this change is permanent, and cannot be undone."),
|
||||||
|
sample_path.AfterLast('/')),
|
||||||
|
wxMessageBoxCaptionStr,
|
||||||
|
wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP | wxCENTER);
|
||||||
|
|
||||||
|
wxMessageDialog multipleMsgDialog(this, wxString::Format(_("Are you sure you want to delete "
|
||||||
|
"%d selected samples from database? Warning this change is "
|
||||||
|
"permanent, and cannot be undone."), rows),
|
||||||
|
wxMessageBoxCaptionStr,
|
||||||
|
wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxSTAY_ON_TOP | wxCENTER);
|
||||||
|
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container;
|
||||||
|
wxDataViewItem child;
|
||||||
|
|
||||||
|
if (this->GetSelectedItemsCount() <= 1)
|
||||||
|
{
|
||||||
|
switch (singleMsgDialog.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_YES:
|
||||||
|
{
|
||||||
|
db.RemoveSampleFromDatabase(filename);
|
||||||
|
this->DeleteItem(selected_row);
|
||||||
|
|
||||||
|
for (int j = 0; j < SampleHive::cHiveData::Get().GetHiveChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < SampleHive::cHiveData::Get().GetHiveChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = SampleHive::cHiveData::Get().GetHiveNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(false, child).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(false, child);
|
||||||
|
|
||||||
|
if (child_text == filename)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveDeleteItem(child);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Deleted %s from database successfully"), selection);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
msg = _("Cancel delete");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wxMessageBox(_("Unexpected wxMessageDialog return code!"), _("Error!"),
|
||||||
|
wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (multipleMsgDialog.ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_YES:
|
||||||
|
{
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
int row = this->ItemToRow(items[i]);
|
||||||
|
|
||||||
|
wxString text_value = this->GetTextValue(row, 1);
|
||||||
|
|
||||||
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
|
text_value.BeforeLast('.').ToStdString() : text_value.ToStdString() ;
|
||||||
|
|
||||||
|
db.RemoveSampleFromDatabase(multi_selection);
|
||||||
|
this->DeleteItem(row);
|
||||||
|
|
||||||
|
for (int j = 0; j < SampleHive::cHiveData::Get().GetHiveChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < SampleHive::cHiveData::Get().GetHiveChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = SampleHive::cHiveData::Get().GetHiveNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(false, child).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(false, child);
|
||||||
|
|
||||||
|
if (child_text == multi_selection)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveDeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Deleted %s from database successfully"), text_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
msg = _("Cancel delete");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
wxMessageBox(_("Unexpected wxMessageDialog return code!"), _("Error!"),
|
||||||
|
wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_TrashSample:
|
||||||
|
{
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container, child;
|
||||||
|
|
||||||
|
if (db.IsTrashed(filename))
|
||||||
|
SH_LOG_INFO("{} already trashed", filename);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxDataViewItemArray items;
|
||||||
|
int rows = this->GetSelections(items);
|
||||||
|
|
||||||
|
wxString name;
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
int item_row = this->ItemToRow(items[i]);
|
||||||
|
|
||||||
|
wxString text_value = this->GetTextValue(item_row, 1);
|
||||||
|
|
||||||
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
|
this->GetTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
||||||
|
this->GetTextValue(item_row, 1).ToStdString() ;
|
||||||
|
|
||||||
|
file_data.AddFile(multi_selection);
|
||||||
|
|
||||||
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
||||||
|
{
|
||||||
|
this->SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
|
for (int j = 0; j < SampleHive::cHiveData::Get().GetHiveChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < SampleHive::cHiveData::Get().GetHiveChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = SampleHive::cHiveData::Get().GetHiveNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(false, child).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(false, child);
|
||||||
|
|
||||||
|
if (child_text == files[i])
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveDeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().TrashAppendItem(SampleHive::cHiveData::Get().GetTrashRoot(), text_value);
|
||||||
|
|
||||||
|
this->DeleteItem(item_row);
|
||||||
|
|
||||||
|
db.UpdateTrashColumn(files[i].ToStdString(), 1);
|
||||||
|
db.UpdateHiveName(files[i].ToStdString(), SampleHive::cHiveData::Get().GetHiveItemText(true).ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s sent to trash"), text_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_EditTagSample:
|
||||||
|
{
|
||||||
|
tagEditor = new cTagEditor(this, static_cast<std::string>(sample_path));
|
||||||
|
|
||||||
|
switch (tagEditor->ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_OK:
|
||||||
|
SH_LOG_DEBUG("tags dialog ok, Return code: {}", tagEditor->GetReturnCode());
|
||||||
|
break;
|
||||||
|
case wxID_APPLY:
|
||||||
|
SH_LOG_DEBUG("tags dialog apply, Return code: {}", tagEditor->GetReturnCode());
|
||||||
|
break;
|
||||||
|
case wxID_CANCEL:
|
||||||
|
SH_LOG_DEBUG("tags dialog cancel, Return code: {}", tagEditor->GetReturnCode());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
msg = _("Unexpected TagEditor return code!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_OpenFile:
|
||||||
|
wxExecute(wxString::Format("xdg-open '%s'", sample_path.BeforeLast('/')));
|
||||||
|
break;
|
||||||
|
case wxID_NONE:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
wxMessageBox(_("Unexpected wxMenu return code!"), _("Error!"),
|
||||||
|
wxOK | wxICON_ERROR | wxCENTRE, this);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
wxDataViewColumn* FavoriteColumn = this->GetColumn(0);
|
||||||
|
wxDataViewColumn* FilenameColumn = this->GetColumn(1);
|
||||||
|
wxDataViewColumn* SamplePackColumn = this->GetColumn(2);
|
||||||
|
wxDataViewColumn* TypeColumn = this->GetColumn(3);
|
||||||
|
wxDataViewColumn* ChannelsColumn = this->GetColumn(4);
|
||||||
|
wxDataViewColumn* LengthColumn = this->GetColumn(5);
|
||||||
|
wxDataViewColumn* SampleRateColumn = this->GetColumn(6);
|
||||||
|
wxDataViewColumn* BitrateColumn = this->GetColumn(7);
|
||||||
|
wxDataViewColumn* PathColumn = this->GetColumn(8);
|
||||||
|
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnFavorite, _("Favorites"),
|
||||||
|
_("Toggle favorites column"))->Check(FavoriteColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnFilename, _("Filename"),
|
||||||
|
_("Toggle filename column"))->Check(FilenameColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnSamplePack, _("Sample Pack"),
|
||||||
|
_("Toggle sample pack column"))->Check(SamplePackColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnType, _("Type"),
|
||||||
|
_("Toggle type column"))->Check(TypeColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnChannels, _("Channels"),
|
||||||
|
_("Toggle channels column"))->Check(ChannelsColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnLength, _("Length"),
|
||||||
|
_("Toggle length column"))->Check(LengthColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnSampleRate, _("Sample Rate"),
|
||||||
|
_("Toggle sample rate column"))->Check(SampleRateColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnBitrate, _("Bitrate"),
|
||||||
|
_("Toggle bitrate column"))->Check(BitrateColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(SampleHive::ID::MN_ColumnPath, _("Path"),
|
||||||
|
_("Toggle path column"))->Check(PathColumn->IsShown());
|
||||||
|
|
||||||
|
switch (this->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
|
{
|
||||||
|
case SampleHive::ID::MN_ColumnFavorite:
|
||||||
|
FavoriteColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnFavorite));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnFilename:
|
||||||
|
FilenameColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnFilename));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnSamplePack:
|
||||||
|
SamplePackColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnSamplePack));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnType:
|
||||||
|
TypeColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnType));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnChannels:
|
||||||
|
ChannelsColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnChannels));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnLength:
|
||||||
|
LengthColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnLength));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnSampleRate:
|
||||||
|
SampleRateColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnSampleRate));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnBitrate:
|
||||||
|
BitrateColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnBitrate));
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_ColumnPath:
|
||||||
|
PathColumn->SetHidden(!menu.IsChecked(SampleHive::ID::MN_ColumnPath));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cListCtrl::~cListCtrl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cListCtrl : public wxDataViewListCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cListCtrl(wxWindow* window);
|
||||||
|
~cListCtrl();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxDataViewListCtrl* GetListCtrlObject() { return this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Library event handlers
|
||||||
|
void OnClickLibrary(wxDataViewEvent& event);
|
||||||
|
void OnDragAndDropToLibrary(wxDropFilesEvent& event);
|
||||||
|
void OnDragFromLibrary(wxDataViewEvent& event);
|
||||||
|
void OnShowLibraryContextMenu(wxDataViewEvent& event);
|
||||||
|
void OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -20,227 +20,40 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Database/Database.hpp"
|
#include "GUI/Library.hpp"
|
||||||
|
#include "GUI/Notebook.hpp"
|
||||||
|
#include "GUI/TransportControls.hpp"
|
||||||
#include "GUI/WaveformViewer.hpp"
|
#include "GUI/WaveformViewer.hpp"
|
||||||
#include "SampleHiveConfig.hpp"
|
#include "Database/Database.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
#include "Utility/Serialize.hpp"
|
||||||
#include "Utility/SH_Event.hpp"
|
#include "Utility/Event.hpp"
|
||||||
|
#include "SampleHiveConfig.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/bmpbuttn.h>
|
|
||||||
#include <wx/checkbox.h>
|
|
||||||
#include <wx/collpane.h>
|
|
||||||
#include <wx/dataview.h>
|
|
||||||
#include <wx/dirctrl.h>
|
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include <wx/frame.h>
|
#include <wx/frame.h>
|
||||||
#include <wx/fswatcher.h>
|
#include <wx/fswatcher.h>
|
||||||
#include <wx/infobar.h>
|
|
||||||
#include <wx/listctrl.h>
|
|
||||||
#include <wx/mediactrl.h>
|
#include <wx/mediactrl.h>
|
||||||
#include <wx/notebook.h>
|
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
#include <wx/setup.h>
|
|
||||||
#include <wx/srchctrl.h>
|
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/slider.h>
|
|
||||||
#include <wx/splitter.h>
|
#include <wx/splitter.h>
|
||||||
#include <wx/settings.h>
|
|
||||||
#include <wx/statbmp.h>
|
#include <wx/statbmp.h>
|
||||||
#include <wx/statusbr.h>
|
#include <wx/statusbr.h>
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
#include <wx/tglbtn.h>
|
|
||||||
#include <wx/timer.h>
|
#include <wx/timer.h>
|
||||||
#include <wx/toplevel.h>
|
|
||||||
#include <wx/treebase.h>
|
|
||||||
#include <wx/treectrl.h>
|
|
||||||
#include <wx/window.h>
|
|
||||||
|
|
||||||
#include <taglib/tag.h>
|
class cMainFrame : public wxFrame
|
||||||
#include <taglib/fileref.h>
|
|
||||||
|
|
||||||
#ifndef USE_SYSTEM_INCLUDE_PATH
|
|
||||||
#include <taglib/toolkit/tstring.h>
|
|
||||||
#else
|
|
||||||
#include <taglib/tstring.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct FileInfo
|
|
||||||
{
|
|
||||||
wxString Path;
|
|
||||||
std::string Extension;
|
|
||||||
std::string Filename;
|
|
||||||
};
|
|
||||||
|
|
||||||
class MainFrame : public wxFrame
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MainFrame();
|
cMainFrame();
|
||||||
~MainFrame();
|
~cMainFrame();
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Main Panel
|
|
||||||
wxPanel* m_MainPanel;
|
|
||||||
wxBoxSizer* m_MainSizer;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Hive bitmap icon for the statusbar
|
|
||||||
wxStaticBitmap* m_HiveBitmap;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// App statusbar
|
|
||||||
wxStatusBar* m_StatusBar;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// App menubar
|
|
||||||
wxMenuBar* m_MenuBar;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Menu and menu items for the menubar
|
|
||||||
wxMenu* m_FileMenu;
|
|
||||||
wxMenu* m_EditMenu;
|
|
||||||
wxMenu* m_ViewMenu;
|
|
||||||
wxMenu* m_HelpMenu;
|
|
||||||
wxMenuItem* m_AddFile;
|
|
||||||
wxMenuItem* m_AddDirectory;
|
|
||||||
wxMenuItem* m_ToggleExtension;
|
|
||||||
wxMenuItem* m_ToggleMenuBar;
|
|
||||||
wxMenuItem* m_ToggleStatusBar;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Splitter windows
|
|
||||||
wxSplitterWindow* m_TopSplitter;
|
|
||||||
wxSplitterWindow* m_BottomSplitter;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Top panel controls
|
|
||||||
wxPanel* m_TopPanel;
|
|
||||||
WaveformViewer* m_TopWaveformPanel;
|
|
||||||
wxPanel* m_TopControlsPanel;
|
|
||||||
wxBoxSizer* m_TopSizer;
|
|
||||||
wxBoxSizer* m_TopPanelMainSizer;
|
|
||||||
wxBoxSizer* m_WaveformDisplaySizer;
|
|
||||||
wxBoxSizer* m_BrowserControlSizer;
|
|
||||||
wxBitmapButton* m_PlayButton;
|
|
||||||
wxBitmapToggleButton* m_LoopButton;
|
|
||||||
wxBitmapButton* m_StopButton;
|
|
||||||
wxButton* m_SettingsButton;
|
|
||||||
wxBitmapToggleButton* m_MuteButton;
|
|
||||||
wxBitmapToggleButton* m_LoopABButton;
|
|
||||||
wxStaticText* m_SamplePosition;
|
|
||||||
wxSlider* m_VolumeSlider;
|
|
||||||
wxCheckBox* m_AutoPlayCheck;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Left panel controls
|
|
||||||
wxPanel* m_BottomLeftPanel;
|
|
||||||
wxPanel* m_HivesPanel;
|
|
||||||
wxPanel* m_TrashPanel;
|
|
||||||
wxNotebook* m_Notebook;
|
|
||||||
wxBoxSizer* m_BottomLeftPanelMainSizer;
|
|
||||||
wxBoxSizer* m_HivesMainSizer;
|
|
||||||
wxBoxSizer* m_HivesFavoritesSizer;
|
|
||||||
wxBoxSizer* m_HivesButtonSizer;
|
|
||||||
wxBoxSizer* m_TrashMainSizer;
|
|
||||||
wxBoxSizer* m_TrashItemSizer;
|
|
||||||
wxBoxSizer* m_TrashButtonSizer;
|
|
||||||
wxGenericDirCtrl* m_DirCtrl;
|
|
||||||
wxDataViewTreeCtrl* m_Hives;
|
|
||||||
wxDataViewItem favorites_hive;
|
|
||||||
wxTreeItemId trash_root;
|
|
||||||
wxTreeCtrl* m_Trash;
|
|
||||||
wxButton* m_AddHiveButton;
|
|
||||||
wxButton* m_RemoveHiveButton;
|
|
||||||
wxButton* m_RestoreTrashedItemButton;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Right panel controls
|
|
||||||
wxPanel* m_BottomRightPanel;
|
|
||||||
wxBoxSizer* m_BottomRightPanelMainSizer;
|
|
||||||
wxSearchCtrl* m_SearchBox;
|
|
||||||
wxInfoBar* m_InfoBar;
|
|
||||||
wxDataViewListCtrl* m_Library;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// MediaCtrl
|
|
||||||
wxMediaCtrl* m_MediaCtrl;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Timer
|
|
||||||
wxTimer* m_Timer;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
std::unique_ptr<Database> m_Database;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// FileSystemWatcher
|
|
||||||
wxFileSystemWatcher* m_FsWatcher = nullptr;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
wxLongLong m_LoopA, m_LoopB;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
bool bAutoplay = false;
|
|
||||||
bool bLoop = false;
|
|
||||||
bool bMuted = false;
|
|
||||||
bool bStopped = false;
|
|
||||||
bool bFiltered = false;
|
|
||||||
bool bShowMenuBar = false;
|
|
||||||
bool bShowStatusBar = false;
|
|
||||||
bool bLoopPointsSet = false;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Top panel control handlers
|
// Top panel control handlers
|
||||||
void OnClickPlay(wxCommandEvent& event);
|
|
||||||
void OnClickLoop(wxCommandEvent& event);
|
|
||||||
void OnClickStop(wxCommandEvent& event);
|
|
||||||
void OnClickMute(wxCommandEvent& event);
|
|
||||||
void OnMediaFinished(wxMediaEvent& event);
|
void OnMediaFinished(wxMediaEvent& event);
|
||||||
void OnCheckAutoplay(wxCommandEvent& event);
|
|
||||||
void OnSlideVolume(wxScrollEvent& event);
|
|
||||||
void OnReleaseVolumeSlider(wxScrollEvent& event);
|
|
||||||
void OnClickSettings(wxCommandEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// DirCtrl event handlers
|
|
||||||
void OnClickDirCtrl(wxCommandEvent& event);
|
|
||||||
void OnDragFromDirCtrl(wxTreeEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// TrashPane event handlers
|
|
||||||
void OnShowTrashContextMenu(wxTreeEvent& event);
|
|
||||||
void OnClickRestoreTrashItem(wxCommandEvent& event);
|
|
||||||
void OnDragAndDropToTrash(wxDropFilesEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Hives panel button event handlers
|
|
||||||
void OnDragAndDropToHives(wxDropFilesEvent& event);
|
|
||||||
void OnClickAddHive(wxCommandEvent& event);
|
|
||||||
void OnClickRemoveHive(wxCommandEvent& event);
|
|
||||||
void OnShowHivesContextMenu(wxDataViewEvent& event);
|
|
||||||
void OnHiveStartEditing(wxDataViewEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// SearchCtrl event handlers
|
|
||||||
void OnDoSearch(wxCommandEvent& event);
|
|
||||||
void OnCancelSearch(wxCommandEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Library event handlers
|
|
||||||
void OnClickLibrary(wxDataViewEvent& event);
|
|
||||||
void OnDragAndDropToLibrary(wxDropFilesEvent& event);
|
|
||||||
void OnDragFromLibrary(wxDataViewEvent& event);
|
|
||||||
void OnShowLibraryContextMenu(wxDataViewEvent& event);
|
|
||||||
void OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// App menu items event handlers
|
// App menu items event handlers
|
||||||
|
|
@ -270,32 +83,27 @@ class MainFrame : public wxFrame
|
||||||
// Timer update event handler
|
// Timer update event handler
|
||||||
void UpdateElapsedTime(wxTimerEvent& event);
|
void UpdateElapsedTime(wxTimerEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
void AddSamples(wxArrayString& files);
|
|
||||||
void OnAutoImportDir(const wxString& pathToDirectory);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void PlaySample(const std::string& filepath, const std::string& sample, bool seek = false,
|
void PlaySample(const std::string& filepath, const std::string& sample, bool seek = false,
|
||||||
wxFileOffset where = NULL, wxSeekMode mode = wxFromStart);
|
wxFileOffset where = NULL, wxSeekMode mode = wxFromStart);
|
||||||
|
|
||||||
// Recieve custom events
|
// Recieve custom events
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event);
|
void OnRecieveLoopPoints(SampleHive::cLoopPointsEvent& event);
|
||||||
void OnRecievePushStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
|
void OnRecieveClearLoopPointsStatus(SampleHive::cLoopPointsEvent& event);
|
||||||
void OnRecievePopStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
|
void OnRecieveLoopABButtonValueChange(SampleHive::cLoopPointsEvent& event);
|
||||||
void OnRecieveSetStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
|
void OnRecievePushStatusBarStatus(SampleHive::cStatusBarStatusEvent& event);
|
||||||
void OnRecieveInfoBarStatus(SampleHive::SH_InfoBarMessageEvent& event);
|
void OnRecievePopStatusBarStatus(SampleHive::cStatusBarStatusEvent& event);
|
||||||
void OnRecieveTimerStopStatus(SampleHive::SH_TimerEvent& event);
|
void OnRecieveSetStatusBarStatus(SampleHive::cStatusBarStatusEvent& event);
|
||||||
|
void OnRecieveInfoBarStatus(SampleHive::cInfoBarMessageEvent& event);
|
||||||
|
void OnRecieveTimerStopStatus(SampleHive::cTimerEvent& event);
|
||||||
|
void OnRecieveCallFunctionPlay(SampleHive::cCallFunctionEvent& event);
|
||||||
|
void OnRecieveWaveformUpdateStatus(SampleHive::cWaveformUpdateEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void LoadDatabase();
|
void LoadDatabase();
|
||||||
void RefreshDatabase();
|
|
||||||
void LoadConfigFile();
|
void LoadConfigFile();
|
||||||
|
// void RefreshDatabase();
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Getters
|
|
||||||
FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
|
||||||
bool checkExtension = true, bool doGetFilename = true) const;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Directory watchers
|
// Directory watchers
|
||||||
|
|
@ -304,8 +112,6 @@ class MainFrame : public wxFrame
|
||||||
void AddWatchEntry(wxFSWPathType type, std::string path);
|
void AddWatchEntry(wxFSWPathType type, std::string path);
|
||||||
void OnFileSystemEvent(wxFileSystemWatcherEvent& event);
|
void OnFileSystemEvent(wxFileSystemWatcherEvent& event);
|
||||||
|
|
||||||
// wxString TagLibTowx(const TagLib::String& in);
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Call after frame creation
|
// Call after frame creation
|
||||||
void SetAfterFrameCreate();
|
void SetAfterFrameCreate();
|
||||||
|
|
@ -314,5 +120,82 @@ class MainFrame : public wxFrame
|
||||||
void ClearLoopPoints();
|
void ClearLoopPoints();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
friend class App;
|
void InitDatabase();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
friend class cApp;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Main Panel
|
||||||
|
wxBoxSizer* m_pMainSizer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Hive bitmap icon for the statusbar
|
||||||
|
wxStaticBitmap* m_pHiveBitmap = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// App statusbar
|
||||||
|
wxStatusBar* m_pStatusBar = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// App menubar
|
||||||
|
wxMenuBar* m_pMenuBar = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Menu and menu items for the menubar
|
||||||
|
wxMenu* m_pFileMenu = nullptr;
|
||||||
|
wxMenu* m_pEditMenu = nullptr;
|
||||||
|
wxMenu* m_pViewMenu = nullptr;
|
||||||
|
wxMenu* m_pHelpMenu = nullptr;
|
||||||
|
wxMenuItem* m_pAddFile = nullptr;
|
||||||
|
wxMenuItem* m_pAddDirectory = nullptr;
|
||||||
|
wxMenuItem* m_pToggleExtension = nullptr;
|
||||||
|
wxMenuItem* m_pToggleMenuBar = nullptr;
|
||||||
|
wxMenuItem* m_pToggleStatusBar = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Splitter windows
|
||||||
|
wxSplitterWindow* m_pTopSplitter = nullptr;
|
||||||
|
wxSplitterWindow* m_pBottomSplitter = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Top panel controls
|
||||||
|
wxPanel* m_pTopPanel = nullptr;
|
||||||
|
cWaveformViewer* m_pWaveformViewer = nullptr;
|
||||||
|
cTransportControls* m_pTransportControls = nullptr;
|
||||||
|
wxBoxSizer* m_pTopPanelMainSizer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Left panel controls
|
||||||
|
cNotebook* m_pNotebook = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Right panel controls
|
||||||
|
cLibrary* m_pLibrary = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// MediaCtrl
|
||||||
|
wxMediaCtrl* m_pMediaCtrl = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Timer
|
||||||
|
wxTimer* m_pTimer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
std::unique_ptr<cDatabase> m_pDatabase = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// FileSystemWatcher
|
||||||
|
wxFileSystemWatcher* m_pFsWatcher = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxLongLong m_LoopA, m_LoopB;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
bool m_bFiltered = false;
|
||||||
|
bool m_bShowMenuBar = false;
|
||||||
|
bool m_bShowStatusBar = false;
|
||||||
|
bool m_bLoopPointsSet = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/Notebook.hpp"
|
||||||
|
#include "GUI/DirectoryBrowser.hpp"
|
||||||
|
#include "GUI/Hives.hpp"
|
||||||
|
#include "GUI/Trash.hpp"
|
||||||
|
|
||||||
|
cNotebook::cNotebook(wxWindow* window)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
|
||||||
|
{
|
||||||
|
m_pNotebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
|
||||||
|
|
||||||
|
m_DirectoryBrowser = new cDirectoryBrowser(m_pNotebook);
|
||||||
|
m_HivesPanel = new cHivesPanel(m_pNotebook);
|
||||||
|
m_TrashPanel = new cTrashPanel(m_pNotebook);
|
||||||
|
|
||||||
|
// Adding the pages to wxNotebook
|
||||||
|
m_pNotebook->AddPage(m_DirectoryBrowser, _("Browse"), false);
|
||||||
|
m_pNotebook->AddPage(m_HivesPanel, _("Hives"), false);
|
||||||
|
m_pNotebook->AddPage(m_TrashPanel, _("Trash"), false);
|
||||||
|
|
||||||
|
m_pSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
m_pSizer->Add(m_pNotebook, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
this->SetSizer(m_pSizer);
|
||||||
|
m_pSizer->Fit(this);
|
||||||
|
m_pSizer->SetSizeHints(this);
|
||||||
|
m_pSizer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
cNotebook::~cNotebook()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GUI/DirectoryBrowser.hpp"
|
||||||
|
#include "GUI/Hives.hpp"
|
||||||
|
#include "GUI/Trash.hpp"
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/notebook.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
|
||||||
|
class cNotebook : public wxPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cNotebook(wxWindow* window);
|
||||||
|
~cNotebook();
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cDirectoryBrowser* GetDirectoryBrowser() const { return m_DirectoryBrowser; }
|
||||||
|
cHivesPanel* GetHivesPanel() const { return m_HivesPanel; }
|
||||||
|
cTrashPanel* GetTrashPanel() const { return m_TrashPanel; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxNotebook* m_pNotebook = nullptr;
|
||||||
|
wxBoxSizer* m_pSizer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cDirectoryBrowser* m_DirectoryBrowser = nullptr;
|
||||||
|
cHivesPanel* m_HivesPanel = nullptr;
|
||||||
|
cTrashPanel* m_TrashPanel = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/SearchBar.hpp"
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
cSearchBar::cSearchBar(wxWindow* window)
|
||||||
|
: wxSearchCtrl(window, SampleHive::ID::BC_Search, _("Search for samples.."),
|
||||||
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER),
|
||||||
|
m_pWindow(window)
|
||||||
|
{
|
||||||
|
// Set minimum and maximum size of m_SearchBox
|
||||||
|
// so it doesn't expand too wide when resizing the main frame.
|
||||||
|
SetMinSize(wxSize(-1, 38));
|
||||||
|
SetMaxSize(wxSize(-1, 38));
|
||||||
|
|
||||||
|
ShowSearchButton(true);
|
||||||
|
ShowCancelButton(true);
|
||||||
|
|
||||||
|
Bind(wxEVT_TEXT, &cSearchBar::OnDoSearch, this, SampleHive::ID::BC_Search);
|
||||||
|
Bind(wxEVT_SEARCHCTRL_SEARCH_BTN, &cSearchBar::OnDoSearch, this, SampleHive::ID::BC_Search);
|
||||||
|
Bind(wxEVT_SEARCHCTRL_CANCEL_BTN, &cSearchBar::OnCancelSearch, this, SampleHive::ID::BC_Search);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSearchBar::OnDoSearch(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
const auto search = this->GetValue().ToStdString();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto dataset = db.FilterDatabaseBySampleName(search, serializer.DeserializeShowFileExtension(),
|
||||||
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
|
if (dataset.empty())
|
||||||
|
{
|
||||||
|
SH_LOG_INFO("Error! Database is empty.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlDeleteAllItems();
|
||||||
|
|
||||||
|
std::cout << search << std::endl;
|
||||||
|
|
||||||
|
for (const auto& data : dataset)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error loading data. {}", e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSearchBar::OnCancelSearch(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
this->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
cSearchBar::~cSearchBar()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/srchctrl.h>
|
||||||
|
|
||||||
|
class cSearchBar : public wxSearchCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cSearchBar(wxWindow* window);
|
||||||
|
~cSearchBar();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxSearchCtrl* GetSearchCtrlObject() { return this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// SearchCtrl event handlers
|
||||||
|
void OnDoSearch(wxCommandEvent& event);
|
||||||
|
void OnCancelSearch(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,298 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/TransportControls.hpp"
|
||||||
|
#include "GUI/Dialogs/Settings.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/Event.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
|
#include "Utility/Sample.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Utils.hpp"
|
||||||
|
|
||||||
|
#include <wx/bmpbndl.h>
|
||||||
|
|
||||||
|
cTransportControls::cTransportControls(wxWindow* window, wxMediaCtrl& mediaCtrl)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER),
|
||||||
|
m_MediaCtrl(mediaCtrl)
|
||||||
|
{
|
||||||
|
m_pMainSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
// Looping region controls
|
||||||
|
if (m_Theme.IsDark())
|
||||||
|
m_pLoopABButton = new wxBitmapToggleButton(this, SampleHive::ID::BC_LoopABButton,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_AB_LIGHT_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
else
|
||||||
|
m_pLoopABButton = new wxBitmapToggleButton(this, SampleHive::ID::BC_LoopABButton,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_AB_DARK_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
|
||||||
|
m_pLoopABButton->SetToolTip(_("Loop selected region"));
|
||||||
|
|
||||||
|
// Autoplay checkbox
|
||||||
|
m_pAutoPlayCheck = new wxCheckBox(this, SampleHive::ID::BC_Autoplay, _("Autoplay"),
|
||||||
|
wxDefaultPosition, wxDefaultSize, wxCHK_2STATE);
|
||||||
|
m_pAutoPlayCheck->SetToolTip(_("Autoplay"));
|
||||||
|
|
||||||
|
// Volume slider
|
||||||
|
m_pVolumeSlider = new wxSlider(this, SampleHive::ID::BC_Volume, 100, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL);
|
||||||
|
m_pVolumeSlider->SetToolTip(_("Volume"));
|
||||||
|
m_pVolumeSlider->SetMinSize(wxSize(120, -1));
|
||||||
|
m_pVolumeSlider->SetMaxSize(wxSize(120, -1));
|
||||||
|
|
||||||
|
// Sample position static text
|
||||||
|
m_pSamplePosition = new wxStaticText(this, SampleHive::ID::BC_SamplePosition, "--:--/--:--",
|
||||||
|
wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL);
|
||||||
|
|
||||||
|
// Transport control buttons
|
||||||
|
if (m_Theme.IsDark())
|
||||||
|
{
|
||||||
|
m_pPlayButton = new wxBitmapButton(this, SampleHive::ID::BC_Play,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_PLAY_LIGHT_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pLoopButton = new wxBitmapToggleButton(this, SampleHive::ID::BC_Loop,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_LOOP_LIGHT_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pStopButton = new wxBitmapButton(this, SampleHive::ID::BC_Stop,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_STOP_LIGHT_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pMuteButton = new wxBitmapToggleButton(this, SampleHive::ID::BC_Mute,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_MUTE_LIGHT_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_pPlayButton = new wxBitmapButton(this, SampleHive::ID::BC_Play,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_PLAY_DARK_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pLoopButton = new wxBitmapToggleButton(this, SampleHive::ID::BC_Loop,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_LOOP_DARK_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pStopButton = new wxBitmapButton(this, SampleHive::ID::BC_Stop,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_STOP_DARK_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pMuteButton = new wxBitmapToggleButton(this, SampleHive::ID::BC_Mute,
|
||||||
|
wxBitmapBundle::FromBitmap(static_cast<wxString>(ICON_MUTE_DARK_16px)),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pPlayButton->SetToolTip(_("Play"));
|
||||||
|
m_pLoopButton->SetToolTip(_("Loop"));
|
||||||
|
m_pStopButton->SetToolTip(_("Stop"));
|
||||||
|
m_pMuteButton->SetToolTip(_("Mute"));
|
||||||
|
|
||||||
|
m_pSettingsButton = new wxButton(this, SampleHive::ID::BC_Settings, _("Settings"), wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pSettingsButton->SetToolTip(_("Settings"));
|
||||||
|
|
||||||
|
m_pMainSizer->Add(m_pPlayButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(m_pStopButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(m_pLoopButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(m_pLoopABButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(m_pSettingsButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(0,0,1, wxALL | wxEXPAND, 0);
|
||||||
|
m_pMainSizer->Add(m_pSamplePosition, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(30,0,0, wxALL | wxEXPAND, 0);
|
||||||
|
m_pMainSizer->Add(m_pMuteButton, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(m_pVolumeSlider, 1, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
m_pMainSizer->Add(m_pAutoPlayCheck, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||||
|
|
||||||
|
this->SetSizer(m_pMainSizer);
|
||||||
|
m_pMainSizer->Fit(this);
|
||||||
|
m_pMainSizer->SetSizeHints(this);
|
||||||
|
m_pMainSizer->Layout();
|
||||||
|
|
||||||
|
Bind(wxEVT_BUTTON, &cTransportControls::OnClickPlay, this, SampleHive::ID::BC_Play);
|
||||||
|
Bind(wxEVT_TOGGLEBUTTON, &cTransportControls::OnClickLoop, this, SampleHive::ID::BC_Loop);
|
||||||
|
Bind(wxEVT_BUTTON, &cTransportControls::OnClickStop, this, SampleHive::ID::BC_Stop);
|
||||||
|
Bind(wxEVT_TOGGLEBUTTON, &cTransportControls::OnClickMute, this, SampleHive::ID::BC_Mute);
|
||||||
|
Bind(wxEVT_BUTTON, &cTransportControls::OnClickSettings, this, SampleHive::ID::BC_Settings);
|
||||||
|
Bind(wxEVT_CHECKBOX, &cTransportControls::OnCheckAutoplay, this, SampleHive::ID::BC_Autoplay);
|
||||||
|
Bind(wxEVT_SCROLL_THUMBTRACK, &cTransportControls::OnSlideVolume, this, SampleHive::ID::BC_Volume);
|
||||||
|
Bind(wxEVT_SCROLL_THUMBRELEASE, &cTransportControls::OnReleaseVolumeSlider, this, SampleHive::ID::BC_Volume);
|
||||||
|
|
||||||
|
// Load control values from config file
|
||||||
|
LoadConfigFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnClickSettings(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
cSettings* settings = new cSettings(this);
|
||||||
|
|
||||||
|
switch (settings->ShowModal())
|
||||||
|
{
|
||||||
|
case wxID_OK:
|
||||||
|
if (settings->CanAutoImport())
|
||||||
|
{
|
||||||
|
SampleHive::cUtils::Get().OnAutoImportDir(settings->GetImportDirPath(), this);
|
||||||
|
// RefreshDatabase();
|
||||||
|
}
|
||||||
|
if (settings->IsWaveformColourChanged())
|
||||||
|
{
|
||||||
|
SampleHive::cSignal::SendWaveformUpdateStatus(*this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_CANCEL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnClickPlay(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
m_bStopped = false;
|
||||||
|
|
||||||
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
|
if (selected_row < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString selection = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
// Send custom event to MainFrame to play the sample
|
||||||
|
SampleHive::cSignal::SendCallFunctionPlay(selection, false, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnClickLoop(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
m_bLoop = m_pLoopButton->GetValue();
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("loop", m_bLoop);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnClickStop(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
if (!m_MediaCtrl.Stop())
|
||||||
|
SH_LOG_ERROR("Error! Unable to stop media.");
|
||||||
|
|
||||||
|
m_bStopped = true;
|
||||||
|
|
||||||
|
// Send custom event to MainFrame to stop the timer
|
||||||
|
SampleHive::cSignal::SendTimerStopStatus(*this);
|
||||||
|
|
||||||
|
m_pSamplePosition->SetLabel("--:--/--:--");
|
||||||
|
|
||||||
|
// Send custom event to MainFrame to set the statusbar status
|
||||||
|
SampleHive::cSignal::SendSetStatusBarStatus(_("Stopped"), 1, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnClickMute(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
if (m_pMuteButton->GetValue())
|
||||||
|
{
|
||||||
|
m_MediaCtrl.SetVolume(0.0);
|
||||||
|
m_bMuted = true;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("muted", m_bMuted);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_MediaCtrl.SetVolume(double(m_pVolumeSlider->GetValue()) / 100);
|
||||||
|
m_bMuted = false;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("muted", m_bMuted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnCheckAutoplay(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
if (m_pAutoPlayCheck->GetValue())
|
||||||
|
{
|
||||||
|
m_bAutoplay = true;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("autoplay", m_bAutoplay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_bAutoplay = false;
|
||||||
|
|
||||||
|
serializer.SerializeMediaOptions("autoplay", m_bAutoplay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnSlideVolume(wxScrollEvent& event)
|
||||||
|
{
|
||||||
|
m_MediaCtrl.SetVolume(double(m_pVolumeSlider->GetValue()) / 100);
|
||||||
|
|
||||||
|
// Send custom event to MainFrame to push status to statusbar
|
||||||
|
SampleHive::cSignal::SendPushStatusBarStatus(wxString::Format(_("Volume: %d"), m_pVolumeSlider->GetValue()), 1, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::OnReleaseVolumeSlider(wxScrollEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
serializer.SerializeMediaVolume(m_pVolumeSlider->GetValue());
|
||||||
|
|
||||||
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
|
if (selected_row < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxString selection = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
// Wait a second then remove the status from statusbar
|
||||||
|
wxSleep(1);
|
||||||
|
|
||||||
|
// Send custom event to MainFrame to pop status from statusbar
|
||||||
|
SampleHive::cSignal::SendPopStatusBarStatus(1, *this);
|
||||||
|
|
||||||
|
if (m_MediaCtrl.GetState() == wxMEDIASTATE_STOPPED)
|
||||||
|
SampleHive::cSignal::SendSetStatusBarStatus(_("Stopped"), 1, *this);
|
||||||
|
else
|
||||||
|
SampleHive::cSignal::SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selection), 1, *this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTransportControls::LoadConfigFile()
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
|
SH_LOG_INFO("Reading transport control values..");
|
||||||
|
|
||||||
|
m_bAutoplay = serializer.DeserializeMediaOptions("autoplay");
|
||||||
|
m_bLoop = serializer.DeserializeMediaOptions("loop");
|
||||||
|
m_bMuted = serializer.DeserializeMediaOptions("muted");
|
||||||
|
|
||||||
|
m_pAutoPlayCheck->SetValue(m_bAutoplay);
|
||||||
|
m_pLoopButton->SetValue(m_bLoop);
|
||||||
|
m_pMuteButton->SetValue(m_bMuted);
|
||||||
|
|
||||||
|
m_pVolumeSlider->SetValue(serializer.DeserializeMediaVolume());
|
||||||
|
|
||||||
|
if (!m_bMuted)
|
||||||
|
m_MediaCtrl.SetVolume(double(m_pVolumeSlider->GetValue()) / 100);
|
||||||
|
else
|
||||||
|
m_MediaCtrl.SetVolume(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
cTransportControls::~cTransportControls()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/bmpbuttn.h>
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/checkbox.h>
|
||||||
|
#include <wx/event.h>
|
||||||
|
#include <wx/mediactrl.h>
|
||||||
|
#include <wx/settings.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/slider.h>
|
||||||
|
#include <wx/stattext.h>
|
||||||
|
#include <wx/tglbtn.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/version.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cTransportControls : public wxPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cTransportControls(wxWindow* window, wxMediaCtrl& mediaCtrl);
|
||||||
|
~cTransportControls();
|
||||||
|
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
bool IsLoopABOn() const { return m_pLoopABButton->GetValue(); }
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
inline bool CanAutoplay() const { return m_bAutoplay; };
|
||||||
|
inline bool CanLoop() const { return m_bLoop; };
|
||||||
|
inline bool IsMuted() const { return m_bMuted; };
|
||||||
|
inline bool IsStopped() const { return m_bStopped; };
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void SetLoopABValue(bool value) { m_pLoopABButton->SetValue(value); }
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void SetCanAutoplay(bool autoplay) { m_bAutoplay = autoplay; }
|
||||||
|
void SetCanLoop(bool loop) { m_bLoop = loop; }
|
||||||
|
void SetIsMuted(bool muted) { m_bMuted = muted; }
|
||||||
|
void SetIsStopped(bool stopped) { m_bStopped = stopped; }
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
inline wxString GetSamplePositionText() const { return m_pSamplePosition->GetLabelText(); }
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void SetSamplePositionText(const wxString& text) { m_pSamplePosition->SetLabel(text); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Event handlers
|
||||||
|
void OnClickPlay(wxCommandEvent& event);
|
||||||
|
void OnClickLoop(wxCommandEvent& event);
|
||||||
|
void OnClickStop(wxCommandEvent& event);
|
||||||
|
void OnClickMute(wxCommandEvent& event);
|
||||||
|
void OnClickSettings(wxCommandEvent& event);
|
||||||
|
void OnCheckAutoplay(wxCommandEvent& event);
|
||||||
|
void OnSlideVolume(wxScrollEvent& event);
|
||||||
|
void OnReleaseVolumeSlider(wxScrollEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Load control values from config file
|
||||||
|
void LoadConfigFile();
|
||||||
|
|
||||||
|
void OnAutoImportDir(const wxString& pathToDirectory);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxMediaCtrl& m_MediaCtrl;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
bool m_bAutoplay = false;
|
||||||
|
bool m_bLoop = false;
|
||||||
|
bool m_bMuted = false;
|
||||||
|
bool m_bStopped = false;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxBitmapButton* m_pPlayButton = nullptr;
|
||||||
|
wxBitmapToggleButton* m_pLoopButton = nullptr;
|
||||||
|
wxBitmapButton* m_pStopButton = nullptr;
|
||||||
|
wxButton* m_pSettingsButton = nullptr;
|
||||||
|
wxBitmapToggleButton* m_pMuteButton = nullptr;
|
||||||
|
wxBitmapToggleButton* m_pLoopABButton = nullptr;
|
||||||
|
wxStaticText* m_pSamplePosition = nullptr;
|
||||||
|
wxSlider* m_pVolumeSlider = nullptr;
|
||||||
|
wxCheckBox* m_pAutoPlayCheck = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxBoxSizer* m_pMainSizer = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,307 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "GUI/Trash.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Utils.hpp"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
#include <wx/menu.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
cTrashPanel::cTrashPanel(wxWindow* window)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
|
||||||
|
m_pWindow(window)
|
||||||
|
{
|
||||||
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pTrashSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
m_pTrash = new wxTreeCtrl(this, SampleHive::ID::BC_Trash, wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxTR_NO_BUTTONS | wxTR_HIDE_ROOT | wxTR_MULTIPLE);
|
||||||
|
|
||||||
|
// Setting m_Trash to accept files to be dragged and dropped on it
|
||||||
|
m_pTrash->DragAcceptFiles(true);
|
||||||
|
|
||||||
|
m_pTrashSizer->Add(m_pTrash, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
m_pRestoreTrashedItemButton = new wxButton(this, SampleHive::ID::BC_RestoreTrashedItem, _("Restore sample"),
|
||||||
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pRestoreTrashedItemButton->SetToolTip(_("Restore selected sample"));
|
||||||
|
|
||||||
|
m_pButtonSizer->Add(m_pRestoreTrashedItemButton, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
// Addubg root to TrashedItems
|
||||||
|
m_TrashRoot = m_pTrash->AddRoot("Trash");
|
||||||
|
|
||||||
|
m_pTrash->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(cTrashPanel::OnDragAndDropToTrash), NULL, this);
|
||||||
|
Bind(wxEVT_TREE_ITEM_RIGHT_CLICK, &cTrashPanel::OnShowTrashContextMenu, this, SampleHive::ID::BC_Trash);
|
||||||
|
Bind(wxEVT_BUTTON, &cTrashPanel::OnClickRestoreTrashItem, this, SampleHive::ID::BC_RestoreTrashedItem);
|
||||||
|
|
||||||
|
m_pMainSizer->Add(m_pTrashSizer, wxSizerFlags(1).Expand());
|
||||||
|
m_pMainSizer->Add(m_pButtonSizer, wxSizerFlags(0).Expand());
|
||||||
|
|
||||||
|
// Sizer for trash pane
|
||||||
|
this->SetSizer(m_pMainSizer);
|
||||||
|
m_pMainSizer->Fit(this);
|
||||||
|
m_pMainSizer->SetSizeHints(this);
|
||||||
|
m_pMainSizer->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTrashPanel::OnDragAndDropToTrash(wxDropFilesEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
if (event.GetNumberOfFiles() > 0)
|
||||||
|
{
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
wxDataViewItemArray items;
|
||||||
|
int rows = SampleHive::cHiveData::Get().GetListCtrlSelections(items);
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container, child;
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
int item_row = SampleHive::cHiveData::Get().GetListCtrlRowFromItem(items, i);
|
||||||
|
|
||||||
|
wxString text_value = SampleHive::cHiveData::Get().GetListCtrlTextValue(item_row, 1);
|
||||||
|
|
||||||
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
||||||
|
SampleHive::cHiveData::Get().GetListCtrlTextValue(item_row, 1).ToStdString() ;
|
||||||
|
|
||||||
|
file_data.AddFile(multi_selection);
|
||||||
|
|
||||||
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlSetVariant(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
|
for (int j = 0; j < SampleHive::cHiveData::Get().GetHiveChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = SampleHive::cHiveData::Get().GetHiveNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < SampleHive::cHiveData::Get().GetHiveChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = SampleHive::cHiveData::Get().GetHiveNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(child).BeforeLast('.') :
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(child);
|
||||||
|
|
||||||
|
if (child_text == files[i])
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().HiveDeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db.UpdateTrashColumn(files[i].ToStdString(), 1);
|
||||||
|
db.UpdateHiveName(files[i].ToStdString(),
|
||||||
|
SampleHive::cHiveData::Get().GetHiveItemText(SampleHive::cHiveData::Get().GetFavoritesHive()).ToStdString());
|
||||||
|
|
||||||
|
m_pTrash->AppendItem(m_TrashRoot, text_value);
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlDeleteItem(item_row);
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s sent to trash"), text_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_ERROR, *this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTrashPanel::OnShowTrashContextMenu(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxTreeItemId selected_trashed_item = event.GetItem();
|
||||||
|
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
menu.Append(SampleHive::ID::MN_DeleteTrash, _("Delete from database"), _("Delete the selected sample(s) from database"));
|
||||||
|
menu.Append(SampleHive::ID::MN_RestoreTrashedItem, _("Restore sample"), _("Restore the selected sample(s) back to library"));
|
||||||
|
|
||||||
|
if (selected_trashed_item.IsOk())
|
||||||
|
{
|
||||||
|
switch (m_pTrash->GetPopupMenuSelectionFromUser(menu, event.GetPoint()))
|
||||||
|
{
|
||||||
|
case SampleHive::ID::MN_DeleteTrash:
|
||||||
|
{
|
||||||
|
wxString trashed_item_name = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_pTrash->GetItemText(selected_trashed_item).BeforeLast('.') :
|
||||||
|
m_pTrash->GetItemText(selected_trashed_item);
|
||||||
|
|
||||||
|
db.RemoveSampleFromDatabase(trashed_item_name.ToStdString());
|
||||||
|
|
||||||
|
m_pTrash->Delete(selected_trashed_item);
|
||||||
|
|
||||||
|
SH_LOG_INFO("{} deleted from trash and databse", trashed_item_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SampleHive::ID::MN_RestoreTrashedItem:
|
||||||
|
{
|
||||||
|
wxArrayTreeItemIds selected_item_ids;
|
||||||
|
m_pTrash->GetSelections(selected_item_ids);
|
||||||
|
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
wxString selected_item_text;
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < selected_item_ids.GetCount(); i++)
|
||||||
|
{
|
||||||
|
selected_item_text = m_pTrash->GetItemText(selected_item_ids[i]);
|
||||||
|
|
||||||
|
filename = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected_item_text).Filename;
|
||||||
|
|
||||||
|
file_data.AddFile(filename);
|
||||||
|
|
||||||
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
|
db.UpdateTrashColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
wxVector<wxVector<wxVariant>> dataset;
|
||||||
|
|
||||||
|
if (db.RestoreFromTrashByFilename(files[i].ToStdString(),
|
||||||
|
dataset,
|
||||||
|
serializer.DeserializeShowFileExtension(),
|
||||||
|
ICON_STAR_FILLED_16px,
|
||||||
|
ICON_STAR_EMPTY_16px).empty())
|
||||||
|
{
|
||||||
|
SH_LOG_INFO("Error! Database is empty.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto data : dataset)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error loading data. {}", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTrash->Delete(selected_item_ids[i]);
|
||||||
|
|
||||||
|
SH_LOG_INFO("{} restored from trash", files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTrashPanel::OnClickRestoreTrashItem(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxArrayTreeItemIds selected_item_ids;
|
||||||
|
m_pTrash->GetSelections(selected_item_ids);
|
||||||
|
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
wxString selected_item_text;
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
if (m_pTrash->GetChildrenCount(m_TrashRoot) == 0)
|
||||||
|
{
|
||||||
|
wxMessageBox(_("Trash is empty, nothing to restore!"), wxMessageBoxCaptionStr, wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selected_item_ids.IsEmpty())
|
||||||
|
{
|
||||||
|
wxMessageBox(_("No item selected, try selected a item first."), wxMessageBoxCaptionStr, wxOK | wxCENTRE, this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < selected_item_ids.GetCount(); i++)
|
||||||
|
{
|
||||||
|
selected_item_text = m_pTrash->GetItemText(selected_item_ids[i]);
|
||||||
|
|
||||||
|
filename = SampleHive::cUtils::Get().GetFilenamePathAndExtension(selected_item_text).Filename;
|
||||||
|
|
||||||
|
file_data.AddFile(filename);
|
||||||
|
|
||||||
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
|
db.UpdateTrashColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
wxVector<wxVector<wxVariant>> dataset;
|
||||||
|
|
||||||
|
if (db.RestoreFromTrashByFilename(files[i].ToStdString(), dataset,
|
||||||
|
serializer.DeserializeShowFileExtension(),
|
||||||
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px).empty())
|
||||||
|
{
|
||||||
|
SH_LOG_INFO("Error! Database is empty.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto data : dataset)
|
||||||
|
{
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::exception& e)
|
||||||
|
{
|
||||||
|
SH_LOG_ERROR("Error loading data. {}", e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTrash->Delete(selected_item_ids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cTrashPanel::~cTrashPanel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/button.h>
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/panel.h>
|
||||||
|
#include <wx/sizer.h>
|
||||||
|
#include <wx/treebase.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cTrashPanel : public wxPanel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cTrashPanel(wxWindow* window);
|
||||||
|
~cTrashPanel();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxTreeCtrl* GetTrashObject() { return m_pTrash; }
|
||||||
|
wxTreeItemId& GetTrashRoot() { return m_TrashRoot; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// TrashPane event handlers
|
||||||
|
void OnShowTrashContextMenu(wxTreeEvent& event);
|
||||||
|
void OnClickRestoreTrashItem(wxCommandEvent& event);
|
||||||
|
void OnDragAndDropToTrash(wxDropFilesEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxTreeItemId m_TrashRoot;
|
||||||
|
wxTreeCtrl* m_pTrash = nullptr;
|
||||||
|
wxButton* m_pRestoreTrashedItemButton = nullptr;
|
||||||
|
wxBoxSizer* m_pMainSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pTrashSizer = nullptr;
|
||||||
|
wxBoxSizer* m_pButtonSizer = nullptr;
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
};
|
||||||
|
|
@ -19,11 +19,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "GUI/WaveformViewer.hpp"
|
#include "GUI/WaveformViewer.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
#include "Utility/HiveData.hpp"
|
||||||
#include "Utility/Tags.hpp"
|
|
||||||
#include "Utility/SH_Event.hpp"
|
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Event.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Tags.hpp"
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -39,28 +41,33 @@
|
||||||
#include <sndfile.h>
|
#include <sndfile.h>
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
|
|
||||||
WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
cWaveformViewer::cWaveformViewer(wxWindow* window, wxMediaCtrl& mediaCtrl, cDatabase& database)
|
||||||
wxMediaCtrl& mediaCtrl, Database& database)
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
||||||
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
m_Window(window), m_Database(database), m_MediaCtrl(mediaCtrl)
|
||||||
wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
|
||||||
m_Window(window), m_Database(database), m_Library(library), m_MediaCtrl(mediaCtrl)
|
|
||||||
{
|
{
|
||||||
this->SetDoubleBuffered(true);
|
this->SetDoubleBuffered(true);
|
||||||
|
|
||||||
Bind(wxEVT_PAINT, &WaveformViewer::OnPaint, this);
|
Bind(wxEVT_PAINT, &cWaveformViewer::OnPaint, this);
|
||||||
Bind(wxEVT_MOTION, &WaveformViewer::OnMouseMotion, this);
|
Bind(wxEVT_MOTION, &cWaveformViewer::OnMouseMotion, this);
|
||||||
Bind(wxEVT_LEFT_DOWN, &WaveformViewer::OnMouseLeftButtonDown, this);
|
Bind(wxEVT_LEFT_DOWN, &cWaveformViewer::OnMouseLeftButtonDown, this);
|
||||||
Bind(wxEVT_LEFT_UP, &WaveformViewer::OnMouseLeftButtonUp, this);
|
Bind(wxEVT_LEFT_UP, &cWaveformViewer::OnMouseLeftButtonUp, this);
|
||||||
// Bind(wxEVT_KEY_DOWN, &WaveformViewer::OnControlKeyDown, this);
|
// Bind(wxEVT_KEY_DOWN, &cWaveformViewer::OnControlKeyDown, this);
|
||||||
Bind(wxEVT_KEY_UP, &WaveformViewer::OnControlKeyUp, this);
|
Bind(wxEVT_KEY_UP, &cWaveformViewer::OnControlKeyUp, this);
|
||||||
|
|
||||||
|
m_Sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
this->SetSizer(m_Sizer);
|
||||||
|
m_Sizer->Fit(this);
|
||||||
|
m_Sizer->SetSizeHints(this);
|
||||||
|
m_Sizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
WaveformViewer::~WaveformViewer()
|
cWaveformViewer::~cWaveformViewer()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnPaint(wxPaintEvent& event)
|
void cWaveformViewer::OnPaint(wxPaintEvent& event)
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
|
|
@ -103,23 +110,24 @@ void WaveformViewer::OnPaint(wxPaintEvent& event)
|
||||||
this->GetSize().GetHeight() + 5));
|
this->GetSize().GetHeight() + 5));
|
||||||
|
|
||||||
bAreaSelected = true;
|
bAreaSelected = true;
|
||||||
SendLoopPoints();
|
// SendLoopPoints();
|
||||||
|
SampleHive::cSignal::SendLoopPoints(CalculateLoopPoints(), *this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bAreaSelected = false;
|
bAreaSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::RenderPlayhead(wxDC& dc)
|
void cWaveformViewer::RenderPlayhead(wxDC& dc)
|
||||||
{
|
{
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
int length = tags.GetAudioInfo().length;
|
int length = tags.GetAudioInfo().length;
|
||||||
SH_LOG_DEBUG("Sample length: {}", length);
|
SH_LOG_DEBUG("Sample length: {}", length);
|
||||||
|
|
@ -143,23 +151,21 @@ void WaveformViewer::RenderPlayhead(wxDC& dc)
|
||||||
|
|
||||||
// Draw the line
|
// Draw the line
|
||||||
dc.SetPen(wxPen(m_PlayheadColour, 2, wxPENSTYLE_SOLID));
|
dc.SetPen(wxPen(m_PlayheadColour, 2, wxPENSTYLE_SOLID));
|
||||||
dc.DrawLine(line_pos, this->GetSize().GetHeight() - (this->GetSize().GetHeight() - 1),
|
dc.DrawLine(line_pos, this->GetSize().GetHeight() - (this->GetSize().GetHeight() - 1), line_pos, this->GetSize().GetHeight() - 1);
|
||||||
line_pos, this->GetSize().GetHeight() - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::UpdateWaveformBitmap()
|
void cWaveformViewer::UpdateWaveformBitmap()
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
SampleHive::cSerializer serializer;
|
||||||
|
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selection = m_Library.GetTextValue(selected_row, 1);
|
wxString selection = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
|
|
||||||
wxString filepath_with_extension =
|
wxString filepath_with_extension = m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
||||||
m_Database.GetSamplePathByFilename(selection.BeforeLast('.').ToStdString());
|
|
||||||
wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString());
|
wxString filepath_without_extension = m_Database.GetSamplePathByFilename(selection.ToStdString());
|
||||||
|
|
||||||
std::string extension = serializer.DeserializeShowFileExtension() ?
|
std::string extension = serializer.DeserializeShowFileExtension() ?
|
||||||
|
|
@ -261,7 +267,7 @@ void WaveformViewer::UpdateWaveformBitmap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
void cWaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
||||||
{
|
{
|
||||||
switch (event.GetKeyCode())
|
switch (event.GetKeyCode())
|
||||||
{
|
{
|
||||||
|
|
@ -276,7 +282,7 @@ void WaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnControlKeyUp(wxKeyEvent &event)
|
void cWaveformViewer::OnControlKeyUp(wxKeyEvent &event)
|
||||||
{
|
{
|
||||||
switch (event.GetKeyCode())
|
switch (event.GetKeyCode())
|
||||||
{
|
{
|
||||||
|
|
@ -284,9 +290,12 @@ void WaveformViewer::OnControlKeyUp(wxKeyEvent &event)
|
||||||
if (bSelectRange)
|
if (bSelectRange)
|
||||||
{
|
{
|
||||||
SetCursor(wxCURSOR_ARROW);
|
SetCursor(wxCURSOR_ARROW);
|
||||||
|
|
||||||
bSelectRange = false;
|
bSelectRange = false;
|
||||||
bDrawSelectedArea = false;
|
bDrawSelectedArea = false;
|
||||||
|
|
||||||
ReleaseMouse();
|
ReleaseMouse();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -297,17 +306,17 @@ void WaveformViewer::OnControlKeyUp(wxKeyEvent &event)
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnMouseMotion(wxMouseEvent& event)
|
void cWaveformViewer::OnMouseMotion(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
int length = tags.GetAudioInfo().length;
|
int length = tags.GetAudioInfo().length;
|
||||||
|
|
||||||
|
|
@ -337,17 +346,17 @@ void WaveformViewer::OnMouseMotion(wxMouseEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnMouseLeftButtonDown(wxMouseEvent& event)
|
void cWaveformViewer::OnMouseLeftButtonDown(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
int length = tags.GetAudioInfo().length;
|
int length = tags.GetAudioInfo().length;
|
||||||
|
|
||||||
|
|
@ -386,17 +395,17 @@ void WaveformViewer::OnMouseLeftButtonDown(wxMouseEvent& event)
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
|
void cWaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
|
||||||
{
|
{
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
int length = tags.GetAudioInfo().length;
|
int length = tags.GetAudioInfo().length;
|
||||||
|
|
||||||
|
|
@ -437,12 +446,12 @@ void WaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
|
||||||
SetCursor(wxCURSOR_ARROW);
|
SetCursor(wxCURSOR_ARROW);
|
||||||
|
|
||||||
m_MediaCtrl.Seek(seek_to, wxFromStart);
|
m_MediaCtrl.Seek(seek_to, wxFromStart);
|
||||||
SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selected), 1);
|
SampleHive::cSignal::SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selected), 1, *this);
|
||||||
m_MediaCtrl.Play();
|
SampleHive::cSignal::SendCallFunctionPlay(selected, false, *this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::ResetDC()
|
void cWaveformViewer::ResetDC()
|
||||||
{
|
{
|
||||||
bBitmapDirty = true;
|
bBitmapDirty = true;
|
||||||
bSelectRange = false;
|
bSelectRange = false;
|
||||||
|
|
@ -451,22 +460,17 @@ void WaveformViewer::ResetDC()
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::SendLoopPoints()
|
std::pair<double, double> cWaveformViewer::CalculateLoopPoints()
|
||||||
{
|
{
|
||||||
SH_LOG_DEBUG("{} Called", __FUNCTION__);
|
int selected_row = SampleHive::cHiveData::Get().GetListCtrlSelectedRow();
|
||||||
|
|
||||||
SampleHive::SH_LoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
|
||||||
|
|
||||||
if (selected_row < 0)
|
if (selected_row < 0)
|
||||||
return;
|
return { 0.0, 0.0 };
|
||||||
|
|
||||||
wxString selected = m_Library.GetTextValue(selected_row, 1);
|
wxString selected = SampleHive::cHiveData::Get().GetListCtrlTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
||||||
Tags tags(path);
|
SampleHive::cTags tags(path);
|
||||||
|
|
||||||
int length = tags.GetAudioInfo().length;
|
int length = tags.GetAudioInfo().length;
|
||||||
|
|
||||||
|
|
@ -477,19 +481,5 @@ void WaveformViewer::SendLoopPoints()
|
||||||
double loopA = ((double)a / panel_width) * length;
|
double loopA = ((double)a / panel_width) * length;
|
||||||
double loopB = ((double)b / panel_width) * length;
|
double loopB = ((double)b / panel_width) * length;
|
||||||
|
|
||||||
event.SetLoopPoints({ loopA, loopB });
|
return { loopA, loopB };
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
|
|
||||||
SH_LOG_DEBUG("{} processed event, sending loop points..", __FUNCTION__);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WaveformViewer::SendPushStatusBarStatus(const wxString& msg, int section)
|
|
||||||
{
|
|
||||||
SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
event.SetPushMessageAndSection({ msg, section });
|
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,33 +22,30 @@
|
||||||
|
|
||||||
#include "Database/Database.hpp"
|
#include "Database/Database.hpp"
|
||||||
|
|
||||||
#include <wx/dataview.h>
|
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#include <wx/colour.h>
|
#include <wx/colour.h>
|
||||||
#include <wx/dc.h>
|
#include <wx/dc.h>
|
||||||
#include <wx/event.h>
|
#include <wx/event.h>
|
||||||
#include <wx/infobar.h>
|
|
||||||
#include <wx/mediactrl.h>
|
#include <wx/mediactrl.h>
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/statusbr.h>
|
#include <wx/statusbr.h>
|
||||||
#include <wx/timer.h>
|
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
|
||||||
class WaveformViewer : public wxPanel
|
class cWaveformViewer : public wxPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
cWaveformViewer(wxWindow* window, wxMediaCtrl& mediaCtrl, cDatabase& database);
|
||||||
wxMediaCtrl& mediaCtrl, Database& database);
|
~cWaveformViewer();
|
||||||
~WaveformViewer();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxWindow* m_Window;
|
wxWindow* m_Window;
|
||||||
|
|
||||||
|
wxBoxSizer* m_Sizer;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
Database& m_Database;
|
cDatabase& m_Database;
|
||||||
wxDataViewListCtrl& m_Library;
|
|
||||||
wxMediaCtrl& m_MediaCtrl;
|
wxMediaCtrl& m_MediaCtrl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -85,9 +82,7 @@ class WaveformViewer : public wxPanel
|
||||||
void OnControlKeyDown(wxKeyEvent& event);
|
void OnControlKeyDown(wxKeyEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Send custom events
|
std::pair<double, double> CalculateLoopPoints();
|
||||||
void SendLoopPoints();
|
|
||||||
void SendPushStatusBarStatus(const wxString& msg, int section);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
/* SampleHive
|
|
||||||
* Copyright (C) 2021 Apoorv Singh
|
|
||||||
* A simple, modern audio sample browser/manager for GNU/Linux.
|
|
||||||
*
|
|
||||||
* This file is a part of SampleHive
|
|
||||||
*
|
|
||||||
* SampleHive is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* SampleHive is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <wx/defs.h>
|
|
||||||
|
|
||||||
enum ControlIDs
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
** BC = Browser control
|
|
||||||
** SD = Settings dialog
|
|
||||||
** MN = Popup menu
|
|
||||||
** ET = Edit tag dialog
|
|
||||||
*/
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Browser controls
|
|
||||||
BC_Play = wxID_HIGHEST + 1,
|
|
||||||
BC_Settings,
|
|
||||||
BC_Loop,
|
|
||||||
BC_Stop,
|
|
||||||
BC_LoopABButton,
|
|
||||||
BC_Mute,
|
|
||||||
BC_Autoplay,
|
|
||||||
BC_Volume,
|
|
||||||
BC_SamplePosition,
|
|
||||||
BC_Hives,
|
|
||||||
BC_DirCtrl,
|
|
||||||
BC_Library,
|
|
||||||
BC_Search,
|
|
||||||
BC_MediaCtrl,
|
|
||||||
BC_Trash,
|
|
||||||
BC_RestoreTrashedItem,
|
|
||||||
BC_HiveAdd,
|
|
||||||
BC_HiveRemove,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Setting dialog controls
|
|
||||||
SD_BrowseConfigDir,
|
|
||||||
SD_BrowseDatabaseDir,
|
|
||||||
SD_AutoImport,
|
|
||||||
SD_FollowSymLinks,
|
|
||||||
SD_RecursiveImport,
|
|
||||||
SD_ShowFileExtension,
|
|
||||||
SD_BrowseAutoImportDir,
|
|
||||||
SD_FontType,
|
|
||||||
SD_FontSize,
|
|
||||||
SD_FontBrowseButton,
|
|
||||||
SD_WaveformColourPickerCtrl,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// App Menu items
|
|
||||||
MN_AddFile,
|
|
||||||
MN_AddDirectory,
|
|
||||||
MN_ToggleExtension,
|
|
||||||
MN_ToggleMenuBar,
|
|
||||||
MN_ToggleStatusBar,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Library Menu items
|
|
||||||
MN_FavoriteSample,
|
|
||||||
MN_DeleteSample,
|
|
||||||
MN_TrashSample,
|
|
||||||
MN_EditTagSample,
|
|
||||||
MN_OpenFile,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Library Column Header Menu items
|
|
||||||
MN_ColumnFavorite,
|
|
||||||
MN_ColumnFilename,
|
|
||||||
MN_ColumnSamplePack,
|
|
||||||
MN_ColumnType,
|
|
||||||
MN_ColumnChannels,
|
|
||||||
MN_ColumnLength,
|
|
||||||
MN_ColumnSampleRate,
|
|
||||||
MN_ColumnBitrate,
|
|
||||||
MN_ColumnPath,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Hives Menu items
|
|
||||||
MN_RenameHive,
|
|
||||||
MN_DeleteHive,
|
|
||||||
MN_RemoveSample,
|
|
||||||
MN_FilterLibrary,
|
|
||||||
MN_ShowInLibrary,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Trash Menu items
|
|
||||||
MN_DeleteTrash,
|
|
||||||
MN_RestoreTrashedItem,
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Edit tags dialog controls
|
|
||||||
ET_TitleCheck,
|
|
||||||
ET_ArtistCheck,
|
|
||||||
ET_AlbumCheck,
|
|
||||||
ET_GenreCheck,
|
|
||||||
ET_CommentsCheck,
|
|
||||||
ET_TypeCheck,
|
|
||||||
ET_CustomTag,
|
|
||||||
};
|
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <wx/defs.h>
|
||||||
|
|
||||||
|
namespace SampleHive { namespace ID {
|
||||||
|
|
||||||
|
enum ControlIDs
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
** BC = Browser control
|
||||||
|
** SD = Settings dialog
|
||||||
|
** MN = Popup menu
|
||||||
|
** ET = Edit tag dialog
|
||||||
|
*/
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Browser controls
|
||||||
|
BC_Play = wxID_HIGHEST + 1,
|
||||||
|
BC_Settings,
|
||||||
|
BC_Loop,
|
||||||
|
BC_Stop,
|
||||||
|
BC_LoopABButton,
|
||||||
|
BC_Mute,
|
||||||
|
BC_Autoplay,
|
||||||
|
BC_Volume,
|
||||||
|
BC_SamplePosition,
|
||||||
|
BC_Hives,
|
||||||
|
BC_DirCtrl,
|
||||||
|
BC_Library,
|
||||||
|
BC_Search,
|
||||||
|
BC_MediaCtrl,
|
||||||
|
BC_Trash,
|
||||||
|
BC_RestoreTrashedItem,
|
||||||
|
BC_HiveAdd,
|
||||||
|
BC_HiveRemove,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Setting dialog controls
|
||||||
|
SD_BrowseConfigDir,
|
||||||
|
SD_BrowseDatabaseDir,
|
||||||
|
SD_AutoImport,
|
||||||
|
SD_FollowSymLinks,
|
||||||
|
SD_RecursiveImport,
|
||||||
|
SD_ShowFileExtension,
|
||||||
|
SD_BrowseAutoImportDir,
|
||||||
|
SD_FontType,
|
||||||
|
SD_FontSize,
|
||||||
|
SD_FontBrowseButton,
|
||||||
|
SD_WaveformColourPickerCtrl,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// App Menu items
|
||||||
|
MN_AddFile,
|
||||||
|
MN_AddDirectory,
|
||||||
|
MN_ToggleExtension,
|
||||||
|
MN_ToggleMenuBar,
|
||||||
|
MN_ToggleStatusBar,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Library Menu items
|
||||||
|
MN_FavoriteSample,
|
||||||
|
MN_DeleteSample,
|
||||||
|
MN_TrashSample,
|
||||||
|
MN_EditTagSample,
|
||||||
|
MN_OpenFile,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Library Column Header Menu items
|
||||||
|
MN_ColumnFavorite,
|
||||||
|
MN_ColumnFilename,
|
||||||
|
MN_ColumnSamplePack,
|
||||||
|
MN_ColumnType,
|
||||||
|
MN_ColumnChannels,
|
||||||
|
MN_ColumnLength,
|
||||||
|
MN_ColumnSampleRate,
|
||||||
|
MN_ColumnBitrate,
|
||||||
|
MN_ColumnPath,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Hives Menu items
|
||||||
|
MN_RenameHive,
|
||||||
|
MN_DeleteHive,
|
||||||
|
MN_RemoveSample,
|
||||||
|
MN_FilterLibrary,
|
||||||
|
MN_ShowInLibrary,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Trash Menu items
|
||||||
|
MN_DeleteTrash,
|
||||||
|
MN_RestoreTrashedItem,
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Edit tags dialog controls
|
||||||
|
ET_TitleCheck,
|
||||||
|
ET_ArtistCheck,
|
||||||
|
ET_AlbumCheck,
|
||||||
|
ET_GenreCheck,
|
||||||
|
ET_CommentsCheck,
|
||||||
|
ET_TypeCheck,
|
||||||
|
ET_CustomTag,
|
||||||
|
};
|
||||||
|
|
||||||
|
}}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Utility/Event.hpp"
|
||||||
|
|
||||||
|
namespace SampleHive
|
||||||
|
{
|
||||||
|
cLoopPointsEvent::cLoopPointsEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cLoopPointsEvent::~cLoopPointsEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, cLoopPointsEvent);
|
||||||
|
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_CLEAR, cLoopPointsEvent);
|
||||||
|
wxDEFINE_EVENT(SH_EVT_LOOP_AB_BUTTON_VALUE_CHANGE, cLoopPointsEvent);
|
||||||
|
|
||||||
|
// MediaEvent::MediaEvent(wxEventType eventType, int winId)
|
||||||
|
// : wxCommandEvent(eventType, winId)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// MediaEvent::~MediaEvent()
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, MediaEvent);
|
||||||
|
|
||||||
|
cStatusBarStatusEvent::cStatusBarStatusEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cStatusBarStatusEvent::~cStatusBarStatusEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, cStatusBarStatusEvent);
|
||||||
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, cStatusBarStatusEvent);
|
||||||
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, cStatusBarStatusEvent);
|
||||||
|
|
||||||
|
cInfoBarMessageEvent::cInfoBarMessageEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cInfoBarMessageEvent::~cInfoBarMessageEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, cInfoBarMessageEvent);
|
||||||
|
|
||||||
|
cTimerEvent::cTimerEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cTimerEvent::~cTimerEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, cTimerEvent);
|
||||||
|
|
||||||
|
cCallFunctionEvent::cCallFunctionEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cCallFunctionEvent::~cCallFunctionEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_CALL_FUNC_PLAY, cCallFunctionEvent);
|
||||||
|
|
||||||
|
cWaveformUpdateEvent::cWaveformUpdateEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cWaveformUpdateEvent::~cWaveformUpdateEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_UPDATE_WAVEFORM, cWaveformUpdateEvent);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <wx/event.h>
|
||||||
|
|
||||||
|
namespace SampleHive
|
||||||
|
{
|
||||||
|
class cLoopPointsEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cLoopPointsEvent(wxEventType eventType, int winId);
|
||||||
|
~cLoopPointsEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new cLoopPointsEvent(*this); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
|
||||||
|
void SetLoopPoints(std::pair<double&, double&> loopPoints)
|
||||||
|
{ m_LoopA = loopPoints.first; m_LoopB = loopPoints.second; };
|
||||||
|
|
||||||
|
private:
|
||||||
|
double m_LoopA, m_LoopB;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, cLoopPointsEvent);
|
||||||
|
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_CLEAR, cLoopPointsEvent);
|
||||||
|
wxDECLARE_EVENT(SH_EVT_LOOP_AB_BUTTON_VALUE_CHANGE, cLoopPointsEvent);
|
||||||
|
|
||||||
|
// class cMediaEvent : public wxCommandEvent
|
||||||
|
// {
|
||||||
|
// public:
|
||||||
|
// cMediaEvent(wxEventType eventType, int winId);
|
||||||
|
// ~cMediaEvent();
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// virtual wxEvent* Clone() const { return new cMediaEvent(*this); }
|
||||||
|
|
||||||
|
// public:
|
||||||
|
// void SetPath(const wxString& path) { m_Path = path; }
|
||||||
|
// wxString GetPath() const { return m_Path; }
|
||||||
|
|
||||||
|
// private:
|
||||||
|
// wxString m_Path;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, cMediaEvent);
|
||||||
|
|
||||||
|
class cStatusBarStatusEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cStatusBarStatusEvent(wxEventType eventType, int winId);
|
||||||
|
~cStatusBarStatusEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new cStatusBarStatusEvent(*this); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
|
||||||
|
void SetPushMessageAndSection(std::pair<const wxString&, int> status)
|
||||||
|
{ m_Msg = status.first; m_PushSection = status.second; }
|
||||||
|
|
||||||
|
std::pair<wxString, int> GetStatusTextAndSection() const { return { m_Text, m_SetSection }; }
|
||||||
|
void SetStatusTextAndSection(std::pair<const wxString&, int> status)
|
||||||
|
{ m_Text = status.first, m_SetSection = status.second; }
|
||||||
|
|
||||||
|
int GetPopMessageSection() const { return m_PopSection; }
|
||||||
|
void SetPopMessageSection(int section) { m_PopSection = section; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_Msg, m_Text;
|
||||||
|
int m_PushSection, m_PopSection, m_SetSection;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, cStatusBarStatusEvent);
|
||||||
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, cStatusBarStatusEvent);
|
||||||
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, cStatusBarStatusEvent);
|
||||||
|
|
||||||
|
class cInfoBarMessageEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cInfoBarMessageEvent(wxEventType eventType, int winId);
|
||||||
|
~cInfoBarMessageEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new cInfoBarMessageEvent(*this); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
||||||
|
void SetInfoBarMessage(std::pair<const wxString&, int> info)
|
||||||
|
{ m_Msg = info.first; m_Mode = info.second; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_Msg;
|
||||||
|
int m_Mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, cInfoBarMessageEvent);
|
||||||
|
|
||||||
|
class cTimerEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cTimerEvent(wxEventType eventType, int winId);
|
||||||
|
~cTimerEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new cTimerEvent(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, cTimerEvent);
|
||||||
|
|
||||||
|
class cCallFunctionEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cCallFunctionEvent(wxEventType eventType, int winId);
|
||||||
|
~cCallFunctionEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new cCallFunctionEvent(*this); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxString GetSlection() const { return m_Selection; }
|
||||||
|
bool GetAutoplayValue() const { return m_bCheckAutoplay; }
|
||||||
|
void SetSelection(const wxString& selection) { m_Selection = selection; }
|
||||||
|
void SetAutoplayValue(bool autoplay) { m_bCheckAutoplay = autoplay; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_Selection;
|
||||||
|
bool m_bCheckAutoplay;
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_CALL_FUNC_PLAY, cCallFunctionEvent);
|
||||||
|
|
||||||
|
class cWaveformUpdateEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cWaveformUpdateEvent(wxEventType eventType, int winId);
|
||||||
|
~cWaveformUpdateEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new cWaveformUpdateEvent(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_UPDATE_WAVEFORM, cWaveformUpdateEvent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,115 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wx/dataview.h"
|
||||||
|
#include "wx/string.h"
|
||||||
|
#include "wx/treectrl.h"
|
||||||
|
#include "wx/treebase.h"
|
||||||
|
#include "wx/variant.h"
|
||||||
|
#include "wx/vector.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
class cHiveData
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
cHiveData() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cHiveData(const cHiveData&) = delete;
|
||||||
|
cHiveData& operator=(const cHiveData) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static cHiveData& Get()
|
||||||
|
{
|
||||||
|
static cHiveData s_HiveData;
|
||||||
|
return s_HiveData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
// ===============================================================
|
||||||
|
// HivesPanel functions
|
||||||
|
void InitHiveData(wxDataViewListCtrl& listCtrl, wxDataViewTreeCtrl& hives, wxDataViewItem favoriteHive,
|
||||||
|
wxTreeCtrl& trash, wxTreeItemId trashRoot)
|
||||||
|
{
|
||||||
|
m_pListCtrl = &listCtrl;
|
||||||
|
m_FavoriteHive = favoriteHive;
|
||||||
|
m_pHives = &hives;
|
||||||
|
m_TrashRoot = trashRoot;
|
||||||
|
m_pTrash = &trash;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wxDataViewTreeCtrl& GetHivesObj() { return *m_pHives; }
|
||||||
|
inline wxDataViewItem& GetFavoritesHive() { return m_FavoriteHive; }
|
||||||
|
|
||||||
|
wxString GetHiveItemText(bool ofFavHive = false, wxDataViewItem hive = wxDataViewItem(0))
|
||||||
|
{
|
||||||
|
wxString item_text;
|
||||||
|
|
||||||
|
if (ofFavHive)
|
||||||
|
item_text = m_pHives->GetItemText(m_FavoriteHive);
|
||||||
|
else
|
||||||
|
item_text = m_pHives->GetItemText(hive);
|
||||||
|
|
||||||
|
return item_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline wxDataViewItem GetHiveItemSelection() { return m_pHives->GetSelection(); }
|
||||||
|
inline bool IsHiveItemContainer(wxDataViewItem& hiveItem) { return m_pHives->IsContainer(hiveItem); }
|
||||||
|
inline int GetHiveChildCount(wxDataViewItem& root) { return m_pHives->GetChildCount(root); }
|
||||||
|
inline wxDataViewItem GetHiveNthChild(wxDataViewItem& root, int pos) { return m_pHives->GetNthChild(root, pos); }
|
||||||
|
inline void HiveAppendItem(wxDataViewItem& hiveItem, wxString name) { m_pHives->AppendItem(hiveItem, name); }
|
||||||
|
inline void HiveDeleteItem(wxDataViewItem& hiveItem) { m_pHives->DeleteItem(hiveItem); }
|
||||||
|
|
||||||
|
// ===============================================================
|
||||||
|
// TrashPanel functions
|
||||||
|
inline wxTreeCtrl& GetTrashObj() { return *m_pTrash; }
|
||||||
|
inline wxTreeItemId& GetTrashRoot() { return m_TrashRoot; }
|
||||||
|
inline void TrashAppendItem(const wxTreeItemId& parent, const wxString& text) { m_pTrash->AppendItem(parent, text); }
|
||||||
|
|
||||||
|
// ===============================================================
|
||||||
|
// ListCtrl functions
|
||||||
|
inline wxDataViewListCtrl& GetListCtrlObj() { return *m_pListCtrl; }
|
||||||
|
inline int GetListCtrlSelections(wxDataViewItemArray& items) { return m_pListCtrl->GetSelections(items); }
|
||||||
|
inline int GetListCtrlRowFromItem(wxDataViewItemArray& items, int index) { return m_pListCtrl->ItemToRow(items[index]); }
|
||||||
|
inline int GetListCtrlSelectedRow() { return m_pListCtrl->GetSelectedRow(); }
|
||||||
|
inline wxDataViewItem GetListCtrlItemFromRow(int row) { return m_pListCtrl->RowToItem(row); }
|
||||||
|
inline wxString GetListCtrlTextValue(unsigned int row, unsigned int col) { return m_pListCtrl->GetTextValue(row, col); }
|
||||||
|
inline int GetListCtrlItemCount() { return m_pListCtrl->GetItemCount(); }
|
||||||
|
inline void ListCtrlAppendItem(const wxVector<wxVariant>& values) { m_pListCtrl->AppendItem(values); }
|
||||||
|
inline void ListCtrlSetVariant(const wxVariant& variant, unsigned int row, unsigned int col)
|
||||||
|
{ m_pListCtrl->SetValue(variant, row, col); }
|
||||||
|
inline void ListCtrlUnselectAllItems() { m_pListCtrl->UnselectAll(); }
|
||||||
|
inline void ListCtrlSelectRow(int row) { m_pListCtrl->SelectRow(row); }
|
||||||
|
inline void ListCtrlEnsureVisible(const wxDataViewItem& item) { m_pListCtrl->EnsureVisible(item); }
|
||||||
|
inline void ListCtrlDeleteItem(unsigned int row) { m_pListCtrl->DeleteItem(row); }
|
||||||
|
inline void ListCtrlDeleteAllItems() { m_pListCtrl->DeleteAllItems(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDataViewListCtrl* m_pListCtrl = nullptr;
|
||||||
|
wxDataViewItem m_FavoriteHive;
|
||||||
|
wxDataViewTreeCtrl* m_pHives = nullptr;
|
||||||
|
wxTreeCtrl* m_pTrash = nullptr;
|
||||||
|
wxTreeItemId m_TrashRoot;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "Log.hpp"
|
#include "Log.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -6,16 +26,16 @@
|
||||||
|
|
||||||
namespace SampleHive {
|
namespace SampleHive {
|
||||||
|
|
||||||
std::shared_ptr<spdlog::logger> Log::s_Logger;
|
std::shared_ptr<spdlog::logger> cLog::s_pLogger;
|
||||||
|
|
||||||
void Log::InitLogger(const std::string& logger)
|
void cLog::InitLogger(const std::string& logger)
|
||||||
{
|
{
|
||||||
spdlog::set_pattern("%^[%-T] [%-n] [%l]: %v %@%$");
|
spdlog::set_pattern("%^[%-T] [%-n] [%l]: %v %@%$");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
s_Logger = spdlog::stdout_color_mt(logger);
|
s_pLogger = spdlog::stdout_color_mt(logger);
|
||||||
s_Logger->set_level(spdlog::level::trace);
|
s_pLogger->set_level(spdlog::level::trace);
|
||||||
}
|
}
|
||||||
catch (const spdlog::spdlog_ex& ex)
|
catch (const spdlog::spdlog_ex& ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,23 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -8,24 +28,24 @@
|
||||||
|
|
||||||
namespace SampleHive {
|
namespace SampleHive {
|
||||||
|
|
||||||
class Log
|
class cLog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void InitLogger(const std::string& logger);
|
static void InitLogger(const std::string& logger);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline static std::shared_ptr<spdlog::logger>& GetLogger() { return s_Logger; }
|
inline static std::shared_ptr<spdlog::logger>& GetLogger() { return s_pLogger; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::shared_ptr<spdlog::logger> s_Logger;
|
static std::shared_ptr<spdlog::logger> s_pLogger;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
// Log macros
|
||||||
|
#define SH_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
|
||||||
|
#define SH_LOG_INFO(...) SPDLOG_LOGGER_INFO(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
|
||||||
|
#define SH_LOG_WARN(...) SPDLOG_LOGGER_WARN(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
|
||||||
|
#define SH_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
|
||||||
|
#define SH_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
|
||||||
|
#define SH_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(::SampleHive::cLog::GetLogger(), __VA_ARGS__)
|
||||||
|
|
||||||
// Log macros
|
}
|
||||||
#define SH_LOG_TRACE(...) SPDLOG_LOGGER_TRACE(::SampleHive::Log::GetLogger(), __VA_ARGS__)
|
|
||||||
#define SH_LOG_INFO(...) SPDLOG_LOGGER_INFO(::SampleHive::Log::GetLogger(), __VA_ARGS__)
|
|
||||||
#define SH_LOG_WARN(...) SPDLOG_LOGGER_WARN(::SampleHive::Log::GetLogger(), __VA_ARGS__)
|
|
||||||
#define SH_LOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(::SampleHive::Log::GetLogger(), __VA_ARGS__)
|
|
||||||
#define SH_LOG_ERROR(...) SPDLOG_LOGGER_ERROR(::SampleHive::Log::GetLogger(), __VA_ARGS__)
|
|
||||||
#define SH_LOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(::SampleHive::Log::GetLogger(), __VA_ARGS__)
|
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,55 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SampleHiveConfig.hpp"
|
#include "SampleHiveConfig.hpp"
|
||||||
|
|
||||||
// Path to all the assets
|
namespace SampleHive {
|
||||||
#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 SPLASH_LOGO SAMPLEHIVE_DATADIR "/logo/logo-samplehive_768x432.png"
|
|
||||||
|
|
||||||
// Path to useful directories and files
|
// Path to all the assets
|
||||||
#define USER_HOME_DIR wxGetUserHome()
|
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
|
||||||
#define APP_CONFIG_DIR USER_HOME_DIR + "/.config/SampleHive"
|
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"
|
||||||
#define APP_DATA_DIR USER_HOME_DIR + "/.local/share/SampleHive"
|
#define ICON_HIVE_32px SAMPLEHIVE_DATADIR "/icons/icon-hive_32x32.png"
|
||||||
#define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml"
|
#define ICON_HIVE_64px SAMPLEHIVE_DATADIR "/icons/icon-hive_64x64.png"
|
||||||
#define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive"
|
#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 SPLASH_LOGO SAMPLEHIVE_DATADIR "/logo/logo-samplehive_768x432.png"
|
||||||
|
|
||||||
|
// Path to useful directories and files
|
||||||
|
#define USER_HOME_DIR wxGetUserHome()
|
||||||
|
#define APP_CONFIG_DIR USER_HOME_DIR + "/.config/SampleHive"
|
||||||
|
#define APP_DATA_DIR USER_HOME_DIR + "/.local/share/SampleHive"
|
||||||
|
#define CONFIG_FILEPATH APP_CONFIG_DIR + "/config.yaml"
|
||||||
|
#define DATABASE_FILEPATH APP_DATA_DIR "/sample.hive"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
/* SampleHive
|
|
||||||
* Copyright (C) 2021 Apoorv Singh
|
|
||||||
* A simple, modern audio sample browser/manager for GNU/Linux.
|
|
||||||
*
|
|
||||||
* This file is a part of SampleHive
|
|
||||||
*
|
|
||||||
* SampleHive is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* SampleHive is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Utility/SH_Event.hpp"
|
|
||||||
|
|
||||||
namespace SampleHive
|
|
||||||
{
|
|
||||||
SH_LoopPointsEvent::SH_LoopPointsEvent(wxEventType eventType, int winId)
|
|
||||||
: wxCommandEvent(eventType, winId)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SH_LoopPointsEvent::~SH_LoopPointsEvent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, SH_LoopPointsEvent);
|
|
||||||
|
|
||||||
// SH_AddSampleEvent::SH_AddSampleEvent(wxEventType eventType, int winId)
|
|
||||||
// : wxCommandEvent(eventType, winId)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// SH_AddSampleEvent::~SH_AddSampleEvent()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// wxDEFINE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, SH_AddSampleEvent);
|
|
||||||
|
|
||||||
// SH_MediaEvent::SH_MediaEvent(wxEventType eventType, int winId)
|
|
||||||
// : wxCommandEvent(eventType, winId)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// SH_MediaEvent::~SH_MediaEvent()
|
|
||||||
// {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
|
||||||
|
|
||||||
SH_StatusBarStatusEvent::SH_StatusBarStatusEvent(wxEventType eventType, int winId)
|
|
||||||
: wxCommandEvent(eventType, winId)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SH_StatusBarStatusEvent::~SH_StatusBarStatusEvent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
|
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
|
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
|
|
||||||
|
|
||||||
SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
|
|
||||||
: wxCommandEvent(eventType, winId)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SH_InfoBarMessageEvent::~SH_InfoBarMessageEvent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
|
|
||||||
|
|
||||||
SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
|
|
||||||
: wxCommandEvent(eventType, winId)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SH_TimerEvent::~SH_TimerEvent()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
|
|
||||||
}
|
|
||||||
|
|
@ -1,149 +0,0 @@
|
||||||
/* SampleHive
|
|
||||||
* Copyright (C) 2021 Apoorv Singh
|
|
||||||
* A simple, modern audio sample browser/manager for GNU/Linux.
|
|
||||||
*
|
|
||||||
* This file is a part of SampleHive
|
|
||||||
*
|
|
||||||
* SampleHive is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* SampleHive is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include <wx/event.h>
|
|
||||||
|
|
||||||
namespace SampleHive
|
|
||||||
{
|
|
||||||
class SH_LoopPointsEvent : public wxCommandEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SH_LoopPointsEvent(wxEventType eventType, int winId);
|
|
||||||
~SH_LoopPointsEvent();
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual wxEvent* Clone() const { return new SH_LoopPointsEvent(*this); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
|
|
||||||
void SetLoopPoints(std::pair<double&, double&> loopPoints)
|
|
||||||
{ m_LoopA = loopPoints.first; m_LoopB = loopPoints.second; };
|
|
||||||
|
|
||||||
private:
|
|
||||||
double m_LoopA, m_LoopB;
|
|
||||||
};
|
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, SH_LoopPointsEvent);
|
|
||||||
|
|
||||||
// class SH_AddSampleEvent : public wxCommandEvent
|
|
||||||
// {
|
|
||||||
// public:
|
|
||||||
// SH_AddSampleEvent(wxEventType eventType, int winId);
|
|
||||||
// ~SH_AddSampleEvent();
|
|
||||||
|
|
||||||
// public:
|
|
||||||
// virtual wxEvent* Clone() const { return new SH_AddSampleEvent(*this); }
|
|
||||||
|
|
||||||
// public:
|
|
||||||
// wxArrayString GetArrayString() const { return m_Files; };
|
|
||||||
// void SetArrayString(const wxArrayString& files) { m_Files = files; };
|
|
||||||
|
|
||||||
// private:
|
|
||||||
// wxArrayString m_Files;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// wxDECLARE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, SH_AddSampleEvent);
|
|
||||||
|
|
||||||
// class SH_MediaEvent : public wxCommandEvent
|
|
||||||
// {
|
|
||||||
// public:
|
|
||||||
// SH_MediaEvent(wxEventType eventType, int winId);
|
|
||||||
// ~SH_MediaEvent();
|
|
||||||
|
|
||||||
// public:
|
|
||||||
// virtual wxEvent* Clone() const { return new SH_MediaEvent(*this); }
|
|
||||||
|
|
||||||
// public:
|
|
||||||
// void SetPath(const wxString& path) { m_Path = path; }
|
|
||||||
// wxString GetPath() const { return m_Path; }
|
|
||||||
|
|
||||||
// private:
|
|
||||||
// wxString m_Path;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
|
||||||
|
|
||||||
class SH_StatusBarStatusEvent : public wxCommandEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SH_StatusBarStatusEvent(wxEventType eventType, int winId);
|
|
||||||
~SH_StatusBarStatusEvent();
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual wxEvent* Clone() const { return new SH_StatusBarStatusEvent(*this); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
|
|
||||||
void SetPushMessageAndSection(std::pair<const wxString&, int> status)
|
|
||||||
{ m_Msg = status.first; m_PushSection = status.second; }
|
|
||||||
|
|
||||||
std::pair<wxString, int> GetStatusTextAndSection() const { return { m_Text, m_SetSection }; }
|
|
||||||
void SetStatusTextAndSection(std::pair<const wxString&, int> status)
|
|
||||||
{ m_Text = status.first, m_SetSection = status.second; }
|
|
||||||
|
|
||||||
int GetPopMessageSection() const { return m_PopSection; }
|
|
||||||
void SetPopMessageSection(int section) { m_PopSection = section; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxString m_Msg, m_Text;
|
|
||||||
int m_PushSection, m_PopSection, m_SetSection;
|
|
||||||
};
|
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
|
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
|
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
|
|
||||||
|
|
||||||
class SH_InfoBarMessageEvent : public wxCommandEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SH_InfoBarMessageEvent(wxEventType eventType, int winId);
|
|
||||||
~SH_InfoBarMessageEvent();
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
|
||||||
void SetInfoBarMessage(std::pair<const wxString&, int> info)
|
|
||||||
{ m_Msg = info.first; m_Mode = info.second; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
wxString m_Msg;
|
|
||||||
int m_Mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
|
|
||||||
|
|
||||||
class SH_TimerEvent : public wxCommandEvent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SH_TimerEvent(wxEventType eventType, int winId);
|
|
||||||
~SH_TimerEvent();
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
|
|
||||||
};
|
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -42,67 +42,71 @@ typedef std::pair<int, int> WindowSize;
|
||||||
// typedef std::pair<wxString, int> FontType;
|
// typedef std::pair<wxString, int> FontType;
|
||||||
typedef std::pair<bool, wxString> ImportDirInfo;
|
typedef std::pair<bool, wxString> ImportDirInfo;
|
||||||
|
|
||||||
class Serializer
|
namespace SampleHive {
|
||||||
{
|
|
||||||
public:
|
|
||||||
Serializer();
|
|
||||||
~Serializer();
|
|
||||||
|
|
||||||
private:
|
class cSerializer
|
||||||
// -------------------------------------------------------------------
|
{
|
||||||
YAML::Emitter m_Emitter;
|
public:
|
||||||
|
cSerializer();
|
||||||
|
~cSerializer();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Window size
|
// Window size
|
||||||
void SerializeWinSize(int w, int h);
|
void SerializeWinSize(int w, int h);
|
||||||
WindowSize DeserializeWinSize() const;
|
WindowSize DeserializeWinSize() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Menu and status bar
|
// Menu and status bar
|
||||||
void SerializeShowMenuAndStatusBar(std::string key, bool value);
|
void SerializeShowMenuAndStatusBar(std::string key, bool value);
|
||||||
bool DeserializeShowMenuAndStatusBar(std::string key) const;
|
bool DeserializeShowMenuAndStatusBar(std::string key) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Splitter window sash pos
|
// Splitter window sash pos
|
||||||
void SerializeSplitterSashPos(std::string key, int pos);
|
void SerializeSplitterSashPos(std::string key, int pos);
|
||||||
int DeserializeSplitterSashPos(std::string key) const;
|
int DeserializeSplitterSashPos(std::string key) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Browser controls
|
// Browser controls
|
||||||
void SerializeMediaOptions(std::string key, bool value);
|
void SerializeMediaOptions(std::string key, bool value);
|
||||||
bool DeserializeMediaOptions(std::string key) const;
|
bool DeserializeMediaOptions(std::string key) const;
|
||||||
|
|
||||||
void SerializeMediaVolume(int volume);
|
void SerializeMediaVolume(int volume);
|
||||||
int DeserializeMediaVolume() const;
|
int DeserializeMediaVolume() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Display settings
|
// Display settings
|
||||||
void SerializeFontSettings(wxFont& font);
|
void SerializeFontSettings(wxFont& font);
|
||||||
wxFont DeserializeFontSettings() const;
|
wxFont DeserializeFontSettings() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Waveform colour
|
// Waveform colour
|
||||||
void SerializeWaveformColour(wxColour& colour);
|
void SerializeWaveformColour(wxColour& colour);
|
||||||
wxColour DeserializeWaveformColour() const;
|
wxColour DeserializeWaveformColour() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Auto import settings
|
// Auto import settings
|
||||||
void SerializeAutoImport(bool autoImport, const std::string& importDir);
|
void SerializeAutoImport(bool autoImport, const std::string& importDir);
|
||||||
ImportDirInfo DeserializeAutoImport() const;
|
ImportDirInfo DeserializeAutoImport() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Follow symbolic links
|
// Follow symbolic links
|
||||||
void SerializeFollowSymLink(bool followSymLink);
|
void SerializeFollowSymLink(bool followSymLink);
|
||||||
bool DeserializeFollowSymLink() const;
|
bool DeserializeFollowSymLink() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Recursive import
|
// Recursive import
|
||||||
void SerializeRecursiveImport(bool recursiveImport);
|
void SerializeRecursiveImport(bool recursiveImport);
|
||||||
bool DeserializeRecursiveImport() const;
|
bool DeserializeRecursiveImport() const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Show file extension
|
// Show file extension
|
||||||
void SerializeShowFileExtension(bool showExtension);
|
void SerializeShowFileExtension(bool showExtension);
|
||||||
bool DeserializeShowFileExtension() const;
|
bool DeserializeShowFileExtension() const;
|
||||||
};
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
YAML::Emitter m_Emitter;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Event.hpp"
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
void cSignal::SendInfoBarMessage(const wxString& msg, int mode, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cInfoBarMessageEvent event(SampleHive::SH_EVT_INFOBAR_MESSAGE_SHOW, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetInfoBarMessage({ msg, mode });
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendPushStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cStatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetPushMessageAndSection({ msg, section });
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendPopStatusBarStatus(int section, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cStatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_POP, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetPopMessageSection(section);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendSetStatusBarStatus(const wxString& text, int section, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cStatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_SET, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetStatusTextAndSection({ text, section });
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendCallFunctionPlay(const wxString& selection, bool checkAutoplay, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cCallFunctionEvent event(SampleHive::SH_EVT_CALL_FUNC_PLAY, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetSelection(selection);
|
||||||
|
event.SetAutoplayValue(checkAutoplay);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendTimerStopStatus(wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cTimerEvent event(SampleHive::SH_EVT_TIMER_STOP, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendLoopPoints(std::pair<double, double> loopPoint, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cLoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetLoopPoints({loopPoint.first, loopPoint.second});
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendClearLoopPointsStatus(wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cLoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_CLEAR, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendLoopABButtonValueChange(wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cLoopPointsEvent event(SampleHive::SH_EVT_LOOP_AB_BUTTON_VALUE_CHANGE, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSignal::SendWaveformUpdateStatus(wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::cWaveformUpdateEvent event(SampleHive::SH_EVT_UPDATE_WAVEFORM, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
class cSignal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cSignal();
|
||||||
|
~cSignal();
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void SendInfoBarMessage(const wxString& msg, int mode, wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendPushStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendSetStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendPopStatusBarStatus(int section, wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendCallFunctionPlay(const wxString& selection, bool checkAutoplay, wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendTimerStopStatus(wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendLoopPoints(std::pair<double, double> loopPoint, wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendClearLoopPointsStatus(wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendLoopABButtonValueChange(wxWindow& window, bool isDialog = false);
|
||||||
|
static void SendWaveformUpdateStatus(wxWindow& window, bool isDialog = false);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -33,142 +33,125 @@
|
||||||
#include <taglib/tstring.h>
|
#include <taglib/tstring.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Tags::Tags(const std::string& filename)
|
namespace SampleHive {
|
||||||
: m_Filepath(filename)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
cTags::cTags(const std::string& filename)
|
||||||
|
: m_Filepath(filename)
|
||||||
Tags::~Tags()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AudioInfo Tags::GetAudioInfo()
|
|
||||||
{
|
|
||||||
wxString artist, album, genre, title, comment;
|
|
||||||
int channels = 0, length_ms = 0, length_s = 0, sample_rate = 0, bitrate = 0;
|
|
||||||
|
|
||||||
TagLib::FileRef f(static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
|
||||||
TagLib::AudioProperties* properties = f.audioProperties();
|
|
||||||
// TagLib::PropertyMap property_map = f.file()->properties();
|
|
||||||
|
|
||||||
TagLib::String Title = tag->title();
|
|
||||||
TagLib::String Artist = tag->artist();
|
|
||||||
TagLib::String Album = tag->album();
|
|
||||||
TagLib::String Genre = tag->genre();
|
|
||||||
TagLib::String Comment = tag->comment();
|
|
||||||
|
|
||||||
int seconds = properties->length() % 60;
|
|
||||||
int minutes = (properties->length() - seconds) / 60;
|
|
||||||
|
|
||||||
bitrate = properties->bitrate();
|
|
||||||
channels = properties->channels();
|
|
||||||
length_ms = properties->lengthInMilliseconds();
|
|
||||||
length_s = properties->lengthInSeconds();
|
|
||||||
sample_rate = properties->sampleRate();
|
|
||||||
|
|
||||||
title = wxString::FromUTF8(Title.toCString(true));
|
|
||||||
artist = wxString::FromUTF8(Artist.toCString(true));
|
|
||||||
album = wxString::FromUTF8(Album.toCString(true));
|
|
||||||
genre = wxString::FromUTF8(Genre.toCString(true));
|
|
||||||
comment = wxString::FromUTF8(Comment.toCString(true));
|
|
||||||
|
|
||||||
bValid = true;
|
|
||||||
|
|
||||||
// unsigned int longest = 0;
|
|
||||||
|
|
||||||
// for(TagLib::PropertyMap::ConstIterator i = property_map.begin(); i != property_map.end(); ++i)
|
|
||||||
// {
|
|
||||||
// if (i->first.size() > longest)
|
|
||||||
// {
|
|
||||||
// longest = i->first.size();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// std::cout << "-- TAG (properties) --" << std::endl;
|
|
||||||
|
|
||||||
// for(TagLib::PropertyMap::ConstIterator i = property_map.begin(); i != property_map.end(); ++i)
|
|
||||||
// {
|
|
||||||
// for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j)
|
|
||||||
// {
|
|
||||||
// std::cout << std::left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << std::endl;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bValid = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { title, artist, album, genre, comment, channels, length_ms, sample_rate, bitrate };
|
cTags::~cTags()
|
||||||
}
|
|
||||||
|
|
||||||
void Tags::SetTitle(std::string title)
|
|
||||||
{
|
|
||||||
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
|
||||||
|
|
||||||
tag->setTitle(title);
|
|
||||||
f.save();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Tags::SetArtist(std::string artist)
|
cTags::AudioInfo cTags::GetAudioInfo()
|
||||||
{
|
|
||||||
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
wxString artist, album, genre, title, comment;
|
||||||
|
int channels = 0, length = 0, sample_rate = 0, bitrate = 0;
|
||||||
|
|
||||||
tag->setArtist(artist);
|
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
f.save();
|
|
||||||
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
|
{
|
||||||
|
TagLib::Tag* tag = f.tag();
|
||||||
|
TagLib::AudioProperties* properties = f.audioProperties();
|
||||||
|
|
||||||
|
TagLib::String Title = tag->title();
|
||||||
|
TagLib::String Artist = tag->artist();
|
||||||
|
TagLib::String Album = tag->album();
|
||||||
|
TagLib::String Genre = tag->genre();
|
||||||
|
TagLib::String Comment = tag->comment();
|
||||||
|
|
||||||
|
int seconds = properties->length() % 60;
|
||||||
|
int minutes = (properties->length() - seconds) / 60;
|
||||||
|
|
||||||
|
bitrate = properties->bitrate();
|
||||||
|
channels = properties->channels();
|
||||||
|
length = properties->lengthInMilliseconds();
|
||||||
|
int length_sec = properties->lengthInSeconds();
|
||||||
|
sample_rate = properties->sampleRate();
|
||||||
|
|
||||||
|
title = wxString::FromUTF8(Title.toCString(true));
|
||||||
|
artist = wxString::FromUTF8(Artist.toCString(true));
|
||||||
|
album = wxString::FromUTF8(Album.toCString(true));
|
||||||
|
genre = wxString::FromUTF8(Genre.toCString(true));
|
||||||
|
comment = wxString::FromUTF8(Comment.toCString(true));
|
||||||
|
|
||||||
|
m_bValid = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_bValid = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { title, artist, album, genre, comment, channels, length, sample_rate, bitrate };
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Tags::SetAlbum(std::string album)
|
void cTags::SetTitle(std::string title)
|
||||||
{
|
|
||||||
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
|
|
||||||
tag->setAlbum(album);
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
f.save();
|
{
|
||||||
|
TagLib::Tag* tag = f.tag();
|
||||||
|
|
||||||
|
tag->setTitle(title);
|
||||||
|
f.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Tags::SetGenre(std::string genre)
|
void cTags::SetArtist(std::string artist)
|
||||||
{
|
|
||||||
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
|
|
||||||
tag->setGenre(genre);
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
f.save();
|
{
|
||||||
|
TagLib::Tag* tag = f.tag();
|
||||||
|
|
||||||
|
tag->setArtist(artist);
|
||||||
|
f.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Tags::SetComment(std::string comment)
|
void cTags::SetAlbum(std::string album)
|
||||||
{
|
|
||||||
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
|
||||||
|
|
||||||
if (!f.isNull() && f.tag() && f.audioProperties())
|
|
||||||
{
|
{
|
||||||
TagLib::Tag* tag = f.tag();
|
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
|
|
||||||
tag->setComment(comment);
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
f.save();
|
{
|
||||||
|
TagLib::Tag* tag = f.tag();
|
||||||
|
|
||||||
|
tag->setAlbum(album);
|
||||||
|
f.save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cTags::SetGenre(std::string genre)
|
||||||
|
{
|
||||||
|
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
|
|
||||||
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
|
{
|
||||||
|
TagLib::Tag* tag = f.tag();
|
||||||
|
|
||||||
|
tag->setGenre(genre);
|
||||||
|
f.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTags::SetComment(std::string comment)
|
||||||
|
{
|
||||||
|
TagLib::FileRef f (static_cast<const char*>(m_Filepath.c_str()), true, TagLib::AudioProperties::ReadStyle::Average);
|
||||||
|
|
||||||
|
if (!f.isNull() && f.tag() && f.audioProperties())
|
||||||
|
{
|
||||||
|
TagLib::Tag* tag = f.tag();
|
||||||
|
|
||||||
|
tag->setComment(comment);
|
||||||
|
f.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,42 +24,46 @@
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
struct AudioInfo
|
namespace SampleHive {
|
||||||
{
|
|
||||||
wxString title;
|
|
||||||
wxString artist;
|
|
||||||
wxString album;
|
|
||||||
wxString genre;
|
|
||||||
wxString comment;
|
|
||||||
|
|
||||||
int channels;
|
class cTags
|
||||||
int length;
|
{
|
||||||
int sample_rate;
|
struct AudioInfo
|
||||||
int bitrate;
|
{
|
||||||
};
|
wxString title;
|
||||||
|
wxString artist;
|
||||||
|
wxString album;
|
||||||
|
wxString genre;
|
||||||
|
wxString comment;
|
||||||
|
|
||||||
class Tags
|
int channels;
|
||||||
{
|
int length;
|
||||||
public:
|
int sample_rate;
|
||||||
Tags(const std::string& filepath);
|
int bitrate;
|
||||||
~Tags();
|
};
|
||||||
|
|
||||||
private:
|
public:
|
||||||
// -------------------------------------------------------------------
|
cTags(const std::string& filepath);
|
||||||
const std::string& m_Filepath;
|
~cTags();
|
||||||
|
|
||||||
bool bValid = false;
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cTags::AudioInfo GetAudioInfo();
|
||||||
|
void SetTitle(std::string artist);
|
||||||
|
void SetArtist(std::string artist);
|
||||||
|
void SetAlbum(std::string album);
|
||||||
|
void SetGenre(std::string genre);
|
||||||
|
void SetComment(std::string comment);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
AudioInfo GetAudioInfo();
|
inline bool IsFileValid() { return m_bValid; }
|
||||||
void SetTitle(std::string artist);
|
|
||||||
void SetArtist(std::string artist);
|
|
||||||
void SetAlbum(std::string album);
|
|
||||||
void SetGenre(std::string genre);
|
|
||||||
void SetComment(std::string comment);
|
|
||||||
|
|
||||||
public:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
inline bool IsFileValid() { return bValid; }
|
const std::string& m_Filepath;
|
||||||
};
|
|
||||||
|
bool m_bValid = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/HiveData.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Tags.hpp"
|
||||||
|
#include "Utility/Utils.hpp"
|
||||||
|
|
||||||
|
#include <wx/dir.h>
|
||||||
|
#include <wx/progdlg.h>
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
SampleHive::cUtils::FileInfo SampleHive::cUtils::GetFilenamePathAndExtension(const wxString& selected,
|
||||||
|
bool checkExtension, bool doGetFilename) const
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxString path;
|
||||||
|
std::string extension, filename;
|
||||||
|
|
||||||
|
wxString filename_with_extension = db.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
wxString filename_without_extension = db.GetSamplePathByFilename(selected.ToStdString());
|
||||||
|
|
||||||
|
if (checkExtension)
|
||||||
|
{
|
||||||
|
extension = serializer.DeserializeShowFileExtension() ?
|
||||||
|
db.GetSampleFileExtension(selected.ToStdString()) :
|
||||||
|
db.GetSampleFileExtension(selected.BeforeLast('.').ToStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
path = selected.Contains(wxString::Format(".%s", extension)) ?
|
||||||
|
filename_with_extension : filename_without_extension;
|
||||||
|
|
||||||
|
if (doGetFilename)
|
||||||
|
filename = path.AfterLast('/').BeforeLast('.').ToStdString();
|
||||||
|
|
||||||
|
return { path, extension, filename };
|
||||||
|
}
|
||||||
|
|
||||||
|
void SampleHive::cUtils::AddSamples(wxArrayString& files, wxWindow* parent)
|
||||||
|
{
|
||||||
|
SampleHive::cSerializer serializer;
|
||||||
|
cDatabase db;
|
||||||
|
|
||||||
|
wxBusyCursor busy_cursor;
|
||||||
|
wxWindowDisabler window_disabler;
|
||||||
|
|
||||||
|
wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."),
|
||||||
|
_("Adding files, please wait..."),
|
||||||
|
static_cast<int>(files.size()), parent,
|
||||||
|
wxPD_APP_MODAL | wxPD_SMOOTH | wxPD_CAN_ABORT |
|
||||||
|
wxPD_AUTO_HIDE);
|
||||||
|
progressDialog->CenterOnParent(wxBOTH);
|
||||||
|
|
||||||
|
std::vector<Sample> sample_array;
|
||||||
|
|
||||||
|
std::string path;
|
||||||
|
std::string artist;
|
||||||
|
std::string filename_with_extension;
|
||||||
|
std::string filename_without_extension;
|
||||||
|
std::string extension;
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
//Check All Files At Once
|
||||||
|
wxArrayString sorted_files;
|
||||||
|
|
||||||
|
sorted_files = db.CheckDuplicates(files);
|
||||||
|
files = sorted_files;
|
||||||
|
|
||||||
|
if (files.size() < 1)
|
||||||
|
{
|
||||||
|
progressDialog->Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->SetRange(files.size());
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < files.size(); i++)
|
||||||
|
{
|
||||||
|
progressDialog->Update(i, wxString::Format(_("Getting Data For %s"), files[i].AfterLast('/')));
|
||||||
|
|
||||||
|
if (progressDialog->WasCancelled())
|
||||||
|
{
|
||||||
|
progressDialog->Destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = files[i].ToStdString();
|
||||||
|
filename_with_extension = files[i].AfterLast('/').ToStdString();
|
||||||
|
filename_without_extension = files[i].AfterLast('/').BeforeLast('.').ToStdString();
|
||||||
|
extension = files[i].AfterLast('.').ToStdString();
|
||||||
|
|
||||||
|
filename = serializer.DeserializeShowFileExtension() ?
|
||||||
|
filename_with_extension : filename_without_extension;
|
||||||
|
|
||||||
|
Sample sample;
|
||||||
|
|
||||||
|
sample.SetPath(path);
|
||||||
|
sample.SetFilename(filename_without_extension);
|
||||||
|
sample.SetFileExtension(extension);
|
||||||
|
|
||||||
|
cTags tags(path);
|
||||||
|
|
||||||
|
artist = tags.GetAudioInfo().artist.ToStdString();
|
||||||
|
|
||||||
|
sample.SetSamplePack(artist);
|
||||||
|
sample.SetChannels(tags.GetAudioInfo().channels);
|
||||||
|
sample.SetLength(tags.GetAudioInfo().length);
|
||||||
|
sample.SetSampleRate(tags.GetAudioInfo().sample_rate);
|
||||||
|
sample.SetBitrate(tags.GetAudioInfo().bitrate);
|
||||||
|
|
||||||
|
wxLongLong llLength = sample.GetLength();
|
||||||
|
int total_min = static_cast<int>((llLength / 60000).GetValue());
|
||||||
|
int total_sec = static_cast<int>(((llLength % 60000) / 1000).GetValue());
|
||||||
|
|
||||||
|
wxVector<wxVariant> data;
|
||||||
|
|
||||||
|
wxVariant icon = wxVariant(wxBitmap(ICON_STAR_EMPTY_16px));
|
||||||
|
|
||||||
|
if (tags.IsFileValid())
|
||||||
|
{
|
||||||
|
data.clear();
|
||||||
|
data.push_back(icon);
|
||||||
|
data.push_back(filename);
|
||||||
|
data.push_back(sample.GetSamplePack());
|
||||||
|
data.push_back("");
|
||||||
|
data.push_back(wxString::Format("%d", sample.GetChannels()));
|
||||||
|
data.push_back(wxString::Format("%2i:%02i", total_min, total_sec));
|
||||||
|
data.push_back(wxString::Format("%d", sample.GetSampleRate()));
|
||||||
|
data.push_back(wxString::Format("%d", sample.GetBitrate()));
|
||||||
|
data.push_back(path);
|
||||||
|
|
||||||
|
SH_LOG_INFO("Adding file: {}, Extension: {}", sample.GetFilename(), sample.GetFileExtension());
|
||||||
|
|
||||||
|
SampleHive::cHiveData::Get().ListCtrlAppendItem(data);
|
||||||
|
|
||||||
|
sample_array.push_back(sample);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString msg = wxString::Format(_("Error! Cannot open %s, Invalid file type."),
|
||||||
|
filename_with_extension);
|
||||||
|
|
||||||
|
SampleHive::cSignal::SendInfoBarMessage(msg, wxICON_ERROR, *parent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->Pulse(_("Updating Database.."), NULL);
|
||||||
|
|
||||||
|
db.InsertIntoSamples(sample_array);
|
||||||
|
|
||||||
|
progressDialog->Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cUtils::OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Start Importing Samples");
|
||||||
|
|
||||||
|
wxBusyCursor busy_cursor;
|
||||||
|
wxWindowDisabler window_disabler;
|
||||||
|
|
||||||
|
wxString filepath;
|
||||||
|
wxArrayString filepath_array;
|
||||||
|
|
||||||
|
size_t number_of_files = wxDir::GetAllFiles(pathToDirectory, &filepath_array, wxEmptyString, wxDIR_DEFAULT);
|
||||||
|
|
||||||
|
wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."),
|
||||||
|
_("Adding files, please wait..."),
|
||||||
|
static_cast<int>(number_of_files), parent,
|
||||||
|
wxPD_APP_MODAL | wxPD_SMOOTH |
|
||||||
|
wxPD_CAN_ABORT | wxPD_AUTO_HIDE);
|
||||||
|
|
||||||
|
progressDialog->CenterOnParent(wxBOTH);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < number_of_files; i++)
|
||||||
|
{
|
||||||
|
filepath = filepath_array[i];
|
||||||
|
|
||||||
|
if (wxFileExists(filepath))
|
||||||
|
{
|
||||||
|
filepath_array.push_back(filepath);
|
||||||
|
}
|
||||||
|
else if (wxDirExists(filepath))
|
||||||
|
{
|
||||||
|
wxDir::GetAllFiles(filepath, &filepath_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->Pulse(_("Reading Samples"), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->Destroy();
|
||||||
|
|
||||||
|
AddSamples(filepath_array, parent);
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("Done Importing Samples");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
/* SampleHive
|
||||||
|
* Copyright (C) 2021 Apoorv Singh
|
||||||
|
* A simple, modern audio sample browser/manager for GNU/Linux.
|
||||||
|
*
|
||||||
|
* This file is a part of SampleHive
|
||||||
|
*
|
||||||
|
* SampleHive is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* SampleHive is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wx/arrstr.h"
|
||||||
|
#include "wx/string.h"
|
||||||
|
#include "wx/window.h"
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
class cUtils
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
cUtils() = default;
|
||||||
|
|
||||||
|
public:
|
||||||
|
cUtils(const cUtils&) = delete;
|
||||||
|
cUtils& operator=(const cUtils) = delete;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static cUtils& Get()
|
||||||
|
{
|
||||||
|
static cUtils s_cUtils;
|
||||||
|
return s_cUtils;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct FileInfo
|
||||||
|
{
|
||||||
|
wxString Path;
|
||||||
|
std::string Extension;
|
||||||
|
std::string Filename;
|
||||||
|
};
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cUtils::FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
||||||
|
bool checkExtension = true,
|
||||||
|
bool doGetFilename = true) const;
|
||||||
|
void AddSamples(wxArrayString& files, wxWindow* parent);
|
||||||
|
void OnAutoImportDir(const wxString& pathToDirectory, wxWindow* parent);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue