Skip to content

Commit

Permalink
Merge branch 'develop-1.5.0-key-update-buffer' into develop-1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Aug 15, 2024
2 parents 6d38534 + ac46a94 commit a3aa271
Show file tree
Hide file tree
Showing 14 changed files with 259 additions and 183 deletions.
67 changes: 35 additions & 32 deletions Source/actions/BatchColourActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ApplyBatchColourAdjustments::ApplyBatchColourAdjustments(const LumatoneEditorSta
newData = editData;
previousData = getBatchColourEditData();

if (keySelectionIn.size() > 0 && keySelection.size() < (MAXNUMBOARDS * MAXBOARDSIZE)) // todo get actual number from each board
if (keySelectionIn.size() > 0 && keySelection.size() < (MAX_LUMATONE_BOARDS * MAX_LUMATONE_BOARD_KEYS)) // todo get actual number from each board
{
for (const MappedLumatoneKey& key : keySelectionIn)
{
Expand All @@ -107,19 +107,19 @@ ApplyBatchColourAdjustments::~ApplyBatchColourAdjustments()

bool ApplyBatchColourAdjustments::perform()
{
if (fullLayout)
{
for (const MappedLumatoneKey& key : keySelection)
{
MappedLumatoneKey updatedKey = key;
applyColourAdjustmentToKey(updatedKey, newData);
updatedLayout.setKey(updatedKey, key.boardIndex, key.keyIndex);
}

setLayout(updatedLayout);
}
else
{
// if (fullLayout)
// {
// for (const MappedLumatoneKey& key : keySelection)
// {
// MappedLumatoneKey updatedKey = key;
// applyColourAdjustmentToKey(updatedKey, newData);
// updatedLayout.setKey(updatedKey, key.boardIndex, key.keyIndex);
// }

// setLayout(updatedLayout);
// }
// else
// {
juce::Array<MappedLumatoneKey> updatedKeys;
for (const MappedLumatoneKey& key : keySelection)
{
Expand All @@ -128,36 +128,39 @@ bool ApplyBatchColourAdjustments::perform()
updatedKeys.add(updatedKey);
}

sendSelectionColours(updatedKeys);
}
bool useBuffer = keySelection.size() > 48;
sendSelectionColours(updatedKeys, true, useBuffer);
// }

return true;
}

bool ApplyBatchColourAdjustments::undo()
{
if (fullLayout)
{
for (const MappedLumatoneKey& key : keySelection)
{
MappedLumatoneKey baseKey = baseLayout->getMappedKey(key.boardIndex, key.keyIndex);
applyColourAdjustmentToKey(baseKey, previousData);
updatedLayout.setKey(baseKey);
}

setLayout(updatedLayout);
}
else
{
// if (fullLayout)
// {
// for (const MappedLumatoneKey& key : keySelection)
// {
// MappedLumatoneKey baseKey = baseLayout->getMappedKey(key.boardIndex, key.keyIndex);
// applyColourAdjustmentToKey(baseKey, previousData);
// updatedLayout.setKey(baseKey);
// }

// setLayout(updatedLayout);
// }
// else
// {
for (MappedLumatoneKey& key : keySelection)
{
juce::Colour baseColour = baseLayout->getKey(key.boardIndex, key.keyIndex)
.getColour();
key.setColour(baseColour);
applyColourAdjustmentToKey(key, previousData);
// applyColourAdjustmentToKey(key, previousData);
}
sendSelectionParam(keySelection, true);
}

bool useBuffer = keySelection.size() > 48;
sendSelectionColours(keySelection, true, useBuffer);
// }

return true;
}
Expand Down
10 changes: 6 additions & 4 deletions Source/actions/EditorControlActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,22 +132,24 @@ bool ApplyAssignmentsToSelectionAction::perform()
if (newData.ccFaderDefault)
keyUpdate.setDefaultCCFader(newData.ccFaderDefault);

setKey((const LumatoneKey&) keyUpdate, keyUpdate.boardIndex + 1, keyUpdate.keyIndex);
LumatoneState::setKey((const LumatoneKey&) keyUpdate, keyUpdate.boardIndex + 1, keyUpdate.keyIndex);
updatedKeys.add(keyUpdate);
}

bool useBuffer = updatedKeys.size() > 48;

if (!newData.useColour)
{
// todo param-only update (no colour)
sendSelectionParam(updatedKeys);
sendSelectionParam(updatedKeys, true, useBuffer);
}
else if (newData.useType || newData.useNote || newData.useChannel || newData.ccFaderDefault)
{
sendSelectionParam(updatedKeys);
sendSelectionParam(updatedKeys, true, useBuffer);
}
else
{
sendSelectionColours(updatedKeys);
sendSelectionColours(updatedKeys, true, useBuffer);
}

updatedSelectedKeys();
Expand Down
50 changes: 32 additions & 18 deletions Source/lumatone_editor_library/data/lumatone_board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ LumatoneBoard::LumatoneBoard(LumatoneKeyType newKeyType, int numKeysIn, int boar
theKeys[i] = LumatoneKey(newKeyType);

//key_idx = 0;
state = juce::ValueTree(LumatoneBoardProperty::State);
updateState();
// state = juce::ValueTree(LumatoneBoardProperty::State);
// updateState();
}

LumatoneBoard::LumatoneBoard(const LumatoneBoard& copyBoard)
{
state = juce::ValueTree(LumatoneBoardProperty::State);
// state = juce::ValueTree(LumatoneBoardProperty::State);
board_idx = copyBoard.board_idx;
operator=(copyBoard);
}
Expand All @@ -41,8 +41,8 @@ LumatoneBoard::LumatoneBoard(juce::ValueTree stateIn)
if (stateIn.hasType(LumatoneBoardProperty::State))
stateToCopy = stateIn;

state = stateToCopy;
refreshFromState();
// state = stateToCopy;
refreshFromState(stateToCopy);
}

void LumatoneBoard::operator=(const LumatoneBoard& copyBoard)
Expand All @@ -54,7 +54,7 @@ void LumatoneBoard::operator=(const LumatoneBoard& copyBoard)
theKeys[i] = copyBoard.getKey(i);
}

updateState();
// updateState();
}

bool LumatoneBoard::isEmpty() const
Expand All @@ -68,6 +68,19 @@ bool LumatoneBoard::isEmpty() const
return true;
}

juce::ValueTree LumatoneBoard::getState() const
{
juce::ValueTree newState(LumatoneBoardProperty::State);

newState.setProperty(LumatoneBoardProperty::Id, board_idx, nullptr);
for (int i = 0; i < numKeys; i++)
{
newState.addChild(theKeys[i].getState(), i, nullptr);
}

return newState;
}

int LumatoneBoard::getNumKeys() const
{
return numKeys;
Expand Down Expand Up @@ -165,22 +178,23 @@ juce::Array<LumatoneKeyCoord> LumatoneBoard::getKeysWithColour(const juce::Colou
return keyCoords;
}

void LumatoneBoard::updateState()
{
juce::ValueTree newState(LumatoneBoardProperty::State);
// void LumatoneBoard::updateState()
// {
// juce::ValueTree newState(LumatoneBoardProperty::State);

newState.setProperty(LumatoneBoardProperty::Id, board_idx, nullptr);
for (int i = 0; i < numKeys; i++)
{
newState.addChild(theKeys[i].getState(), i, nullptr);
}
// newState.setProperty(LumatoneBoardProperty::Id, board_idx, nullptr);
// for (int i = 0; i < numKeys; i++)
// {
// newState.addChild(theKeys[i].getState(), i, nullptr);
// }

state.copyPropertiesAndChildrenFrom(newState, nullptr);
}
// state.copyPropertiesAndChildrenFrom(newState, nullptr);
// }

void LumatoneBoard::refreshFromState()
void LumatoneBoard::refreshFromState(const juce::ValueTree& state)
{
board_idx = (int)state[LumatoneBoardProperty::Id];
juce::var defaultIndex = 0;
board_idx = (int)state.getProperty(LumatoneBoardProperty::Id, defaultIndex);

for (int i = 0; i < numKeys; i++)
{
Expand Down
14 changes: 7 additions & 7 deletions Source/lumatone_editor_library/data/lumatone_board.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "../data/lumatone_editor_common.h"
#include "lumatone_key.h"

#define MAXBOARDSIZE 56
#define MAX_LUMATONE_BOARD_KEYS 56

namespace LumatoneBoardProperty
{
Expand All @@ -29,7 +29,7 @@ class LumatoneLayout;
class LumatoneBoard
{
public:
LumatoneBoard(LumatoneKeyType newKeyType = LumatoneKeyType::disabled, int numKeysIn=MAXBOARDSIZE, int boardIndex = 0);
LumatoneBoard(LumatoneKeyType newKeyType = LumatoneKeyType::disabled, int numKeysIn=MAX_LUMATONE_BOARD_KEYS, int boardIndex = 0);
LumatoneBoard(const LumatoneBoard& copyBoard);
LumatoneBoard(juce::ValueTree stateIn);

Expand All @@ -38,7 +38,7 @@ class LumatoneBoard
int getBoardIndex() const { return board_idx; }
bool isEmpty() const;

juce::ValueTree getState() const { return state; }
juce::ValueTree getState() const;

int getNumKeys() const;
const LumatoneKey& getKey(int index) const;
Expand All @@ -54,16 +54,16 @@ class LumatoneBoard
juce::Array<LumatoneKeyCoord> getKeysWithColour(const juce::Colour& c) const;

private:
void updateState();
void refreshFromState();
// void updateState();
void refreshFromState(const juce::ValueTree& state);

private:
LumatoneKey theKeys[MAXBOARDSIZE];
LumatoneKey theKeys[MAX_LUMATONE_BOARD_KEYS];
int board_idx;

int numKeys;

juce::ValueTree state;
// juce::ValueTree state;

friend class LumatoneLayout;
};
Expand Down
Loading

0 comments on commit a3aa271

Please sign in to comment.