Skip to content

Commit

Permalink
refactor KeyboardClickListener
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jul 21, 2024
1 parent da3548f commit 7078145
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<KeySelectionController>(*this, allKeysOverview.get());
keyboardClickListener = std::make_unique<KeyboardClickListener>(*this, allKeysOverview.get());

// Edit function area
// noteEditArea.reset(new NoteEditArea(stateIn));
Expand Down Expand Up @@ -145,7 +145,7 @@ MainContentComponent::MainContentComponent(const LumatoneEditorState& stateIn, j

MainContentComponent::~MainContentComponent()
{
keySelectionController = nullptr;
keyboardClickListener = nullptr;

copiedSubBoardData = nullptr;

Expand Down
4 changes: 2 additions & 2 deletions Source/MainComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class LumatoneKeyboardComponent;

class KeySelectionController;
class KeyboardClickListener;
class MidiEditArea;
class KeyEditorPanel;
class MappingSettingsPanel;
Expand Down Expand Up @@ -120,7 +120,7 @@ class MainContentComponent : public juce::Component

//==============================================================================

std::unique_ptr<KeySelectionController> keySelectionController;
std::unique_ptr<KeyboardClickListener> keyboardClickListener;

//==============================================================================
// Position and Size helpers
Expand Down
Original file line number Diff line number Diff line change
@@ -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<LumatoneEditorState&>(*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)
{
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
==============================================================================
KeySelectionController.h
KeyboardClickListener.h
Created: 15 June 2024
Author: Vincenzo
Expand All @@ -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
Expand Down

0 comments on commit 7078145

Please sign in to comment.