Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start on Hover remediation #6014

Merged
merged 1 commit into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/surge-xt/gui/SurgeGUICallbackInterfaces.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,25 @@ struct IComponentTagValue
virtual float getValue() const = 0;
virtual void setValue(float) = 0;

virtual void startHover(const juce::Point<float> &) {}
virtual void endHover() {}
int hoverCount{0};
virtual int incrementHover()
{
hoverCount++;
return hoverCount;
}
virtual int decrementHover()
{
hoverCount--;
return hoverCount;
}
virtual void forceEndHover()
{
hoverCount = 1;
endHover();
}

virtual void startHover(const juce::Point<float> &) { incrementHover(); }
virtual void endHover() { decrementHover(); }

juce::Component *asJuceComponent()
{
Expand Down
4 changes: 3 additions & 1 deletion src/surge-xt/gui/SurgeJUCEHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ inline std::function<void(int)> makeEndHoverCallback(Surge::GUI::IComponentTagVa
if (!that)
return [](int) {};

that->incrementHover();

return
[safethat = juce::Component::SafePointer<juce::Component>(that->asJuceComponent())](int x) {
if (safethat)
{
auto igtv = dynamic_cast<Surge::GUI::IComponentTagValue *>(safethat.getComponent());
if (igtv)
igtv->endHover();
igtv->forceEndHover();
}
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/surge-xt/gui/widgets/ModulatableSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,9 @@ void ModulatableSlider::onSkinChanged()
void ModulatableSlider::mouseEnter(const juce::MouseEvent &event) { startHover(event.position); }
void ModulatableSlider::startHover(const juce::Point<float> &p)
{
if (incrementHover() > 1)
return;

enqueueFutureInfowindow(SurgeGUIEditor::InfoQAction::START, p);
isHovered = true;
auto sge = firstListenerOfType<SurgeGUIEditor>();
Expand All @@ -391,6 +394,9 @@ void ModulatableSlider::mouseExit(const juce::MouseEvent &event) { endHover(); }

void ModulatableSlider::endHover()
{
if (decrementHover() != 0)
return;

enqueueFutureInfowindow(SurgeGUIEditor::InfoQAction::LEAVE);
isHovered = false;
auto sge = firstListenerOfType<SurgeGUIEditor>();
Expand Down
6 changes: 6 additions & 0 deletions src/surge-xt/gui/widgets/MultiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ void MultiSwitch::mouseEnter(const juce::MouseEvent &event) { startHover(event.p

void MultiSwitch::startHover(const juce::Point<float> &p)
{
if (incrementHover() > 1)
return;

if (everDragged && isMouseDown) // don't change hover state during a drag
{
hoverSelection = getIntegerValue();
Expand All @@ -261,6 +264,9 @@ void MultiSwitch::mouseExit(const juce::MouseEvent &event) { endHover(); }

void MultiSwitch::endHover()
{
if (decrementHover() != 0)
return;

isHovered = false;
repaint();
}
Expand Down