Add new custom events.

This commit is contained in:
apoorv569 2021-11-08 13:22:03 +05:30
parent 77fb65377b
commit f40f514912
10 changed files with 82 additions and 55 deletions

View File

@ -19,7 +19,6 @@
*/
#include "App.hpp"
#include "SampleHiveConfig.hpp"
#include "Utility/Paths.hpp"
#include "Utility/Log.hpp"

View File

@ -319,7 +319,7 @@ void TagEditor::SendInfoBarMessage(const wxString& msg, int mode)
{
SH_LOG_INFO("{} called..", __FUNCTION__);
SampleHive::SH_InfoBarMessageEvent event(SampleHive::SH_EVT_INFOBAR_MESSAGE_UPDATED, this->GetId());
SampleHive::SH_InfoBarMessageEvent event(SampleHive::SH_EVT_INFOBAR_MESSAGE_SHOW, this->GetId());
event.SetEventObject(this);
event.SetInfoBarMessage({ msg, mode });

View File

@ -459,8 +459,11 @@ MainFrame::MainFrame()
Bind(wxEVT_BUTTON, &MainFrame::OnClickRemoveHive, this, BC_HiveRemove);
Bind(SampleHive::SH_EVT_LOOP_POINTS_UPDATED, &MainFrame::OnRecieveLoopPoints, this);
Bind(SampleHive::SH_EVT_STATUSBAR_MESSAGE_UPDATED, &MainFrame::OnRecieveStatusBarStatus, this);
Bind(SampleHive::SH_EVT_INFOBAR_MESSAGE_UPDATED, &MainFrame::OnRecieveInfoBarStatus, this);
Bind(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, &MainFrame::OnRecievePushStatusBarStatus, this);
Bind(SampleHive::SH_EVT_STATUSBAR_STATUS_POP, &MainFrame::OnRecievePopStatusBarStatus, this);
Bind(SampleHive::SH_EVT_STATUSBAR_STATUS_SET, &MainFrame::OnRecieveSetStatusBarStatus, this);
Bind(SampleHive::SH_EVT_INFOBAR_MESSAGE_SHOW, &MainFrame::OnRecieveInfoBarStatus, this);
Bind(SampleHive::SH_EVT_TIMER_STOP, &MainFrame::OnRecieveTimerStopStatus, this);
// Adding widgets to their sizers
m_MainSizer->Add(m_MainPanel, 1, wxALL | wxEXPAND, 0);
@ -3012,21 +3015,33 @@ void MainFrame::OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event)
int loopB_min = static_cast<int>((m_LoopB / 60000).GetValue());
int loopB_sec = static_cast<int>(((m_LoopB % 60000) / 1000).GetValue());
// SH_LOG_INFO(wxString::Format(_("Loop points set: A: %2i:%02i, B: %2i:%02i"),
// loopA_min, loopA_sec, loopB_min, loopB_sec));
SH_LOG_INFO(wxString::Format(_("Loop points set: A: %2i:%02i, B: %2i:%02i"),
loopA_min, loopA_sec, loopB_min, loopB_sec));
m_LoopABButton->SetValue(true);
bLoopPointsSet = true;
}
void MainFrame::OnRecieveStatusBarStatus(SampleHive::SH_StatusBarMessageEvent& event)
void MainFrame::OnRecievePushStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event)
{
std::pair<wxString, int> status = event.GetMessageAndSection();
std::pair<wxString, int> status = event.GetPushMessageAndSection();
m_StatusBar->PushStatusText(status.first, status.second);
}
void MainFrame::OnRecievePopStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event)
{
m_StatusBar->PopStatusText(event.GetPopMessageSection());
}
void MainFrame::OnRecieveSetStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event)
{
std::pair<wxString, int> status = event.GetStatusTextAndSection();
m_StatusBar->SetStatusText(status.first, status.second);
}
void MainFrame::OnRecieveInfoBarStatus(SampleHive::SH_InfoBarMessageEvent& event)
{
SH_LOG_INFO("{} called..", __FUNCTION__);
@ -3038,6 +3053,12 @@ void MainFrame::OnRecieveInfoBarStatus(SampleHive::SH_InfoBarMessageEvent& event
SH_LOG_INFO("{} event processed", __FUNCTION__);
}
void MainFrame::OnRecieveTimerStopStatus(SampleHive::SH_TimerEvent& event)
{
if (m_Timer->IsRunning())
m_Timer->Stop();
}
void MainFrame::ClearLoopPoints()
{
m_LoopA = 0;

View File

@ -273,8 +273,11 @@ class MainFrame : public wxFrame
// Recieve custom events
// -------------------------------------------------------------------
void OnRecieveLoopPoints(SampleHive::SH_LoopPointsEvent& event);
void OnRecieveStatusBarStatus(SampleHive::SH_StatusBarMessageEvent& event);
void OnRecievePushStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
void OnRecievePopStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
void OnRecieveSetStatusBarStatus(SampleHive::SH_StatusBarStatusEvent& event);
void OnRecieveInfoBarStatus(SampleHive::SH_InfoBarMessageEvent& event);
void OnRecieveTimerStopStatus(SampleHive::SH_TimerEvent& event);
// -------------------------------------------------------------------
void LoadDatabase();

View File

@ -427,7 +427,7 @@ void WaveformViewer::OnMouseLeftButtonUp(wxMouseEvent& event)
SetCursor(wxCURSOR_ARROW);
m_MediaCtrl.Seek(seek_to, wxFromStart);
SendStatusBarStatus(wxString::Format(_("Now playing: %s"), selected), 1);
SendPushStatusBarStatus(wxString::Format(_("Now playing: %s"), selected), 1);
m_MediaCtrl.Play();
}
}
@ -474,12 +474,12 @@ void WaveformViewer::SendLoopPoints()
SH_LOG_DEBUG("{} processed event, sending loop points..", __FUNCTION__);
}
void WaveformViewer::SendStatusBarStatus(const wxString& msg, int section)
void WaveformViewer::SendPushStatusBarStatus(const wxString& msg, int section)
{
SampleHive::SH_StatusBarMessageEvent event(SampleHive::SH_EVT_STATUSBAR_MESSAGE_UPDATED, this->GetId());
SampleHive::SH_StatusBarStatusEvent event(SampleHive::SH_EVT_STATUSBAR_STATUS_PUSH, this->GetId());
event.SetEventObject(this);
event.SetMessageAndSection({ msg, section });
event.SetPushMessageAndSection({ msg, section });
HandleWindowEvent(event);
}

View File

@ -87,7 +87,7 @@ class WaveformViewer : public wxPanel
// -------------------------------------------------------------------
// Send custom events
void SendLoopPoints();
void SendStatusBarStatus(const wxString& msg, int section);
void SendPushStatusBarStatus(const wxString& msg, int section);
public:
// -------------------------------------------------------------------

View File

@ -1,5 +1,7 @@
#pragma once
#include "SampleHiveConfig.hpp"
// Path to all the assets
#define ICON_HIVE_16px SAMPLEHIVE_DATADIR "/icons/icon-hive_16x16.png"
#define ICON_HIVE_24px SAMPLEHIVE_DATADIR "/icons/icon-hive_24x24.png"

View File

@ -61,18 +61,20 @@ namespace SampleHive
// wxDEFINE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
SH_StatusBarMessageEvent::SH_StatusBarMessageEvent(wxEventType eventType, int winId)
SH_StatusBarStatusEvent::SH_StatusBarStatusEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
}
SH_StatusBarMessageEvent::~SH_StatusBarMessageEvent()
SH_StatusBarStatusEvent::~SH_StatusBarStatusEvent()
{
}
wxDEFINE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_StatusBarMessageEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
SH_InfoBarMessageEvent::SH_InfoBarMessageEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
@ -85,18 +87,18 @@ namespace SampleHive
}
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
wxDEFINE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
// SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
// : wxCommandEvent(eventType, winId)
// {
SH_TimerEvent::SH_TimerEvent(wxEventType eventType, int winId)
: wxCommandEvent(eventType, winId)
{
// }
}
// SH_TimerEvent::~SH_TimerEvent()
// {
SH_TimerEvent::~SH_TimerEvent()
{
// }
}
// wxDEFINE_EVENT(SH_EVT_TIMER_STATUS_UPDATED, SH_TimerEvent);
wxDEFINE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
}

View File

@ -84,26 +84,35 @@ namespace SampleHive
// wxDECLARE_EVENT(SH_EVT_MEDIA_STATUS_UPDATED, SH_MediaEvent);
class SH_StatusBarMessageEvent : public wxCommandEvent
class SH_StatusBarStatusEvent : public wxCommandEvent
{
public:
SH_StatusBarMessageEvent(wxEventType eventType, int winId);
~SH_StatusBarMessageEvent();
SH_StatusBarStatusEvent(wxEventType eventType, int winId);
~SH_StatusBarStatusEvent();
public:
virtual wxEvent* Clone() const { return new SH_StatusBarMessageEvent(*this); }
virtual wxEvent* Clone() const { return new SH_StatusBarStatusEvent(*this); }
public:
std::pair<wxString, int> GetMessageAndSection() const { return { m_Msg, m_Section }; }
void SetMessageAndSection(std::pair<const wxString&, int> status)
{ m_Msg = status.first; m_Section = status.second; }
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
void SetPushMessageAndSection(std::pair<const wxString&, int> status)
{ m_Msg = status.first; m_PushSection = status.second; }
std::pair<wxString, int> GetStatusTextAndSection() const { return { m_Text, m_SetSection }; }
void SetStatusTextAndSection(std::pair<const wxString&, int> status)
{ m_Text = status.first, m_SetSection = status.second; }
int GetPopMessageSection() const { return m_PopSection; }
void SetPopMessageSection(int section) { m_PopSection = section; }
private:
wxString m_Msg;
int m_Section;
wxString m_Msg, m_Text;
int m_PushSection, m_PopSection, m_SetSection;
};
wxDECLARE_EVENT(SH_EVT_STATUSBAR_MESSAGE_UPDATED, SH_StatusBarMessageEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
class SH_InfoBarMessageEvent : public wxCommandEvent
{
@ -124,25 +133,17 @@ namespace SampleHive
int m_Mode;
};
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_UPDATED, SH_InfoBarMessageEvent);
wxDECLARE_EVENT(SH_EVT_INFOBAR_MESSAGE_SHOW, SH_InfoBarMessageEvent);
// class SH_TimerEvent : public wxCommandEvent
// {
// public:
// SH_TimerEvent(wxEventType eventType, int winId);
// ~SH_TimerEvent();
class SH_TimerEvent : public wxCommandEvent
{
public:
SH_TimerEvent(wxEventType eventType, int winId);
~SH_TimerEvent();
// public:
// virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
public:
virtual wxEvent* Clone() const { return new SH_TimerEvent(*this); }
};
// public:
// std::pair<int, bool> GetSecondsAndMode() const { return { m_Seconds, m_Mode }; }
// void SetSecondsAndMode(std::pair<int, bool> timerStatus) { m_Seconds = timerStatus.first; m_Mode = timerStatus.second; }
// private:
// int m_Seconds;
// bool m_Mode;
// };
// wxDECLARE_EVENT(SH_EVT_TIMER_STATUS_UPDATED, SH_TimerEvent);
wxDECLARE_EVENT(SH_EVT_TIMER_STOP, SH_TimerEvent);
}

View File

@ -39,7 +39,6 @@ class Sample
{
public:
Sample();
Sample(int favorite, const std::string& filename, const std::string& fileExtension,
const std::string& samplePack, const std::string& type, int channels, int length,
int sampleRate, int bitrate, const std::string& path, int trashed);