More encapsulation and add new class Signal for handling custom events.
This commit is contained in:
parent
7dd7f2b3c1
commit
9e0be8f55a
|
|
@ -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/"))))))
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,14 @@ src = [
|
||||||
'src/GUI/MainFrame.cpp',
|
'src/GUI/MainFrame.cpp',
|
||||||
'src/GUI/TransportControls.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',
|
||||||
|
|
@ -156,6 +164,7 @@ src = [
|
||||||
'src/Utility/Serialize.cpp',
|
'src/Utility/Serialize.cpp',
|
||||||
'src/Utility/Tags.cpp',
|
'src/Utility/Tags.cpp',
|
||||||
'src/Utility/SH_Event.cpp',
|
'src/Utility/SH_Event.cpp',
|
||||||
|
'src/Utility/Signal.cpp',
|
||||||
'src/Utility/Log.cpp',
|
'src/Utility/Log.cpp',
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ void show_modal_dialog_and_log(const std::string &message, const std::string &ti
|
||||||
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();
|
||||||
|
|
||||||
|
|
@ -899,7 +899,7 @@ void Database::LoadHivesDatabase(wxDataViewTreeCtrl &treeCtrl)
|
||||||
}
|
}
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "Utility/ControlIDs.hpp"
|
#include "Utility/ControlIDs.hpp"
|
||||||
#include "Utility/SH_Event.hpp"
|
#include "Utility/SH_Event.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
#include "Database/Database.hpp"
|
#include "Database/Database.hpp"
|
||||||
|
|
@ -312,20 +313,20 @@ void TagEditor::OnClickApply(wxCommandEvent& event)
|
||||||
info_msg = "Error, cannot change tag!";
|
info_msg = "Error, cannot change tag!";
|
||||||
}
|
}
|
||||||
|
|
||||||
SendInfoBarMessage(info_msg, wxICON_INFORMATION);
|
SampleHive::Signal::SendInfoBarMessage(info_msg, wxICON_INFORMATION, *this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TagEditor::SendInfoBarMessage(const wxString& msg, int mode)
|
// void TagEditor::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()
|
TagEditor::~TagEditor()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -106,5 +106,5 @@ class TagEditor : public wxDialog
|
||||||
void OnClickApply(wxCommandEvent& event);
|
void OnClickApply(wxCommandEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void SendInfoBarMessage(const wxString& msg, int mode);
|
// void SendInfoBarMessage(const wxString& msg, int mode);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
#include "GUI/DirectoryBrowser.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
|
||||||
|
#include <wx/dataobj.h>
|
||||||
|
#include <wx/dnd.h>
|
||||||
|
|
||||||
|
cDirectoryBrowser::cDirectoryBrowser(wxWindow* window)
|
||||||
|
: wxGenericDirCtrl(window, BC_DirCtrl, wxDirDialogDefaultFolderStr, wxDefaultPosition,
|
||||||
|
wxDefaultSize, wxDIRCTRL_SHOW_FILTERS,
|
||||||
|
_("All files|*|Ogg files (*.ogg)|*.ogg|Wav files (*.wav)|*.wav|"
|
||||||
|
"Flac files (*.flac)|*.flac"), 0)
|
||||||
|
{
|
||||||
|
SetPath(USER_HOME_DIR);
|
||||||
|
|
||||||
|
Bind(wxEVT_DIRCTRL_FILEACTIVATED, &cDirectoryBrowser::OnClickDirCtrl, this, 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());
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// AddSamples(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
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,18 @@
|
||||||
|
#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);
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,766 @@
|
||||||
|
#include "GUI/Hives.hpp"
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
#include <wx/textdlg.h>
|
||||||
|
#include <wx/menu.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
cHivesPanel::cHivesPanel(wxWindow* window, wxDataViewListCtrl& listCtrl)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
|
||||||
|
m_ListCtrl(listCtrl), m_pWindow(window)
|
||||||
|
{
|
||||||
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pHivesSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
m_pAddHiveButton = new wxButton(this, BC_HiveAdd, "+", wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_pAddHiveButton->SetToolTip(_("Create new hive"));
|
||||||
|
|
||||||
|
m_pButtonSizer->Add(m_pAddHiveButton, wxSizerFlags(1).Expand());
|
||||||
|
|
||||||
|
m_pRemoveHiveButton = new wxButton(this, 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, 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, BC_Hives);
|
||||||
|
Bind(wxEVT_DATAVIEW_ITEM_START_EDITING, &cHivesPanel::OnHiveStartEditing, this, BC_Hives);
|
||||||
|
Bind(wxEVT_BUTTON, &cHivesPanel::OnClickAddHive, this, BC_HiveAdd);
|
||||||
|
Bind(wxEVT_BUTTON, &cHivesPanel::OnClickRemoveHive, this, 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)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cListCtrl m_ListCtrl.m_pWindow);
|
||||||
|
|
||||||
|
if (event.GetNumberOfFiles() > 0)
|
||||||
|
{
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
wxDataViewItemArray items;
|
||||||
|
int rows = m_ListCtrl.GetSelections(items);
|
||||||
|
// int rows = 2;
|
||||||
|
|
||||||
|
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 = m_ListCtrl.ItemToRow(items[i]);
|
||||||
|
|
||||||
|
wxString name = m_ListCtrl.GetTextValue(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]);
|
||||||
|
|
||||||
|
m_ListCtrl.SetValue(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::Signal::SendInfoBarMessage(msg, wxICON_ERROR, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnShowHivesContextMenu(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cListCtrl m_ListCtrl.m_pWindow);
|
||||||
|
|
||||||
|
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(MN_RenameHive, _("Rename hive"), _("Rename selected hive"));
|
||||||
|
menu.Append(MN_DeleteHive, _("Delete hive"), _("Delete selected hive"));
|
||||||
|
|
||||||
|
if (!m_bFiltered)
|
||||||
|
menu.Append(MN_FilterLibrary, _("Filter library"),
|
||||||
|
_("Show only samples from current hive in library"));
|
||||||
|
else
|
||||||
|
menu.Append(MN_FilterLibrary, _("Clear filter"), _("Clear the filter"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Child menu items
|
||||||
|
menu.Append(MN_RemoveSample, _("Remove sample"), _("Remove the selected sample(s)"));
|
||||||
|
menu.Append(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 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::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MN_DeleteHive:
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxMessageDialog deleteEmptyHiveDialog(this, wxString::Format(_("Are you sure you want to "
|
||||||
|
"delete %s from chives?"),
|
||||||
|
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 chives?"),
|
||||||
|
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 chives."),
|
||||||
|
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 chives 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 < m_ListCtrl.GetItemCount(); i++)
|
||||||
|
// for (int i = 0; i < 1; i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample =
|
||||||
|
serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_ListCtrl.GetTextValue(i, 1).BeforeLast('.') :
|
||||||
|
m_ListCtrl.GetTextValue(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)
|
||||||
|
// if (child_name == "")
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
m_ListCtrl.SetValue(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 chives successfully."),
|
||||||
|
hive_name, hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 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
|
||||||
|
{
|
||||||
|
m_ListCtrl.DeleteAllItems();
|
||||||
|
|
||||||
|
for (auto data : dataset)
|
||||||
|
{
|
||||||
|
m_ListCtrl.AppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
wxMessageBox(_("Error loading data, cannot filter sample view"), _("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
|
||||||
|
{
|
||||||
|
m_ListCtrl.DeleteAllItems();
|
||||||
|
|
||||||
|
for (auto data : dataset)
|
||||||
|
{
|
||||||
|
m_ListCtrl.AppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
wxMessageBox(_("Error loading data, cannot filter sample view"), _("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 MN_RemoveSample:
|
||||||
|
for(int i = 0; i < m_ListCtrl.GetItemCount(); i++)
|
||||||
|
// for(int i = 0; i < 1; i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_ListCtrl.GetTextValue(i, 1).BeforeLast('.') :
|
||||||
|
m_ListCtrl.GetTextValue(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)
|
||||||
|
// if(selected_sample_name == "")
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
m_ListCtrl.SetValue(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()));
|
||||||
|
|
||||||
|
// m_InfoBar->ShowMessage(wxString::Format(_("Removed %s from %s"),
|
||||||
|
// m_Hives->GetItemText(event.GetItem()),
|
||||||
|
// db.GetHiveByFilename(matched_sample.ToStdString())),
|
||||||
|
// wxICON_INFORMATION);
|
||||||
|
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MN_ShowInLibrary:
|
||||||
|
for(int i = 0; i < m_ListCtrl.GetItemCount(); i++)
|
||||||
|
// for(int i = 0; i < 1; i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_ListCtrl.GetTextValue(i, 1).BeforeLast('.') :
|
||||||
|
m_ListCtrl.GetTextValue(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)
|
||||||
|
// if(selected_sample_name == "")
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
wxDataViewItem matched_item = m_ListCtrl.RowToItem(i);
|
||||||
|
|
||||||
|
m_ListCtrl.UnselectAll();
|
||||||
|
m_ListCtrl.SelectRow(i);
|
||||||
|
m_ListCtrl.EnsureVisible(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)
|
||||||
|
{
|
||||||
|
Database 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 cHivesPanel."), hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case wxID_CANCEL:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cHivesPanel::OnClickRemoveHive(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cListCtrl m_ListCtrl.m_pWindow);
|
||||||
|
|
||||||
|
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 chives?"),
|
||||||
|
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 chives?"),
|
||||||
|
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 chives."), 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 chives 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 < m_ListCtrl.GetItemCount(); i++)
|
||||||
|
// for (int i = 0; i < 1; i++)
|
||||||
|
{
|
||||||
|
wxString matched_sample = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_ListCtrl.GetTextValue(i, 1).BeforeLast('.') :
|
||||||
|
m_ListCtrl.GetTextValue(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)
|
||||||
|
// if (child_name == "")
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("Found match");
|
||||||
|
|
||||||
|
m_ListCtrl.SetValue(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 chives successfully."),
|
||||||
|
hive_name, hive_name);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case wxID_NO:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
cHivesPanel::~cHivesPanel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
|
||||||
|
#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, wxDataViewListCtrl& listCtrl);
|
||||||
|
~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;
|
||||||
|
|
||||||
|
wxDataViewListCtrl& m_ListCtrl;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// friend class cListCtrl;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include "InfoBar.hpp"
|
||||||
|
|
||||||
|
cInfoBar::cInfoBar(wxWindow* window)
|
||||||
|
: wxInfoBar(window)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cInfoBar::~cInfoBar()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#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,29 @@
|
||||||
|
#include "GUI/Library.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
|
||||||
|
cLibrary::cLibrary(wxWindow* window, wxDataViewItem favHive, wxDataViewTreeCtrl& hives,
|
||||||
|
wxTreeItemId trashRoot, wxTreeCtrl& trash)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
|
||||||
|
m_FavoritesHive(favHive), m_pHives(hives), m_pTrash(trash), m_TrashRoot(trashRoot)
|
||||||
|
{
|
||||||
|
m_pSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
m_pSearchBar = new cSearchBar(this, *m_pListCtrl);
|
||||||
|
m_pInfoBar = new cInfoBar(this);
|
||||||
|
m_pListCtrl = new cListCtrl(this, m_FavoritesHive, hives, trashRoot, trash);
|
||||||
|
|
||||||
|
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,40 @@
|
||||||
|
#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, wxDataViewItem favHive, wxDataViewTreeCtrl& hives,
|
||||||
|
wxTreeItemId trashRoot, wxTreeCtrl& trash);
|
||||||
|
~cLibrary();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxSearchCtrl* GetSearchCtrlObject() const { return m_pSearchBar; }
|
||||||
|
wxInfoBar* GetInfoBarObject() const { return m_pInfoBar; }
|
||||||
|
wxDataViewListCtrl* GetListCtrlObject() const { return m_pListCtrl; }
|
||||||
|
|
||||||
|
// void SetHivesObject(wxDataViewTreeCtrl& hives) { m_pHives = &hives;}
|
||||||
|
// void SetFavoritesHive(wxDataViewItem favHive) { m_FavoritesHive = favHive;}
|
||||||
|
// void SetTrashObject(wxTreeCtrl& trash) { m_pTrash = &trash;}
|
||||||
|
// void SetTrashRoot(wxTreeItemId trashRoot) { m_TrashRoot = trashRoot;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
cSearchBar* m_pSearchBar = nullptr;
|
||||||
|
cInfoBar* m_pInfoBar = nullptr;
|
||||||
|
cListCtrl* m_pListCtrl = nullptr;
|
||||||
|
wxBoxSizer* m_pSizer = nullptr;
|
||||||
|
|
||||||
|
wxDataViewItem m_FavoritesHive;
|
||||||
|
wxDataViewTreeCtrl& m_pHives;
|
||||||
|
wxTreeCtrl& m_pTrash;
|
||||||
|
wxTreeItemId m_TrashRoot;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,935 @@
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
// #include "GUI/Hives.hpp"
|
||||||
|
// #include "GUI/Trash.hpp"
|
||||||
|
#include "GUI/Dialogs/TagEditor.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "GUI/Hives.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/SH_Event.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
|
||||||
|
#include <wx/dir.h>
|
||||||
|
#include <wx/menu.h>
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include <wx/progdlg.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
// cListCtrl::cListCtrl(wxWindow* window)
|
||||||
|
cListCtrl::cListCtrl(wxWindow* window, wxDataViewItem favHive, wxDataViewTreeCtrl& hives,
|
||||||
|
wxTreeItemId trashRoot, wxTreeCtrl& trash)
|
||||||
|
: wxDataViewListCtrl(window, BC_Library, wxDefaultPosition, wxDefaultSize,
|
||||||
|
wxDV_MULTIPLE | wxDV_HORIZ_RULES | wxDV_VERT_RULES | wxDV_ROW_LINES),
|
||||||
|
// m_pWindow(window)
|
||||||
|
m_pWindow(window), m_Hives(hives), m_FavoritesHive(favHive), m_TrashRoot(trashRoot), m_Trash(trash)
|
||||||
|
{
|
||||||
|
// 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, 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, BC_Library);
|
||||||
|
Bind(wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK,
|
||||||
|
&cListCtrl::OnShowLibraryColumnHeaderContextMenu, this, BC_Library);
|
||||||
|
|
||||||
|
LoadDatabase();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::OnClickLibrary(wxDataViewEvent& event)
|
||||||
|
{
|
||||||
|
// cHivesPanel hives(m_pWindow);
|
||||||
|
Database 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::Signal::SendWaveformUpdateStatus(*this);
|
||||||
|
// m_TopWaveformPanel->ResetDC();
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// SampleHive::Signal::SendSetLoopABButton(*this);
|
||||||
|
// m_LoopABButton->SetValue(false);
|
||||||
|
|
||||||
|
SampleHive::Signal::SendTimerStopStatus(*this);
|
||||||
|
// if (m_Timer->IsRunning())
|
||||||
|
// {
|
||||||
|
// m_Timer->Stop();
|
||||||
|
// SH_LOG_DEBUG("TIMER STOPPED");
|
||||||
|
// }
|
||||||
|
|
||||||
|
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 = GetFilenamePathAndExtension(selection).Path;
|
||||||
|
std::string filename = GetFilenamePathAndExtension(selection).Filename;
|
||||||
|
std::string extension = GetFilenamePathAndExtension(selection).Extension;
|
||||||
|
|
||||||
|
if (CurrentColumn != FavoriteColumn)
|
||||||
|
{
|
||||||
|
SampleHive::Signal::SendCallFunctionPlay(selection, *this);
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// ClearLoopPoints();
|
||||||
|
|
||||||
|
// if (bAutoplay)
|
||||||
|
// {
|
||||||
|
// if (bLoopPointsSet && m_LoopABButton->GetValue())
|
||||||
|
// PlaySample(sample_path.ToStdString(), selection.ToStdString(),
|
||||||
|
// true, m_LoopA.ToDouble(), wxFromStart);
|
||||||
|
// else
|
||||||
|
// PlaySample(sample_path.ToStdString(), selection.ToStdString());
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// m_MediaCtrl->Stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
// Get hive name and location
|
||||||
|
std::string hive_name = m_Hives.GetItemText(m_FavoritesHive).ToStdString();
|
||||||
|
wxDataViewItem hive_selection = m_Hives.GetSelection();
|
||||||
|
|
||||||
|
SH_LOG_DEBUG("HIVE NAME: {}", hive_name);
|
||||||
|
|
||||||
|
if (hive_selection.IsOk() && m_Hives.IsContainer(hive_selection))
|
||||||
|
hive_name = m_Hives.GetItemText(hive_selection).ToStdString();
|
||||||
|
|
||||||
|
wxString name = this->GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
|
// Get root
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container;
|
||||||
|
wxDataViewItem child;
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(filename) == 0)
|
||||||
|
{
|
||||||
|
SH_LOG_DEBUG("TRUE COND....");
|
||||||
|
|
||||||
|
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 < m_Hives.GetChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, i);
|
||||||
|
|
||||||
|
if (m_Hives.GetItemText(container).ToStdString() == hive_name)
|
||||||
|
{
|
||||||
|
m_Hives.AppendItem(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, m_Hives.GetItemText(m_FavoritesHive).ToStdString());
|
||||||
|
|
||||||
|
for (int i = 0; i < m_Hives.GetChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, i);
|
||||||
|
|
||||||
|
for (int j = 0; j < m_Hives.GetChildCount(container); j++)
|
||||||
|
{
|
||||||
|
child = m_Hives.GetNthChild(container, j);
|
||||||
|
|
||||||
|
if (m_Hives.GetItemText(child) == name)
|
||||||
|
{
|
||||||
|
m_Hives.DeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Removed %s from %s"), name, hive_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_INFORMATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
AddSamples(filepath_array);
|
||||||
|
|
||||||
|
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 = 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)
|
||||||
|
{
|
||||||
|
TagEditor* tagEditor;
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cHivesPanel hives(m_pWindow);
|
||||||
|
|
||||||
|
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 = GetFilenamePathAndExtension(selection).Path;
|
||||||
|
std::string filename = GetFilenamePathAndExtension(selection).Filename;
|
||||||
|
std::string extension = GetFilenamePathAndExtension(selection).Extension;
|
||||||
|
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
//true = add false = remove
|
||||||
|
bool favorite_add = false;
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(filename) == 1)
|
||||||
|
menu.Append(MN_FavoriteSample, _("Remove from hive"), _("Remove the selected sample(s) from hive"));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.Append(MN_FavoriteSample, _("Add to hive"), _("Add selected sample(s) to hive"));
|
||||||
|
favorite_add = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.Append(MN_DeleteSample, _("Delete"), _("Delete the selected sample(s) from database"));
|
||||||
|
menu.Append(MN_TrashSample, _("Trash"), _("Send the selected sample(s) to trash"));
|
||||||
|
|
||||||
|
if (this->GetSelectedItemsCount() <= 1)
|
||||||
|
{
|
||||||
|
menu.Append(MN_EditTagSample, _("Edit tags"),
|
||||||
|
_("Edit the tags for the selected sample"))->Enable(true);
|
||||||
|
menu.Append(MN_OpenFile, _("Open in file manager"),
|
||||||
|
_("Open the selected sample in system's file manager"))->Enable(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
menu.Append(MN_EditTagSample, _("Edit tags"),
|
||||||
|
_("Edit the tags for the selected sample"))->Enable(false);
|
||||||
|
menu.Append(MN_OpenFile, _("Open in file manager"),
|
||||||
|
_("Open the selected sample in system's file manager"))->Enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (this->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
|
{
|
||||||
|
case MN_FavoriteSample:
|
||||||
|
{
|
||||||
|
std::string hive_name = m_Hives.GetItemText(m_FavoritesHive).ToStdString();
|
||||||
|
|
||||||
|
wxDataViewItem hive_selection = m_Hives.GetSelection();
|
||||||
|
|
||||||
|
if (hive_selection.IsOk() && m_Hives.IsContainer(hive_selection))
|
||||||
|
hive_name = m_Hives.GetItemText(hive_selection).ToStdString();
|
||||||
|
|
||||||
|
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 < m_Hives.GetChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, i);
|
||||||
|
|
||||||
|
if (m_Hives.GetItemText(container).ToStdString() == hive_name)
|
||||||
|
{
|
||||||
|
m_Hives.AppendItem(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,
|
||||||
|
m_Hives.GetItemText(m_FavoritesHive).ToStdString());
|
||||||
|
|
||||||
|
for (int i = 0; i < m_Hives.GetChildCount(root); i++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, i);
|
||||||
|
|
||||||
|
for (int j = 0; j < m_Hives.GetChildCount(container); j++)
|
||||||
|
{
|
||||||
|
child = m_Hives.GetNthChild(container, j);
|
||||||
|
|
||||||
|
if (m_Hives.GetItemText(child) == name)
|
||||||
|
{
|
||||||
|
m_Hives.DeleteItem(child);
|
||||||
|
|
||||||
|
msg = wxString::Format(_("Removed %s from %s"), name, hive_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 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 < m_Hives.GetChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < m_Hives.GetChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = m_Hives.GetNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_Hives.GetItemText(child).BeforeLast('.') :
|
||||||
|
m_Hives.GetItemText(child);
|
||||||
|
|
||||||
|
if (child_text == filename)
|
||||||
|
{
|
||||||
|
m_Hives.DeleteItem(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 < m_Hives.GetChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < m_Hives.GetChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = m_Hives.GetNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_Hives.GetItemText(child).BeforeLast('.') :
|
||||||
|
m_Hives.GetItemText(child);
|
||||||
|
|
||||||
|
if (child_text == multi_selection)
|
||||||
|
{
|
||||||
|
m_Hives.DeleteItem(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 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 < m_Hives.GetChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = m_Hives.GetNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < m_Hives.GetChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = m_Hives.GetNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_Hives.GetItemText(child).BeforeLast('.') :
|
||||||
|
m_Hives.GetItemText(child);
|
||||||
|
|
||||||
|
if (child_text == files[i])
|
||||||
|
{
|
||||||
|
m_Hives.DeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Trash.AppendItem(m_TrashRoot, text_value);
|
||||||
|
|
||||||
|
this->DeleteItem(item_row);
|
||||||
|
|
||||||
|
db.UpdateTrashColumn(files[i].ToStdString(), 1);
|
||||||
|
db.UpdateHiveName(files[i].ToStdString(),
|
||||||
|
m_Hives.GetItemText(m_FavoritesHive).ToStdString());
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s sent to trash"), text_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MN_EditTagSample:
|
||||||
|
{
|
||||||
|
tagEditor = new TagEditor(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 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::Signal::SendInfoBarMessage(msg, wxICON_INFORMATION, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
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(MN_ColumnFavorite, _("Favorites"),
|
||||||
|
_("Toggle favorites column"))->Check(FavoriteColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnFilename, _("Filename"),
|
||||||
|
_("Toggle filename column"))->Check(FilenameColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnSamplePack, _("Sample Pack"),
|
||||||
|
_("Toggle sample pack column"))->Check(SamplePackColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnType, _("Type"),
|
||||||
|
_("Toggle type column"))->Check(TypeColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnChannels, _("Channels"),
|
||||||
|
_("Toggle channels column"))->Check(ChannelsColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnLength, _("Length"),
|
||||||
|
_("Toggle length column"))->Check(LengthColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnSampleRate, _("Sample Rate"),
|
||||||
|
_("Toggle sample rate column"))->Check(SampleRateColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnBitrate, _("Bitrate"),
|
||||||
|
_("Toggle bitrate column"))->Check(BitrateColumn->IsShown());
|
||||||
|
menu.AppendCheckItem(MN_ColumnPath, _("Path"),
|
||||||
|
_("Toggle path column"))->Check(PathColumn->IsShown());
|
||||||
|
|
||||||
|
switch (this->GetPopupMenuSelectionFromUser(menu, event.GetPosition()))
|
||||||
|
{
|
||||||
|
case MN_ColumnFavorite:
|
||||||
|
FavoriteColumn->SetHidden(!menu.IsChecked(MN_ColumnFavorite));
|
||||||
|
break;
|
||||||
|
case MN_ColumnFilename:
|
||||||
|
FilenameColumn->SetHidden(!menu.IsChecked(MN_ColumnFilename));
|
||||||
|
break;
|
||||||
|
case MN_ColumnSamplePack:
|
||||||
|
SamplePackColumn->SetHidden(!menu.IsChecked(MN_ColumnSamplePack));
|
||||||
|
break;
|
||||||
|
case MN_ColumnType:
|
||||||
|
TypeColumn->SetHidden(!menu.IsChecked(MN_ColumnType));
|
||||||
|
break;
|
||||||
|
case MN_ColumnChannels:
|
||||||
|
ChannelsColumn->SetHidden(!menu.IsChecked(MN_ColumnChannels));
|
||||||
|
break;
|
||||||
|
case MN_ColumnLength:
|
||||||
|
LengthColumn->SetHidden(!menu.IsChecked(MN_ColumnLength));
|
||||||
|
break;
|
||||||
|
case MN_ColumnSampleRate:
|
||||||
|
SampleRateColumn->SetHidden(!menu.IsChecked(MN_ColumnSampleRate));
|
||||||
|
break;
|
||||||
|
case MN_ColumnBitrate:
|
||||||
|
BitrateColumn->SetHidden(!menu.IsChecked(MN_ColumnBitrate));
|
||||||
|
break;
|
||||||
|
case MN_ColumnPath:
|
||||||
|
PathColumn->SetHidden(!menu.IsChecked(MN_ColumnPath));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cListCtrl::AddSamples(wxArrayString& files)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
|
||||||
|
wxBusyCursor busy_cursor;
|
||||||
|
wxWindowDisabler window_disabler;
|
||||||
|
|
||||||
|
wxProgressDialog* progressDialog = new wxProgressDialog(_("Adding files.."),
|
||||||
|
_("Adding files, please wait..."),
|
||||||
|
static_cast<int>(files.size()), this,
|
||||||
|
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);
|
||||||
|
|
||||||
|
Tags 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());
|
||||||
|
|
||||||
|
this->AppendItem(data);
|
||||||
|
|
||||||
|
sample_array.push_back(sample);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString msg = wxString::Format(_("Error! Cannot open %s, Invalid file type."),
|
||||||
|
filename_with_extension);
|
||||||
|
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_ERROR, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
progressDialog->Pulse(_("Updating Database.."), NULL);
|
||||||
|
|
||||||
|
db.InsertIntoSamples(sample_array);
|
||||||
|
|
||||||
|
progressDialog->Destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
cListCtrl::FileInfo cListCtrl::GetFilenamePathAndExtension(const wxString& selected,
|
||||||
|
bool checkExtension, bool doGetFilename) const
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database 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 cListCtrl::LoadDatabase()
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cHivesPanel hives(m_pWindow);
|
||||||
|
// cTrashPanel trash(m_pWindow);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto dataset = db.LoadSamplesDatabase(m_Hives, m_FavoritesHive,
|
||||||
|
m_Trash, m_TrashRoot,
|
||||||
|
serializer.DeserializeShowFileExtension(),
|
||||||
|
ICON_STAR_FILLED_16px, ICON_STAR_EMPTY_16px);
|
||||||
|
|
||||||
|
if (dataset.empty())
|
||||||
|
SH_LOG_INFO("Error! Database is empty.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (auto data : dataset)
|
||||||
|
this->AppendItem(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
db.LoadHivesDatabase(m_Hives);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
std::cerr << "Error loading data." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cListCtrl::~cListCtrl()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/treectrl.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
class cListCtrl : public wxDataViewListCtrl
|
||||||
|
{
|
||||||
|
|
||||||
|
struct FileInfo
|
||||||
|
{
|
||||||
|
wxString Path;
|
||||||
|
std::string Extension;
|
||||||
|
std::string Filename;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// cListCtrl(wxWindow* window);
|
||||||
|
cListCtrl(wxWindow* window, wxDataViewItem favHive, wxDataViewTreeCtrl& hives,
|
||||||
|
wxTreeItemId trashRoot, wxTreeCtrl& trash);
|
||||||
|
~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);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void AddSamples(wxArrayString& files);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cListCtrl::FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
||||||
|
bool checkExtension = true,
|
||||||
|
bool doGetFilename = true) const;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
void LoadDatabase();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
|
wxDataViewTreeCtrl& m_Hives;
|
||||||
|
wxDataViewItem m_FavoritesHive;
|
||||||
|
wxTreeItemId m_TrashRoot;
|
||||||
|
wxTreeCtrl& m_Trash;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// friend class cHives;
|
||||||
|
// friend class cTrash;
|
||||||
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -21,11 +21,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Database/Database.hpp"
|
#include "Database/Database.hpp"
|
||||||
|
#include "GUI/Library.hpp"
|
||||||
#include "GUI/TransportControls.hpp"
|
#include "GUI/TransportControls.hpp"
|
||||||
#include "GUI/WaveformViewer.hpp"
|
#include "GUI/WaveformViewer.hpp"
|
||||||
#include "SampleHiveConfig.hpp"
|
#include "GUI/Notebook.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
#include "Utility/Serialize.hpp"
|
||||||
#include "Utility/SH_Event.hpp"
|
#include "Utility/SH_Event.hpp"
|
||||||
|
#include "SampleHiveConfig.hpp"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
@ -85,7 +87,7 @@ class MainFrame : public wxFrame
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Main Panel
|
// Main Panel
|
||||||
wxPanel* m_MainPanel;
|
// wxPanel* m_MainPanel;
|
||||||
wxBoxSizer* m_MainSizer;
|
wxBoxSizer* m_MainSizer;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -120,41 +122,43 @@ class MainFrame : public wxFrame
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Top panel controls
|
// Top panel controls
|
||||||
wxPanel* m_TopPanel;
|
wxPanel* m_TopPanel;
|
||||||
TransportControls* m_TransportControls;
|
cTransportControls* m_TransportControls;
|
||||||
WaveformViewer* m_WaveformViewer;
|
cWaveformViewer* m_WaveformViewer;
|
||||||
wxBoxSizer* m_TopSizer;
|
// wxBoxSizer* m_TopSizer;
|
||||||
wxBoxSizer* m_TopPanelMainSizer;
|
wxBoxSizer* m_TopPanelMainSizer;
|
||||||
wxBoxSizer* m_WaveformDisplaySizer;
|
// wxBoxSizer* m_WaveformDisplaySizer;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Left panel controls
|
// Left panel controls
|
||||||
wxPanel* m_BottomLeftPanel;
|
// wxPanel* m_BottomLeftPanel;
|
||||||
wxPanel* m_HivesPanel;
|
cNotebook* m_Notebook;
|
||||||
wxPanel* m_TrashPanel;
|
// wxPanel* m_HivesPanel;
|
||||||
wxNotebook* m_Notebook;
|
// wxPanel* m_TrashPanel;
|
||||||
wxBoxSizer* m_BottomLeftPanelMainSizer;
|
// wxNotebook* m_Notebook;
|
||||||
wxBoxSizer* m_HivesMainSizer;
|
// wxBoxSizer* m_BottomLeftPanelMainSizer;
|
||||||
wxBoxSizer* m_HivesFavoritesSizer;
|
// wxBoxSizer* m_HivesMainSizer;
|
||||||
wxBoxSizer* m_HivesButtonSizer;
|
// wxBoxSizer* m_HivesFavoritesSizer;
|
||||||
wxBoxSizer* m_TrashMainSizer;
|
// wxBoxSizer* m_HivesButtonSizer;
|
||||||
wxBoxSizer* m_TrashItemSizer;
|
// wxBoxSizer* m_TrashMainSizer;
|
||||||
wxBoxSizer* m_TrashButtonSizer;
|
// wxBoxSizer* m_TrashItemSizer;
|
||||||
wxGenericDirCtrl* m_DirCtrl;
|
// wxBoxSizer* m_TrashButtonSizer;
|
||||||
wxDataViewTreeCtrl* m_Hives;
|
// wxGenericDirCtrl* m_DirCtrl;
|
||||||
wxDataViewItem favorites_hive;
|
// wxDataViewTreeCtrl* m_Hives;
|
||||||
wxTreeItemId trash_root;
|
// wxDataViewItem favorites_hive;
|
||||||
wxTreeCtrl* m_Trash;
|
// wxTreeItemId trash_root;
|
||||||
wxButton* m_AddHiveButton;
|
// wxTreeCtrl* m_Trash;
|
||||||
wxButton* m_RemoveHiveButton;
|
// wxButton* m_AddHiveButton;
|
||||||
wxButton* m_RestoreTrashedItemButton;
|
// wxButton* m_RemoveHiveButton;
|
||||||
|
// wxButton* m_RestoreTrashedItemButton;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Right panel controls
|
// Right panel controls
|
||||||
wxPanel* m_BottomRightPanel;
|
cLibrary* m_Library;
|
||||||
wxBoxSizer* m_BottomRightPanelMainSizer;
|
// wxPanel* m_BottomRightPanel;
|
||||||
wxSearchCtrl* m_SearchBox;
|
// wxBoxSizer* m_BottomRightPanelMainSizer;
|
||||||
wxInfoBar* m_InfoBar;
|
// wxSearchCtrl* m_SearchBox;
|
||||||
wxDataViewListCtrl* m_Library;
|
// wxInfoBar* m_InfoBar;
|
||||||
|
// wxDataViewListCtrl* m_Library;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// MediaCtrl
|
// MediaCtrl
|
||||||
|
|
@ -175,7 +179,7 @@ class MainFrame : public wxFrame
|
||||||
wxLongLong m_LoopA, m_LoopB;
|
wxLongLong m_LoopA, m_LoopB;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
// wxSystemAppearance m_Theme = wxSystemSettings::GetAppearance();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -188,39 +192,39 @@ class MainFrame : public wxFrame
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Top panel control handlers
|
// Top panel control handlers
|
||||||
void OnMediaFinished(wxMediaEvent& event);
|
void OnMediaFinished(wxMediaEvent& event);
|
||||||
void OnClickSettings(wxCommandEvent& event);
|
// void OnClickSettings(wxCommandEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// DirCtrl event handlers
|
// DirCtrl event handlers
|
||||||
void OnClickDirCtrl(wxCommandEvent& event);
|
// void OnClickDirCtrl(wxCommandEvent& event);
|
||||||
void OnDragFromDirCtrl(wxTreeEvent& event);
|
// void OnDragFromDirCtrl(wxTreeEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// TrashPane event handlers
|
// TrashPane event handlers
|
||||||
void OnShowTrashContextMenu(wxTreeEvent& event);
|
// void OnShowTrashContextMenu(wxTreeEvent& event);
|
||||||
void OnClickRestoreTrashItem(wxCommandEvent& event);
|
// void OnClickRestoreTrashItem(wxCommandEvent& event);
|
||||||
void OnDragAndDropToTrash(wxDropFilesEvent& event);
|
// void OnDragAndDropToTrash(wxDropFilesEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Hives panel button event handlers
|
// Hives panel button event handlers
|
||||||
void OnDragAndDropToHives(wxDropFilesEvent& event);
|
// void OnDragAndDropToHives(wxDropFilesEvent& event);
|
||||||
void OnClickAddHive(wxCommandEvent& event);
|
// void OnClickAddHive(wxCommandEvent& event);
|
||||||
void OnClickRemoveHive(wxCommandEvent& event);
|
// void OnClickRemoveHive(wxCommandEvent& event);
|
||||||
void OnShowHivesContextMenu(wxDataViewEvent& event);
|
// void OnShowHivesContextMenu(wxDataViewEvent& event);
|
||||||
void OnHiveStartEditing(wxDataViewEvent& event);
|
// void OnHiveStartEditing(wxDataViewEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// SearchCtrl event handlers
|
// SearchCtrl event handlers
|
||||||
void OnDoSearch(wxCommandEvent& event);
|
// void OnDoSearch(wxCommandEvent& event);
|
||||||
void OnCancelSearch(wxCommandEvent& event);
|
// void OnCancelSearch(wxCommandEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Library event handlers
|
// Library event handlers
|
||||||
void OnClickLibrary(wxDataViewEvent& event);
|
// void OnClickLibrary(wxDataViewEvent& event);
|
||||||
void OnDragAndDropToLibrary(wxDropFilesEvent& event);
|
// void OnDragAndDropToLibrary(wxDropFilesEvent& event);
|
||||||
void OnDragFromLibrary(wxDataViewEvent& event);
|
// void OnDragFromLibrary(wxDataViewEvent& event);
|
||||||
void OnShowLibraryContextMenu(wxDataViewEvent& event);
|
// void OnShowLibraryContextMenu(wxDataViewEvent& event);
|
||||||
void OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event);
|
// void OnShowLibraryColumnHeaderContextMenu(wxDataViewEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// App menu items event handlers
|
// App menu items event handlers
|
||||||
|
|
@ -251,8 +255,8 @@ class MainFrame : public wxFrame
|
||||||
void UpdateElapsedTime(wxTimerEvent& event);
|
void UpdateElapsedTime(wxTimerEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void AddSamples(wxArrayString& files);
|
// void AddSamples(wxArrayString& files);
|
||||||
void OnAutoImportDir(const wxString& pathToDirectory);
|
// 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,
|
||||||
|
|
@ -260,23 +264,24 @@ class MainFrame : public wxFrame
|
||||||
|
|
||||||
// Recieve custom events
|
// Recieve custom events
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event);
|
void OnRecieveLoopPoints(SampleHive::LoopPointsEvent& event);
|
||||||
void OnRecievePushStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
|
void OnRecievePushStatusBarStatus(SampleHive::StatusBarStatusEvent& event);
|
||||||
void OnRecievePopStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
|
void OnRecievePopStatusBarStatus(SampleHive::StatusBarStatusEvent& event);
|
||||||
void OnRecieveSetStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
|
void OnRecieveSetStatusBarStatus(SampleHive::StatusBarStatusEvent& event);
|
||||||
void OnRecieveInfoBarStatus(SampleHive::SH_InfoBarMessageEvent& event);
|
void OnRecieveInfoBarStatus(SampleHive::InfoBarMessageEvent& event);
|
||||||
void OnRecieveTimerStopStatus(SampleHive::SH_TimerEvent& event);
|
void OnRecieveTimerStopStatus(SampleHive::TimerEvent& event);
|
||||||
void OnRecieveCallFunctionPlay(SampleHive::SH_CallFunctionEvent& event);
|
void OnRecieveCallFunctionPlay(SampleHive::CallFunctionEvent& event);
|
||||||
|
void OnRecieveWaveformUpdateStatus(SampleHive::WaveformUpdateEvent& event);
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void LoadDatabase();
|
// void LoadDatabase();
|
||||||
void RefreshDatabase();
|
// void RefreshDatabase();
|
||||||
void LoadConfigFile();
|
void LoadConfigFile();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Getters
|
// Getters
|
||||||
FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
// FileInfo GetFilenamePathAndExtension(const wxString& selected,
|
||||||
bool checkExtension = true, bool doGetFilename = true) const;
|
// bool checkExtension = true, bool doGetFilename = true) const;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Directory watchers
|
// Directory watchers
|
||||||
|
|
@ -294,6 +299,8 @@ class MainFrame : public wxFrame
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
void ClearLoopPoints();
|
void ClearLoopPoints();
|
||||||
|
|
||||||
|
void InitDatabase();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
friend class App;
|
friend class App;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
#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_pListCtrl);
|
||||||
|
m_TrashPanel = new cTrashPanel(m_pNotebook, *m_pListCtrl);
|
||||||
|
|
||||||
|
// 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,37 @@
|
||||||
|
#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; }
|
||||||
|
|
||||||
|
void SetListCtrlObject(wxDataViewListCtrl& listCtrl) { m_pListCtrl = &listCtrl; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxNotebook* m_pNotebook = nullptr;
|
||||||
|
wxBoxSizer* m_pSizer = nullptr;
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
cDirectoryBrowser* m_DirectoryBrowser = nullptr;
|
||||||
|
cHivesPanel* m_HivesPanel = nullptr;
|
||||||
|
cTrashPanel* m_TrashPanel = nullptr;
|
||||||
|
|
||||||
|
wxDataViewListCtrl* m_pListCtrl;
|
||||||
|
};
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
#include "GUI/SearchBar.hpp"
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
|
||||||
|
cSearchBar::cSearchBar(wxWindow* window, wxDataViewListCtrl& listCtrl)
|
||||||
|
: wxSearchCtrl(window, BC_Search, _("Search for samples.."),
|
||||||
|
wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER),
|
||||||
|
m_pWindow(window), m_ListCtrl(listCtrl)
|
||||||
|
{
|
||||||
|
// 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, BC_Search);
|
||||||
|
Bind(wxEVT_SEARCHCTRL_SEARCH_BTN, &cSearchBar::OnDoSearch, this, BC_Search);
|
||||||
|
Bind(wxEVT_SEARCHCTRL_CANCEL_BTN, &cSearchBar::OnCancelSearch, this, BC_Search);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSearchBar::OnDoSearch(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cListCtrl m_ListCtrl(m_pWindow);
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
m_ListCtrl.DeleteAllItems();
|
||||||
|
|
||||||
|
std::cout << search << std::endl;
|
||||||
|
|
||||||
|
for (const auto& data : dataset)
|
||||||
|
{
|
||||||
|
m_ListCtrl.AppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr << "Error loading data." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cSearchBar::OnCancelSearch(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
this->Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
cSearchBar::~cSearchBar()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/dataview.h>
|
||||||
|
#include <wx/srchctrl.h>
|
||||||
|
|
||||||
|
class cSearchBar : public wxSearchCtrl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cSearchBar(wxWindow* window, wxDataViewListCtrl& listCtrl);
|
||||||
|
~cSearchBar();
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxSearchCtrl* GetSearchCtrlObject() { return this; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// SearchCtrl event handlers
|
||||||
|
void OnDoSearch(wxCommandEvent& event);
|
||||||
|
void OnCancelSearch(wxCommandEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
wxWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
|
wxDataViewListCtrl& m_ListCtrl;
|
||||||
|
};
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
#include "GUI/TransportControls.hpp"
|
#include "GUI/TransportControls.hpp"
|
||||||
#include "Utility/ControlIDs.hpp"
|
#include "Utility/ControlIDs.hpp"
|
||||||
#include "Utility/SH_Event.hpp"
|
#include "Utility/SH_Event.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
#include "Utility/Serialize.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
#include "Utility/Paths.hpp"
|
#include "Utility/Paths.hpp"
|
||||||
|
|
||||||
TransportControls::TransportControls(wxWindow* window, wxDataViewListCtrl& library,
|
cTransportControls::cTransportControls(wxWindow* window, wxDataViewListCtrl& library,
|
||||||
wxMediaCtrl& mediaCtrl, wxTimer& timer)
|
wxMediaCtrl& mediaCtrl, wxTimer& timer)
|
||||||
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER),
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxNO_BORDER),
|
||||||
m_Library(library), m_MediaCtrl(mediaCtrl), m_Timer(timer)
|
m_Library(library), m_MediaCtrl(mediaCtrl), m_Timer(timer)
|
||||||
{
|
{
|
||||||
|
|
@ -21,6 +22,7 @@ TransportControls::TransportControls(wxWindow* window, wxDataViewListCtrl& libra
|
||||||
m_pLoopABButton = new wxBitmapToggleButton(this, BC_LoopABButton,
|
m_pLoopABButton = new wxBitmapToggleButton(this, BC_LoopABButton,
|
||||||
static_cast<wxString>(ICON_AB_DARK_16px),
|
static_cast<wxString>(ICON_AB_DARK_16px),
|
||||||
wxDefaultPosition, wxDefaultSize, 0);
|
wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
|
||||||
m_pLoopABButton->SetToolTip(_("Loop selected region"));
|
m_pLoopABButton->SetToolTip(_("Loop selected region"));
|
||||||
|
|
||||||
// Autoplay checkbox
|
// Autoplay checkbox
|
||||||
|
|
@ -101,20 +103,20 @@ TransportControls::TransportControls(wxWindow* window, wxDataViewListCtrl& libra
|
||||||
m_pMainSizer->SetSizeHints(this);
|
m_pMainSizer->SetSizeHints(this);
|
||||||
m_pMainSizer->Layout();
|
m_pMainSizer->Layout();
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &TransportControls::OnClickPlay, this, BC_Play);
|
Bind(wxEVT_BUTTON, &cTransportControls::OnClickPlay, this, BC_Play);
|
||||||
Bind(wxEVT_TOGGLEBUTTON, &TransportControls::OnClickLoop, this, BC_Loop);
|
Bind(wxEVT_TOGGLEBUTTON, &cTransportControls::OnClickLoop, this, BC_Loop);
|
||||||
Bind(wxEVT_BUTTON, &TransportControls::OnClickStop, this, BC_Stop);
|
Bind(wxEVT_BUTTON, &cTransportControls::OnClickStop, this, BC_Stop);
|
||||||
Bind(wxEVT_TOGGLEBUTTON, &TransportControls::OnClickMute, this, BC_Mute);
|
Bind(wxEVT_TOGGLEBUTTON, &cTransportControls::OnClickMute, this, BC_Mute);
|
||||||
// Bind(wxEVT_BUTTON, &Controls::OnClickSettings, this, BC_Settings);
|
// Bind(wxEVT_BUTTON, &Controls::OnClickSettings, this, BC_Settings);
|
||||||
Bind(wxEVT_CHECKBOX, &TransportControls::OnCheckAutoplay, this, BC_Autoplay);
|
Bind(wxEVT_CHECKBOX, &cTransportControls::OnCheckAutoplay, this, BC_Autoplay);
|
||||||
Bind(wxEVT_SCROLL_THUMBTRACK, &TransportControls::OnSlideVolume, this, BC_Volume);
|
Bind(wxEVT_SCROLL_THUMBTRACK, &cTransportControls::OnSlideVolume, this, BC_Volume);
|
||||||
Bind(wxEVT_SCROLL_THUMBRELEASE, &TransportControls::OnReleaseVolumeSlider, this, BC_Volume);
|
Bind(wxEVT_SCROLL_THUMBRELEASE, &cTransportControls::OnReleaseVolumeSlider, this, BC_Volume);
|
||||||
|
|
||||||
// Load control values from config file
|
// Load control values from config file
|
||||||
LoadConfigFile();
|
LoadConfigFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnClickPlay(wxCommandEvent& event)
|
void cTransportControls::OnClickPlay(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
m_bStopped = false;
|
m_bStopped = false;
|
||||||
|
|
||||||
|
|
@ -126,10 +128,10 @@ void TransportControls::OnClickPlay(wxCommandEvent& event)
|
||||||
wxString selection = m_Library.GetTextValue(selected_row, 1);
|
wxString selection = m_Library.GetTextValue(selected_row, 1);
|
||||||
|
|
||||||
// Send custom event to MainFrame to play the sample
|
// Send custom event to MainFrame to play the sample
|
||||||
SendCallFunctionPlay(selection);
|
SampleHive::Signal::SendCallFunctionPlay(selection, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnClickLoop(wxCommandEvent& event)
|
void cTransportControls::OnClickLoop(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
|
|
@ -138,7 +140,7 @@ void TransportControls::OnClickLoop(wxCommandEvent& event)
|
||||||
serializer.SerializeMediaOptions("loop", m_bLoop);
|
serializer.SerializeMediaOptions("loop", m_bLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnClickStop(wxCommandEvent& event)
|
void cTransportControls::OnClickStop(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
if (!m_MediaCtrl.Stop())
|
if (!m_MediaCtrl.Stop())
|
||||||
SH_LOG_ERROR("Error! Unable to stop media.");
|
SH_LOG_ERROR("Error! Unable to stop media.");
|
||||||
|
|
@ -146,15 +148,15 @@ void TransportControls::OnClickStop(wxCommandEvent& event)
|
||||||
m_bStopped = true;
|
m_bStopped = true;
|
||||||
|
|
||||||
// Send custom event to MainFrame to stop the timer
|
// Send custom event to MainFrame to stop the timer
|
||||||
SendTimerStopStatus();
|
SampleHive::Signal::SendTimerStopStatus(*this);
|
||||||
|
|
||||||
m_pSamplePosition->SetLabel("--:--/--:--");
|
m_pSamplePosition->SetLabel("--:--/--:--");
|
||||||
|
|
||||||
// Send custom event to MainFrame to set the statusbar status
|
// Send custom event to MainFrame to set the statusbar status
|
||||||
SendSetStatusBarStatus(_("Stopped"), 1);
|
SampleHive::Signal::SendSetStatusBarStatus(_("Stopped"), 1, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnClickMute(wxCommandEvent& event)
|
void cTransportControls::OnClickMute(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
|
|
@ -174,7 +176,7 @@ void TransportControls::OnClickMute(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnCheckAutoplay(wxCommandEvent& event)
|
void cTransportControls::OnCheckAutoplay(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
|
|
@ -192,15 +194,16 @@ void TransportControls::OnCheckAutoplay(wxCommandEvent& event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnSlideVolume(wxScrollEvent& event)
|
void cTransportControls::OnSlideVolume(wxScrollEvent& event)
|
||||||
{
|
{
|
||||||
m_MediaCtrl.SetVolume(double(m_pVolumeSlider->GetValue()) / 100);
|
m_MediaCtrl.SetVolume(double(m_pVolumeSlider->GetValue()) / 100);
|
||||||
|
|
||||||
// Send custom event to MainFrame to push status to statusbar
|
// Send custom event to MainFrame to push status to statusbar
|
||||||
SendPushStatusBarStatus(wxString::Format(_("Volume: %d"), m_pVolumeSlider->GetValue()), 1);
|
SampleHive::Signal::SendPushStatusBarStatus(wxString::Format(_("Volume: %d"),
|
||||||
|
m_pVolumeSlider->GetValue()), 1, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::OnReleaseVolumeSlider(wxScrollEvent& event)
|
void cTransportControls::OnReleaseVolumeSlider(wxScrollEvent& event)
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
|
|
@ -217,15 +220,16 @@ void TransportControls::OnReleaseVolumeSlider(wxScrollEvent& event)
|
||||||
wxSleep(1);
|
wxSleep(1);
|
||||||
|
|
||||||
// Send custom event to MainFrame to pop status from statusbar
|
// Send custom event to MainFrame to pop status from statusbar
|
||||||
SendPopStatusBarStatus(1);
|
SampleHive::Signal::SendPopStatusBarStatus(1, *this);
|
||||||
|
|
||||||
if (m_MediaCtrl.GetState() == wxMEDIASTATE_STOPPED)
|
if (m_MediaCtrl.GetState() == wxMEDIASTATE_STOPPED)
|
||||||
SendSetStatusBarStatus(_("Stopped"), 1);
|
SampleHive::Signal::SendSetStatusBarStatus(_("Stopped"), 1, *this);
|
||||||
else
|
else
|
||||||
SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selection), 1);
|
SampleHive::Signal::SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selection),
|
||||||
|
1, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::LoadConfigFile()
|
void cTransportControls::LoadConfigFile()
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
|
|
@ -247,55 +251,7 @@ void TransportControls::LoadConfigFile()
|
||||||
m_MediaCtrl.SetVolume(0.0);
|
m_MediaCtrl.SetVolume(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportControls::SendPushStatusBarStatus(const wxString& msg, int section)
|
cTransportControls::~cTransportControls()
|
||||||
{
|
|
||||||
SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
event.SetPushMessageAndSection({ msg, section });
|
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransportControls::SendPopStatusBarStatus(int section)
|
|
||||||
{
|
|
||||||
SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_POP, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
event.SetPopMessageSection(section);
|
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransportControls::SendSetStatusBarStatus(const wxString& text, int section)
|
|
||||||
{
|
|
||||||
SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_SET, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
event.SetStatusTextAndSection({ text, section });
|
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransportControls::SendCallFunctionPlay(const wxString& selection)
|
|
||||||
{
|
|
||||||
SampleHive::SH_CallFunctionEvent event(SampleHive::SH_EVT_CALL_FUNC_PLAY, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
event.SetSelection(selection);
|
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransportControls::SendTimerStopStatus()
|
|
||||||
{
|
|
||||||
SampleHive::SH_TimerEvent event(SampleHive::SH_EVT_TIMER_STOP, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
TransportControls::~TransportControls()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,27 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "wx/bmpbuttn.h"
|
#include <wx/bmpbuttn.h>
|
||||||
#include "wx/button.h"
|
#include <wx/button.h>
|
||||||
#include "wx/checkbox.h"
|
#include <wx/checkbox.h>
|
||||||
#include "wx/dataview.h"
|
#include <wx/dataview.h>
|
||||||
#include "wx/event.h"
|
#include <wx/event.h>
|
||||||
#include "wx/mediactrl.h"
|
#include <wx/mediactrl.h>
|
||||||
#include "wx/settings.h"
|
#include <wx/settings.h>
|
||||||
#include "wx/sizer.h"
|
#include <wx/sizer.h>
|
||||||
#include "wx/slider.h"
|
#include <wx/slider.h>
|
||||||
#include "wx/stattext.h"
|
#include <wx/stattext.h>
|
||||||
#include "wx/tglbtn.h"
|
#include <wx/tglbtn.h>
|
||||||
#include "wx/panel.h"
|
#include <wx/panel.h>
|
||||||
#include "wx/timer.h"
|
#include <wx/timer.h>
|
||||||
#include "wx/window.h"
|
#include <wx/version.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
class TransportControls : public wxPanel
|
class cTransportControls : public wxPanel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
TransportControls(wxWindow* window, wxDataViewListCtrl& library, wxMediaCtrl& mediaCtrl, wxTimer& timer);
|
cTransportControls(wxWindow* window, wxDataViewListCtrl& library, wxMediaCtrl& mediaCtrl, wxTimer& timer);
|
||||||
~TransportControls();
|
~cTransportControls();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
@ -59,15 +60,6 @@ class TransportControls : public wxPanel
|
||||||
void OnSlideVolume(wxScrollEvent& event);
|
void OnSlideVolume(wxScrollEvent& event);
|
||||||
void OnReleaseVolumeSlider(wxScrollEvent& event);
|
void OnReleaseVolumeSlider(wxScrollEvent& event);
|
||||||
|
|
||||||
private:
|
|
||||||
// -------------------------------------------------------------------
|
|
||||||
// Custom events for sending infomation to MainFrame
|
|
||||||
void SendPushStatusBarStatus(const wxString& msg, int section);
|
|
||||||
void SendSetStatusBarStatus(const wxString& msg, int section);
|
|
||||||
void SendPopStatusBarStatus(int section);
|
|
||||||
void SendCallFunctionPlay(const wxString& selection);
|
|
||||||
void SendTimerStopStatus();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Load control values from config file
|
// Load control values from config file
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,292 @@
|
||||||
|
#include "GUI/Trash.hpp"
|
||||||
|
#include "GUI/Hives.hpp"
|
||||||
|
#include "GUI/ListCtrl.hpp"
|
||||||
|
#include "Database/Database.hpp"
|
||||||
|
#include "Utility/ControlIDs.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/Paths.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Serialize.hpp"
|
||||||
|
|
||||||
|
#include <wx/menu.h>
|
||||||
|
#include <wx/msgdlg.h>
|
||||||
|
|
||||||
|
cTrashPanel::cTrashPanel(wxWindow* window, wxDataViewListCtrl& listCtrl)
|
||||||
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
|
||||||
|
m_pWindow(window), m_ListCtrl(listCtrl)
|
||||||
|
{
|
||||||
|
m_pMainSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pTrashSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
m_pButtonSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
|
m_pTrash = new wxTreeCtrl(this, 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, 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, BC_Trash);
|
||||||
|
Bind(wxEVT_BUTTON, &cTrashPanel::OnClickRestoreTrashItem, this, 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)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
cHivesPanel hives(m_pWindow, m_ListCtrl);
|
||||||
|
// cListCtrl m_ListCtrl.m_pWindow);
|
||||||
|
|
||||||
|
if (event.GetNumberOfFiles() > 0)
|
||||||
|
{
|
||||||
|
wxFileDataObject file_data;
|
||||||
|
wxArrayString files;
|
||||||
|
|
||||||
|
wxDataViewItemArray items;
|
||||||
|
int rows = m_ListCtrl.GetSelections(items);
|
||||||
|
// int rows = 2;
|
||||||
|
|
||||||
|
wxString msg;
|
||||||
|
|
||||||
|
wxDataViewItem root = wxDataViewItem(wxNullPtr);
|
||||||
|
wxDataViewItem container, child;
|
||||||
|
|
||||||
|
for (int i = 0; i < rows; i++)
|
||||||
|
{
|
||||||
|
int item_row = m_ListCtrl.ItemToRow(items[i]);
|
||||||
|
|
||||||
|
wxString text_value = m_ListCtrl.GetTextValue(item_row, 1);
|
||||||
|
|
||||||
|
std::string multi_selection = serializer.DeserializeShowFileExtension() ?
|
||||||
|
m_ListCtrl.GetTextValue(item_row, 1).BeforeLast('.').ToStdString() :
|
||||||
|
m_ListCtrl.GetTextValue(item_row, 1).ToStdString() ;
|
||||||
|
|
||||||
|
file_data.AddFile(multi_selection);
|
||||||
|
|
||||||
|
files = file_data.GetFilenames();
|
||||||
|
|
||||||
|
if (db.GetFavoriteColumnValueByFilename(files[i].ToStdString()))
|
||||||
|
{
|
||||||
|
m_ListCtrl.SetValue(wxVariant(wxBitmap(ICON_STAR_EMPTY_16px)), item_row, 0);
|
||||||
|
|
||||||
|
db.UpdateFavoriteColumn(files[i].ToStdString(), 0);
|
||||||
|
|
||||||
|
for (int j = 0; j < hives.GetHivesObject()->GetChildCount(root); j++)
|
||||||
|
{
|
||||||
|
container = hives.GetHivesObject()->GetNthChild(root, j);
|
||||||
|
|
||||||
|
for (int k = 0; k < hives.GetHivesObject()->GetChildCount(container); k++)
|
||||||
|
{
|
||||||
|
child = hives.GetHivesObject()->GetNthChild(container, k);
|
||||||
|
|
||||||
|
wxString child_text = serializer.DeserializeShowFileExtension() ?
|
||||||
|
hives.GetHivesObject()->GetItemText(child).BeforeLast('.') :
|
||||||
|
hives.GetHivesObject()->GetItemText(child);
|
||||||
|
|
||||||
|
if (child_text == files[i])
|
||||||
|
{
|
||||||
|
hives.GetHivesObject()->DeleteItem(child);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
db.UpdateTrashColumn(files[i].ToStdString(), 1);
|
||||||
|
db.UpdateHiveName(files[i].ToStdString(),
|
||||||
|
hives.GetHivesObject()->GetItemText(hives.GetFavoritesHive()).ToStdString());
|
||||||
|
|
||||||
|
m_pTrash->AppendItem(m_TrashRoot, text_value);
|
||||||
|
|
||||||
|
m_ListCtrl.DeleteItem(item_row);
|
||||||
|
|
||||||
|
msg = wxString::Format(_("%s sent to trash"), text_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!msg.IsEmpty())
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(msg, wxICON_ERROR, *this);
|
||||||
|
// m_InfoBar->ShowMessage(msg, wxICON_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTrashPanel::OnShowTrashContextMenu(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cListCtrl m_ListCtrl.m_pWindow);
|
||||||
|
|
||||||
|
wxTreeItemId selected_trashed_item = event.GetItem();
|
||||||
|
|
||||||
|
wxMenu menu;
|
||||||
|
|
||||||
|
menu.Append(MN_DeleteTrash, _("Delete from database"), _("Delete the selected sample(s) from database"));
|
||||||
|
menu.Append(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 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 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 = 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)
|
||||||
|
{
|
||||||
|
m_ListCtrl.AppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr << "Error loading data." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTrash->Delete(selected_item_ids[i]);
|
||||||
|
|
||||||
|
SH_LOG_INFO("{} restored from trash", files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cTrashPanel::OnClickRestoreTrashItem(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
Serializer serializer;
|
||||||
|
Database db;
|
||||||
|
// cListCtrl m_ListCtrl.m_pWindow);
|
||||||
|
|
||||||
|
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 = 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)
|
||||||
|
{
|
||||||
|
m_ListCtrl.AppendItem(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr << "Error loading data." << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pTrash->Delete(selected_item_ids[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cTrashPanel::~cTrashPanel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
#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, wxDataViewListCtrl& listCtrl);
|
||||||
|
~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;
|
||||||
|
wxDataViewListCtrl& m_ListCtrl;
|
||||||
|
// friend class cListCtrl;
|
||||||
|
};
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "GUI/WaveformViewer.hpp"
|
#include "GUI/WaveformViewer.hpp"
|
||||||
#include "Utility/Serialize.hpp"
|
#include "Utility/Serialize.hpp"
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
#include "Utility/Tags.hpp"
|
#include "Utility/Tags.hpp"
|
||||||
#include "Utility/SH_Event.hpp"
|
#include "Utility/SH_Event.hpp"
|
||||||
#include "Utility/Log.hpp"
|
#include "Utility/Log.hpp"
|
||||||
|
|
@ -37,7 +38,7 @@
|
||||||
|
|
||||||
#include <sndfile.hh>
|
#include <sndfile.hh>
|
||||||
|
|
||||||
WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
cWaveformViewer::cWaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
||||||
wxMediaCtrl& mediaCtrl, Database& database)
|
wxMediaCtrl& mediaCtrl, Database& database)
|
||||||
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
: wxPanel(window, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||||
wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
wxTAB_TRAVERSAL | wxNO_BORDER | wxFULL_REPAINT_ON_RESIZE),
|
||||||
|
|
@ -45,20 +46,27 @@ WaveformViewer::WaveformViewer(wxWindow* window, wxDataViewListCtrl& library,
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
||||||
|
|
@ -101,13 +109,14 @@ void WaveformViewer::OnPaint(wxPaintEvent& event)
|
||||||
this->GetSize().GetHeight() + 5));
|
this->GetSize().GetHeight() + 5));
|
||||||
|
|
||||||
bAreaSelected = true;
|
bAreaSelected = true;
|
||||||
SendLoopPoints();
|
// SendLoopPoints();
|
||||||
|
SampleHive::Signal::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 = m_Library.GetSelectedRow();
|
||||||
|
|
||||||
|
|
@ -145,7 +154,7 @@ void WaveformViewer::RenderPlayhead(wxDC& dc)
|
||||||
line_pos, this->GetSize().GetHeight() - 1);
|
line_pos, this->GetSize().GetHeight() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::UpdateWaveformBitmap()
|
void cWaveformViewer::UpdateWaveformBitmap()
|
||||||
{
|
{
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
|
|
@ -251,7 +260,7 @@ void WaveformViewer::UpdateWaveformBitmap()
|
||||||
SH_LOG_DEBUG("Done drawing bitmap..");
|
SH_LOG_DEBUG("Done drawing bitmap..");
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
void cWaveformViewer::OnControlKeyDown(wxKeyEvent &event)
|
||||||
{
|
{
|
||||||
switch (event.GetKeyCode())
|
switch (event.GetKeyCode())
|
||||||
{
|
{
|
||||||
|
|
@ -266,7 +275,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())
|
||||||
{
|
{
|
||||||
|
|
@ -287,7 +296,7 @@ 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 = m_Library.GetSelectedRow();
|
||||||
|
|
||||||
|
|
@ -327,7 +336,7 @@ 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 = m_Library.GetSelectedRow();
|
||||||
|
|
||||||
|
|
@ -376,7 +385,7 @@ 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 = m_Library.GetSelectedRow();
|
||||||
|
|
||||||
|
|
@ -427,12 +436,13 @@ 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);
|
// SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selected), 1);
|
||||||
|
SampleHive::Signal::SendInfoBarMessage(wxString::Format(_("Now playing: %s"), selected), 1, *this);
|
||||||
m_MediaCtrl.Play();
|
m_MediaCtrl.Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::ResetDC()
|
void cWaveformViewer::ResetDC()
|
||||||
{
|
{
|
||||||
bBitmapDirty = true;
|
bBitmapDirty = true;
|
||||||
bSelectRange = false;
|
bSelectRange = false;
|
||||||
|
|
@ -441,17 +451,12 @@ void WaveformViewer::ResetDC()
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveformViewer::SendLoopPoints()
|
std::pair<double, double> cWaveformViewer::CalculateLoopPoints()
|
||||||
{
|
{
|
||||||
SH_LOG_DEBUG("{} Called", __FUNCTION__);
|
|
||||||
|
|
||||||
SampleHive::SH_LoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, this->GetId());
|
|
||||||
event.SetEventObject(this);
|
|
||||||
|
|
||||||
int selected_row = m_Library.GetSelectedRow();
|
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 = m_Library.GetTextValue(selected_row, 1);
|
||||||
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
std::string path = m_Database.GetSamplePathByFilename(selected.BeforeLast('.').ToStdString());
|
||||||
|
|
@ -467,19 +472,15 @@ 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)
|
// void cWaveformViewer::SendPushStatusBarStatus(const wxString& msg, int section)
|
||||||
{
|
// {
|
||||||
SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, this->GetId());
|
// SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, this->GetId());
|
||||||
event.SetEventObject(this);
|
// event.SetEventObject(this);
|
||||||
|
|
||||||
event.SetPushMessageAndSection({ msg, section });
|
// event.SetPushMessageAndSection({ msg, section });
|
||||||
|
|
||||||
HandleWindowEvent(event);
|
// HandleWindowEvent(event);
|
||||||
}
|
// }
|
||||||
|
|
|
||||||
|
|
@ -35,17 +35,19 @@
|
||||||
#include <wx/timer.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, wxDataViewListCtrl& library,
|
||||||
wxMediaCtrl& mediaCtrl, Database& database);
|
wxMediaCtrl& mediaCtrl, Database& database);
|
||||||
~WaveformViewer();
|
~cWaveformViewer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
wxWindow* m_Window;
|
wxWindow* m_Window;
|
||||||
|
|
||||||
|
wxBoxSizer* m_Sizer;
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
Database& m_Database;
|
Database& m_Database;
|
||||||
wxDataViewListCtrl& m_Library;
|
wxDataViewListCtrl& m_Library;
|
||||||
|
|
@ -84,10 +86,13 @@ class WaveformViewer : public wxPanel
|
||||||
void OnControlKeyUp(wxKeyEvent& event);
|
void OnControlKeyUp(wxKeyEvent& event);
|
||||||
void OnControlKeyDown(wxKeyEvent& event);
|
void OnControlKeyDown(wxKeyEvent& event);
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
std::pair<double, double> CalculateLoopPoints();
|
||||||
|
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
// Send custom events
|
// Send custom events
|
||||||
void SendLoopPoints();
|
// void SendLoopPoints();
|
||||||
void SendPushStatusBarStatus(const wxString& msg, int section);
|
// void SendPushStatusBarStatus(const wxString& msg, int section);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// -------------------------------------------------------------------
|
// -------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -22,96 +22,109 @@
|
||||||
|
|
||||||
namespace SampleHive
|
namespace SampleHive
|
||||||
{
|
{
|
||||||
SH_LoopPointsEvent::SH_LoopPointsEvent(wxEventType eventType, int winId)
|
LoopPointsEvent::LoopPointsEvent(wxEventType eventType, int winId)
|
||||||
: wxCommandEvent(eventType, winId)
|
: wxCommandEvent(eventType, winId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_LoopPointsEvent::~SH_LoopPointsEvent()
|
LoopPointsEvent::~LoopPointsEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, SH_LoopPointsEvent);
|
wxDEFINE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, LoopPointsEvent);
|
||||||
|
|
||||||
// SH_AddSampleEvent::SH_AddSampleEvent(wxEventType eventType, int winId)
|
// AddSampleEvent::AddSampleEvent(wxEventType eventType, int winId)
|
||||||
// : wxCommandEvent(eventType, winId)
|
// : wxCommandEvent(eventType, winId)
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// SH_AddSampleEvent::~SH_AddSampleEvent()
|
// AddSampleEvent::~AddSampleEvent()
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// wxDEFINE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, SH_AddSampleEvent);
|
// wxDEFINE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, AddSampleEvent);
|
||||||
|
|
||||||
// SH_MediaEvent::SH_MediaEvent(wxEventType eventType, int winId)
|
// MediaEvent::MediaEvent(wxEventType eventType, int winId)
|
||||||
// : wxCommandEvent(eventType, winId)
|
// : wxCommandEvent(eventType, winId)
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// SH_MediaEvent::~SH_MediaEvent()
|
// MediaEvent::~MediaEvent()
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, MediaEvent);
|
||||||
|
|
||||||
SH_StatusBarStatusEvent::SH_StatusBarStatusEvent(wxEventType eventType, int winId)
|
StatusBarStatusEvent::StatusBarStatusEvent(wxEventType eventType, int winId)
|
||||||
: wxCommandEvent(eventType, winId)
|
: wxCommandEvent(eventType, winId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_StatusBarStatusEvent::~SH_StatusBarStatusEvent()
|
StatusBarStatusEvent::~StatusBarStatusEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, StatusBarStatusEvent);
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, StatusBarStatusEvent);
|
||||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
|
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, StatusBarStatusEvent);
|
||||||
|
|
||||||
SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
|
InfoBarMessageEvent::InfoBarMessageEvent(wxEventType eventType, int winId)
|
||||||
: wxCommandEvent(eventType, winId)
|
: wxCommandEvent(eventType, winId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_InfoBarMessageEvent::~SH_InfoBarMessageEvent()
|
InfoBarMessageEvent::~InfoBarMessageEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
|
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, InfoBarMessageEvent);
|
||||||
|
|
||||||
SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
|
TimerEvent::TimerEvent(wxEventType eventType, int winId)
|
||||||
: wxCommandEvent(eventType, winId)
|
: wxCommandEvent(eventType, winId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_TimerEvent::~SH_TimerEvent()
|
TimerEvent::~TimerEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
|
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, TimerEvent);
|
||||||
|
|
||||||
SH_CallFunctionEvent::SH_CallFunctionEvent(wxEventType eventType, int winId)
|
CallFunctionEvent::CallFunctionEvent(wxEventType eventType, int winId)
|
||||||
: wxCommandEvent(eventType, winId)
|
: wxCommandEvent(eventType, winId)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SH_CallFunctionEvent::~SH_CallFunctionEvent()
|
CallFunctionEvent::~CallFunctionEvent()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDEFINE_EVENT(SH_EVT_CALL_FUNC_PLAY, SH_CallFunctionEvent);
|
wxDEFINE_EVENT(SH_EVT_CALL_FUNC_PLAY, CallFunctionEvent);
|
||||||
|
|
||||||
|
WaveformUpdateEvent::WaveformUpdateEvent(wxEventType eventType, int winId)
|
||||||
|
: wxCommandEvent(eventType, winId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WaveformUpdateEvent::~WaveformUpdateEvent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDEFINE_EVENT(SH_EVT_UPDATE_WAVEFORM, WaveformUpdateEvent);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,14 @@
|
||||||
|
|
||||||
namespace SampleHive
|
namespace SampleHive
|
||||||
{
|
{
|
||||||
class SH_LoopPointsEvent : public wxCommandEvent
|
class LoopPointsEvent : public wxCommandEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SH_LoopPointsEvent(wxEventType eventType, int winId);
|
LoopPointsEvent(wxEventType eventType, int winId);
|
||||||
~SH_LoopPointsEvent();
|
~LoopPointsEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual wxEvent* Clone() const { return new SH_LoopPointsEvent(*this); }
|
virtual wxEvent* Clone() const { return new LoopPointsEvent(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
|
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
|
||||||
|
|
@ -44,16 +44,16 @@ namespace SampleHive
|
||||||
double m_LoopA, m_LoopB;
|
double m_LoopA, m_LoopB;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, SH_LoopPointsEvent);
|
wxDECLARE_EVENT(SH_EVT_LOOP_POINTS_UPDATED, LoopPointsEvent);
|
||||||
|
|
||||||
// class SH_AddSampleEvent : public wxCommandEvent
|
// class AddSampleEvent : public wxCommandEvent
|
||||||
// {
|
// {
|
||||||
// public:
|
// public:
|
||||||
// SH_AddSampleEvent(wxEventType eventType, int winId);
|
// AddSampleEvent(wxEventType eventType, int winId);
|
||||||
// ~SH_AddSampleEvent();
|
// ~AddSampleEvent();
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
// virtual wxEvent* Clone() const { return new SH_AddSampleEvent(*this); }
|
// virtual wxEvent* Clone() const { return new AddSampleEvent(*this); }
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
// wxArrayString GetArrayString() const { return m_Files; };
|
// wxArrayString GetArrayString() const { return m_Files; };
|
||||||
|
|
@ -63,16 +63,16 @@ namespace SampleHive
|
||||||
// wxArrayString m_Files;
|
// wxArrayString m_Files;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// wxDECLARE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, SH_AddSampleEvent);
|
// wxDECLARE_EVENT(SH_EVT_STATUS_ADD_SAMPLE, AddSampleEvent);
|
||||||
|
|
||||||
// class SH_MediaEvent : public wxCommandEvent
|
// class MediaEvent : public wxCommandEvent
|
||||||
// {
|
// {
|
||||||
// public:
|
// public:
|
||||||
// SH_MediaEvent(wxEventType eventType, int winId);
|
// MediaEvent(wxEventType eventType, int winId);
|
||||||
// ~SH_MediaEvent();
|
// ~MediaEvent();
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
// virtual wxEvent* Clone() const { return new SH_MediaEvent(*this); }
|
// virtual wxEvent* Clone() const { return new MediaEvent(*this); }
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
// void SetPath(const wxString& path) { m_Path = path; }
|
// void SetPath(const wxString& path) { m_Path = path; }
|
||||||
|
|
@ -82,16 +82,16 @@ namespace SampleHive
|
||||||
// wxString m_Path;
|
// wxString m_Path;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
|
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, MediaEvent);
|
||||||
|
|
||||||
class SH_StatusBarStatusEvent : public wxCommandEvent
|
class StatusBarStatusEvent : public wxCommandEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SH_StatusBarStatusEvent(wxEventType eventType, int winId);
|
StatusBarStatusEvent(wxEventType eventType, int winId);
|
||||||
~SH_StatusBarStatusEvent();
|
~StatusBarStatusEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual wxEvent* Clone() const { return new SH_StatusBarStatusEvent(*this); }
|
virtual wxEvent* Clone() const { return new StatusBarStatusEvent(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
|
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
|
||||||
|
|
@ -110,18 +110,18 @@ namespace SampleHive
|
||||||
int m_PushSection, m_PopSection, m_SetSection;
|
int m_PushSection, m_PopSection, m_SetSection;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, StatusBarStatusEvent);
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, StatusBarStatusEvent);
|
||||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
|
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, StatusBarStatusEvent);
|
||||||
|
|
||||||
class SH_InfoBarMessageEvent : public wxCommandEvent
|
class InfoBarMessageEvent : public wxCommandEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SH_InfoBarMessageEvent(wxEventType eventType, int winId);
|
InfoBarMessageEvent(wxEventType eventType, int winId);
|
||||||
~SH_InfoBarMessageEvent();
|
~InfoBarMessageEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
|
virtual wxEvent* Clone() const { return new InfoBarMessageEvent(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
||||||
|
|
@ -133,28 +133,28 @@ namespace SampleHive
|
||||||
int m_Mode;
|
int m_Mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
|
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, InfoBarMessageEvent);
|
||||||
|
|
||||||
class SH_TimerEvent : public wxCommandEvent
|
class TimerEvent : public wxCommandEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SH_TimerEvent(wxEventType eventType, int winId);
|
TimerEvent(wxEventType eventType, int winId);
|
||||||
~SH_TimerEvent();
|
~TimerEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
|
virtual wxEvent* Clone() const { return new TimerEvent(*this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
|
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, TimerEvent);
|
||||||
|
|
||||||
class SH_CallFunctionEvent : public wxCommandEvent
|
class CallFunctionEvent : public wxCommandEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SH_CallFunctionEvent(wxEventType eventType, int winId);
|
CallFunctionEvent(wxEventType eventType, int winId);
|
||||||
~SH_CallFunctionEvent();
|
~CallFunctionEvent();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual wxEvent* Clone() const { return new SH_CallFunctionEvent(*this); }
|
virtual wxEvent* Clone() const { return new CallFunctionEvent(*this); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxString GetSlection() { return m_Selection; }
|
wxString GetSlection() { return m_Selection; }
|
||||||
|
|
@ -164,5 +164,18 @@ namespace SampleHive
|
||||||
wxString m_Selection;
|
wxString m_Selection;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_EVENT(SH_EVT_CALL_FUNC_PLAY, SH_CallFunctionEvent);
|
wxDECLARE_EVENT(SH_EVT_CALL_FUNC_PLAY, CallFunctionEvent);
|
||||||
|
|
||||||
|
class WaveformUpdateEvent : public wxCommandEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WaveformUpdateEvent(wxEventType eventType, int winId);
|
||||||
|
~WaveformUpdateEvent();
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual wxEvent* Clone() const { return new WaveformUpdateEvent(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
wxDECLARE_EVENT(SH_EVT_UPDATE_WAVEFORM, WaveformUpdateEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,104 @@
|
||||||
|
#include "Utility/Signal.hpp"
|
||||||
|
#include "Utility/Log.hpp"
|
||||||
|
#include "Utility/SH_Event.hpp"
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
void Signal::SendInfoBarMessage(const wxString& msg, int mode, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::InfoBarMessageEvent 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 Signal::SendPushStatusBarStatus(const wxString& msg, int section, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::StatusBarStatusEvent 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 Signal::SendPopStatusBarStatus(int section, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::StatusBarStatusEvent 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 Signal::SendSetStatusBarStatus(const wxString& text, int section, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::StatusBarStatusEvent 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 Signal::SendCallFunctionPlay(const wxString& selection, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::CallFunctionEvent event(SampleHive::SH_EVT_CALL_FUNC_PLAY, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetSelection(selection);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal::SendTimerStopStatus(wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::TimerEvent event(SampleHive::SH_EVT_TIMER_STOP, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
if (isDialog)
|
||||||
|
window.GetParent()->GetEventHandler()->ProcessEvent(event);
|
||||||
|
else
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal::SendLoopPoints(std::pair<double, double> loopPoint, wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::LoopPointsEvent event(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, window.GetId());
|
||||||
|
event.SetEventObject(&window);
|
||||||
|
|
||||||
|
event.SetLoopPoints({loopPoint.first, loopPoint.second});
|
||||||
|
|
||||||
|
window.HandleWindowEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Signal::SendWaveformUpdateStatus(wxWindow& window, bool isDialog)
|
||||||
|
{
|
||||||
|
SampleHive::WaveformUpdateEvent 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,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wx/string.h>
|
||||||
|
#include <wx/window.h>
|
||||||
|
|
||||||
|
namespace SampleHive {
|
||||||
|
|
||||||
|
class Signal
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Signal();
|
||||||
|
~Signal();
|
||||||
|
|
||||||
|
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, 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 SendWaveformUpdateStatus(wxWindow& window, bool isDialog = false);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue