1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00

fix(builder): Cap percentage values

This commit is contained in:
Michael Carlberg 2016-06-22 20:06:30 +02:00
parent 8caa95de7f
commit 911b862f06

View file

@ -9,6 +9,7 @@
#include "bar.hpp"
#include "services/builder.hpp"
#include "utils/string.hpp"
#include "utils/math.hpp"
// Private
@ -191,7 +192,7 @@ void Builder::node(std::string str, int font_index, bool add_space)
void Builder::node(drawtypes::Bar *bar, float percentage, bool add_space)
{
this->node(bar->get_output(percentage), add_space);
this->node(bar->get_output(math::cap<float>(percentage, 0, 100)), add_space);
}
void Builder::node(std::unique_ptr<drawtypes::Bar> &bar, float percentage, bool add_space) {
@ -248,7 +249,7 @@ void Builder::node(std::unique_ptr<drawtypes::Icon> &icon, bool add_space) {
}
void Builder::node(drawtypes::Ramp *ramp, float percentage, bool add_space) {
if (*ramp) this->node(ramp->get_by_percentage(percentage), add_space);
if (*ramp) this->node(ramp->get_by_percentage(math::cap<float>(percentage, 0, 100)), add_space);
}
void Builder::node(std::unique_ptr<drawtypes::Ramp> &ramp, float percentage, bool add_space) {