File: progressbar.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 (45 lines) | stat: -rw-r--r-- 1,109 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
#pragma once

#include "common.hpp"
#include "components/builder.hpp"
#include "components/config.hpp"
#include "components/types.hpp"
#include "utils/mixins.hpp"

POLYBAR_NS

namespace drawtypes {
  class progressbar : public non_copyable_mixin {
   public:
    explicit progressbar(const bar_settings& bar, int width, string format);

    void set_fill(label_t&& fill);
    void set_empty(label_t&& empty);
    void set_indicator(label_t&& indicator);
    void set_gradient(bool mode);
    void set_colors(vector<rgba>&& colors);

    string output(float percentage);

   protected:
    void fill(unsigned int perc, unsigned int fill_width);

   private:
    unique_ptr<builder> m_builder;
    vector<rgba> m_colors;
    string m_format;
    unsigned int m_width;
    unsigned int m_colorstep = 1;
    bool m_gradient = false;

    label_t m_fill;
    label_t m_empty;
    label_t m_indicator;
  };

  using progressbar_t = shared_ptr<progressbar>;

  progressbar_t load_progressbar(const bar_settings& bar, const config& conf, const string& section, string name);
}  // namespace drawtypes

POLYBAR_NS_END