From c207201a4a5a47e4ad286ba7371e4176c8ed5056 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 19 Mar 2021 12:22:25 +0100 Subject: Start on touch support, add support for ui scaling, revert back to old get_message_by_id method for matrix to support loading user display names in replies --- src/SearchBar.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/SearchBar.cpp') diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp index 9b5e882..8232033 100644 --- a/src/SearchBar.cpp +++ b/src/SearchBar.cpp @@ -1,6 +1,7 @@ #include "../include/SearchBar.hpp" #include "../include/Scale.hpp" #include "../include/ResourceLoader.hpp" +#include "../include/Utils.hpp" #include #include #include @@ -11,11 +12,11 @@ static const sf::Color text_placeholder_color(255, 255, 255, 100); static const sf::Color front_color(55, 60, 68); -static const float background_margin_horizontal = 15.0f; -static const float PADDING_HORIZONTAL = 25.0f; -static const float padding_top = 10.0f; -static const float padding_bottom = 15.0f; -static const float background_margin_vertical = 4.0f; +static const float background_margin_horizontal = 10.0f + 5.0f * QuickMedia::get_ui_scale(); +static const float PADDING_HORIZONTAL = 25.0f * QuickMedia::get_ui_scale(); +static const float padding_top = 10.0f * QuickMedia::get_ui_scale(); +static const float padding_bottom = 15.0f * QuickMedia::get_ui_scale(); +static const float background_margin_vertical = 4.0f * QuickMedia::get_ui_scale(); namespace QuickMedia { SearchBar::SearchBar(sf::Texture *plugin_logo, const std::string &placeholder, bool input_masked) : @@ -26,8 +27,8 @@ namespace QuickMedia { text_autosearch_delay(0), autocomplete_search_delay(0), caret_visible(true), - text(placeholder, *FontLoader::get_font(FontLoader::FontType::LATIN), 16), - autocomplete_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), 16), + text(placeholder, *FontLoader::get_font(FontLoader::FontType::LATIN), 16 * get_ui_scale()), + autocomplete_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), 16 * get_ui_scale()), background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10), placeholder_str(placeholder), show_placeholder(true), @@ -144,14 +145,14 @@ namespace QuickMedia { sf::Vector2f texture_size_f(texture_size.x, texture_size.y); sf::Vector2f new_size = wrap_to_size(texture_size_f, sf::Vector2f(200.0f, one_line_height)); plugin_logo_sprite.setScale(get_ratio(texture_size_f, new_size)); - plugin_logo_sprite.setPosition(25.0f, padding_top + vertical_pos); + plugin_logo_sprite.setPosition(25.0f, padding_top + vertical_pos + rect_height * 0.5f - plugin_logo_sprite.getTexture()->getSize().y * plugin_logo_sprite.getScale().y * 0.5f); offset_x = 25.0f + new_size.x + 25.0f; } - const float width = std::floor(window_size.x - offset_x - padding_horizontal); + const float width = std::floor(window_size.x - offset_x - 25.0f); background.setSize(sf::Vector2f(width, rect_height)); shade.setSize(sf::Vector2f(window_size.x, padding_top + rect_height + padding_bottom)); - caret.setSize(sf::Vector2f(2.0f, text.getCharacterSize() + 2.0f)); + caret.setSize(sf::Vector2f(2.0f * get_ui_scale(), text.getCharacterSize() + 2.0f * get_ui_scale())); background_shadow.setSize(sf::Vector2f(window_size.x, 5.0f)); background.setPosition(offset_x, padding_top + vertical_pos); -- cgit v1.2.3