From 707814593c67a73e27d1e6578253db4f572aa05a Mon Sep 17 00:00:00 2001 From: Vincenzo Sicurella Date: Fri, 19 Jul 2024 18:20:32 -0400 Subject: [PATCH] refactor KeyboardClickListener --- Source/MainComponent.cpp | 6 +++--- Source/MainComponent.h | 4 ++-- ...nController.cpp => KeyboardClickListener.cpp} | 16 ++++++++-------- ...ctionController.h => KeyboardClickListener.h} | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) rename Source/mapping_editors/{KeySelectionController.cpp => KeyboardClickListener.cpp} (61%) rename Source/mapping_editors/{KeySelectionController.h => KeyboardClickListener.h} (80%) diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index f34348c..a283f52 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -16,7 +16,7 @@ #include "MidiEditArea.h" -#include "mapping_editors/KeySelectionController.h" +#include "mapping_editors/KeyboardClickListener.h" #include "mapping_editors/KeyEditorPanel.h" #include "mapping_editors/MappingSettingsPanel.h" #include "GlobalSettingsArea.h" @@ -47,7 +47,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j addAndMakeVisible(allKeysOverview.get()); // Listens to key selection and creates selection edit actions - keySelectionController = std::make_unique(*this, allKeysOverview.get()); + keyboardClickListener = std::make_unique(*this, allKeysOverview.get()); // Edit function area // noteEditArea.reset(new NoteEditArea(stateIn)); @@ -145,7 +145,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j MainContentComponent::~MainContentComponent() { - keySelectionController = nullptr; + keyboardClickListener = nullptr; copiedSubBoardData = nullptr; diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 315001c..bf13d84 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -18,7 +18,7 @@ class LumatoneKeyboardComponent; -class KeySelectionController; +class KeyboardClickListener; class MidiEditArea; class KeyEditorPanel; class MappingSettingsPanel; @@ -120,7 +120,7 @@ class MainContentComponent : public juce::Component //============================================================================== - std::unique_ptr keySelectionController; + std::unique_ptr keyboardClickListener; //============================================================================== // Position and Size helpers diff --git a/Source/mapping_editors/KeySelectionController.cpp b/Source/mapping_editors/KeyboardClickListener.cpp similarity index 61% rename from Source/mapping_editors/KeySelectionController.cpp rename to Source/mapping_editors/KeyboardClickListener.cpp index c2e08db..b834f04 100644 --- a/Source/mapping_editors/KeySelectionController.cpp +++ b/Source/mapping_editors/KeyboardClickListener.cpp @@ -1,33 +1,33 @@ -#include "KeySelectionController.h" +#include "KeyboardClickListener.h" #include "../actions/KeySelectionControlActions.h" -KeySelectionController::KeySelectionController(const LumatoneEditorState &stateIn, LumatoneKeyboardComponent *keyboardComponentIn) - : LumatoneEditorState("LumatoneKeySelectionController", stateIn) +KeyboardClickListener::KeyboardClickListener(const LumatoneEditorState &stateIn, LumatoneKeyboardComponent *keyboardComponentIn) + : LumatoneEditorState("LumatoneKeyboardClickListener", stateIn) , LumatoneEditorState::Controller(static_cast(*this)) , keyboardComponent(keyboardComponentIn) { keyboardComponent->addListener(this); } -KeySelectionController::~KeySelectionController() +KeyboardClickListener::~KeyboardClickListener() { keyboardComponent->removeListener(this); } -void KeySelectionController::handleKeyUp(int keyNum) +void KeyboardClickListener::handleKeyUp(int keyNum) { } -void KeySelectionController::handleKeyDown(int keyNum) +void KeyboardClickListener::handleKeyDown(int keyNum) { lastKeyDown = keyNum; // make quicker? toggleKeySelection(keyNum); } -void KeySelectionController::handleKeyHold(int key, float xDistance, float yDistance) +void KeyboardClickListener::handleKeyHold(int key, float xDistance, float yDistance) { if (key != lastKeyDown) { @@ -36,7 +36,7 @@ void KeySelectionController::handleKeyHold(int key, float xDistance, float yDist } } -void KeySelectionController::toggleKeySelection(int keyNum) +void KeyboardClickListener::toggleKeySelection(int keyNum) { bool isSelected = false; for (const MappedLumatoneKey& key : *getSelectedKeys()) diff --git a/Source/mapping_editors/KeySelectionController.h b/Source/mapping_editors/KeyboardClickListener.h similarity index 80% rename from Source/mapping_editors/KeySelectionController.h rename to Source/mapping_editors/KeyboardClickListener.h index 455c88d..2f24073 100644 --- a/Source/mapping_editors/KeySelectionController.h +++ b/Source/mapping_editors/KeyboardClickListener.h @@ -1,7 +1,7 @@ /* ============================================================================== - KeySelectionController.h + KeyboardClickListener.h Created: 15 June 2024 Author: Vincenzo @@ -15,14 +15,14 @@ #include "../lumatone_editor_library/ui/keyboard_component.h" // Maybe KeyboardComponentSelectionController -class KeySelectionController : public LumatoneEditorState +class KeyboardClickListener : public LumatoneEditorState , private LumatoneEditorState::Controller , public LumatoneKeyboardComponent::Listener { public: - KeySelectionController(const LumatoneEditorState& stateIn, LumatoneKeyboardComponent* keyboardComponent); - ~KeySelectionController() override; + KeyboardClickListener(const LumatoneEditorState& stateIn, LumatoneKeyboardComponent* keyboardComponent); + ~KeyboardClickListener() override; // LumatoneKeyboardComponent::Listener