From 62bbf0daacdd110509f8166e9a1bf162ecb23138 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 19 Mar 2021 12:55:55 +0100 Subject: Fix glitching when using fractional scaling --- src/Entry.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/Entry.cpp') diff --git a/src/Entry.cpp b/src/Entry.cpp index facb615..fdd7225 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -6,18 +6,18 @@ #include #include -const float background_margin_horizontal = 5.0f * QuickMedia::get_ui_scale(); -const float padding_vertical = 3.0f * QuickMedia::get_ui_scale(); -const float background_margin_vertical = 0.0f * QuickMedia::get_ui_scale(); +const float background_margin_horizontal = std::floor(5.0f * QuickMedia::get_ui_scale()); +const float padding_vertical = std::floor(3.0f * QuickMedia::get_ui_scale()); +const float background_margin_vertical = std::floor(0.0f * QuickMedia::get_ui_scale()); namespace QuickMedia { Entry::Entry(const std::string &placeholder_text) : on_submit_callback(nullptr), draw_background(true), - text("", false, 16 * get_ui_scale(), 0.0f), + text("", false, std::floor(16 * get_ui_scale()), 0.0f), width(0.0f), background(sf::Vector2f(1.0f, 1.0f), 7.0f, 10), - placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), 16 * get_ui_scale()) + placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale())) { text.setEditable(true); background.setFillColor(sf::Color(55, 60, 68)); @@ -75,8 +75,8 @@ namespace QuickMedia { void Entry::set_position(const sf::Vector2f &pos) { background.setPosition(pos); - text.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical - 3.0f * get_ui_scale())); - placeholder.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical + 3.0f * get_ui_scale())); + text.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical - std::floor(3.0f * get_ui_scale()))); + placeholder.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical + std::floor(3.0f * get_ui_scale()))); } void Entry::set_max_width(float width) { -- cgit v1.2.3