Skip to content

Commit

Permalink
Using GOMisiSendingObject in GOLabelControl
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg68 committed Jan 15, 2025
1 parent c255941 commit 7ba7021
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 38 deletions.
41 changes: 12 additions & 29 deletions src/grandorgue/control/GOLabelControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,36 @@

#include <wx/intl.h>

#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; }

Expand Down
11 changes: 2 additions & 9 deletions src/grandorgue/control/GOLabelControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <wx/string.h>

#include "midi/GOMidiSender.h"
#include "midi/objects/GOMidiObject.h"
#include "midi/objects/GOMidiSendingObject.h"
#include "sound/GOSoundStateHandler.h"

#include "GOControl.h"
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/grandorgue/midi/objects/GOMidiSendingObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 7ba7021

Please sign in to comment.