Last active
February 13, 2017 15:15
-
-
Save yairchu/11d8555710683dff77a8e38f65dc447c to your computer and use it in GitHub Desktop.
PluginListManager for JUCE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "PluginListManager.h" | |
class PluginListManager::Window : public DocumentWindow | |
{ | |
public: | |
Window (PluginListManager* manager) | |
: DocumentWindow ( | |
"Available Plugins", Colours::white, | |
DocumentWindow::minimiseButton | DocumentWindow::closeButton) | |
, manager_ (manager) | |
{ | |
const File deadMansPedalFile ( | |
manager_->props_->getUserSettings()->getFile().getSiblingFile ("RecentlyCrashedPluginsList")); | |
setContentOwned ( | |
new PluginListComponent (manager_->formatManager, *manager_->list_, deadMansPedalFile, manager_->props_->getUserSettings(), true), true); | |
setResizable (true, false); | |
setResizeLimits (300, 400, 800, 1500); | |
setTopLeftPosition (60, 60); | |
restoreWindowStateFromString (manager_->props_->getUserSettings()->getValue ("listWindowPos")); | |
setVisible (true); | |
} | |
~Window() | |
{ | |
manager_->props_->getUserSettings()->setValue ("listWindowPos", getWindowStateAsString()); | |
clearContentComponent(); | |
} | |
void closeButtonPressed() override | |
{ | |
manager_->window_ = nullptr; | |
} | |
private: | |
PluginListManager* manager_; | |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Window) | |
}; | |
PluginListManager::PluginListManager (KnownPluginList* list, ApplicationProperties* props) | |
: list_ (list), props_ (props) | |
{ | |
{ | |
ScopedPointer<XmlElement> savedPluginList (props->getUserSettings()->getXmlValue ("pluginList")); | |
if (savedPluginList != nullptr) | |
list->recreateFromXml (*savedPluginList); | |
} | |
formatManager.addDefaultFormats(); | |
list_->addChangeListener (this); | |
} | |
PluginListManager::~PluginListManager() | |
{ | |
list_->removeChangeListener (this); | |
} | |
void PluginListManager::changeListenerCallback (ChangeBroadcaster* source) | |
{ | |
jassert (source == list_); | |
ScopedPointer<XmlElement> savedPluginList (list_->createXml()); | |
if (savedPluginList != nullptr) | |
{ | |
props_->getUserSettings()->setValue ("pluginList", savedPluginList); | |
props_->saveIfNeeded(); | |
} | |
} | |
void PluginListManager::showWindow() | |
{ | |
if (DocumentWindow* win = window_) | |
win->toFront (true); | |
else | |
window_ = new Window (this); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef PLUGINLISTWINDOW_H_INCLUDED | |
#define PLUGINLISTWINDOW_H_INCLUDED | |
#include "JuceHeader.h" | |
class PluginListManager : private ChangeListener | |
{ | |
public: | |
// The constructor loads the saved list, | |
// relying on the ApplicationProperties to be initialized. | |
PluginListManager (KnownPluginList*, ApplicationProperties*); | |
~PluginListManager(); | |
void showWindow(); | |
AudioPluginFormatManager formatManager; | |
private: | |
class Window; | |
void changeListenerCallback (ChangeBroadcaster*) override; | |
KnownPluginList* list_; | |
ApplicationProperties* props_; | |
ScopedPointer<DocumentWindow> window_; | |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginListManager) | |
}; | |
#endif // PLUGINLISTWINDOW_H_INCLUDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment