Browse Source

Made the plugin host demo close its plugin windows before attempting to quit.

tags/2021-05-28
jules 13 years ago
parent
commit
a16aee5fa5
4 changed files with 75 additions and 93 deletions
  1. +16
    -13
      extras/audio plugin host/Source/GraphEditorPanel.cpp
  2. +1
    -1
      extras/audio plugin host/Source/GraphEditorPanel.h
  3. +55
    -79
      extras/audio plugin host/Source/MainHostWindow.cpp
  4. +3
    -0
      extras/audio plugin host/Source/MainHostWindow.h

+ 16
- 13
extras/audio plugin host/Source/GraphEditorPanel.cpp View File

@@ -61,8 +61,15 @@ void PluginWindow::closeCurrentlyOpenWindowsFor (const uint32 nodeId)
void PluginWindow::closeAllCurrentlyOpenWindows() void PluginWindow::closeAllCurrentlyOpenWindows()
{ {
for (int i = activePluginWindows.size(); --i >= 0;)
delete activePluginWindows.getUnchecked(i);
if (activePluginWindows.size() > 0)
{
for (int i = activePluginWindows.size(); --i >= 0;)
delete activePluginWindows.getUnchecked(i);
Component dummyModalComp;
dummyModalComp.enterModalState();
MessageManager::getInstance()->runDispatchLoopUntil (50);
}
} }
PluginWindow* PluginWindow::getWindowFor (AudioProcessorGraph::Node* node, PluginWindow* PluginWindow::getWindowFor (AudioProcessorGraph::Node* node,
@@ -84,9 +91,7 @@ PluginWindow* PluginWindow::getWindowFor (AudioProcessorGraph::Node* node,
} }
if (useGenericView) if (useGenericView)
{
ui = new GenericAudioProcessorEditor (node->getProcessor()); ui = new GenericAudioProcessorEditor (node->getProcessor());
}
if (ui != nullptr) if (ui != nullptr)
{ {
@@ -701,8 +706,7 @@ private:
//============================================================================== //==============================================================================
GraphEditorPanel::GraphEditorPanel (FilterGraph& graph_) GraphEditorPanel::GraphEditorPanel (FilterGraph& graph_)
: graph (graph_),
draggingConnector (nullptr)
: graph (graph_)
{ {
graph.addChangeListener (this); graph.addChangeListener (this);
setOpaque (true); setOpaque (true);
@@ -711,7 +715,7 @@ GraphEditorPanel::GraphEditorPanel (FilterGraph& graph_)
GraphEditorPanel::~GraphEditorPanel() GraphEditorPanel::~GraphEditorPanel()
{ {
graph.removeChangeListener (this); graph.removeChangeListener (this);
deleteAndZero (draggingConnector);
draggingConnector = nullptr;
deleteAllChildren(); deleteAllChildren();
} }
@@ -866,7 +870,6 @@ void GraphEditorPanel::beginConnectorDrag (const uint32 sourceFilterID, const in
const uint32 destFilterID, const int destFilterChannel, const uint32 destFilterID, const int destFilterChannel,
const MouseEvent& e) const MouseEvent& e)
{ {
delete draggingConnector;
draggingConnector = dynamic_cast <ConnectorComponent*> (e.originalComponent); draggingConnector = dynamic_cast <ConnectorComponent*> (e.originalComponent);
if (draggingConnector == nullptr) if (draggingConnector == nullptr)
@@ -897,9 +900,9 @@ void GraphEditorPanel::dragConnector (const MouseEvent& e)
if (pin != nullptr) if (pin != nullptr)
{ {
uint32 srcFilter = draggingConnector->sourceFilterID; uint32 srcFilter = draggingConnector->sourceFilterID;
int srcChannel = draggingConnector->sourceFilterChannel;
int srcChannel = draggingConnector->sourceFilterChannel;
uint32 dstFilter = draggingConnector->destFilterID; uint32 dstFilter = draggingConnector->destFilterID;
int dstChannel = draggingConnector->destFilterChannel;
int dstChannel = draggingConnector->destFilterChannel;
if (srcFilter == 0 && ! pin->isInput) if (srcFilter == 0 && ! pin->isInput)
{ {
@@ -938,11 +941,11 @@ void GraphEditorPanel::endDraggingConnector (const MouseEvent& e)
const MouseEvent e2 (e.getEventRelativeTo (this)); const MouseEvent e2 (e.getEventRelativeTo (this));
uint32 srcFilter = draggingConnector->sourceFilterID; uint32 srcFilter = draggingConnector->sourceFilterID;
int srcChannel = draggingConnector->sourceFilterChannel;
int srcChannel = draggingConnector->sourceFilterChannel;
uint32 dstFilter = draggingConnector->destFilterID; uint32 dstFilter = draggingConnector->destFilterID;
int dstChannel = draggingConnector->destFilterChannel;
int dstChannel = draggingConnector->destFilterChannel;
deleteAndZero (draggingConnector);
draggingConnector = nullptr;
PinComponent* const pin = findPinAt (e2.x, e2.y); PinComponent* const pin = findPinAt (e2.x, e2.y);


+ 1
- 1
extras/audio plugin host/Source/GraphEditorPanel.h View File

@@ -67,7 +67,7 @@ public:
//============================================================================== //==============================================================================
private: private:
FilterGraph& graph; FilterGraph& graph;
ConnectorComponent* draggingConnector;
ScopedPointer<ConnectorComponent> draggingConnector;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GraphEditorPanel);
}; };


+ 55
- 79
extras/audio plugin host/Source/MainHostWindow.cpp View File

@@ -29,19 +29,18 @@
//============================================================================== //==============================================================================
class PluginListWindow : public DocumentWindow
class MainHostWindow::PluginListWindow : public DocumentWindow
{ {
public: public:
PluginListWindow (KnownPluginList& knownPluginList)
PluginListWindow (MainHostWindow& owner_)
: DocumentWindow ("Available Plugins", Colours::white, : DocumentWindow ("Available Plugins", Colours::white,
DocumentWindow::minimiseButton | DocumentWindow::closeButton)
DocumentWindow::minimiseButton | DocumentWindow::closeButton),
owner (owner_)
{ {
currentPluginListWindow = this;
const File deadMansPedalFile (appProperties->getUserSettings() const File deadMansPedalFile (appProperties->getUserSettings()
->getFile().getSiblingFile ("RecentlyCrashedPluginsList")); ->getFile().getSiblingFile ("RecentlyCrashedPluginsList"));
setContentOwned (new PluginListComponent (knownPluginList,
setContentOwned (new PluginListComponent (owner.knownPluginList,
deadMansPedalFile, deadMansPedalFile,
appProperties->getUserSettings()), true); appProperties->getUserSettings()), true);
@@ -58,21 +57,18 @@ public:
appProperties->getUserSettings()->setValue ("listWindowPos", getWindowStateAsString()); appProperties->getUserSettings()->setValue ("listWindowPos", getWindowStateAsString());
clearContentComponent(); clearContentComponent();
jassert (currentPluginListWindow == this);
currentPluginListWindow = 0;
} }
void closeButtonPressed() void closeButtonPressed()
{ {
delete this;
owner.pluginListWindow = nullptr;
} }
static PluginListWindow* currentPluginListWindow;
};
PluginListWindow* PluginListWindow::currentPluginListWindow = 0;
private:
MainHostWindow& owner;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PluginListWindow);
};
//============================================================================== //==============================================================================
MainHostWindow::MainHostWindow() MainHostWindow::MainHostWindow()
@@ -120,12 +116,12 @@ MainHostWindow::MainHostWindow()
MainHostWindow::~MainHostWindow() MainHostWindow::~MainHostWindow()
{ {
delete PluginListWindow::currentPluginListWindow;
pluginListWindow = nullptr;
#if JUCE_MAC #if JUCE_MAC
setMacMainMenu (0);
setMacMainMenu (nullptr);
#else #else
setMenuBar (0);
setMenuBar (nullptr);
#endif #endif
knownPluginList.removeChangeListener (this); knownPluginList.removeChangeListener (this);
@@ -141,8 +137,10 @@ void MainHostWindow::closeButtonPressed()
bool MainHostWindow::tryToQuitApplication() bool MainHostWindow::tryToQuitApplication()
{ {
if (getGraphEditor() != 0
&& getGraphEditor()->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
PluginWindow::closeAllCurrentlyOpenWindows();
if (getGraphEditor() == nullptr
|| getGraphEditor()->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
{ {
JUCEApplication::quit(); JUCEApplication::quit();
return true; return true;
@@ -159,7 +157,7 @@ void MainHostWindow::changeListenerCallback (ChangeBroadcaster*)
// and it crashes, we've still saved the previous ones // and it crashes, we've still saved the previous ones
ScopedPointer<XmlElement> savedPluginList (knownPluginList.createXml()); ScopedPointer<XmlElement> savedPluginList (knownPluginList.createXml());
if (savedPluginList != 0)
if (savedPluginList != nullptr)
{ {
appProperties->getUserSettings()->setValue ("pluginList", savedPluginList); appProperties->getUserSettings()->setValue ("pluginList", savedPluginList);
appProperties->saveIfNeeded(); appProperties->saveIfNeeded();
@@ -168,7 +166,7 @@ void MainHostWindow::changeListenerCallback (ChangeBroadcaster*)
const StringArray MainHostWindow::getMenuBarNames() const StringArray MainHostWindow::getMenuBarNames()
{ {
const char* const names[] = { "File", "Plugins", "Options", 0 };
const char* const names[] = { "File", "Plugins", "Options", nullptr };
return StringArray (names); return StringArray (names);
} }
@@ -203,7 +201,6 @@ const PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const St
menu.addSubMenu ("Create plugin", pluginsMenu); menu.addSubMenu ("Create plugin", pluginsMenu);
menu.addSeparator(); menu.addSeparator();
menu.addItem (250, "Delete all plugins"); menu.addItem (250, "Delete all plugins");
} }
else if (topLevelMenuIndex == 2) else if (topLevelMenuIndex == 2)
{ {
@@ -212,10 +209,10 @@ const PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const St
menu.addCommandItem (commandManager, CommandIDs::showPluginListEditor); menu.addCommandItem (commandManager, CommandIDs::showPluginListEditor);
PopupMenu sortTypeMenu; PopupMenu sortTypeMenu;
sortTypeMenu.addItem (200, "List plugins in default order", true, pluginSortMethod == KnownPluginList::defaultOrder);
sortTypeMenu.addItem (200, "List plugins in default order", true, pluginSortMethod == KnownPluginList::defaultOrder);
sortTypeMenu.addItem (201, "List plugins in alphabetical order", true, pluginSortMethod == KnownPluginList::sortAlphabetically); sortTypeMenu.addItem (201, "List plugins in alphabetical order", true, pluginSortMethod == KnownPluginList::sortAlphabetically);
sortTypeMenu.addItem (202, "List plugins by category", true, pluginSortMethod == KnownPluginList::sortByCategory);
sortTypeMenu.addItem (203, "List plugins by manufacturer", true, pluginSortMethod == KnownPluginList::sortByManufacturer);
sortTypeMenu.addItem (202, "List plugins by category", true, pluginSortMethod == KnownPluginList::sortByCategory);
sortTypeMenu.addItem (203, "List plugins by manufacturer", true, pluginSortMethod == KnownPluginList::sortByManufacturer);
sortTypeMenu.addItem (204, "List plugins based on the directory structure", true, pluginSortMethod == KnownPluginList::sortByFileSystemLocation); sortTypeMenu.addItem (204, "List plugins based on the directory structure", true, pluginSortMethod == KnownPluginList::sortByFileSystemLocation);
menu.addSubMenu ("Plugin menu type", sortTypeMenu); menu.addSubMenu ("Plugin menu type", sortTypeMenu);
@@ -235,7 +232,7 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/
if (menuItemID == 250) if (menuItemID == 250)
{ {
if (graphEditor != 0)
if (graphEditor != nullptr)
graphEditor->graph.clear(); graphEditor->graph.clear();
} }
else if (menuItemID >= 100 && menuItemID < 200) else if (menuItemID >= 100 && menuItemID < 200)
@@ -244,28 +241,23 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/
recentFiles.restoreFromString (appProperties->getUserSettings() recentFiles.restoreFromString (appProperties->getUserSettings()
->getValue ("recentFilterGraphFiles")); ->getValue ("recentFilterGraphFiles"));
if (graphEditor != 0 && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
if (graphEditor != nullptr && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
graphEditor->graph.loadFrom (recentFiles.getFile (menuItemID - 100), true); graphEditor->graph.loadFrom (recentFiles.getFile (menuItemID - 100), true);
} }
else if (menuItemID >= 200 && menuItemID < 210) else if (menuItemID >= 200 && menuItemID < 210)
{ {
if (menuItemID == 200)
pluginSortMethod = KnownPluginList::defaultOrder;
else if (menuItemID == 201)
pluginSortMethod = KnownPluginList::sortAlphabetically;
else if (menuItemID == 202)
pluginSortMethod = KnownPluginList::sortByCategory;
else if (menuItemID == 203)
pluginSortMethod = KnownPluginList::sortByManufacturer;
else if (menuItemID == 204)
pluginSortMethod = KnownPluginList::sortByFileSystemLocation;
if (menuItemID == 200) pluginSortMethod = KnownPluginList::defaultOrder;
else if (menuItemID == 201) pluginSortMethod = KnownPluginList::sortAlphabetically;
else if (menuItemID == 202) pluginSortMethod = KnownPluginList::sortByCategory;
else if (menuItemID == 203) pluginSortMethod = KnownPluginList::sortByManufacturer;
else if (menuItemID == 204) pluginSortMethod = KnownPluginList::sortByFileSystemLocation;
appProperties->getUserSettings()->setValue ("pluginSortMethod", (int) pluginSortMethod); appProperties->getUserSettings()->setValue ("pluginSortMethod", (int) pluginSortMethod);
} }
else else
{ {
createPlugin (getChosenType (menuItemID), createPlugin (getChosenType (menuItemID),
proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f)); proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f));
} }
} }
@@ -274,7 +266,7 @@ void MainHostWindow::createPlugin (const PluginDescription* desc, int x, int y)
{ {
GraphDocumentComponent* const graphEditor = getGraphEditor(); GraphDocumentComponent* const graphEditor = getGraphEditor();
if (graphEditor != 0)
if (graphEditor != nullptr)
graphEditor->createNewPlugin (desc, x, y); graphEditor->createNewPlugin (desc, x, y);
} }
@@ -291,13 +283,9 @@ void MainHostWindow::addPluginsToMenu (PopupMenu& m) const
const PluginDescription* MainHostWindow::getChosenType (const int menuID) const const PluginDescription* MainHostWindow::getChosenType (const int menuID) const
{ {
if (menuID >= 1 && menuID < 1 + internalTypes.size()) if (menuID >= 1 && menuID < 1 + internalTypes.size())
{
return internalTypes [menuID - 1]; return internalTypes [menuID - 1];
}
else
{
return knownPluginList.getType (knownPluginList.getIndexChosenByMenu (menuID));
}
return knownPluginList.getType (knownPluginList.getIndexChosenByMenu (menuID));
} }
//============================================================================== //==============================================================================
@@ -373,26 +361,26 @@ bool MainHostWindow::perform (const InvocationInfo& info)
switch (info.commandID) switch (info.commandID)
{ {
case CommandIDs::open: case CommandIDs::open:
if (graphEditor != 0 && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
if (graphEditor != nullptr && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
graphEditor->graph.loadFromUserSpecifiedFile (true); graphEditor->graph.loadFromUserSpecifiedFile (true);
break; break;
case CommandIDs::save: case CommandIDs::save:
if (graphEditor != 0)
if (graphEditor != nullptr)
graphEditor->graph.save (true, true); graphEditor->graph.save (true, true);
break; break;
case CommandIDs::saveAs: case CommandIDs::saveAs:
if (graphEditor != 0)
if (graphEditor != nullptr)
graphEditor->graph.saveAs (File::nonexistent, true, true, true); graphEditor->graph.saveAs (File::nonexistent, true, true, true);
break; break;
case CommandIDs::showPluginListEditor: case CommandIDs::showPluginListEditor:
if (PluginListWindow::currentPluginListWindow == 0)
PluginListWindow::currentPluginListWindow = new PluginListWindow (knownPluginList);
if (pluginListWindow == nullptr)
pluginListWindow = new PluginListWindow (*this);
PluginListWindow::currentPluginListWindow->toFront (true);
pluginListWindow->toFront (true);
break; break;
case CommandIDs::showAudioSettings: case CommandIDs::showAudioSettings:
@@ -400,15 +388,7 @@ bool MainHostWindow::perform (const InvocationInfo& info)
break; break;
case CommandIDs::aboutBox: case CommandIDs::aboutBox:
{
/* AboutBoxComponent aboutComp;
DialogWindow::showModalDialog ("About",
&aboutComp,
this, Colours::white,
true, false, false);
*/ }
// TODO
break; break;
default: default:
@@ -440,7 +420,7 @@ void MainHostWindow::showAudioSettings()
GraphDocumentComponent* const graphEditor = getGraphEditor(); GraphDocumentComponent* const graphEditor = getGraphEditor();
if (graphEditor != 0)
if (graphEditor != nullptr)
graphEditor->graph.removeIllegalConnections(); graphEditor->graph.removeIllegalConnections();
} }
@@ -463,29 +443,25 @@ void MainHostWindow::fileDragExit (const StringArray&)
void MainHostWindow::filesDropped (const StringArray& files, int x, int y) void MainHostWindow::filesDropped (const StringArray& files, int x, int y)
{ {
if (files.size() == 1 && File (files[0]).hasFileExtension (filenameSuffix))
{
GraphDocumentComponent* const graphEditor = getGraphEditor();
GraphDocumentComponent* const graphEditor = getGraphEditor();
if (graphEditor != 0
&& graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
if (graphEditor != nullptr)
{
if (files.size() == 1 && File (files[0]).hasFileExtension (filenameSuffix))
{ {
graphEditor->graph.loadFrom (File (files[0]), true);
if (graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
graphEditor->graph.loadFrom (File (files[0]), true);
} }
}
else
{
OwnedArray <PluginDescription> typesFound;
knownPluginList.scanAndAddDragAndDroppedFiles (files, typesFound);
GraphDocumentComponent* const graphEditor = getGraphEditor();
else
{
OwnedArray <PluginDescription> typesFound;
knownPluginList.scanAndAddDragAndDroppedFiles (files, typesFound);
Point<int> pos (x, y);
if (graphEditor != 0)
pos = graphEditor->getLocalPoint (this, pos);
Point<int> pos (graphEditor->getLocalPoint (this, Point<int> (x, y)));
for (int i = 0; i < jmin (5, typesFound.size()); ++i)
createPlugin (typesFound.getUnchecked(i), pos.getX(), pos.getY());
for (int i = 0; i < jmin (5, typesFound.size()); ++i)
createPlugin (typesFound.getUnchecked(i), pos.getX(), pos.getY());
}
} }
} }


+ 3
- 0
extras/audio plugin host/Source/MainHostWindow.h View File

@@ -93,6 +93,9 @@ private:
KnownPluginList knownPluginList; KnownPluginList knownPluginList;
KnownPluginList::SortMethod pluginSortMethod; KnownPluginList::SortMethod pluginSortMethod;
class PluginListWindow;
ScopedPointer <PluginListWindow> pluginListWindow;
void showAudioSettings(); void showAudioSettings();
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainHostWindow); JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainHostWindow);


Loading…
Cancel
Save