polybar-dwm/include/drawtypes/ramp.hpp
TheDoctor314 55eb19fdc7
feat(ramp): Allow specifying ramp weights (#2505)
* 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.
2021-09-22 21:46:20 +02:00

34 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