Skip to content

Commit 7e7fc07

Browse files
committed
Simplified code of GOButtonCreator
1 parent abf4bbf commit 7e7fc07

14 files changed

+182
-243
lines changed

src/grandorgue/GOAudioRecorder.cpp

+10-17
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,25 @@ enum {
2424
ID_AUDIO_RECORDER_RECORD_RENAME,
2525
};
2626

27-
const struct GOElementCreator::ButtonDefinitionEntry
28-
GOAudioRecorder::m_element_types[]
29-
= {
30-
{wxT("AudioRecorderRecord"), ID_AUDIO_RECORDER_RECORD, false, true, false},
31-
{wxT("AudioRecorderStop"), ID_AUDIO_RECORDER_STOP, false, true, false},
32-
{wxT("AudioRecorderRecordRename"),
33-
ID_AUDIO_RECORDER_RECORD_RENAME,
34-
false,
35-
true,
36-
false},
37-
{wxT(""), -1, false, false, false},
27+
const struct GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = {
28+
{wxT("AudioRecorderRecord"), ID_AUDIO_RECORDER_RECORD, false, true, false},
29+
{wxT("AudioRecorderStop"), ID_AUDIO_RECORDER_STOP, false, true, false},
30+
{wxT("AudioRecorderRecordRename"),
31+
ID_AUDIO_RECORDER_RECORD_RENAME,
32+
false,
33+
true,
34+
false},
35+
{wxT(""), -1, false, false, false},
3836
};
3937

40-
const struct GOElementCreator::ButtonDefinitionEntry *GOAudioRecorder::
41-
GetButtonDefinitionList() {
42-
return m_element_types;
43-
}
44-
4538
GOAudioRecorder::GOAudioRecorder(GOOrganController *organController)
4639
: m_OrganController(organController),
4740
m_recorder(NULL),
4841
m_RecordingTime(*organController),
4942
m_RecordSeconds(0),
5043
m_Filename(),
5144
m_DoRename(false) {
52-
CreateButtons(*m_OrganController);
45+
CreateButtons(*m_OrganController, BUTTON_DEFS);
5346
UpdateDisplay();
5447
}
5548

src/grandorgue/GOAudioRecorder.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright 2006 Milan Digital Audio LLC
3-
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
3+
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS)
44
* License GPL-2.0 or later
55
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
66
*/
@@ -27,9 +27,6 @@ class GOAudioRecorder : public GOElementCreator, private GOTimerCallback {
2727
wxString m_Filename;
2828
bool m_DoRename;
2929

30-
static const struct ButtonDefinitionEntry m_element_types[];
31-
const struct ButtonDefinitionEntry *GetButtonDefinitionList() override;
32-
3330
void ButtonStateChanged(int id, bool newState) override;
3431

3532
void UpdateDisplay();

src/grandorgue/GOMetronome.cpp

+10-17
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,17 @@ enum {
2929
ID_METRONOME_BEAT_M10,
3030
};
3131

32-
const struct GOElementCreator::ButtonDefinitionEntry
33-
GOMetronome::m_element_types[]
34-
= {
35-
{wxT("MetronomeOn"), ID_METRONOME_ON, false, false, false},
36-
{wxT("MetronomeMeasureP1"), ID_METRONOME_MEASURE_P1, false, true, false},
37-
{wxT("MetronomeMeasureM1"), ID_METRONOME_MEASURE_M1, false, true, false},
38-
{wxT("MetronomeBpmP1"), ID_METRONOME_BEAT_P1, false, true, false},
39-
{wxT("MetronomeBpmM1"), ID_METRONOME_BEAT_M1, false, true, false},
40-
{wxT("MetronomeBpmP10"), ID_METRONOME_BEAT_P10, false, true, false},
41-
{wxT("MetronomeBpmM10"), ID_METRONOME_BEAT_M10, false, true, false},
42-
{wxT(""), -1, false, false, false},
32+
const struct GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = {
33+
{wxT("MetronomeOn"), ID_METRONOME_ON, false, false, false},
34+
{wxT("MetronomeMeasureP1"), ID_METRONOME_MEASURE_P1, false, true, false},
35+
{wxT("MetronomeMeasureM1"), ID_METRONOME_MEASURE_M1, false, true, false},
36+
{wxT("MetronomeBpmP1"), ID_METRONOME_BEAT_P1, false, true, false},
37+
{wxT("MetronomeBpmM1"), ID_METRONOME_BEAT_M1, false, true, false},
38+
{wxT("MetronomeBpmP10"), ID_METRONOME_BEAT_P10, false, true, false},
39+
{wxT("MetronomeBpmM10"), ID_METRONOME_BEAT_M10, false, true, false},
40+
{wxT(""), -1, false, false, false},
4341
};
4442

45-
const struct GOElementCreator::ButtonDefinitionEntry *GOMetronome::
46-
GetButtonDefinitionList() {
47-
return m_element_types;
48-
}
49-
5043
GOMetronome::GOMetronome(GOOrganController *organController)
5144
: m_OrganController(organController),
5245
m_BPM(80),
@@ -57,7 +50,7 @@ GOMetronome::GOMetronome(GOOrganController *organController)
5750
m_MeasureDisplay(*organController),
5851
m_rank(NULL),
5952
m_StopID(0) {
60-
CreateButtons(*m_OrganController);
53+
CreateButtons(*m_OrganController, BUTTON_DEFS);
6154

6255
m_buttons[ID_METRONOME_ON]->SetInitialMidiIndex(25);
6356
m_buttons[ID_METRONOME_MEASURE_P1]->SetInitialMidiIndex(28);

src/grandorgue/GOMetronome.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright 2006 Milan Digital Audio LLC
3-
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
3+
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS)
44
* License GPL-2.0 or later
55
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
66
*/
@@ -34,10 +34,6 @@ class GOMetronome : private GOTimerCallback,
3434
GORank *m_rank;
3535
unsigned m_StopID;
3636

37-
static const struct GOElementCreator::ButtonDefinitionEntry m_element_types[];
38-
const struct GOElementCreator::ButtonDefinitionEntry *
39-
GetButtonDefinitionList() override;
40-
4137
void HandleTimer() override;
4238

4339
void ButtonStateChanged(int id, bool newState) override;

src/grandorgue/combinations/GODivisionalSetter.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ enum {
4343
ID_FIRST = 0
4444
};
4545

46-
const struct GOElementCreator::ButtonDefinitionEntry *GODivisionalSetter::
47-
GetButtonDefinitionList() {
48-
return m_ButtonDefinitions;
49-
}
50-
5146
// fills a button definition
5247
void fill_button_definition(
5348
wxString name,
@@ -115,7 +110,7 @@ GODivisionalSetter::GODivisionalSetter(
115110

116111
// create button conrols for all buttons. It calls the GetButtonDefinitionList
117112
// callback
118-
CreateButtons(*organController);
113+
CreateButtons(*organController, m_ButtonDefinitions);
119114
organController->RegisterCombinationButtonSet(this);
120115
for (unsigned manualN = 0; manualN < m_NManuals; manualN++) {
121116
m_manualBanks.push_back(0);

src/grandorgue/combinations/GODivisionalSetter.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright 2006 Milan Digital Audio LLC
3-
* Copyright 2009-2024 GrandOrgue contributors (see AUTHORS)
3+
* Copyright 2009-2025 GrandOrgue contributors (see AUTHORS)
44
* License GPL-2.0 or later
55
* (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html).
66
*/
@@ -84,11 +84,6 @@ class GODivisionalSetter : public GOElementCreator,
8484
void UpdateAllButtonsLight(
8585
GOButtonControl *buttonToLight, int manualIndexOnlyFor) override;
8686

87-
protected:
88-
// called from GOElementCreator::CreateButtons()
89-
const struct GOElementCreator::ButtonDefinitionEntry *
90-
GetButtonDefinitionList() override;
91-
9287
// called on pressing any button. id is mapped to manualN and divisionalN
9388
void ButtonStateChanged(int id, bool newState) override;
9489

0 commit comments

Comments
 (0)