From 7ba7021d7b1202d6bf5bc74c7b67323314670b14 Mon Sep 17 00:00:00 2001 From: Oleg Samarin Date: Wed, 15 Jan 2025 22:28:03 +0300 Subject: [PATCH] Using GOMisiSendingObject in GOLabelControl --- src/grandorgue/control/GOLabelControl.cpp | 41 ++++++------------- src/grandorgue/control/GOLabelControl.h | 11 +---- .../midi/objects/GOMidiSendingObject.h | 1 + 3 files changed, 15 insertions(+), 38 deletions(-) diff --git a/src/grandorgue/control/GOLabelControl.cpp b/src/grandorgue/control/GOLabelControl.cpp index 63750b9e8..1d44e9b36 100644 --- a/src/grandorgue/control/GOLabelControl.cpp +++ b/src/grandorgue/control/GOLabelControl.cpp @@ -9,53 +9,36 @@ #include +#include "config/GOConfig.h" + #include "GODocument.h" #include "GOOrganController.h" -#include "config/GOConfig.h" static const wxString WX_MIDI_TYPE_CODE = wxT("Label"); static const wxString WX_MIDI_TYPE_NAME = _("Label"); GOLabelControl::GOLabelControl(GOOrganController *organController) - : GOMidiObject( - *organController, - WX_MIDI_TYPE_CODE, - WX_MIDI_TYPE_NAME, - &m_sender, - nullptr, - nullptr, - nullptr), - m_OrganController(organController), - m_sender(*organController, MIDI_SEND_LABEL) {} - -void GOLabelControl::LoadMidiObject( - GOConfigReader &cfg, const wxString &group, GOMidiMap &midiMap) { - GOMidiObject::LoadMidiObject(cfg, group, midiMap); - m_sender.Load(cfg, group, midiMap); -} - -void GOLabelControl::SaveMidiObject( - GOConfigWriter &cfg, const wxString &group, GOMidiMap &midiMap) { - GOMidiObject::SaveMidiObject(cfg, group, midiMap); - m_sender.Save(cfg, group, midiMap); -} + : GOMidiSendingObject( + *organController, WX_MIDI_TYPE_CODE, WX_MIDI_TYPE_NAME, MIDI_SEND_LABEL), + m_OrganController(organController) {} const wxString &GOLabelControl::GetContent() { return m_Content; } void GOLabelControl::SetContent(wxString name) { m_Content = name; - m_sender.SetLabel(m_Content); + SendMidiValue(m_Content); m_OrganController->SendControlChanged(this); } void GOLabelControl::AbortPlayback() { - m_sender.SetLabel(wxEmptyString); - m_sender.SetName(wxEmptyString); + SendMidiValue(wxEmptyString); + GOMidiSendingObject::AbortPlayback(); } -void GOLabelControl::PreparePlayback() { m_sender.SetName(GetName()); } - -void GOLabelControl::PrepareRecording() { m_sender.SetLabel(m_Content); } +void GOLabelControl::PrepareRecording() { + GOMidiSendingObject::PrepareRecording(); + SendMidiValue(m_Content); +} wxString GOLabelControl::GetElementStatus() { return m_Content; } diff --git a/src/grandorgue/control/GOLabelControl.h b/src/grandorgue/control/GOLabelControl.h index f7a15f01c..7aa4f5015 100644 --- a/src/grandorgue/control/GOLabelControl.h +++ b/src/grandorgue/control/GOLabelControl.h @@ -11,7 +11,7 @@ #include #include "midi/GOMidiSender.h" -#include "midi/objects/GOMidiObject.h" +#include "midi/objects/GOMidiSendingObject.h" #include "sound/GOSoundStateHandler.h" #include "GOControl.h" @@ -21,19 +21,12 @@ class GOConfigReader; class GOConfigWriter; class GOOrganController; -class GOLabelControl : public GOMidiObject, public GOControl { +class GOLabelControl : public GOMidiSendingObject, public GOControl { protected: wxString m_Content; GOOrganController *m_OrganController; - GOMidiSender m_sender; - - void LoadMidiObject( - GOConfigReader &cfg, const wxString &group, GOMidiMap &midiMap) override; - void SaveMidiObject( - GOConfigWriter &cfg, const wxString &group, GOMidiMap &midiMap) override; void AbortPlayback() override; - void PreparePlayback() override; void PrepareRecording() override; public: diff --git a/src/grandorgue/midi/objects/GOMidiSendingObject.h b/src/grandorgue/midi/objects/GOMidiSendingObject.h index 6b7e95429..0189bdbae 100644 --- a/src/grandorgue/midi/objects/GOMidiSendingObject.h +++ b/src/grandorgue/midi/objects/GOMidiSendingObject.h @@ -37,6 +37,7 @@ class GOMidiSendingObject : public GOMidiObject { void SendMidiValue(bool value) { m_sender.SetDisplay(value); } void SendMidiValue(int value) { m_sender.SetValue(value); } + void SendMidiValue(const wxString &value) { m_sender.SetLabel(value); } void SendMidiKey(unsigned key, unsigned value) { m_sender.SetKey(key, value); }