Browse Source

AudioPluginHost: Fix bug where internal plugins could not be created from the main menu

v7.0.9
reuk 2 years ago
parent
commit
145d3819eb
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
3 changed files with 17 additions and 18 deletions
  1. +3
    -3
      extras/AudioPluginHost/Source/UI/GraphEditorPanel.cpp
  2. +13
    -12
      extras/AudioPluginHost/Source/UI/MainHostWindow.cpp
  3. +1
    -3
      extras/AudioPluginHost/Source/UI/MainHostWindow.h

+ 3
- 3
extras/AudioPluginHost/Source/UI/GraphEditorPanel.cpp View File

@@ -894,9 +894,9 @@ void GraphEditorPanel::showPopupMenu (Point<int> mousePos)
menu->showMenuAsync ({},
ModalCallbackFunction::create ([this, mousePos] (int r)
{
if (r > 0)
if (auto* mainWin = findParentComponentOfClass<MainHostWindow>())
createNewPlugin (mainWin->getChosenType (r), mousePos);
if (auto* mainWin = findParentComponentOfClass<MainHostWindow>())
if (const auto chosen = mainWin->getChosenType (r))
createNewPlugin (*chosen, mousePos);
}));
}
}


+ 13
- 12
extras/AudioPluginHost/Source/UI/MainHostWindow.cpp View File

@@ -602,9 +602,9 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/
}
else
{
if (getIndexChosenByMenu (menuItemID) >= 0)
createPlugin (getChosenType (menuItemID), { proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f) });
if (const auto chosen = getChosenType (menuItemID))
createPlugin (*chosen, { proportionOfWidth (0.3f + Random::getSystemRandom().nextFloat() * 0.6f),
proportionOfHeight (0.3f + Random::getSystemRandom().nextFloat() * 0.6f) });
}
}
@@ -697,18 +697,19 @@ void MainHostWindow::addPluginsToMenu (PopupMenu& m)
addToMenu (*tree, m, pluginDescriptions, pluginDescriptionsAndPreference);
}
int MainHostWindow::getIndexChosenByMenu (int menuID) const
std::optional<PluginDescriptionAndPreference> MainHostWindow::getChosenType (const int menuID) const
{
const auto i = menuID - menuIDBase;
return isPositiveAndBelow (i, pluginDescriptionsAndPreference.size()) ? i : -1;
}
const auto internalIndex = menuID - 1;
PluginDescriptionAndPreference MainHostWindow::getChosenType (const int menuID) const
{
if (menuID >= 1 && menuID < (int) (1 + internalTypes.size()))
return PluginDescriptionAndPreference { internalTypes[(size_t) (menuID - 1)] };
if (isPositiveAndBelow (internalIndex, internalTypes.size()))
return PluginDescriptionAndPreference { internalTypes[(size_t) internalIndex] };
const auto externalIndex = menuID - menuIDBase;
if (isPositiveAndBelow (externalIndex, pluginDescriptionsAndPreference.size()))
return pluginDescriptionsAndPreference[externalIndex];
return pluginDescriptionsAndPreference[getIndexChosenByMenu (menuID)];
return {};
}
//==============================================================================


+ 1
- 3
extras/AudioPluginHost/Source/UI/MainHostWindow.h View File

@@ -110,7 +110,7 @@ public:
void createPlugin (const PluginDescriptionAndPreference&, Point<int> pos);
void addPluginsToMenu (PopupMenu&);
PluginDescriptionAndPreference getChosenType (int menuID) const;
std::optional<PluginDescriptionAndPreference> getChosenType (int menuID) const;
std::unique_ptr<GraphDocumentComponent> graphHolder;
@@ -124,8 +124,6 @@ private:
void showAudioSettings();
int getIndexChosenByMenu (int menuID) const;
//==============================================================================
AudioDeviceManager deviceManager;
AudioPluginFormatManager formatManager;


Loading…
Cancel
Save