mirror of
https://github.com/polybar/polybar.git
synced 2024-11-11 13:50:56 -05:00
55eb19fdc7
* feat(ramp) Implement ramp weights *Add test for ramp weights *[drawtypes/ramp] Implement ramp weights Simply clone `label_t` weight no. of times in the icon list This helps us not to change any of the calculations. *Fix silly bug Forgot to add a hyphen for the `weight` parameter. Co-authored-by: Patrick Ziegler <p.ziegler96@gmail.com> *doc: add #1750 to CHANGELOG * Fix compile error in ramp test Use std::make_shared.
33 lines
886 B
C++
33 lines
886 B
C++
#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<ramp> {
|
|
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);
|
|
}
|
|
|
|
POLYBAR_NS_END
|