mirror of
https://gitlab.com/samplehive/sample-hive.git
synced 2026-10-23 13:15:00 +02:00
More encapsulation and add new class Signal for handling custom events.
This commit is contained in:
+36
-23
@@ -22,96 +22,109 @@
|
||||
|
||||
namespace SampleHive
|
||||
{
|
||||
SH_LoopPointsEvent::SH_LoopPointsEvent(wxEventType eventType, int winId)
|
||||
LoopPointsEvent::LoopPointsEvent(wxEventType eventType, int 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)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// 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)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SH_StatusBarStatusEvent::~SH_StatusBarStatusEvent()
|
||||
StatusBarStatusEvent::~StatusBarStatusEvent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
|
||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
|
||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
|
||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, StatusBarStatusEvent);
|
||||
wxDEFINE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, 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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
+50
-37
@@ -26,14 +26,14 @@
|
||||
|
||||
namespace SampleHive
|
||||
{
|
||||
class SH_LoopPointsEvent : public wxCommandEvent
|
||||
class LoopPointsEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
SH_LoopPointsEvent(wxEventType eventType, int winId);
|
||||
~SH_LoopPointsEvent();
|
||||
LoopPointsEvent(wxEventType eventType, int winId);
|
||||
~LoopPointsEvent();
|
||||
|
||||
public:
|
||||
virtual wxEvent* Clone() const { return new SH_LoopPointsEvent(*this); }
|
||||
virtual wxEvent* Clone() const { return new LoopPointsEvent(*this); }
|
||||
|
||||
public:
|
||||
std::pair<double, double> GetLoopPoints() const { return { m_LoopA, m_LoopB }; };
|
||||
@@ -44,16 +44,16 @@ namespace SampleHive
|
||||
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:
|
||||
// SH_AddSampleEvent(wxEventType eventType, int winId);
|
||||
// ~SH_AddSampleEvent();
|
||||
// AddSampleEvent(wxEventType eventType, int winId);
|
||||
// ~AddSampleEvent();
|
||||
|
||||
// public:
|
||||
// virtual wxEvent* Clone() const { return new SH_AddSampleEvent(*this); }
|
||||
// virtual wxEvent* Clone() const { return new AddSampleEvent(*this); }
|
||||
|
||||
// public:
|
||||
// wxArrayString GetArrayString() const { return m_Files; };
|
||||
@@ -63,16 +63,16 @@ namespace SampleHive
|
||||
// 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:
|
||||
// SH_MediaEvent(wxEventType eventType, int winId);
|
||||
// ~SH_MediaEvent();
|
||||
// MediaEvent(wxEventType eventType, int winId);
|
||||
// ~MediaEvent();
|
||||
|
||||
// public:
|
||||
// virtual wxEvent* Clone() const { return new SH_MediaEvent(*this); }
|
||||
// virtual wxEvent* Clone() const { return new MediaEvent(*this); }
|
||||
|
||||
// public:
|
||||
// void SetPath(const wxString& path) { m_Path = path; }
|
||||
@@ -82,16 +82,16 @@ namespace SampleHive
|
||||
// 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:
|
||||
SH_StatusBarStatusEvent(wxEventType eventType, int winId);
|
||||
~SH_StatusBarStatusEvent();
|
||||
StatusBarStatusEvent(wxEventType eventType, int winId);
|
||||
~StatusBarStatusEvent();
|
||||
|
||||
public:
|
||||
virtual wxEvent* Clone() const { return new SH_StatusBarStatusEvent(*this); }
|
||||
virtual wxEvent* Clone() const { return new StatusBarStatusEvent(*this); }
|
||||
|
||||
public:
|
||||
std::pair<wxString, int> GetPushMessageAndSection() const { return { m_Msg, m_PushSection }; }
|
||||
@@ -110,18 +110,18 @@ namespace SampleHive
|
||||
int m_PushSection, m_PopSection, m_SetSection;
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, SH_StatusBarStatusEvent);
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, SH_StatusBarStatusEvent);
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, SH_StatusBarStatusEvent);
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_PUSH, StatusBarStatusEvent);
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_POP, StatusBarStatusEvent);
|
||||
wxDECLARE_EVENT(SH_EVT_STATUSBAR_STATUS_SET, StatusBarStatusEvent);
|
||||
|
||||
class SH_InfoBarMessageEvent : public wxCommandEvent
|
||||
class InfoBarMessageEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
SH_InfoBarMessageEvent(wxEventType eventType, int winId);
|
||||
~SH_InfoBarMessageEvent();
|
||||
InfoBarMessageEvent(wxEventType eventType, int winId);
|
||||
~InfoBarMessageEvent();
|
||||
|
||||
public:
|
||||
virtual wxEvent* Clone() const { return new SH_InfoBarMessageEvent(*this); }
|
||||
virtual wxEvent* Clone() const { return new InfoBarMessageEvent(*this); }
|
||||
|
||||
public:
|
||||
std::pair<wxString, int> GetInfoBarMessage() const { return { m_Msg, m_Mode }; }
|
||||
@@ -133,28 +133,28 @@ namespace SampleHive
|
||||
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:
|
||||
SH_TimerEvent(wxEventType eventType, int winId);
|
||||
~SH_TimerEvent();
|
||||
TimerEvent(wxEventType eventType, int winId);
|
||||
~TimerEvent();
|
||||
|
||||
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:
|
||||
SH_CallFunctionEvent(wxEventType eventType, int winId);
|
||||
~SH_CallFunctionEvent();
|
||||
CallFunctionEvent(wxEventType eventType, int winId);
|
||||
~CallFunctionEvent();
|
||||
|
||||
public:
|
||||
virtual wxEvent* Clone() const { return new SH_CallFunctionEvent(*this); }
|
||||
virtual wxEvent* Clone() const { return new CallFunctionEvent(*this); }
|
||||
|
||||
public:
|
||||
wxString GetSlection() { return m_Selection; }
|
||||
@@ -164,5 +164,18 @@ namespace SampleHive
|
||||
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);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user