mirror of
https://codeberg.org/armin/wavetable.git
synced 2026-09-01 05:50:46 +02:00
Add click to drag wt pos
This commit is contained in:
parent
14304809b7
commit
53897dd461
1 changed files with 29 additions and 2 deletions
|
|
@ -43,6 +43,7 @@ public:
|
||||||
wt->setName ("wt");
|
wt->setName ("wt");
|
||||||
wt->setWavetables (idx == 0 ? &proc.osc1Tables : &proc.osc2Tables);
|
wt->setWavetables (idx == 0 ? &proc.osc1Tables : &proc.osc2Tables);
|
||||||
wt->onFileDrop = [this] (const juce::File& f) { loadUserWavetable (f); };
|
wt->onFileDrop = [this] (const juce::File& f) { loadUserWavetable (f); };
|
||||||
|
wt->addMouseListener (this, false);
|
||||||
addControl (wt);
|
addControl (wt);
|
||||||
|
|
||||||
auto addButton = new gin::SVGButton ("add", gin::Assets::add);
|
auto addButton = new gin::SVGButton ("add", gin::Assets::add);
|
||||||
|
|
@ -112,10 +113,35 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mouseDown (const juce::MouseEvent& e) override
|
||||||
|
{
|
||||||
|
if (e.originalComponent != wt) return;
|
||||||
|
|
||||||
|
auto& pos = *proc.oscParams[idx].pos;
|
||||||
|
pos.beginUserAction();
|
||||||
|
|
||||||
|
mouseDownValue = pos.getUserValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void mouseDrag (const juce::MouseEvent& e) override
|
||||||
|
{
|
||||||
|
if (e.originalComponent != wt) return;
|
||||||
|
|
||||||
|
auto& pos = *proc.oscParams[idx].pos;
|
||||||
|
|
||||||
|
pos.setUserValue (mouseDownValue - e.getDistanceFromDragStartY());
|
||||||
|
}
|
||||||
|
|
||||||
void mouseUp (const juce::MouseEvent& e) override
|
void mouseUp (const juce::MouseEvent& e) override
|
||||||
{
|
{
|
||||||
auto& h = getHeader();
|
auto& h = getHeader();
|
||||||
if (e.originalComponent == &h && e.mouseWasClicked() && e.x >= prevButton.getRight() && e.x <= nextButton.getX())
|
|
||||||
|
if (e.originalComponent == wt)
|
||||||
|
{
|
||||||
|
auto& pos = *proc.oscParams[idx].pos;
|
||||||
|
pos.endUserAction();
|
||||||
|
}
|
||||||
|
else if (e.originalComponent == &h && e.mouseWasClicked() && e.x >= prevButton.getRight() && e.x <= nextButton.getX())
|
||||||
{
|
{
|
||||||
juce::StringArray tables;
|
juce::StringArray tables;
|
||||||
for (auto i = 0; i < BinaryData::namedResourceListSize; i++)
|
for (auto i = 0; i < BinaryData::namedResourceListSize; i++)
|
||||||
|
|
@ -186,6 +212,7 @@ public:
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
gin::ParamComponent::Ptr detune, spread;
|
gin::ParamComponent::Ptr detune, spread;
|
||||||
gin::WavetableComponent* wt;
|
gin::WavetableComponent* wt;
|
||||||
|
float mouseDownValue;
|
||||||
|
|
||||||
gin::CoalescedTimer timer;
|
gin::CoalescedTimer timer;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue