Windows and Linux Copy Paste Preset
This commit is contained in:
parent
64fce498d3
commit
736d34a7a7
3 changed files with 46 additions and 2 deletions
|
@ -865,6 +865,10 @@ void ObxdAudioProcessorEditor::createMenu ()
|
||||||
{
|
{
|
||||||
#if JUCE_MAC
|
#if JUCE_MAC
|
||||||
bool enablePasteOption = macPasteboard::containsPresetData(); // Check if the clipboard contains data for a Preset
|
bool enablePasteOption = macPasteboard::containsPresetData(); // Check if the clipboard contains data for a Preset
|
||||||
|
#else
|
||||||
|
juce::MemoryBlock memoryBlock;
|
||||||
|
memoryBlock.fromBase64Encoding(SystemClipboard::getTextFromClipboard());
|
||||||
|
bool enablePasteOption = processor.isMemoryBlockAPreset(memoryBlock);
|
||||||
#endif
|
#endif
|
||||||
popupMenus.clear();
|
popupMenus.clear();
|
||||||
PopupMenu* menu = new PopupMenu();
|
PopupMenu* menu = new PopupMenu();
|
||||||
|
@ -929,7 +933,6 @@ void ObxdAudioProcessorEditor::createMenu ()
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
#if JUCE_MAC
|
|
||||||
|
|
||||||
fileMenu.addSeparator();
|
fileMenu.addSeparator();
|
||||||
|
|
||||||
|
@ -942,7 +945,7 @@ void ObxdAudioProcessorEditor::createMenu ()
|
||||||
"Paste Preset...",
|
"Paste Preset...",
|
||||||
enablePasteOption,
|
enablePasteOption,
|
||||||
false);
|
false);
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
fileMenu.addItem(static_cast<int>(MenuAction::DeleteBank),
|
fileMenu.addItem(static_cast<int>(MenuAction::DeleteBank),
|
||||||
"Delete Bank...",
|
"Delete Bank...",
|
||||||
|
@ -1366,6 +1369,31 @@ void ObxdAudioProcessorEditor::MenuActionCallback(int action){
|
||||||
processor.loadFromMemoryBlock(memoryBlock); //loadPreset(memoryBlock);
|
processor.loadFromMemoryBlock(memoryBlock); //loadPreset(memoryBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// Copy to clipboard
|
||||||
|
if (action == MenuAction::CopyPreset)
|
||||||
|
{
|
||||||
|
juce::MemoryBlock serializedData;
|
||||||
|
|
||||||
|
// Serialize the Preset, produces the same data as an export but into memory instead of a file.
|
||||||
|
processor.serializePreset(serializedData);
|
||||||
|
|
||||||
|
// Place the data onto the clipboard
|
||||||
|
SystemClipboard::copyTextToClipboard(serializedData.toBase64Encoding());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paste from clipboard
|
||||||
|
if (action == MenuAction::PastePreset)
|
||||||
|
{
|
||||||
|
juce::MemoryBlock memoryBlock;
|
||||||
|
|
||||||
|
// Fetch Preset data from the clipboard
|
||||||
|
memoryBlock.fromBase64Encoding(SystemClipboard::getTextFromClipboard());
|
||||||
|
|
||||||
|
// Load the data
|
||||||
|
processor.loadFromMemoryBlock(memoryBlock); //loadPreset(memoryBlock);
|
||||||
|
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -670,6 +670,21 @@ bool ObxdAudioProcessor::loadFromFXBFile(const File& fxbFile)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ObxdAudioProcessor::isMemoryBlockAPreset(const MemoryBlock& mb)
|
||||||
|
{
|
||||||
|
const void* const data = mb.getData();
|
||||||
|
const size_t dataSize = mb.getSize();
|
||||||
|
|
||||||
|
if (dataSize < 28)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const fxSet* const set = (const fxSet*)data;
|
||||||
|
|
||||||
|
if ((!compareMagic(set->chunkMagic, "CcnK")) || fxbSwap(set->version) > fxbVersionNum)
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ObxdAudioProcessor::loadFromMemoryBlock(MemoryBlock& mb)
|
bool ObxdAudioProcessor::loadFromMemoryBlock(MemoryBlock& mb)
|
||||||
{
|
{
|
||||||
const void* const data = mb.getData();
|
const void* const data = mb.getData();
|
||||||
|
|
|
@ -184,6 +184,7 @@ public:
|
||||||
|
|
||||||
bool loadFromFXPFile(const File& fxbFile);
|
bool loadFromFXPFile(const File& fxbFile);
|
||||||
bool loadFromFXBFile(const File& fxbFile);
|
bool loadFromFXBFile(const File& fxbFile);
|
||||||
|
bool isMemoryBlockAPreset(const MemoryBlock& memoryBlock);
|
||||||
bool loadFromMemoryBlock(MemoryBlock& memoryBlock);
|
bool loadFromMemoryBlock(MemoryBlock& memoryBlock);
|
||||||
bool saveFXBFile(const File& fxbFile);
|
bool saveFXBFile(const File& fxbFile);
|
||||||
bool saveFXPFile(const File& fxpFile);
|
bool saveFXPFile(const File& fxpFile);
|
||||||
|
|
Loading…
Reference in a new issue