Skip to content

Commit 0cb57c7

Browse files
committed
Load preset by drag and drop vvp file on header component
1 parent 2408fae commit 0cb57c7

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

VASTvaporizer/Source/Plugin/VASTAudioProcessor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ void VASTAudioProcessor::initializeToDefaults() {
528528
m_parameterState.undoManager->beginNewTransaction(); //start new transcation only here?
529529
}
530530

531+
void VASTAudioProcessor::loadPresetFile(File presetvvpfile) {
532+
VASTPresetElement lPreset{};
533+
std::unique_ptr<juce::XmlDocument> xml(new XmlDocument(presetvvpfile));
534+
bool success = loadPatchXML(xml.get(), false, &lPreset, lPreset.presetarrayindex, lPreset);
535+
}
536+
531537
void VASTAudioProcessor::setCurrentProgram(int index)
532538
{
533539
if (index >= getNumPrograms()) {

VASTvaporizer/Source/Plugin/VASTAudioProcessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class VASTAudioProcessor : public AudioProcessor
239239
bool isUserPatch();
240240
String getUserPatchName();
241241
void savePatchXML(File *selectedFile);
242+
void loadPresetFile(File presetvvpfile);
242243
bool loadPatchXML(XmlDocument* xmlDoc, bool bNameOnly, const VASTPresetElement* preset, int index, VASTPresetElement& resultPresetData);
243244
static String getVSTPath();
244245
static String getVSTPathAlternative();

VASTvaporizer/Source/Plugin/VASTHeaderComponent.cpp

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,19 @@ void VASTHeaderComponent::buttonClicked (juce::Button* buttonThatWasClicked)
449449
//[/UserbuttonClicked_Post]
450450
}
451451

452+
void VASTHeaderComponent::filesDropped (const juce::StringArray& filenames, int mouseX, int mouseY)
453+
{
454+
//[UserCode_filesDropped] -- Add your code here...
455+
if (filenames.size() < 1)
456+
return;
457+
String filename = filenames[0];
458+
File presetfile = File(filename);
459+
if ((!presetfile.existsAsFile()) || (!presetfile.getFileExtension().equalsIgnoreCase(".vvp")))
460+
return;
461+
myProcessor->loadPresetFile(presetfile);
462+
//[/UserCode_filesDropped]
463+
}
464+
452465
void VASTHeaderComponent::mouseDown (const juce::MouseEvent& e)
453466
{
454467
//[UserCode_mouseDown] -- Add your code here...
@@ -476,6 +489,16 @@ void VASTHeaderComponent::mouseDown (const juce::MouseEvent& e)
476489

477490

478491
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
492+
bool VASTHeaderComponent::isInterestedInFileDrag(const juce::StringArray& filenames)
493+
{
494+
if (filenames.size() < 1)
495+
return false;
496+
String filename = filenames[0];
497+
File presetfile = File(filename);
498+
if ((!presetfile.existsAsFile()) || (!presetfile.getFileExtension().equalsIgnoreCase(".vvp")))
499+
return false;
500+
return true;
501+
}
479502
//[/MiscUserCode]
480503

481504

@@ -489,12 +512,14 @@ void VASTHeaderComponent::mouseDown (const juce::MouseEvent& e)
489512
BEGIN_JUCER_METADATA
490513

491514
<JUCER_COMPONENT documentType="Component" className="VASTHeaderComponent" componentName=""
492-
parentClasses="public Component" constructorParams="AudioProcessorEditor *editor, AudioProcessor* processor"
515+
parentClasses="public Component, public FileDragAndDropTarget"
516+
constructorParams="AudioProcessorEditor *editor, AudioProcessor* processor"
493517
variableInitialisers="myEditor((VASTAudioProcessorEditor*)editor), myProcessor((VASTAudioProcessor*)processor)"
494518
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
495519
fixedSize="1" initialWidth="325" initialHeight="76">
496520
<METHODS>
497521
<METHOD name="mouseDown (const juce::MouseEvent&amp; e)"/>
522+
<METHOD name="filesDropped (const juce::StringArray&amp; filenames, int mouseX, int mouseY)"/>
498523
</METHODS>
499524
<BACKGROUND backgroundColour="ff323e44">
500525
<RECT pos="0 0 0M 0M" fill="linear: -46.769% -42.105%, 100.923% 105.263%, 0=ff212527, 1=ff0b0b0b"

VASTvaporizer/Source/Plugin/VASTHeaderComponent.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
//[/Comments]
3939
*/
4040
class VASTHeaderComponent : public Component,
41+
public FileDragAndDropTarget,
4142
public juce::ComboBox::Listener,
4243
public juce::Button::Listener
4344
{
@@ -54,12 +55,14 @@ class VASTHeaderComponent : public Component,
5455
VASTComboPreset* getComponentCPreset() {
5556
return c_Preset.get();
5657
}
58+
bool isInterestedInFileDrag(const juce::StringArray& filenames);
5759
//[/UserMethods]
5860

5961
void paint (juce::Graphics& g) override;
6062
void resized() override;
6163
void comboBoxChanged (juce::ComboBox* comboBoxThatHasChanged) override;
6264
void buttonClicked (juce::Button* buttonThatWasClicked) override;
65+
void filesDropped (const juce::StringArray& filenames, int mouseX, int mouseY) override;
6366
void mouseDown (const juce::MouseEvent& e) override;
6467

6568
// Binary resources:

build_win.bat

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ rmdir /S /Q cmake-build
2020
for %%t in (%targets%) do (
2121
@echo Building for %%t
2222
if "%%t"=="Win32" (
23-
cmake -B"cmake-build\Win32" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=ON
23+
cmake -B"cmake-build\Win32" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
2424
cmake --build "cmake-build\Win32" --config Release
2525
) else if "%%t"=="Win32SSE2" (
26-
cmake -B"cmake-build\Win32SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=ON
26+
cmake -B"cmake-build\Win32SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A Win32 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=ON -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
2727
cmake --build "cmake-build\Win32SSE2" --config Release
2828
) else if "%%t"=="x64" (
29-
cmake -B"cmake-build\x64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=OFF
29+
cmake -B"cmake-build\x64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=ON -DBUILD_32=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
3030
cmake --build "cmake-build\x64" --config Release
3131
) else if "%%t"=="x64SSE2" (
32-
cmake -B"cmake-build\x64SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=OFF
32+
cmake -B"cmake-build\x64SSE2" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_VERSION=10.0.22000.0 -G "Visual Studio 16 2019" -T v142 -A x64 -DCMAKE_PREFIX_PATH=../JUCE/install -DASIO_SDK_LOCATION:STRING=".\asiosdk" -DAAX_SDK_LOCATION:STRING=".\AAX_SDK\aax-sdk-2-6-0" -DVST2_SDK_LOCATION:STRING=".\VST_SDK\VST2_SDK" -DBUILD_AVX=OFF -DBUILD_32=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
3333
cmake --build "cmake-build\x64SSE2" --config Release
3434
) else (
3535
@echo Unknown target "%%t"

0 commit comments

Comments
 (0)