From 7dfa485ed6d91a4ce96eaecf21313626d3e1c661 Mon Sep 17 00:00:00 2001 From: xenakios Date: Tue, 19 Feb 2019 20:25:24 +0200 Subject: [PATCH] Let the customized file browser component own the look and feel --- Source/PluginEditor.cpp | 9 ++++++--- Source/PluginEditor.h | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index f361a5d..9c4f35f 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -247,8 +247,6 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau PaulstretchpluginAudioProcessorEditor::~PaulstretchpluginAudioProcessorEditor() { - if (m_filechooser) - m_filechooser->setLookAndFeel(nullptr); //Logger::writeToLog("PaulX Editor destroyed"); } @@ -583,7 +581,6 @@ void PaulstretchpluginAudioProcessorEditor::toggleFileBrowser() if (m_filechooser == nullptr) { m_filechooser = std::make_unique(processor); - m_filechooser->setLookAndFeel(&m_filebwlookandfeel); addChildComponent(m_filechooser.get()); } m_filechooser->setBounds(0, 26, getWidth()/2, getHeight() - 75); @@ -1592,6 +1589,12 @@ MyFileBrowserComponent::MyFileBrowserComponent(PaulstretchpluginAudioProcessor & initialloc, &m_filefilter, nullptr); m_fbcomp->addListener(this); addAndMakeVisible(m_fbcomp.get()); + setLookAndFeel(&m_filebwlookandfeel); +} + +MyFileBrowserComponent::~MyFileBrowserComponent() +{ + setLookAndFeel(nullptr); } void MyFileBrowserComponent::resized() diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index 26fed0b..dcb58b2 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -420,6 +420,7 @@ class MyFileBrowserComponent : public Component, public FileBrowserListener { public: MyFileBrowserComponent(PaulstretchpluginAudioProcessor& p); + ~MyFileBrowserComponent(); void resized() override; void paint(Graphics& g) override; std::function OnAction; @@ -437,6 +438,7 @@ private: std::unique_ptr m_fbcomp; WildcardFileFilter m_filefilter; PaulstretchpluginAudioProcessor& m_proc; + LookAndFeel_V3 m_filebwlookandfeel; }; class PaulstretchpluginAudioProcessorEditor : public AudioProcessorEditor, @@ -487,7 +489,7 @@ private: std::unique_ptr m_filechooser; WildcardFileFilter m_filefilter; - LookAndFeel_V3 m_filebwlookandfeel; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor) };