aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-17 19:18:19 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-17 19:18:34 +0100
commit02e029ed40f801e0710b09062069e7083cd30b93 (patch)
treeb3bd567ad0c03074064d62d32a876920aa58fab4 /src/gui
parentd4cd63129ae5dff8fd69525424e0f8cb9ae1a905 (diff)
Add local anime tracking. Check readme for more info about local_anime config
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/Button.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gui/Button.cpp b/src/gui/Button.cpp
index 13bc8c6..bf9c174 100644
--- a/src/gui/Button.cpp
+++ b/src/gui/Button.cpp
@@ -4,9 +4,12 @@
#include <mglpp/system/FloatRect.hpp>
#include <mglpp/window/Window.hpp>
#include <mglpp/window/Event.hpp>
-#include <cmath>
namespace QuickMedia {
+ static float floor(float v) {
+ return (int)v;
+ }
+
static const float PADDING_Y = 5.0f;
Button::Button(const std::string &label, mgl::Font *font, float width, mgl::Shader *rounded_rectangle_shader, float scale) :
@@ -14,7 +17,7 @@ namespace QuickMedia {
background(mgl::vec2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().shade_color, rounded_rectangle_shader),
scale(scale)
{
- background.set_size(mgl::vec2f(std::floor(width * scale), get_height()));
+ background.set_size(mgl::vec2f(floor(width * scale), get_height()));
set_position(mgl::vec2f(0.0f, 0.0f));
}
@@ -60,8 +63,8 @@ namespace QuickMedia {
const auto label_bounds = label.get_bounds();
mgl::vec2f label_pos(pos + background.get_size() * 0.5f - label_bounds.size * 0.5f - mgl::vec2f(0.0f, 5.0f * scale));
- label_pos.x = std::floor(label_pos.x);
- label_pos.y = std::floor(label_pos.y);
+ label_pos.x = floor(label_pos.x);
+ label_pos.y = floor(label_pos.y);
label.set_position(label_pos);
}
@@ -74,6 +77,6 @@ namespace QuickMedia {
}
float Button::get_height() {
- return std::floor((PADDING_Y * 2.0f) * scale + label.get_bounds().size.y);
+ return floor((PADDING_Y * 2.0f) * scale + label.get_bounds().size.y);
}
} \ No newline at end of file