|
Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Generic debouncer that delays execution of a callback until a specified time period has elapsed without the debounce being called again. More...
#include <src/utils/debouncer.h>


Public Types | |
| using | Callback = std::function<void ()> |
Public Member Functions | |
| Debouncer (std::chrono::milliseconds delay, Callback callback, QObject *parent=nullptr) | |
| Construct a debouncer. | |
| void | operator() () |
| Call this to schedule the callback execution. | |
| void | debounce () |
| Alternative method name for scheduling callback execution. | |
| void | set_delay (std::chrono::milliseconds delay) |
| Set the delay for future debounce operations. | |
| std::chrono::milliseconds | get_delay () const |
| Get the current delay. | |
| bool | is_pending () const |
| Check if there's a pending callback execution. | |
| void | cancel () |
| Cancel any pending callback execution. | |
Generic debouncer that delays execution of a callback until a specified time period has elapsed without the debounce being called again.
This is useful for scenarios where you want to batch multiple rapid events into a single operation, such as:
Definition at line 26 of file debouncer.h.
| using zrythm::utils::Debouncer::Callback = std::function<void ()> |
Definition at line 31 of file debouncer.h.
| zrythm::utils::Debouncer::Debouncer | ( | std::chrono::milliseconds | delay, |
| Callback | callback, | ||
| QObject * | parent = nullptr ) |
Construct a debouncer.
| delay | The delay to wait before executing the callback |
| callback | The function to call when debounce period expires |
| parent | QObject parent |
| void zrythm::utils::Debouncer::operator() | ( | ) |
Call this to schedule the callback execution.
If called multiple times before the delay expires, the timer will restart and the callback will only execute once after the final call.
| void zrythm::utils::Debouncer::set_delay | ( | std::chrono::milliseconds | delay | ) |
Set the delay for future debounce operations.
| delay | New delay duration |