forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimer.h
57 lines (41 loc) · 1.02 KB
/
timer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Aseprite UI Library
// Copyright (C) 2020-2022 Igara Studio S.A.
// Copyright (C) 2001-2016 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef UI_TIMER_H_INCLUDED
#define UI_TIMER_H_INCLUDED
#pragma once
#include "base/disable_copying.h"
#include "base/time.h"
#include "obs/signal.h"
namespace ui {
class Widget;
class Timer {
public:
Timer(int interval, Widget* owner = nullptr);
virtual ~Timer();
int interval() const { return m_interval; }
void setInterval(int interval);
bool isRunning() const {
return m_running;
}
void start();
void stop();
void tick();
obs::signal<void()> Tick;
static void pollTimers();
static bool haveTimers();
static bool getNextTimeout(double& timeout);
protected:
virtual void onTick();
private:
Widget* m_owner;
int m_interval;
bool m_running;
base::tick_t m_lastTick;
DISABLE_COPYING(Timer);
};
} // namespace ui
#endif