File: animation.hpp

package info (click to toggle)
polybar 3.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,108 kB
  • sloc: cpp: 30,424; python: 3,750; sh: 284; makefile: 83
file content (47 lines) | stat: -rw-r--r-- 1,125 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#pragma once

#include <atomic>
#include <chrono>

#include "common.hpp"
#include "components/config.hpp"
#include "drawtypes/label.hpp"
#include "utils/mixins.hpp"

POLYBAR_NS

namespace chrono = std::chrono;

namespace drawtypes {
  class animation : public non_copyable_mixin {
   public:
    explicit animation(unsigned int framerate_ms) : m_framerate_ms(framerate_ms) {}
    explicit animation(vector<label_t>&& frames, int framerate_ms)
        : m_frames(move(frames))
        , m_framerate_ms(framerate_ms)
        , m_framecount(m_frames.size())
        , m_frame(m_frames.size() - 1) {}

    void add(label_t&& frame);
    void increment();

    label_t get() const;
    unsigned int framerate() const;

    explicit operator bool() const;

   protected:
    vector<label_t> m_frames;

    unsigned int m_framerate_ms = 1000;
    size_t m_framecount = 0;
    std::atomic_size_t m_frame{0_z};
  };

  using animation_t = shared_ptr<animation>;

  animation_t load_animation(
      const config& conf, const string& section, string name = "animation", bool required = true);
}  // namespace drawtypes

POLYBAR_NS_END