From fa815c3eee27cdae69b2e765b03de62a13f6379d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 4 Sep 2021 02:31:10 +0200 Subject: Make font sizes customizable with a config file, see example-config.json. Remove environment variables --- src/Entry.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Entry.cpp') diff --git a/src/Entry.cpp b/src/Entry.cpp index 771e2fd..f35e34f 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -1,5 +1,6 @@ #include "../include/Entry.hpp" #include "../include/ResourceLoader.hpp" +#include "../include/Config.hpp" #include "../include/Utils.hpp" #include "../include/Theme.hpp" #include @@ -8,17 +9,17 @@ #include namespace QuickMedia { - static const float background_margin_horizontal = std::floor(5.0f * get_ui_scale()); - static const float padding_vertical = std::floor(5.0f * get_ui_scale()); - static const float background_margin_vertical = std::floor(0.0f * get_ui_scale()); + static const float background_margin_horizontal = std::floor(5.0f * get_config().scale); + static const float padding_vertical = std::floor(5.0f * get_config().scale); + static const float background_margin_vertical = std::floor(0.0f * get_config().scale); Entry::Entry(const std::string &placeholder_text, sf::Shader *rounded_rectangle_shader) : on_submit_callback(nullptr), draw_background(true), - text("", false, std::floor(16 * get_ui_scale() * get_font_scale()), 0.0f), + text("", false, std::floor(get_config().input.font_size * get_config().scale * get_config().font_scale), 0.0f), width(0.0f), background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().selected_color, rounded_rectangle_shader), - placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale() * get_font_scale())), + placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(get_config().input.font_size * get_config().scale * get_config().font_scale)), mouse_left_inside(false) { text.setEditable(true); @@ -107,7 +108,7 @@ namespace QuickMedia { void Entry::set_position(const sf::Vector2f &pos) { background.set_position(pos); text.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical)); - placeholder.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical + std::floor(5.0f * get_ui_scale()))); + placeholder.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical + std::floor(5.0f * get_config().scale))); } void Entry::set_max_width(float width) { -- cgit v1.2.3