|
KiCad PCB EDA Suite
|
Debounces an action: runs it only after a quiet period following the last trigger. More...
#include <wx_debounced_action.h>
Public Types | |
| using | ACTION_FN = std::function<void()> |
Public Member Functions | |
| WX_DEBOUNCED_ACTION (ACTION_FN aAction, int aDelayMs) | |
| void | Restart () |
| (Re)start the delay: the action runs by the delay after the call, unless another one is made within the delay period. | |
| void | Cancel () |
| Stop the timer. | |
Static Public Attributes | |
| static constexpr int | TEXT_INPUT_DEBOUNCE_MS = 200 |
| A typical debounce period for text input events, in milliseconds. | |
| static constexpr int | HOVER_PREVIEW_DEBOUNCE_MS = 400 |
| A typical debounce period for hover preview events, in milliseconds. | |
Protected Member Functions | |
| void | Notify () override |
Private Attributes | |
| ACTION_FN | m_action |
| int | m_delayMs |
Debounces an action: runs it only after a quiet period following the last trigger.
Call Restart() to trigger the debounce timer, and on every (potential) trigger. Call Cancel() to drop a pending action.
Definition at line 33 of file wx_debounced_action.h.
| using WX_DEBOUNCED_ACTION::ACTION_FN = std::function<void()> |
Definition at line 36 of file wx_debounced_action.h.
| WX_DEBOUNCED_ACTION::WX_DEBOUNCED_ACTION | ( | ACTION_FN | aAction, |
| int | aDelayMs ) |
| aAction | the action to run when the delay elapses. |
| aDelayMs | the period after a trigger when the action runs |
Definition at line 25 of file wx_debounced_action.cpp.
| void WX_DEBOUNCED_ACTION::Cancel | ( | ) |
Stop the timer.
Any pending action will be canceled.
Does nothing when none is pending. You must do this if the object the action callback will use is about to be destroyed.
Definition at line 41 of file wx_debounced_action.cpp.
|
overrideprotected |
Definition at line 47 of file wx_debounced_action.cpp.
References m_action.
| void WX_DEBOUNCED_ACTION::Restart | ( | ) |
(Re)start the delay: the action runs by the delay after the call, unless another one is made within the delay period.
Definition at line 33 of file wx_debounced_action.cpp.
References m_delayMs.
|
staticconstexpr |
A typical debounce period for hover preview events, in milliseconds.
Definition at line 57 of file wx_debounced_action.h.
|
private |
Definition at line 63 of file wx_debounced_action.h.
Referenced by Notify(), and WX_DEBOUNCED_ACTION().
|
private |
Definition at line 64 of file wx_debounced_action.h.
Referenced by Restart(), and WX_DEBOUNCED_ACTION().
|
staticconstexpr |
A typical debounce period for text input events, in milliseconds.
Definition at line 55 of file wx_debounced_action.h.