From 2489657a97f26b6a6d48fc8e6e1cb150b36f5542 Mon Sep 17 00:00:00 2001 From: George Reales Date: Sun, 17 May 2020 16:03:04 +0200 Subject: [PATCH] Window size recall --- Source/PluginEditor.cpp | 149 ++++++++++++++++++++++++++++++++++++++++ Source/PluginEditor.h | 73 ++++++++++++++++++++ 2 files changed, 222 insertions(+) create mode 100644 Source/PluginEditor.cpp create mode 100644 Source/PluginEditor.h diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp new file mode 100644 index 0000000..abb97fb --- /dev/null +++ b/Source/PluginEditor.cpp @@ -0,0 +1,149 @@ +/* + ============================================================================== + + 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 Projucer version: 5.4.7 + + ------------------------------------------------------------------------------ + + The Projucer is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + ============================================================================== +*/ + +//[Headers] You can add your own extra header files here... +//[/Headers] + +#include "PluginEditor.h" + + +//[MiscUserDefs] You can add your own user definitions and misc code here... +//[/MiscUserDefs] + +//============================================================================== +PluginEditor::PluginEditor (AdlibBlasterAudioProcessor* ownerFilter) + : AudioProcessorEditor (ownerFilter) +{ + //[Constructor_pre] You can add your own custom stuff here.. + + PropertiesFile::Options options; + options.applicationName = ProjectInfo::projectName; + options.osxLibrarySubFolder = "Application Support"; + options.filenameSuffix = ".settings"; + options.storageFormat = PropertiesFile::storeAsXML; + #if JUCE_LINUX + options.folderName = "~/.config"; + #endif + #if JUCE_WINDOWS + options.folderName = "~/"; + #endif + pluginSettings.setStorageParameters (options); + + //[/Constructor_pre] + + comp.reset (new PluginGui (ownerFilter)); + addAndMakeVisible (comp.get()); + comp->setName ("Main GUI"); + + comp->setBounds (0, 0, 860, 580); + + + //[UserPreSize] + setResizable(true, true); + //[/UserPreSize] + + setSize (860, 580); + + + //[Constructor] You can add your own custom stuff here.. + int w,h; + w = pluginSettings.getUserSettings()->getIntValue("Width"); + if(w==0) + w=860; + h = pluginSettings.getUserSettings()->getIntValue("Height"); + if(h==0) + h=580; + setSize(w,h); + //[/Constructor] +} + +PluginEditor::~PluginEditor() +{ + //[Destructor_pre]. You can add your own custom destruction code here.. + //[/Destructor_pre] + + comp = nullptr; + + + //[Destructor]. You can add your own custom destruction code here.. + pluginSettings.getUserSettings()->setValue("Width", getWidth()); + pluginSettings.getUserSettings()->setValue("Height", getHeight()); + pluginSettings.saveIfNeeded(); + //[/Destructor] +} + +//============================================================================== +void PluginEditor::paint (Graphics& g) +{ + //[UserPrePaint] Add your own custom painting code here.. + //[/UserPrePaint] + + g.fillAll (Colours::black); + + //[UserPaint] Add your own custom painting code here.. + //[/UserPaint] +} + +void PluginEditor::resized() +{ + //[UserPreResize] Add your own custom resize code here.. + Path path; // the only reason we use a Path is that it implements the handy getTransformToScaleToFit() + path.addRectangle(0, 0, comp->getWidth(), comp->getHeight()); + auto transform = path.getTransformToScaleToFit(getLocalBounds().toFloat(), true, Justification::centred); + + comp->setTransform(transform); + //[/UserPreResize] + + //[UserResized] Add your own custom resize handling here.. + //[/UserResized] +} + + + +//[MiscUserCode] You can add your own definitions of your custom methods or any other code here... +//[/MiscUserCode] + + +//============================================================================== +#if 0 +/* -- Projucer information section -- + + This is where the Projucer stores the metadata that describe this GUI layout, so + make changes in here at your peril! + +BEGIN_JUCER_METADATA + + + + + + +END_JUCER_METADATA +*/ +#endif + + +//[EndFile] You can add extra defines here... +//[/EndFile] + diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h new file mode 100644 index 0000000..a4aae7f --- /dev/null +++ b/Source/PluginEditor.h @@ -0,0 +1,73 @@ +/* + ============================================================================== + + 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 Projucer version: 5.4.7 + + ------------------------------------------------------------------------------ + + The Projucer is part of the JUCE library. + Copyright (c) 2017 - ROLI Ltd. + + ============================================================================== +*/ + +#pragma once + +//[Headers] -- You can add your own extra header files here -- +#include +#include "PluginGui.h" +#include "PluginProcessor.h" + +//[/Headers] + + + +//============================================================================== +/** + //[Comments] + An auto-generated component, created by the Projucer. + + Describe your class and how it works here! + //[/Comments] +*/ +class PluginEditor : public AudioProcessorEditor +{ +public: + //============================================================================== + PluginEditor (AdlibBlasterAudioProcessor* ownerFilter); + ~PluginEditor() override; + + //============================================================================== + //[UserMethods] -- You can add your own custom methods in this section. + void updateFromParameters() { + comp->updateFromParameters(); + }; + //[/UserMethods] + + void paint (Graphics& g) override; + void resized() override; + + + +private: + //[UserVariables] -- You can add your own custom variables in this section. + ApplicationProperties pluginSettings; + //[/UserVariables] + + //============================================================================== + std::unique_ptr comp; + + + //============================================================================== + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginEditor) +}; + +//[EndFile] You can add extra defines here... +//[/EndFile] +