From 219b23c325667e9530d9c0105a27e886112f9688 Mon Sep 17 00:00:00 2001 From: Oleg Samarin Date: Thu, 27 Feb 2025 20:09:26 +0300 Subject: [PATCH] Simplified code of GOButtonCreator --- src/grandorgue/GOAudioRecorder.cpp | 27 +- src/grandorgue/GOAudioRecorder.h | 5 +- src/grandorgue/GOMetronome.cpp | 27 +- src/grandorgue/GOMetronome.h | 6 +- .../combinations/GODivisionalSetter.cpp | 7 +- .../combinations/GODivisionalSetter.h | 7 +- src/grandorgue/combinations/GOSetter.cpp | 238 +++++++++--------- src/grandorgue/combinations/GOSetter.h | 3 - src/grandorgue/control/GOElementCreator.cpp | 39 +-- src/grandorgue/control/GOElementCreator.h | 8 +- src/grandorgue/midi/GOMidiPlayer.cpp | 19 +- src/grandorgue/midi/GOMidiPlayer.h | 6 +- src/grandorgue/midi/GOMidiRecorder.cpp | 27 +- src/grandorgue/midi/GOMidiRecorder.h | 6 +- 14 files changed, 182 insertions(+), 243 deletions(-) diff --git a/src/grandorgue/GOAudioRecorder.cpp b/src/grandorgue/GOAudioRecorder.cpp index 9f032289c..fe3e67fbd 100644 --- a/src/grandorgue/GOAudioRecorder.cpp +++ b/src/grandorgue/GOAudioRecorder.cpp @@ -24,24 +24,17 @@ 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), @@ -49,7 +42,7 @@ GOAudioRecorder::GOAudioRecorder(GOOrganController *organController) m_RecordSeconds(0), m_Filename(), m_DoRename(false) { - CreateButtons(*m_OrganController); + CreateButtons(*m_OrganController, BUTTON_DEFS); UpdateDisplay(); } diff --git a/src/grandorgue/GOAudioRecorder.h b/src/grandorgue/GOAudioRecorder.h index c74824fdd..10c4597bc 100644 --- a/src/grandorgue/GOAudioRecorder.h +++ b/src/grandorgue/GOAudioRecorder.h @@ -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). */ @@ -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(); diff --git a/src/grandorgue/GOMetronome.cpp b/src/grandorgue/GOMetronome.cpp index c21ff5a01..ae7133167 100644 --- a/src/grandorgue/GOMetronome.cpp +++ b/src/grandorgue/GOMetronome.cpp @@ -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), @@ -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); diff --git a/src/grandorgue/GOMetronome.h b/src/grandorgue/GOMetronome.h index 707d40ccc..960b6cc88 100644 --- a/src/grandorgue/GOMetronome.h +++ b/src/grandorgue/GOMetronome.h @@ -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). */ @@ -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; diff --git a/src/grandorgue/combinations/GODivisionalSetter.cpp b/src/grandorgue/combinations/GODivisionalSetter.cpp index c69c5a161..d5b4d7ccf 100644 --- a/src/grandorgue/combinations/GODivisionalSetter.cpp +++ b/src/grandorgue/combinations/GODivisionalSetter.cpp @@ -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, @@ -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); diff --git a/src/grandorgue/combinations/GODivisionalSetter.h b/src/grandorgue/combinations/GODivisionalSetter.h index 81537d54a..cf0e778b6 100644 --- a/src/grandorgue/combinations/GODivisionalSetter.h +++ b/src/grandorgue/combinations/GODivisionalSetter.h @@ -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). */ @@ -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; diff --git a/src/grandorgue/combinations/GOSetter.cpp b/src/grandorgue/combinations/GOSetter.cpp index bd2dc9956..74c66da49 100644 --- a/src/grandorgue/combinations/GOSetter.cpp +++ b/src/grandorgue/combinations/GOSetter.cpp @@ -166,129 +166,119 @@ const wxString GOSetter::GROUP_LOAD_FILE = wxT("SetterLoadFile"); const wxString GOSetter::GROUP_SAVE_FILE = wxT("SetterSaveFile"); const wxString GOSetter::GROUP_SAVE_SETTINGS = wxT("SetterSave"); -const struct GOElementCreator::ButtonDefinitionEntry GOSetter::m_element_types[] - = { - {wxT("Prev"), ID_SETTER_PREV, true, true, false}, - {wxT("Next"), ID_SETTER_NEXT, true, true, false}, - {wxT("Set"), ID_SETTER_SET, true, false, false}, - {wxT("M1"), ID_SETTER_M1, true, true, false}, - {wxT("M10"), ID_SETTER_M10, true, true, false}, - {wxT("M100"), ID_SETTER_M100, true, true, false}, - {wxT("P1"), ID_SETTER_P1, true, true, false}, - {wxT("P10"), ID_SETTER_P10, true, true, false}, - {wxT("P100"), ID_SETTER_P100, true, true, false}, - {wxT("Current"), ID_SETTER_CURRENT, true, true, false}, - {wxT("Home"), ID_SETTER_HOME, true, true, false}, - {wxT("GC"), ID_SETTER_GC, true, true, false}, - {wxT("L1"), ID_SETTER_L1, true, true, false}, - {wxT("L2"), ID_SETTER_L2, true, true, false}, - {wxT("L3"), ID_SETTER_L3, true, true, false}, - {wxT("L4"), ID_SETTER_L4, true, true, false}, - {wxT("L5"), ID_SETTER_L5, true, true, false}, - {wxT("L6"), ID_SETTER_L6, true, true, false}, - {wxT("L7"), ID_SETTER_L7, true, true, false}, - {wxT("L8"), ID_SETTER_L8, true, true, false}, - {wxT("L9"), ID_SETTER_L9, true, true, false}, - {wxT("L0"), ID_SETTER_L0, true, true, false}, - {wxT("Regular"), ID_SETTER_REGULAR, true, true, false}, - {wxT("Scope"), ID_SETTER_SCOPE, true, true, false}, - {wxT("Scoped"), ID_SETTER_SCOPED, true, true, false}, - {wxT("Full"), ID_SETTER_FULL, true, false, false}, - {wxT("Insert"), ID_SETTER_INSERT, true, true, false}, - {wxT("Delete"), ID_SETTER_DELETE, true, true, false}, - {KEY_REFRESH_FILES, ID_SETTER_REFRESH_FILES, true, true, false}, - {KEY_PREV_FILE, ID_SETTER_PREV_FILE, true, true, false}, - {KEY_NEXT_FILE, ID_SETTER_NEXT_FILE, true, true, false}, - {KEY_LOAD_FILE, ID_SETTER_LOAD_FILE, true, true, false}, - {KEY_SAVE_FILE, ID_SETTER_SAVE_FILE, true, true, false}, - {wxT("General01"), ID_SETTER_GENERAL00, true, true, true}, - {wxT("General02"), ID_SETTER_GENERAL01, true, true, true}, - {wxT("General03"), ID_SETTER_GENERAL02, true, true, true}, - {wxT("General04"), ID_SETTER_GENERAL03, true, true, true}, - {wxT("General05"), ID_SETTER_GENERAL04, true, true, true}, - {wxT("General06"), ID_SETTER_GENERAL05, true, true, true}, - {wxT("General07"), ID_SETTER_GENERAL06, true, true, true}, - {wxT("General08"), ID_SETTER_GENERAL07, true, true, true}, - {wxT("General09"), ID_SETTER_GENERAL08, true, true, true}, - {wxT("General10"), ID_SETTER_GENERAL09, true, true, true}, - {wxT("General11"), ID_SETTER_GENERAL10, true, true, true}, - {wxT("General12"), ID_SETTER_GENERAL11, true, true, true}, - {wxT("General13"), ID_SETTER_GENERAL12, true, true, true}, - {wxT("General14"), ID_SETTER_GENERAL13, true, true, true}, - {wxT("General15"), ID_SETTER_GENERAL14, true, true, true}, - {wxT("General16"), ID_SETTER_GENERAL15, true, true, true}, - {wxT("General17"), ID_SETTER_GENERAL16, true, true, true}, - {wxT("General18"), ID_SETTER_GENERAL17, true, true, true}, - {wxT("General19"), ID_SETTER_GENERAL18, true, true, true}, - {wxT("General20"), ID_SETTER_GENERAL19, true, true, true}, - {wxT("General21"), ID_SETTER_GENERAL20, true, true, true}, - {wxT("General22"), ID_SETTER_GENERAL21, true, true, true}, - {wxT("General23"), ID_SETTER_GENERAL22, true, true, true}, - {wxT("General24"), ID_SETTER_GENERAL23, true, true, true}, - {wxT("General25"), ID_SETTER_GENERAL24, true, true, true}, - {wxT("General26"), ID_SETTER_GENERAL25, true, true, true}, - {wxT("General27"), ID_SETTER_GENERAL26, true, true, true}, - {wxT("General28"), ID_SETTER_GENERAL27, true, true, true}, - {wxT("General29"), ID_SETTER_GENERAL28, true, true, true}, - {wxT("General30"), ID_SETTER_GENERAL29, true, true, true}, - {wxT("General31"), ID_SETTER_GENERAL30, true, true, true}, - {wxT("General32"), ID_SETTER_GENERAL31, true, true, true}, - {wxT("General33"), ID_SETTER_GENERAL32, true, true, true}, - {wxT("General34"), ID_SETTER_GENERAL33, true, true, true}, - {wxT("General35"), ID_SETTER_GENERAL34, true, true, true}, - {wxT("General36"), ID_SETTER_GENERAL35, true, true, true}, - {wxT("General37"), ID_SETTER_GENERAL36, true, true, true}, - {wxT("General38"), ID_SETTER_GENERAL37, true, true, true}, - {wxT("General39"), ID_SETTER_GENERAL38, true, true, true}, - {wxT("General40"), ID_SETTER_GENERAL39, true, true, true}, - {wxT("General41"), ID_SETTER_GENERAL40, true, true, true}, - {wxT("General42"), ID_SETTER_GENERAL41, true, true, true}, - {wxT("General43"), ID_SETTER_GENERAL42, true, true, true}, - {wxT("General44"), ID_SETTER_GENERAL43, true, true, true}, - {wxT("General45"), ID_SETTER_GENERAL44, true, true, true}, - {wxT("General46"), ID_SETTER_GENERAL45, true, true, true}, - {wxT("General47"), ID_SETTER_GENERAL46, true, true, true}, - {wxT("General48"), ID_SETTER_GENERAL47, true, true, true}, - {wxT("General49"), ID_SETTER_GENERAL48, true, true, true}, - {wxT("General50"), ID_SETTER_GENERAL49, true, true, true}, - - {wxT("GeneralPrev"), ID_SETTER_GENERAL_PREV, true, true, false}, - {wxT("GeneralNext"), ID_SETTER_GENERAL_NEXT, true, true, false}, - - {wxT("PitchP1"), ID_SETTER_PITCH_P1, true, true, false}, - {wxT("PitchP10"), ID_SETTER_PITCH_P10, true, true, false}, - {wxT("PitchP100"), ID_SETTER_PITCH_P100, true, true, false}, - {wxT("PitchM1"), ID_SETTER_PITCH_M1, true, true, false}, - {wxT("PitchM10"), ID_SETTER_PITCH_M10, true, true, false}, - {wxT("PitchM100"), ID_SETTER_PITCH_M100, true, true, false}, - {wxT("TemperamentPrev"), ID_SETTER_TEMPERAMENT_PREV, true, true, false}, - {wxT("TemperamentNext"), ID_SETTER_TEMPERAMENT_NEXT, true, true, false}, - {wxT("TransposeDown"), ID_SETTER_TRANSPOSE_DOWN, true, true, false}, - {wxT("TransposeUp"), ID_SETTER_TRANSPOSE_UP, true, true, false}, - - {KEY_SAVE_SETTINGS, ID_SETTER_SAVE_SETTINGS, true, true, false}, - {KEY_ON_STATE, ID_SETTER_ON, false, true, false}, - - {wxT("CrescendoA"), ID_SETTER_CRESCENDO_A, true, true, false}, - {wxT("CrescendoB"), ID_SETTER_CRESCENDO_B, true, true, false}, - {wxT("CrescendoC"), ID_SETTER_CRESCENDO_C, true, true, false}, - {wxT("CrescendoD"), ID_SETTER_CRESCENDO_D, true, true, false}, - {wxT("CrescendoPrev"), ID_SETTER_CRESCENDO_PREV, true, true, false}, - {wxT("CrescendoCurrent"), ID_SETTER_CRESCENDO_CURRENT, true, true, false}, - {wxT("CrescendoNext"), ID_SETTER_CRESCENDO_NEXT, true, true, false}, - {wxT("CrescendoOverride"), - ID_SETTER_CRESCENDO_OVERRIDE, - true, - false, - false}, - {wxT("PanicButton"), ID_SETTER_AUDIO_PANIC, true, true, true}, - {wxT("ExitGO"), ID_SETTER_FILE_EXIT, true, true, true}, - {wxT(""), -1, false, false, false}}; - -const struct GOElementCreator::ButtonDefinitionEntry *GOSetter:: - GetButtonDefinitionList() { - return m_element_types; -} +const GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = { + {wxT("Prev"), ID_SETTER_PREV, true, true, false}, + {wxT("Next"), ID_SETTER_NEXT, true, true, false}, + {wxT("Set"), ID_SETTER_SET, true, false, false}, + {wxT("M1"), ID_SETTER_M1, true, true, false}, + {wxT("M10"), ID_SETTER_M10, true, true, false}, + {wxT("M100"), ID_SETTER_M100, true, true, false}, + {wxT("P1"), ID_SETTER_P1, true, true, false}, + {wxT("P10"), ID_SETTER_P10, true, true, false}, + {wxT("P100"), ID_SETTER_P100, true, true, false}, + {wxT("Current"), ID_SETTER_CURRENT, true, true, false}, + {wxT("Home"), ID_SETTER_HOME, true, true, false}, + {wxT("GC"), ID_SETTER_GC, true, true, false}, + {wxT("L1"), ID_SETTER_L1, true, true, false}, + {wxT("L2"), ID_SETTER_L2, true, true, false}, + {wxT("L3"), ID_SETTER_L3, true, true, false}, + {wxT("L4"), ID_SETTER_L4, true, true, false}, + {wxT("L5"), ID_SETTER_L5, true, true, false}, + {wxT("L6"), ID_SETTER_L6, true, true, false}, + {wxT("L7"), ID_SETTER_L7, true, true, false}, + {wxT("L8"), ID_SETTER_L8, true, true, false}, + {wxT("L9"), ID_SETTER_L9, true, true, false}, + {wxT("L0"), ID_SETTER_L0, true, true, false}, + {wxT("Regular"), ID_SETTER_REGULAR, true, true, false}, + {wxT("Scope"), ID_SETTER_SCOPE, true, true, false}, + {wxT("Scoped"), ID_SETTER_SCOPED, true, true, false}, + {wxT("Full"), ID_SETTER_FULL, true, false, false}, + {wxT("Insert"), ID_SETTER_INSERT, true, true, false}, + {wxT("Delete"), ID_SETTER_DELETE, true, true, false}, + {GOSetter::KEY_REFRESH_FILES, ID_SETTER_REFRESH_FILES, true, true, false}, + {GOSetter::KEY_PREV_FILE, ID_SETTER_PREV_FILE, true, true, false}, + {GOSetter::KEY_NEXT_FILE, ID_SETTER_NEXT_FILE, true, true, false}, + {GOSetter::KEY_LOAD_FILE, ID_SETTER_LOAD_FILE, true, true, false}, + {GOSetter::KEY_SAVE_FILE, ID_SETTER_SAVE_FILE, true, true, false}, + {wxT("General01"), ID_SETTER_GENERAL00, true, true, true}, + {wxT("General02"), ID_SETTER_GENERAL01, true, true, true}, + {wxT("General03"), ID_SETTER_GENERAL02, true, true, true}, + {wxT("General04"), ID_SETTER_GENERAL03, true, true, true}, + {wxT("General05"), ID_SETTER_GENERAL04, true, true, true}, + {wxT("General06"), ID_SETTER_GENERAL05, true, true, true}, + {wxT("General07"), ID_SETTER_GENERAL06, true, true, true}, + {wxT("General08"), ID_SETTER_GENERAL07, true, true, true}, + {wxT("General09"), ID_SETTER_GENERAL08, true, true, true}, + {wxT("General10"), ID_SETTER_GENERAL09, true, true, true}, + {wxT("General11"), ID_SETTER_GENERAL10, true, true, true}, + {wxT("General12"), ID_SETTER_GENERAL11, true, true, true}, + {wxT("General13"), ID_SETTER_GENERAL12, true, true, true}, + {wxT("General14"), ID_SETTER_GENERAL13, true, true, true}, + {wxT("General15"), ID_SETTER_GENERAL14, true, true, true}, + {wxT("General16"), ID_SETTER_GENERAL15, true, true, true}, + {wxT("General17"), ID_SETTER_GENERAL16, true, true, true}, + {wxT("General18"), ID_SETTER_GENERAL17, true, true, true}, + {wxT("General19"), ID_SETTER_GENERAL18, true, true, true}, + {wxT("General20"), ID_SETTER_GENERAL19, true, true, true}, + {wxT("General21"), ID_SETTER_GENERAL20, true, true, true}, + {wxT("General22"), ID_SETTER_GENERAL21, true, true, true}, + {wxT("General23"), ID_SETTER_GENERAL22, true, true, true}, + {wxT("General24"), ID_SETTER_GENERAL23, true, true, true}, + {wxT("General25"), ID_SETTER_GENERAL24, true, true, true}, + {wxT("General26"), ID_SETTER_GENERAL25, true, true, true}, + {wxT("General27"), ID_SETTER_GENERAL26, true, true, true}, + {wxT("General28"), ID_SETTER_GENERAL27, true, true, true}, + {wxT("General29"), ID_SETTER_GENERAL28, true, true, true}, + {wxT("General30"), ID_SETTER_GENERAL29, true, true, true}, + {wxT("General31"), ID_SETTER_GENERAL30, true, true, true}, + {wxT("General32"), ID_SETTER_GENERAL31, true, true, true}, + {wxT("General33"), ID_SETTER_GENERAL32, true, true, true}, + {wxT("General34"), ID_SETTER_GENERAL33, true, true, true}, + {wxT("General35"), ID_SETTER_GENERAL34, true, true, true}, + {wxT("General36"), ID_SETTER_GENERAL35, true, true, true}, + {wxT("General37"), ID_SETTER_GENERAL36, true, true, true}, + {wxT("General38"), ID_SETTER_GENERAL37, true, true, true}, + {wxT("General39"), ID_SETTER_GENERAL38, true, true, true}, + {wxT("General40"), ID_SETTER_GENERAL39, true, true, true}, + {wxT("General41"), ID_SETTER_GENERAL40, true, true, true}, + {wxT("General42"), ID_SETTER_GENERAL41, true, true, true}, + {wxT("General43"), ID_SETTER_GENERAL42, true, true, true}, + {wxT("General44"), ID_SETTER_GENERAL43, true, true, true}, + {wxT("General45"), ID_SETTER_GENERAL44, true, true, true}, + {wxT("General46"), ID_SETTER_GENERAL45, true, true, true}, + {wxT("General47"), ID_SETTER_GENERAL46, true, true, true}, + {wxT("General48"), ID_SETTER_GENERAL47, true, true, true}, + {wxT("General49"), ID_SETTER_GENERAL48, true, true, true}, + {wxT("General50"), ID_SETTER_GENERAL49, true, true, true}, + + {wxT("GeneralPrev"), ID_SETTER_GENERAL_PREV, true, true, false}, + {wxT("GeneralNext"), ID_SETTER_GENERAL_NEXT, true, true, false}, + + {wxT("PitchP1"), ID_SETTER_PITCH_P1, true, true, false}, + {wxT("PitchP10"), ID_SETTER_PITCH_P10, true, true, false}, + {wxT("PitchP100"), ID_SETTER_PITCH_P100, true, true, false}, + {wxT("PitchM1"), ID_SETTER_PITCH_M1, true, true, false}, + {wxT("PitchM10"), ID_SETTER_PITCH_M10, true, true, false}, + {wxT("PitchM100"), ID_SETTER_PITCH_M100, true, true, false}, + {wxT("TemperamentPrev"), ID_SETTER_TEMPERAMENT_PREV, true, true, false}, + {wxT("TemperamentNext"), ID_SETTER_TEMPERAMENT_NEXT, true, true, false}, + {wxT("TransposeDown"), ID_SETTER_TRANSPOSE_DOWN, true, true, false}, + {wxT("TransposeUp"), ID_SETTER_TRANSPOSE_UP, true, true, false}, + + {GOSetter::KEY_SAVE_SETTINGS, ID_SETTER_SAVE_SETTINGS, true, true, false}, + {GOSetter::KEY_ON_STATE, ID_SETTER_ON, false, true, false}, + + {wxT("CrescendoA"), ID_SETTER_CRESCENDO_A, true, true, false}, + {wxT("CrescendoB"), ID_SETTER_CRESCENDO_B, true, true, false}, + {wxT("CrescendoC"), ID_SETTER_CRESCENDO_C, true, true, false}, + {wxT("CrescendoD"), ID_SETTER_CRESCENDO_D, true, true, false}, + {wxT("CrescendoPrev"), ID_SETTER_CRESCENDO_PREV, true, true, false}, + {wxT("CrescendoCurrent"), ID_SETTER_CRESCENDO_CURRENT, true, true, false}, + {wxT("CrescendoNext"), ID_SETTER_CRESCENDO_NEXT, true, true, false}, + {wxT("CrescendoOverride"), ID_SETTER_CRESCENDO_OVERRIDE, true, false, false}, + {wxT("PanicButton"), ID_SETTER_AUDIO_PANIC, true, true, true}, + {wxT("ExitGO"), ID_SETTER_FILE_EXIT, true, true, true}, + {wxT(""), -1, false, false, false}}; GOSetter::GOSetter(GOOrganController *organController) : m_OrganController(organController), @@ -306,7 +296,7 @@ GOSetter::GOSetter(GOOrganController *organController) m_TransposeDisplay(*organController), m_NameDisplay(*organController), m_CrescendoCtrl(*organController) { - CreateButtons(*m_OrganController); + CreateButtons(*m_OrganController, BUTTON_DEFS); m_buttons[ID_SETTER_PREV]->SetInitialMidiIndex(0); m_buttons[ID_SETTER_NEXT]->SetInitialMidiIndex(1); diff --git a/src/grandorgue/combinations/GOSetter.h b/src/grandorgue/combinations/GOSetter.h index 0eb8bca9f..d24200cb8 100644 --- a/src/grandorgue/combinations/GOSetter.h +++ b/src/grandorgue/combinations/GOSetter.h @@ -87,9 +87,6 @@ class GOSetter : private GOSoundStateHandler, wxString GetCrescendoCmbStateName(uint8_t crescendoIdx) const; void Crescendo(int pos, bool force = false); - static const struct ButtonDefinitionEntry m_element_types[]; - const struct ButtonDefinitionEntry *GetButtonDefinitionList() override; - /** * Copy the sequencer combination * @param fromIdx - position of the source combination diff --git a/src/grandorgue/control/GOElementCreator.cpp b/src/grandorgue/control/GOElementCreator.cpp index e90d64d32..36b919922 100644 --- a/src/grandorgue/control/GOElementCreator.cpp +++ b/src/grandorgue/control/GOElementCreator.cpp @@ -1,6 +1,6 @@ /* * Copyright 2006 Milan Digital Audio LLC - * Copyright 2009-2023 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). */ @@ -9,30 +9,33 @@ #include "GOCallbackButtonControl.h" -void GOElementCreator::CreateButtons(GOOrganModel &organModel) { - const struct ButtonDefinitionEntry *entries = GetButtonDefinitionList(); - for (unsigned i = 0; - entries[i].name != wxEmptyString && entries[i].value >= 0; - i++) { - if (m_buttons.size() <= (unsigned)entries[i].value) - m_buttons.resize(entries[i].value + 1); - m_buttons[entries[i].value] = new GOCallbackButtonControl( - organModel, this, entries[i].is_pushbutton, entries[i].is_piston); +void GOElementCreator::CreateButtons( + GOOrganModel &organModel, const ButtonDefinitionEntry *pEntries) { + p_ButtonDefinitions = pEntries; + for (const ButtonDefinitionEntry *pEntry = pEntries; + !pEntry->name.IsEmpty() && pEntry->value >= 0; + pEntry++) { + GOCallbackButtonControl *pButton = new GOCallbackButtonControl( + organModel, this, pEntry->is_pushbutton, pEntry->is_piston); + const unsigned buttonIndex = (unsigned)pEntry->value; + + if (m_buttons.size() <= buttonIndex) + m_buttons.resize(buttonIndex + 1); + m_buttons[buttonIndex] = pButton; } } GOButtonControl *GOElementCreator::GetButtonControl( const wxString &name, bool is_panel) { - const struct ButtonDefinitionEntry *entries = GetButtonDefinitionList(); - for (unsigned i = 0; - entries[i].name != wxEmptyString && entries[i].value >= 0; - i++) - if (name == entries[i].name) { - if (is_panel && !entries[i].is_public) + for (const ButtonDefinitionEntry *pEntry = p_ButtonDefinitions; + pEntry && !pEntry->name.IsEmpty() && pEntry->value >= 0; + pEntry++) { + if (pEntry->name == name) { + if (is_panel && !pEntry->is_public) return NULL; - return m_buttons[entries[i].value]; + return m_buttons[pEntry->value]; } - + } return NULL; } diff --git a/src/grandorgue/control/GOElementCreator.h b/src/grandorgue/control/GOElementCreator.h index f52ca14f0..9409a2f5c 100644 --- a/src/grandorgue/control/GOElementCreator.h +++ b/src/grandorgue/control/GOElementCreator.h @@ -1,6 +1,6 @@ /* * Copyright 2006 Milan Digital Audio LLC - * Copyright 2009-2023 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). */ @@ -29,12 +29,14 @@ class GOElementCreator : private GOButtonCallback { bool is_piston; }; + const ButtonDefinitionEntry *p_ButtonDefinitions; + protected: ptr_vector m_buttons; - virtual const struct ButtonDefinitionEntry *GetButtonDefinitionList() = 0; + void CreateButtons( + GOOrganModel &organModel, const ButtonDefinitionEntry *pEntries); virtual void ButtonStateChanged(int id, bool newState) = 0; - void CreateButtons(GOOrganModel &organModel); public: virtual void Load(GOConfigReader &cfg) = 0; diff --git a/src/grandorgue/midi/GOMidiPlayer.cpp b/src/grandorgue/midi/GOMidiPlayer.cpp index a16e1b977..ca1a77128 100644 --- a/src/grandorgue/midi/GOMidiPlayer.cpp +++ b/src/grandorgue/midi/GOMidiPlayer.cpp @@ -25,20 +25,13 @@ enum { ID_MIDI_PLAYER_PAUSE, }; -const struct GOElementCreator::ButtonDefinitionEntry - GOMidiPlayer::m_element_types[] - = { - {wxT("MidiPlayerPlay"), ID_MIDI_PLAYER_PLAY, false, true, false}, - {wxT("MidiPlayerStop"), ID_MIDI_PLAYER_STOP, false, true, false}, - {wxT("MidiPlayerPause"), ID_MIDI_PLAYER_PAUSE, false, true, false}, - {wxT(""), -1, false, false, false}, +const GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = { + {wxT("MidiPlayerPlay"), ID_MIDI_PLAYER_PLAY, false, true, false}, + {wxT("MidiPlayerStop"), ID_MIDI_PLAYER_STOP, false, true, false}, + {wxT("MidiPlayerPause"), ID_MIDI_PLAYER_PAUSE, false, true, false}, + {wxT(""), -1, false, false, false}, }; -const struct GOElementCreator::ButtonDefinitionEntry *GOMidiPlayer:: - GetButtonDefinitionList() { - return m_element_types; -} - void GOMidiPlayer::ResetUI() { m_buttons[ID_MIDI_PLAYER_PLAY]->Display(false); m_buttons[ID_MIDI_PLAYER_PAUSE]->Display(false); @@ -56,7 +49,7 @@ GOMidiPlayer::GOMidiPlayer(GOOrganController *organController) m_Speed(1), m_IsPlaying(false), m_Pause(false) { - CreateButtons(*organController); + CreateButtons(*organController, BUTTON_DEFS); m_DeviceID = r_MidiMap.GetDeviceIdByLogicalName(_("GrandOrgue MIDI Player")); ResetUI(); } diff --git a/src/grandorgue/midi/GOMidiPlayer.h b/src/grandorgue/midi/GOMidiPlayer.h index 49214cb9c..f7d1ea443 100644 --- a/src/grandorgue/midi/GOMidiPlayer.h +++ b/src/grandorgue/midi/GOMidiPlayer.h @@ -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). */ @@ -41,10 +41,6 @@ class GOMidiPlayer : public GOElementCreator, private GOTimerCallback { bool m_Pause; unsigned m_DeviceID; - static const struct GOElementCreator::ButtonDefinitionEntry m_element_types[]; - const struct GOElementCreator::ButtonDefinitionEntry * - GetButtonDefinitionList() override; - void ButtonStateChanged(int id, bool newState) override; void UpdateDisplay(); diff --git a/src/grandorgue/midi/GOMidiRecorder.cpp b/src/grandorgue/midi/GOMidiRecorder.cpp index 520f3b246..b76dfb36a 100644 --- a/src/grandorgue/midi/GOMidiRecorder.cpp +++ b/src/grandorgue/midi/GOMidiRecorder.cpp @@ -28,24 +28,17 @@ enum { ID_MIDI_RECORDER_RECORD_RENAME, }; -const struct GOElementCreator::ButtonDefinitionEntry - GOMidiRecorder::m_element_types[] - = { - {wxT("MidiRecorderRecord"), ID_MIDI_RECORDER_RECORD, false, true, false}, - {wxT("MidiRecorderStop"), ID_MIDI_RECORDER_STOP, false, true, false}, - {wxT("MidiRecorderRecordRename"), - ID_MIDI_RECORDER_RECORD_RENAME, - false, - true, - false}, - {wxT(""), -1, false, false, false}, +const GOElementCreator::ButtonDefinitionEntry BUTTON_DEFS[] = { + {wxT("MidiRecorderRecord"), ID_MIDI_RECORDER_RECORD, false, true, false}, + {wxT("MidiRecorderStop"), ID_MIDI_RECORDER_STOP, false, true, false}, + {wxT("MidiRecorderRecordRename"), + ID_MIDI_RECORDER_RECORD_RENAME, + false, + true, + false}, + {wxT(""), -1, false, false, false}, }; -const struct GOElementCreator::ButtonDefinitionEntry *GOMidiRecorder:: - GetButtonDefinitionList() { - return m_element_types; -} - GOMidiRecorder::GOMidiRecorder(GOOrganController *organController) : m_OrganController(organController), m_Map(organController->GetSettings().GetMidiMap()), @@ -62,7 +55,7 @@ GOMidiRecorder::GOMidiRecorder(GOOrganController *organController) m_BufferPos(0), m_FileLength(0), m_Last(0) { - CreateButtons(*m_OrganController); + CreateButtons(*m_OrganController, BUTTON_DEFS); Clear(); UpdateDisplay(); } diff --git a/src/grandorgue/midi/GOMidiRecorder.h b/src/grandorgue/midi/GOMidiRecorder.h index 7c14d19c1..ec038918b 100644 --- a/src/grandorgue/midi/GOMidiRecorder.h +++ b/src/grandorgue/midi/GOMidiRecorder.h @@ -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). */ @@ -49,10 +49,6 @@ class GOMidiRecorder : public GOElementCreator, private GOTimerCallback { unsigned m_FileLength; GOTime m_Last; - static const struct GOElementCreator::ButtonDefinitionEntry m_element_types[]; - const struct GOElementCreator::ButtonDefinitionEntry * - GetButtonDefinitionList() override; - void ButtonStateChanged(int id, bool newState) override; void UpdateDisplay();