diff --git a/src/services/builder.cpp b/src/services/builder.cpp index b8920193..f62f187f 100644 --- a/src/services/builder.cpp +++ b/src/services/builder.cpp @@ -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(percentage, 0, 100)), add_space); } void Builder::node(std::unique_ptr &bar, float percentage, bool add_space) { @@ -248,7 +249,7 @@ void Builder::node(std::unique_ptr &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(percentage, 0, 100)), add_space); } void Builder::node(std::unique_ptr &ramp, float percentage, bool add_space) {