summaryrefslogtreecommitdiff
path: root/LibCore/CTimer.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-12 00:09:45 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-12 00:09:45 +0200
commit47a29821190cbb5b239f053ae0d18e13bb420420 (patch)
tree4b963cbdd98c1f788e03d690a426b005ae9cc495 /LibCore/CTimer.h
parent667e678aa6a37c4df1b4a72a09ef4069ac003f3c (diff)
downloadserenity-47a29821190cbb5b239f053ae0d18e13bb420420.zip
LibCore: Move LibGUI/GTimer to LibCore/CTimer.
Diffstat (limited to 'LibCore/CTimer.h')
-rw-r--r--LibCore/CTimer.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/LibCore/CTimer.h b/LibCore/CTimer.h
new file mode 100644
index 0000000000..349917eae4
--- /dev/null
+++ b/LibCore/CTimer.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <LibCore/CObject.h>
+#include <AK/Function.h>
+
+class CTimer final : public CObject {
+public:
+ explicit CTimer(CObject* parent = nullptr);
+ virtual ~CTimer() override;
+
+ void start();
+ void start(int interval);
+ void stop();
+
+ bool is_active() const { return m_active; }
+ int interval() const { return m_interval; }
+ void set_interval(int interval) { m_interval = interval; }
+
+ bool is_single_shot() const { return m_single_shot; }
+ void set_single_shot(bool single_shot) { m_single_shot = single_shot; }
+
+ Function<void()> on_timeout;
+
+ virtual const char* class_name() const override { return "CTimer"; }
+
+private:
+ virtual void timer_event(CTimerEvent&) override;
+
+ bool m_active { false };
+ bool m_single_shot { false };
+ int m_interval { 0 };
+};