aboutsummaryrefslogtreecommitdiff
path: root/src/Entry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entry.cpp')
-rw-r--r--src/Entry.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Entry.cpp b/src/Entry.cpp
index b196009..c3ecb40 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -7,17 +7,20 @@
#include <mglpp/window/Window.hpp>
#include <mglpp/graphics/Rectangle.hpp>
#include <mglpp/window/Event.hpp>
-#include <math.h>
namespace QuickMedia {
- static const float background_margin_horizontal = std::floor(5.0f * get_config().scale * get_config().spacing_scale);
- static const float padding_vertical = std::floor(5.0f * get_config().scale * get_config().spacing_scale);
- static const float background_margin_vertical = std::floor(0.0f * get_config().scale * get_config().spacing_scale);
+ static float floor(float v) {
+ return (int)v;
+ }
+
+ static const float background_margin_horizontal = floor(5.0f * get_config().scale * get_config().spacing_scale);
+ static const float padding_vertical = floor(5.0f * get_config().scale * get_config().spacing_scale);
+ static const float background_margin_vertical = floor(0.0f * get_config().scale * get_config().spacing_scale);
Entry::Entry(const std::string &placeholder_text, mgl::Shader *rounded_rectangle_shader) :
on_submit_callback(nullptr),
draw_background(true),
- text("", false, std::floor(get_config().input.font_size * get_config().scale * get_config().font_scale), 0.0f),
+ text("", false, floor(get_config().input.font_size * get_config().scale * get_config().font_scale), 0.0f),
width(0.0f),
background(mgl::vec2f(1.0f, 1.0f), 10.0f * get_config().scale, get_theme().selected_color, rounded_rectangle_shader),
placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN, get_config().input.font_size * get_config().scale * get_config().font_scale)),
@@ -107,7 +110,7 @@ namespace QuickMedia {
void Entry::set_position(const mgl::vec2f &pos) {
background.set_position(pos);
text.set_position(pos + mgl::vec2f(background_margin_horizontal, background_margin_vertical));
- placeholder.set_position(pos + mgl::vec2f(background_margin_horizontal, background_margin_vertical + std::floor(-1.0f * get_config().scale)));
+ placeholder.set_position(pos + mgl::vec2f(background_margin_horizontal, background_margin_vertical + floor(-1.0f * get_config().scale)));
}
void Entry::set_max_width(float width) {
@@ -121,7 +124,7 @@ namespace QuickMedia {
float Entry::get_height() {
text.updateGeometry();
- return std::floor(text.getHeight() + background_margin_vertical * 2.0f + padding_vertical * 2.0f);
+ return floor(text.getHeight() + background_margin_vertical * 2.0f + padding_vertical * 2.0f);
}
const std::string& Entry::get_text() const {