From 95674ade1244c6e182c63c0635e7195371828872 Mon Sep 17 00:00:00 2001 From: bsutherland Date: Sat, 9 Jul 2016 21:30:56 +0900 Subject: [PATCH] Add load instrument button and version label. --- JuceOPLVSTi.jucer | 7 +++- Source/PluginGui.cpp | 98 +++++++++++++++++++++++++++++++++----------- Source/PluginGui.h | 20 +++++---- 3 files changed, 92 insertions(+), 33 deletions(-) diff --git a/JuceOPLVSTi.jucer b/JuceOPLVSTi.jucer index 402ad4f..0d910db 100644 --- a/JuceOPLVSTi.jucer +++ b/JuceOPLVSTi.jucer @@ -1,13 +1,13 @@ - @@ -111,6 +111,9 @@ + diff --git a/Source/PluginGui.cpp b/Source/PluginGui.cpp index c01497f..7fb399f 100644 --- a/Source/PluginGui.cpp +++ b/Source/PluginGui.cpp @@ -1,17 +1,17 @@ /* ============================================================================== - This is an automatically generated GUI class created by the Introjucer! + This is an automatically generated GUI class created by the Projucer! Be careful when adding custom code to these files, as only the code within the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded and re-saved. - Created with Introjucer version: 4.1.0 + Created with Projucer version: 4.2.3 ------------------------------------------------------------------------------ - The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions" + The Projucer is part of the JUCE library - "Jules' Utility Class Extensions" Copyright (c) 2015 - ROLI Ltd. ============================================================================== @@ -930,6 +930,21 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) exportButton->setColour (TextButton::buttonColourId, Colour (0xff007f00)); exportButton->setColour (TextButton::buttonOnColourId, Colours::lime); + addAndMakeVisible (loadButton = new TextButton ("load button")); + loadButton->setButtonText (TRANS("Load .SBI instrument")); + loadButton->addListener (this); + loadButton->setColour (TextButton::buttonColourId, Colour (0xff007f00)); + loadButton->setColour (TextButton::buttonOnColourId, Colours::lime); + + addAndMakeVisible (versionLabel = new Label ("version label", + String())); + versionLabel->setFont (Font (12.00f, Font::plain)); + versionLabel->setJustificationType (Justification::centredRight); + versionLabel->setEditable (false, false, false); + versionLabel->setColour (Label::textColourId, Colour (0xff007f00)); + versionLabel->setColour (TextEditor::textColourId, Colours::black); + versionLabel->setColour (TextEditor::backgroundColourId, Colour (0x00000000)); + //[UserPreSize] frequencyComboBox->setColour (ComboBox::textColourId, Colour (COLOUR_MID)); @@ -1058,6 +1073,7 @@ PluginGui::PluginGui (AdlibBlasterAudioProcessor* ownerFilter) addAndMakeVisible(channel); channels[i] = channel; } + versionLabel->setText(String(ProjectInfo::versionString), NotificationType::dontSendNotification); //[/UserPreSize] setSize (860, 550); @@ -1158,6 +1174,8 @@ PluginGui::~PluginGui() percussionComboBox = nullptr; percussionLabel = nullptr; exportButton = nullptr; + loadButton = nullptr; + versionLabel = nullptr; //[Destructor]. You can add your own custom destruction code here.. @@ -1265,6 +1283,8 @@ void PluginGui::resized() percussionComboBox->setBounds (256, 488, 112, 24); percussionLabel->setBounds (40, 488, 163, 24); exportButton->setBounds (40, 456, 168, 24); + loadButton->setBounds (232, 456, 168, 24); + versionLabel->setBounds (640, 528, 198, 16); //[UserResized] Add your own custom resize handling here.. for (unsigned int i = 0; i < channels.size(); ++i) channels[i]->setBounds(68+88*i, 36, 20, 20); @@ -1591,8 +1611,8 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) { //[UserButtonCode_exportButton] -- add your button handler code here.. WildcardFileFilter wildcardFilter("*.sbi", String::empty, "SBI files"); - FileBrowserComponent browser(FileBrowserComponent::saveMode, - File::nonexistent, + FileBrowserComponent browser(FileBrowserComponent::saveMode + FileBrowserComponent::canSelectFiles, + instrumentSaveDirectory, &wildcardFilter, nullptr); FileChooserDialogBox dialogBox("Export to", @@ -1603,10 +1623,32 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) if (dialogBox.show()) { File selectedFile = browser.getSelectedFile(0); + instrumentSaveDirectory = browser.getRoot(); processor->saveInstrumentToFile(selectedFile.getFullPathName()); } //[/UserButtonCode_exportButton] } + else if (buttonThatWasClicked == loadButton) + { + //[UserButtonCode_loadButton] -- add your button handler code here.. + WildcardFileFilter wildcardFilter("*.sbi", String::empty, "SBI files"); + FileBrowserComponent browser(FileBrowserComponent::openMode + FileBrowserComponent::canSelectFiles, + instrumentLoadDirectory, + &wildcardFilter, + nullptr); + FileChooserDialogBox dialogBox("Load", + "Select SBI instrument file", + browser, + false, + Colours::darkgreen); + if (dialogBox.show()) + { + File selectedFile = browser.getSelectedFile(0); + instrumentLoadDirectory = browser.getRoot(); + processor->loadInstrumentFromFile(selectedFile.getFullPathName()); + } + //[/UserButtonCode_loadButton] + } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] @@ -1659,9 +1701,9 @@ void PluginGui::buttonClicked (Button* buttonThatWasClicked) //============================================================================== #if 0 -/* -- Introjucer information section -- +/* -- Projucer information section -- - This is where the Introjucer stores the metadata that describe this GUI layout, so + This is where the Projucer stores the metadata that describe this GUI layout, so make changes in here at your peril! BEGIN_JUCER_METADATA @@ -1688,7 +1730,7 @@ BEGIN_JUCER_METADATA thumbcol="ff00af00" trackcol="7f007f00" textboxtext="ff007f00" textboxbkgd="ff000000" textboxhighlight="ff00af00" min="0" max="15" int="1" style="LinearVertical" textBoxPos="TextBoxBelow" textBoxEditable="1" - textBoxWidth="40" textBoxHeight="20" skewFactor="1"/> + textBoxWidth="40" textBoxHeight="20" skewFactor="1" needsCallback="1"/>