mirror of
https://codeberg.org/armin/wavetable.git
synced 2026-09-01 14:00:47 +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
|
|
@ -1 +1 @@
|
||||||
Subproject commit 39aa9c9bf5fc2427e41fad2f01ce3796be32172a
|
Subproject commit 3c168aa48ef18b5fe7f4a671a91e299f9ec1e32c
|
||||||
|
|
@ -51,6 +51,7 @@ public:
|
||||||
auto& h = getHeader();
|
auto& h = getHeader();
|
||||||
h.addAndMakeVisible (nextButton);
|
h.addAndMakeVisible (nextButton);
|
||||||
h.addAndMakeVisible (prevButton);
|
h.addAndMakeVisible (prevButton);
|
||||||
|
h.addMouseListener (this, false);
|
||||||
nextButton.onClick = [this] { proc.incWavetable (idx, +1); };
|
nextButton.onClick = [this] { proc.incWavetable (idx, +1); };
|
||||||
prevButton.onClick = [this] { proc.incWavetable (idx, -1); };
|
prevButton.onClick = [this] { proc.incWavetable (idx, -1); };
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +64,44 @@ public:
|
||||||
proc.osc2Table.removeListener (this);
|
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
|
void resized() override
|
||||||
{
|
{
|
||||||
gin::ParamBox::resized();
|
gin::ParamBox::resized();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue