Skip to content

Commit

Permalink
Simplified code of GOButtonCreator
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg68 committed Feb 27, 2025
1 parent abf4bbf commit 7e7fc07
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 243 deletions.
27 changes: 10 additions & 17 deletions src/grandorgue/GOAudioRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,25 @@ enum {
ID_AUDIO_RECORDER_RECORD_RENAME,
};

const struct GOElementCreator::ButtonDefinitionEntry
GOAudioRecorder::m_element_types[]
= {
{wxT("AudioRecorderRecord"), ID_AUDIO_RECORDER_RECORD, false, true, false},
{wxT("AudioRecorderStop"), ID_AUDIO_RECORDER_STOP, false, true, false},
{wxT("AudioRecorderRecordRename"),
ID_AUDIO_RECORDER_RECORD_RENAME,
false,
true,
false},
{wxT(""), -1, false, false, false},
const struct GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = {
{wxT("AudioRecorderRecord"), ID_AUDIO_RECORDER_RECORD, false, true, false},
{wxT("AudioRecorderStop"), ID_AUDIO_RECORDER_STOP, false, true, false},
{wxT("AudioRecorderRecordRename"),
ID_AUDIO_RECORDER_RECORD_RENAME,
false,
true,
false},
{wxT(""), -1, false, false, false},
};

const struct GOElementCreator::ButtonDefinitionEntry *GOAudioRecorder::
GetButtonDefinitionList() {
return m_element_types;
}

GOAudioRecorder::GOAudioRecorder(GOOrganController *organController)
: m_OrganController(organController),
m_recorder(NULL),
m_RecordingTime(*organController),
m_RecordSeconds(0),
m_Filename(),
m_DoRename(false) {
CreateButtons(*m_OrganController);
CreateButtons(*m_OrganController, BUTTON_DEFS);
UpdateDisplay();
}

Expand Down
5 changes: 1 addition & 4 deletions src/grandorgue/GOAudioRecorder.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/
Expand All @@ -27,9 +27,6 @@ class GOAudioRecorder : public GOElementCreator, private GOTimerCallback {
wxString m_Filename;
bool m_DoRename;

static const struct ButtonDefinitionEntry m_element_types[];
const struct ButtonDefinitionEntry *GetButtonDefinitionList() override;

void ButtonStateChanged(int id, bool newState) override;

void UpdateDisplay();
Expand Down
27 changes: 10 additions & 17 deletions src/grandorgue/GOMetronome.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,17 @@ enum {
ID_METRONOME_BEAT_M10,
};

const struct GOElementCreator::ButtonDefinitionEntry
GOMetronome::m_element_types[]
= {
{wxT("MetronomeOn"), ID_METRONOME_ON, false, false, false},
{wxT("MetronomeMeasureP1"), ID_METRONOME_MEASURE_P1, false, true, false},
{wxT("MetronomeMeasureM1"), ID_METRONOME_MEASURE_M1, false, true, false},
{wxT("MetronomeBpmP1"), ID_METRONOME_BEAT_P1, false, true, false},
{wxT("MetronomeBpmM1"), ID_METRONOME_BEAT_M1, false, true, false},
{wxT("MetronomeBpmP10"), ID_METRONOME_BEAT_P10, false, true, false},
{wxT("MetronomeBpmM10"), ID_METRONOME_BEAT_M10, false, true, false},
{wxT(""), -1, false, false, false},
const struct GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = {
{wxT("MetronomeOn"), ID_METRONOME_ON, false, false, false},
{wxT("MetronomeMeasureP1"), ID_METRONOME_MEASURE_P1, false, true, false},
{wxT("MetronomeMeasureM1"), ID_METRONOME_MEASURE_M1, false, true, false},
{wxT("MetronomeBpmP1"), ID_METRONOME_BEAT_P1, false, true, false},
{wxT("MetronomeBpmM1"), ID_METRONOME_BEAT_M1, false, true, false},
{wxT("MetronomeBpmP10"), ID_METRONOME_BEAT_P10, false, true, false},
{wxT("MetronomeBpmM10"), ID_METRONOME_BEAT_M10, false, true, false},
{wxT(""), -1, false, false, false},
};

const struct GOElementCreator::ButtonDefinitionEntry *GOMetronome::
GetButtonDefinitionList() {
return m_element_types;
}

GOMetronome::GOMetronome(GOOrganController *organController)
: m_OrganController(organController),
m_BPM(80),
Expand All @@ -57,7 +50,7 @@ GOMetronome::GOMetronome(GOOrganController *organController)
m_MeasureDisplay(*organController),
m_rank(NULL),
m_StopID(0) {
CreateButtons(*m_OrganController);
CreateButtons(*m_OrganController, BUTTON_DEFS);

m_buttons[ID_METRONOME_ON]->SetInitialMidiIndex(25);
m_buttons[ID_METRONOME_MEASURE_P1]->SetInitialMidiIndex(28);
Expand Down
6 changes: 1 addition & 5 deletions src/grandorgue/GOMetronome.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/
Expand Down Expand Up @@ -34,10 +34,6 @@ class GOMetronome : private GOTimerCallback,
GORank *m_rank;
unsigned m_StopID;

static const struct GOElementCreator::ButtonDefinitionEntry m_element_types[];
const struct GOElementCreator::ButtonDefinitionEntry *
GetButtonDefinitionList() override;

void HandleTimer() override;

void ButtonStateChanged(int id, bool newState) override;
Expand Down
7 changes: 1 addition & 6 deletions src/grandorgue/combinations/GODivisionalSetter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ enum {
ID_FIRST = 0
};

const struct GOElementCreator::ButtonDefinitionEntry *GODivisionalSetter::
GetButtonDefinitionList() {
return m_ButtonDefinitions;
}

// fills a button definition
void fill_button_definition(
wxString name,
Expand Down Expand Up @@ -115,7 +110,7 @@ GODivisionalSetter::GODivisionalSetter(

// create button conrols for all buttons. It calls the GetButtonDefinitionList
// callback
CreateButtons(*organController);
CreateButtons(*organController, m_ButtonDefinitions);
organController->RegisterCombinationButtonSet(this);
for (unsigned manualN = 0; manualN < m_NManuals; manualN++) {
m_manualBanks.push_back(0);
Expand Down
7 changes: 1 addition & 6 deletions src/grandorgue/combinations/GODivisionalSetter.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2006 Milan Digital Audio LLC
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS)
* License GPL-2.0 or later
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
*/
Expand Down Expand Up @@ -84,11 +84,6 @@ class GODivisionalSetter : public GOElementCreator,
void UpdateAllButtonsLight(
GOButtonControl *buttonToLight, int manualIndexOnlyFor) override;

protected:
// called from GOElementCreator::CreateButtons()
const struct GOElementCreator::ButtonDefinitionEntry *
GetButtonDefinitionList() override;

// called on pressing any button. id is mapped to manualN and divisionalN
void ButtonStateChanged(int id, bool newState) override;

Expand Down
Loading

0 comments on commit 7e7fc07

Please sign in to comment.