2016-05-30 23:58:58 -04:00
|
|
|
#pragma once
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2019-03-09 00:14:39 -05:00
|
|
|
#include <atomic>
|
2016-11-20 17:04:31 -05:00
|
|
|
#include <chrono>
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
#include "common.hpp"
|
|
|
|
#include "components/config.hpp"
|
|
|
|
#include "drawtypes/label.hpp"
|
|
|
|
#include "utils/mixins.hpp"
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
namespace chrono = std::chrono;
|
|
|
|
|
2016-06-14 23:32:35 -04:00
|
|
|
namespace drawtypes {
|
|
|
|
class animation : public non_copyable_mixin<animation> {
|
|
|
|
public:
|
2019-03-09 00:14:39 -05:00
|
|
|
explicit animation(unsigned int framerate_ms) : m_framerate_ms(framerate_ms) {}
|
2018-12-23 16:59:10 -05:00
|
|
|
explicit animation(vector<label_t>&& frames, int framerate_ms)
|
2019-03-09 00:14:39 -05:00
|
|
|
: m_frames(move(frames))
|
2016-06-14 23:32:35 -04:00
|
|
|
, m_framerate_ms(framerate_ms)
|
|
|
|
, m_framecount(m_frames.size())
|
2019-03-09 00:14:39 -05:00
|
|
|
, m_frame(m_frames.size() - 1) {}
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2018-12-23 16:59:10 -05:00
|
|
|
void add(label_t&& frame);
|
2019-03-09 00:14:39 -05:00
|
|
|
void increment();
|
2016-05-19 10:41:06 -04:00
|
|
|
|
2019-03-09 00:14:39 -05:00
|
|
|
label_t get() const;
|
|
|
|
unsigned int framerate() const;
|
|
|
|
|
|
|
|
explicit operator bool() const;
|
2016-11-02 15:22:45 -04:00
|
|
|
|
2019-03-09 00:14:39 -05:00
|
|
|
protected:
|
2018-12-23 16:59:10 -05:00
|
|
|
vector<label_t> m_frames;
|
2019-03-09 00:14:39 -05:00
|
|
|
|
|
|
|
unsigned int m_framerate_ms = 1000;
|
|
|
|
size_t m_framecount = 0;
|
|
|
|
std::atomic_size_t m_frame{0_z};
|
2016-05-19 10:41:06 -04:00
|
|
|
};
|
|
|
|
|
2016-10-25 01:10:03 -04:00
|
|
|
using animation_t = shared_ptr<animation>;
|
|
|
|
|
2016-11-25 07:55:15 -05:00
|
|
|
animation_t load_animation(
|
|
|
|
const config& conf, const string& section, string name = "animation", bool required = true);
|
2019-03-09 00:14:39 -05:00
|
|
|
} // namespace drawtypes
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|