KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_debounced_action.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <functional>
23
24#include <wx/timer.h>
25
26
33class WX_DEBOUNCED_ACTION : public wxTimer
34{
35public:
36 using ACTION_FN = std::function<void()>;
37
42 WX_DEBOUNCED_ACTION( ACTION_FN aAction, int aDelayMs );
43
46 void Restart();
47
52 void Cancel();
53
55 constexpr static int TEXT_INPUT_DEBOUNCE_MS = 200;
57 constexpr static int HOVER_PREVIEW_DEBOUNCE_MS = 400;
58
59protected:
60 void Notify() override;
61
62private:
65};
static constexpr int TEXT_INPUT_DEBOUNCE_MS
A typical debounce period for text input events, in milliseconds.
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 t...
std::function< void()> ACTION_FN
void Cancel()
Stop the timer.
static constexpr int HOVER_PREVIEW_DEBOUNCE_MS
A typical debounce period for hover preview events, in milliseconds.