mirror of
https://codeberg.org/armin/wavetable.git
synced 2026-09-01 05:50:46 +02:00
Add menu for selecting wavetable
This commit is contained in:
parent
134fe08983
commit
bda6188352
2 changed files with 40 additions and 1 deletions
|
|
@ -51,6 +51,7 @@ public:
|
|||
auto& h = getHeader();
|
||||
h.addAndMakeVisible (nextButton);
|
||||
h.addAndMakeVisible (prevButton);
|
||||
h.addMouseListener (this, false);
|
||||
nextButton.onClick = [this] { proc.incWavetable (idx, +1); };
|
||||
prevButton.onClick = [this] { proc.incWavetable (idx, -1); };
|
||||
}
|
||||
|
|
@ -63,6 +64,44 @@ public:
|
|||
proc.osc2Table.removeListener (this);
|
||||
}
|
||||
|
||||
void mouseUp (const juce::MouseEvent& e) override
|
||||
{
|
||||
auto& h = getHeader();
|
||||
if (e.originalComponent == &h && e.mouseWasClicked())
|
||||
{
|
||||
juce::StringArray tables;
|
||||
for (auto i = 0; i < BinaryData::namedResourceListSize; i++)
|
||||
if (juce::String (BinaryData::originalFilenames[i]).endsWith (".wav"))
|
||||
tables.add (juce::String (BinaryData::originalFilenames[i]).upToLastOccurrenceOf (".wav", false, false));
|
||||
|
||||
tables.sortNatural();
|
||||
|
||||
std::map<juce::String, juce::PopupMenu> menus;
|
||||
|
||||
for (auto t : tables)
|
||||
{
|
||||
auto prefix = t.upToFirstOccurrenceOf (" ", false, false);
|
||||
auto suffix = t.fromFirstOccurrenceOf (" ", false, false);
|
||||
|
||||
menus[prefix].addItem (t, [this, t]
|
||||
{
|
||||
if (idx == 0)
|
||||
proc.osc1Table = t;
|
||||
else
|
||||
proc.osc2Table = t;
|
||||
|
||||
proc.reloadWavetables();
|
||||
});
|
||||
}
|
||||
|
||||
juce::PopupMenu m;
|
||||
for (auto itr : menus)
|
||||
m.addSubMenu (itr.first, itr.second);
|
||||
|
||||
m.showMenuAsync ({});
|
||||
}
|
||||
}
|
||||
|
||||
void resized() override
|
||||
{
|
||||
gin::ParamBox::resized();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue