Implement file browser as a separate component
This commit is contained in:
parent
1a42192509
commit
7f7259225f
@ -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)
|
void PaulstretchpluginAudioProcessorEditor::paint (Graphics& g)
|
||||||
{
|
{
|
||||||
@ -598,12 +582,7 @@ void PaulstretchpluginAudioProcessorEditor::toggleFileBrowser()
|
|||||||
{
|
{
|
||||||
if (m_filechooser == nullptr)
|
if (m_filechooser == nullptr)
|
||||||
{
|
{
|
||||||
String initiallocfn = processor.m_propsfile->m_props_file->getValue("importfilefolder",
|
m_filechooser = std::make_unique<MyFileBrowserComponent>(processor);
|
||||||
File::getSpecialLocation(File::userHomeDirectory).getFullPathName());
|
|
||||||
File initialloc(initiallocfn);
|
|
||||||
m_filechooser = std::make_unique<FileBrowserComponent>(1 | 4,
|
|
||||||
initialloc, &m_filefilter, nullptr);
|
|
||||||
m_filechooser->addListener(this);
|
|
||||||
addChildComponent(m_filechooser.get());
|
addChildComponent(m_filechooser.get());
|
||||||
}
|
}
|
||||||
m_filechooser->setBounds(0, 50, getWidth(), getHeight() - 60);
|
m_filechooser->setBounds(0, 50, getWidth(), getHeight() - 60);
|
||||||
@ -1620,3 +1599,43 @@ void AudioFilePreviewComponent::processBlock(double sr, AudioBuffer<float>& buf)
|
|||||||
m_playpos = 0;
|
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<FileBrowserComponent>(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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -416,19 +416,31 @@ private:
|
|||||||
int64 m_playpos = 0;
|
int64 m_playpos = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyFileBrowserComponent : public Component
|
class MyFileBrowserComponent : public Component, public FileBrowserListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MyFileBrowserComponent()
|
MyFileBrowserComponent(PaulstretchpluginAudioProcessor& p);
|
||||||
{
|
void resized() override;
|
||||||
|
void paint(Graphics& g) override;
|
||||||
|
std::function<void(int, File)> 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:
|
private:
|
||||||
std::unique_ptr<FileBrowserComponent> m_fbcomp;
|
std::unique_ptr<FileBrowserComponent> m_fbcomp;
|
||||||
|
WildcardFileFilter m_filefilter;
|
||||||
|
PaulstretchpluginAudioProcessor& m_proc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PaulstretchpluginAudioProcessorEditor : public AudioProcessorEditor,
|
class PaulstretchpluginAudioProcessorEditor : public AudioProcessorEditor,
|
||||||
public MultiTimer, public FileDragAndDropTarget, public DragAndDropContainer, public FileBrowserListener
|
public MultiTimer, public FileDragAndDropTarget, public DragAndDropContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor&);
|
PaulstretchpluginAudioProcessorEditor (PaulstretchpluginAudioProcessor&);
|
||||||
@ -448,16 +460,7 @@ public:
|
|||||||
void executeModalMenuAction(int menuid, int actionid);
|
void executeModalMenuAction(int menuid, int actionid);
|
||||||
SimpleFFTComponent m_sonogram;
|
SimpleFFTComponent m_sonogram;
|
||||||
String m_last_err;
|
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:
|
private:
|
||||||
PaulstretchpluginAudioProcessor& processor;
|
PaulstretchpluginAudioProcessor& processor;
|
||||||
uptrvec<ParameterComponent> m_parcomps;
|
uptrvec<ParameterComponent> m_parcomps;
|
||||||
@ -482,7 +485,7 @@ private:
|
|||||||
void toggleFileBrowser();
|
void toggleFileBrowser();
|
||||||
std::vector<int> m_capturelens{ 2,5,10,30,60,120 };
|
std::vector<int> m_capturelens{ 2,5,10,30,60,120 };
|
||||||
|
|
||||||
std::unique_ptr<FileBrowserComponent> m_filechooser;
|
std::unique_ptr<MyFileBrowserComponent> m_filechooser;
|
||||||
WildcardFileFilter m_filefilter;
|
WildcardFileFilter m_filefilter;
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PaulstretchpluginAudioProcessorEditor)
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user