Skip to content

Commit

Permalink
use key buffer for key set and batch update actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vsicurella committed Aug 15, 2024
1 parent 6f612de commit ac46a94
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 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

0 comments on commit ac46a94

Please sign in to comment.