Skip to content
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
32 changes: 29 additions & 3 deletions include/sst/jucegui/components/ComponentBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,44 @@ struct WithIdleTimer
{
registeredItems.insert(this);
delayInMs = 1000;
idleActive = false;
}
void endTimer()
{
registeredItems.erase(this);
// Remember to end the hover if active when we end the timer
if (idleActive && onIdleHoverEnd)
{
onIdleHoverEnd();
}
idleActive = false;
}
void endTimer() { registeredItems.erase(this); }
void resetTimer(const juce::MouseEvent &e)
{
if (e.x != lx || e.y != ly)
{
if (delayInMs <= 0 && onIdleHoverEnd)
if ((idleActive || delayInMs <= 0) && onIdleHoverEnd)
{
onIdleHoverEnd();
}
idleActive = false;

delayInMs = 1000;
}
lx = e.x;
ly = e.y;
}
uint64_t delayInMs{1};

void immediatelyInitiateIdleAction(int endAfter) // endAfter = -1 for no dismiss
{
delayInMs = endAfter;
if (onIdleHover)
onIdleHover();
idleActive = true;
delayToUnIdleInMs = endAfter;
}
int64_t delayInMs{1}, delayToUnIdleInMs{0};
bool idleActive{false};

int lx{0}, ly{0};

Expand All @@ -67,6 +89,10 @@ template <typename T> struct EditableComponentBase : public WithIdleTimer

std::function<void(void)> onBeginEdit = []() {};
std::function<void(void)> onEndEdit = []() {};

// Wheel calls begin and end but we may want to know it happened for tooltips etc
std::function<void(void)> onWheelEditOccurred = []() {};

std::function<void(const juce::ModifierKeys &m)> onPopupMenu = [](const juce::ModifierKeys &m) {
};

Expand Down
3 changes: 3 additions & 0 deletions include/sst/jucegui/components/DiscreteParamEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ struct DiscreteParamEditor
}
wheel0 = 0;
}

if (onWheelEditOccurred)
onWheelEditOccurred();
}

bool keyPressed(const juce::KeyPress &key) override;
Expand Down
13 changes: 13 additions & 0 deletions src/sst/jucegui/components/ComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ struct wiTimer : juce::Timer
{
w->onIdleHover();
}
w->idleActive = true;
}
}
if (w->delayToUnIdleInMs > 0)
{
w->delayToUnIdleInMs -= WithIdleTimer::idleTimeMS;
if (w->delayToUnIdleInMs <= 0 && w->idleActive)
{
if (w->onIdleHoverEnd)
{
w->onIdleHoverEnd();
}
w->idleActive = false;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/sst/jucegui/components/ContinuousParamEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ void ContinuousParamEditor::mouseWheelMove(const juce::MouseEvent &e,
notifyAccessibleChange();
}
onEndEdit();

if (onWheelEditOccurred)
onWheelEditOccurred();

repaint();
}

Expand Down