1 #ifndef TERMOX_SYSTEM_ANIMATION_ENGINE_HPP
2 #define TERMOX_SYSTEM_ANIMATION_ENGINE_HPP
6 #include <termox/common/lockable.hpp>
7 #include <termox/common/timer.hpp>
8 #include <termox/system/event_loop.hpp>
9 #include <termox/system/event_queue.hpp>
17 using Clock_t = Timer::Clock_t;
18 using Duration_t = Timer::Duration_t;
19 using Time_point = Timer::Time_point;
23 Time_point last_event_time;
26 static auto constexpr default_interval = Duration_t{100};
39 [[nodiscard]]
auto is_empty() const ->
bool;
51 std::map<
Widget*, Registered_data> subjects_;
57 auto get_timer_events() -> std::vector<Timer_event>&;
60 void loop_function(Event_queue& queue);
Registers Widgets with intervals to send timer events.
Definition: animation_engine.hpp:15
auto is_running() const -> bool
Return true if start() has been called, and hasn't been exited.
Definition: animation_engine.cpp:54
void register_widget(Widget &w, Duration_t interval)
Register to start sending Timer_events to w every interval.
Definition: animation_engine.cpp:24
auto is_empty() const -> bool
Return true if there are no registered widgets.
Definition: animation_engine.cpp:41
void start()
Start another thread that waits on intervals and sents timer events.
Definition: animation_engine.cpp:43
void stop()
Sends exit signal and waits for animation thread to exit.
Definition: animation_engine.cpp:48
void unregister_widget(Widget &w)
Stop the given Widget from being sent Timer_events.
Definition: animation_engine.cpp:35
Calls on loop_function(), and then processes the Event_queue.
Definition: event_loop.hpp:17
Definition: lockable.hpp:8
Timer class where begin() and wait() are used to block for a given interval.
Definition: timer.hpp:10
Definition: animation_engine.hpp:21
Frames Per Second.
Definition: fps.hpp:8