29#include <TGUI/Config.hpp>
30#include <TGUI/Duration.hpp>
31#include <TGUI/Optional.hpp>
50 class TGUI_API
Timer :
public std::enable_shared_from_this<Timer>
54 typedef std::shared_ptr<Timer> Ptr;
69 static std::shared_ptr<Timer>
create(
const std::function<
void()>& callback,
Duration interval,
bool enable =
true);
81 static std::shared_ptr<Timer>
create(
const std::function<
void(std::shared_ptr<Timer>)>& callback,
Duration interval,
bool enable =
true);
139 void setCallback(
const std::function<
void(std::shared_ptr<Timer>)>& callback);
154 static bool updateTime(
Duration elapsedTime);
162 static Optional<Duration> getNextScheduledTime();
169 static void clearTimers();
184 static std::vector<std::shared_ptr<Timer>> m_activeTimers;
186 bool m_repeats =
false;
187 bool m_enabled =
false;
189 std::function<void()> m_callback;
Wrapper for durations.
Definition Duration.hpp:52
Executes callbacks after a certain amount of time.
Definition Timer.hpp:51
bool isEnabled() const
Returns whether the timer is running.
Duration getInterval() const
Returns the interval at which a timer callback is send.
static std::shared_ptr< Timer > create(const std::function< void()> &callback, Duration interval, bool enable=true)
Sets the time that the mouse has to stand still before the tooltip becomes visible.
void setCallback(const std::function< void(std::shared_ptr< Timer >)> &callback)
Changes the callback function that should be called by the timer at each interval.
void restart()
Restarts the timer.
void setInterval(Duration interval)
Changes the interval at which a timer callback is send.
void setEnabled(bool enabled)
Starts or stops a timer.
static void scheduleCallback(std::function< void()> callback, Duration interval=Duration())
Starts a timer.
void setCallback(const std::function< void()> &callback)
Changes the callback function that should be called by the timer at each interval.
static std::shared_ptr< Timer > create(const std::function< void(std::shared_ptr< Timer >)> &callback, Duration interval, bool enable=true)
Sets the time that the mouse has to stand still before the tooltip becomes visible.
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36