Skip to content

Commit

Permalink
Fix jog-hold misfire in jog effect selectors (#64)
Browse files Browse the repository at this point in the history
A simple bool on our timer meant if a jog hold fired while
the subsequent mouse was down you would get a double bump.
A simple 'jogging or not' is not enough but a click counter
does the trick, so move to that.

Closes #62
  • Loading branch information
baconpaul authored May 4, 2024
1 parent cfef23b commit 22d7c75
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src-juce/AWConsolidatedEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,28 +416,29 @@ struct Picker : public juce::Component, public juce::TextEditor::Listener
}
}

bool isJogHeld{false};
uint64_t jogHoldCounter{0};
void startJogHold(int dir)
{
isJogHeld = true;
juce::Timer::callAfterDelay(800, [dir, w = juce::Component::SafePointer(this)]() {
juce::Timer::callAfterDelay(800, [hc = jogHoldCounter, dir, w = juce::Component::SafePointer(this)]() {
if (w)
{
w->doJogHold(dir);
w->doJogHold(dir, hc);
}
});
}

void stopJogHold() { isJogHeld = false; }
void doJogHold(int dir)
void stopJogHold() { jogHoldCounter ++; }
void doJogHold(int dir, uint64_t hc)
{
if (!isJogHeld)
if (hc != jogHoldCounter)
{
return;
}
editor->jog(dir);
juce::Timer::callAfterDelay(200, [dir, w = juce::Component::SafePointer(this)]() {
juce::Timer::callAfterDelay(200, [hc, dir, w = juce::Component::SafePointer(this)]() {
if (w)
{
w->doJogHold(dir);
w->doJogHold(dir, hc);
}
});
}
Expand Down

0 comments on commit 22d7c75

Please sign in to comment.