Add Wavetable Editor
This commit is contained in:
@@ -194,6 +194,8 @@ NeuralSynthAudioProcessorEditor::NeuralSynthAudioProcessorEditor (NeuralSynthAud
|
||||
NeuralSynthAudioProcessorEditor::~NeuralSynthAudioProcessorEditor()
|
||||
{
|
||||
stopTimer();
|
||||
if (customPresetWindow != nullptr)
|
||||
customPresetWindow.reset();
|
||||
keyboardState.removeListener(this);
|
||||
}
|
||||
|
||||
@@ -311,6 +313,7 @@ void NeuralSynthAudioProcessorEditor::showPresetMenu()
|
||||
categories.add(preset.category);
|
||||
|
||||
const int baseId = 1000;
|
||||
const int customPresetMenuId = baseId - 1;
|
||||
for (const auto& category : categories)
|
||||
{
|
||||
juce::PopupMenu sub;
|
||||
@@ -325,11 +328,18 @@ void NeuralSynthAudioProcessorEditor::showPresetMenu()
|
||||
menu.addSubMenu(category, sub);
|
||||
}
|
||||
|
||||
menu.addItem(categories.size() + 1, "Custom ...", true, false);
|
||||
menu.addSeparator();
|
||||
menu.addItem(customPresetMenuId, "Custom ...", true, false);
|
||||
|
||||
menu.showMenuAsync(juce::PopupMenu::Options().withParentComponent(this),
|
||||
[this, baseId](int result)
|
||||
[this, baseId, customPresetMenuId](int result)
|
||||
{
|
||||
if (result == customPresetMenuId)
|
||||
{
|
||||
showCustomPresetWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result >= baseId)
|
||||
{
|
||||
const int index = result - baseId;
|
||||
@@ -340,6 +350,22 @@ void NeuralSynthAudioProcessorEditor::showPresetMenu()
|
||||
});
|
||||
}
|
||||
|
||||
void NeuralSynthAudioProcessorEditor::showCustomPresetWindow()
|
||||
{
|
||||
constexpr int windowWidth = 420;
|
||||
constexpr int windowHeight = 320;
|
||||
|
||||
if (customPresetWindow == nullptr)
|
||||
{
|
||||
customPresetWindow = std::make_unique<CustomPresetWindow>();
|
||||
customPresetWindow->setSize(windowWidth, windowHeight);
|
||||
}
|
||||
|
||||
customPresetWindow->centreAroundComponent(this, windowWidth, windowHeight);
|
||||
customPresetWindow->setVisible(true);
|
||||
customPresetWindow->toFront(true);
|
||||
}
|
||||
|
||||
void NeuralSynthAudioProcessorEditor::updatePresetButtonLabel()
|
||||
{
|
||||
const auto& presets = audioProcessor.getFactoryPresets();
|
||||
|
||||
Reference in New Issue
Block a user