Skip to content

Commit

Permalink
application state helper to update selected keys with changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Jul 8, 2024
1 parent 80eb448 commit a30bfb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/lumatone_editor_library/data/application_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,18 @@ void LumatoneApplicationState::Controller::removeSelectedKey(int keyNum)
}
}

void LumatoneApplicationState::Controller::updatedSelectedKeys()
{
juce::Array<MappedLumatoneKey> updatedKeys;
for (const MappedLumatoneKey& key : *appState.selectedKeys)
{
updatedKeys.add(MappedLumatoneKey(appState.getKey(key.boardIndex, key.keyIndex), key.boardIndex, key.keyIndex));
}

appState.selectedKeys->swapWith(updatedKeys);
appState.editorListeners->call(&LumatoneEditor::EditorListener::selectionChanged);
}

bool LumatoneApplicationState::Controller::performAction(LumatoneAction *action, bool undoable, bool newTransaction)
{
return appState.performLumatoneAction(action, undoable, newTransaction);
Expand Down
7 changes: 7 additions & 0 deletions Source/lumatone_editor_library/data/application_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class LumatoneApplicationState : public LumatoneState

// App Methods
const juce::Array<MappedLumatoneKey>* getSelectedKeys() const;
void updateSelecetdKeys();

// Context Methods
bool isContextSet() const { return contextIsSet; }
Expand Down Expand Up @@ -184,6 +185,12 @@ class LumatoneApplicationState : public LumatoneState
void addSelectedKey(int keyNum);
void removeSelectedKey(int keyNum);

protected:

void updatedSelectedKeys();

public:

virtual bool performAction(LumatoneAction* action, bool undoable=true, bool newTransaction=true);

protected:
Expand Down

0 comments on commit a30bfb7

Please sign in to comment.