diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index fee3ef5..03cb1c0 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -311,23 +311,7 @@ void PaulstretchpluginAudioProcessorEditor::executeModalMenuAction(int menuid, i } } -void PaulstretchpluginAudioProcessorEditor::selectionChanged() -{ -} -void PaulstretchpluginAudioProcessorEditor::fileClicked(const File & file, const MouseEvent & e) -{ -} - -void PaulstretchpluginAudioProcessorEditor::fileDoubleClicked(const File & file) -{ - processor.setAudioFile(file); - processor.m_propsfile->m_props_file->setValue("importfilefolder", file.getParentDirectory().getFullPathName()); -} - -void PaulstretchpluginAudioProcessorEditor::browserRootChanged(const File & newRoot) -{ -} void PaulstretchpluginAudioProcessorEditor::paint (Graphics& g) { @@ -598,12 +582,7 @@ void PaulstretchpluginAudioProcessorEditor::toggleFileBrowser() { if (m_filechooser == nullptr) { - String initiallocfn = processor.m_propsfile->m_props_file->getValue("importfilefolder", - File::getSpecialLocation(File::userHomeDirectory).getFullPathName()); - File initialloc(initiallocfn); - m_filechooser = std::make_unique(1 | 4, - initialloc, &m_filefilter, nullptr); - m_filechooser->addListener(this); + m_filechooser = std::make_unique(processor); addChildComponent(m_filechooser.get()); } m_filechooser->setBounds(0, 50, getWidth(), getHeight() - 60); @@ -1620,3 +1599,43 @@ void AudioFilePreviewComponent::processBlock(double sr, AudioBuffer& buf) m_playpos = 0; } } + +MyFileBrowserComponent::MyFileBrowserComponent(PaulstretchpluginAudioProcessor & p) : + m_proc(p), m_filefilter(p.m_afm->getWildcardForAllFormats(),String(),String()) +{ + String initiallocfn = m_proc.m_propsfile->m_props_file->getValue("importfilefolder", + File::getSpecialLocation(File::userHomeDirectory).getFullPathName()); + File initialloc(initiallocfn); + m_fbcomp = std::make_unique(1 | 4, + initialloc, &m_filefilter, nullptr); + m_fbcomp->addListener(this); + addAndMakeVisible(m_fbcomp.get()); +} + +void MyFileBrowserComponent::resized() +{ + m_fbcomp->setBounds(0, 0, getWidth(), getHeight()); +} + +void MyFileBrowserComponent::paint(Graphics & g) +{ + //g.fillAll(Colours::yellow); +} + +void MyFileBrowserComponent::selectionChanged() +{ +} + +void MyFileBrowserComponent::fileClicked(const File & file, const MouseEvent & e) +{ +} + +void MyFileBrowserComponent::fileDoubleClicked(const File & file) +{ + m_proc.setAudioFile(file); + m_proc.m_propsfile->m_props_file->setValue("importfilefolder", file.getParentDirectory().getFullPathName()); +} + +void MyFileBrowserComponent::browserRootChanged(const File & newRoot) +{ +} diff --git a/Source/PluginEditor.h b/Source/PluginEditor.h index f8c840d..37ff045 100644 --- a/Source/PluginEditor.h +++ b/Source/PluginEditor.h @@ -416,19 +416,31 @@ private: int64 m_playpos = 0; }; -class MyFileBrowserComponent : public Component +class MyFileBrowserComponent : public Component, public FileBrowserListener { public: - MyFileBrowserComponent() - { + MyFileBrowserComponent(PaulstretchpluginAudioProcessor& p); + void resized() override; + void paint(Graphics& g) override; + std::function OnAction; + void selectionChanged() override; - } + /** Callback when the user clicks on a file in the browser. */ + void fileClicked(const File& file, const MouseEvent& e) override; + + /** Callback when the user double-clicks on a file in the browser. */ + void fileDoubleClicked(const File& file) override; + + /** Callback when the browser's root folder changes. */ + void browserRootChanged(const File& newRoot) override; private: std::unique_ptr m_fbcomp; + WildcardFileFilter m_filefilter; + PaulstretchpluginAudioProcessor& m_proc; }; class PaulstretchpluginAudioProcessorEditor : public AudioProcessorEditor, - public MultiTimer, public FileDragAndDropTarget, public DragAndDropContainer, public FileBrowserListener + public MultiTimer, public FileDragAndDropTarget, public DragAndDropContainer { public: PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor&); @@ -448,16 +460,7 @@ public: void executeModalMenuAction(int menuid, int actionid); SimpleFFTComponent m_sonogram; String m_last_err; - void selectionChanged() override; - - /** Callback when the user clicks on a file in the browser. */ - void fileClicked(const File& file, const MouseEvent& e) override; - - /** Callback when the user double-clicks on a file in the browser. */ - void fileDoubleClicked(const File& file) override; - - /** Callback when the browser's root folder changes. */ - void browserRootChanged(const File& newRoot) override; + private: PaulstretchpluginAudioProcessor& processor; uptrvec m_parcomps; @@ -482,7 +485,7 @@ private: void toggleFileBrowser(); std::vector m_capturelens{ 2,5,10,30,60,120 }; - std::unique_ptr m_filechooser; + std::unique_ptr m_filechooser; WildcardFileFilter m_filefilter; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor) };