File: ramp.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 (33 lines) | stat: -rw-r--r-- 904 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
#pragma once

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

POLYBAR_NS

namespace drawtypes {
  class ramp : public non_copyable_mixin {
   public:
    explicit ramp() = default;
    explicit ramp(vector<label_t>&& icons) : m_icons(forward<decltype(icons)>(icons)) {}

    void add(label_t&& icon);
    void add(label_t&& icon, unsigned weight);
    label_t get(size_t index);
    label_t get_by_percentage(float percentage);
    label_t get_by_percentage_with_borders(float percentage, float min, float max);
    label_t get_by_percentage_with_borders(int percentage, int min, int max);
    operator bool();

   protected:
    vector<label_t> m_icons;
  };

  using ramp_t = shared_ptr<ramp>;

  ramp_t load_ramp(const config& conf, const string& section, string name, bool required = true);
}  // namespace drawtypes

POLYBAR_NS_END