mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
32 lines
820 B
C++
32 lines
820 B
C++
#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 };
|
|
};
|