From 911b862f064ab652f1f8ce11c1d1eb72a6f99c1f Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 22 Jun 2016 20:06:30 +0200 Subject: [PATCH] fix(builder): Cap percentage values --- src/services/builder.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) {