commit 850f13269525b97c18a9b6d510916c75096c3079
parent 5ed054ba4c5b361ac167f3a75eac85f30d8bbdb1
Author: Tal Aviram <me@talaviram.com>
Date: Tue, 17 Aug 2021 19:48:24 +0300
editor - add temporary part selector.
Diffstat:
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/source/jucePlugin/PluginEditor.cpp b/source/jucePlugin/PluginEditor.cpp
@@ -12,7 +12,7 @@ AudioPluginAudioProcessorEditor::AudioPluginAudioProcessorEditor(AudioPluginAudi
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
- setSize (400, 300);
+ setSize(800, 400);
m_btSingleMode.setRadioGroupId(0x3cf);
m_btMultiMode.setRadioGroupId(0x3cf);
@@ -29,6 +29,26 @@ AudioPluginAudioProcessorEditor::AudioPluginAudioProcessorEditor(AudioPluginAudi
m_btMultiMode.setTopLeftPosition(m_btSingleMode.getPosition().x + m_btSingleMode.getWidth() + 10, 0);
m_btMultiMode.setSize(120,30);
+ for (auto pt = 0; pt < 16; pt++)
+ {
+ m_partSelectors[pt].onClick = [this, pt]() {
+ auto bankA = processorRef.getController().getSinglePresetNames(0);
+ auto bankB = processorRef.getController().getSinglePresetNames(1);
+ juce::PopupMenu pA;
+ juce::PopupMenu pB;
+ for (auto i = 0; i < 128; i++)
+ {
+ pA.addItem(bankA[i], [this, i, pt] { processorRef.getController().setCurrentPartPreset(pt, 0, i); });
+ pB.addItem(bankB[i], [this, i, pt] { processorRef.getController().setCurrentPartPreset(pt, 1, i); });
+ }
+ juce::PopupMenu selector;
+ selector.addSubMenu("Bank A", pA);
+ selector.addSubMenu("Bank B", pB);
+ selector.showMenu(juce::PopupMenu::Options());
+ };
+ addAndMakeVisible(m_partSelectors[pt]);
+ }
+
addAndMakeVisible(m_tempEditor);
}
@@ -50,13 +70,21 @@ void AudioPluginAudioProcessorEditor::paint (juce::Graphics& g)
if(!processorRef.isPluginValid())
message += "\n\nNo ROM, no sound!\nCopy ROM next to plugin, must end with .bin";
- g.drawFittedText(message, getLocalBounds(), juce::Justification::centred, 2);
- g.drawFittedText("To donate: paypal.me/dsp56300", getLocalBounds(), juce::Justification::centredBottom, 2);
+ g.drawFittedText(message, getLocalBounds().removeFromLeft(400).removeFromBottom(45), juce::Justification::centred,
+ 2);
+ g.drawFittedText("To donate: paypal.me/dsp56300", getLocalBounds().removeFromRight(400).removeFromTop(35),
+ juce::Justification::centred, 2);
}
void AudioPluginAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
- m_tempEditor.setBounds(0, 35, getWidth(), getHeight() - 35);
+ auto area = getLocalBounds();
+ area.removeFromTop(35);
+ m_tempEditor.setBounds(area.removeFromRight(400));
+ for (auto pt = 0; pt < 16; pt++)
+ {
+ m_partSelectors[pt].setBounds(area.removeFromTop(20));
+ }
}
diff --git a/source/jucePlugin/PluginEditor.h b/source/jucePlugin/PluginEditor.h
@@ -20,6 +20,8 @@ private:
juce::GenericAudioProcessorEditor m_tempEditor;
+ juce::TextButton m_partSelectors[16];
+
juce::TextButton m_btSingleMode;
juce::TextButton m_btMultiMode;