aboutsummaryrefslogtreecommitdiff
path: root/src/SearchBar.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-03-19 12:22:25 +0100
committerdec05eba <dec05eba@protonmail.com>2021-03-19 12:22:25 +0100
commitc207201a4a5a47e4ad286ba7371e4176c8ed5056 (patch)
tree253b84dae998a7506042ef924caf8beb498c6ba9 /src/SearchBar.cpp
parent5f022066684f8ed6c4b827fabf8554d8730add2f (diff)
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
Diffstat (limited to 'src/SearchBar.cpp')
-rw-r--r--src/SearchBar.cpp21
1 files changed, 11 insertions, 10 deletions
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 <SFML/Window/Event.hpp>
#include <SFML/Window/Clipboard.hpp>
#include <SFML/Graphics/RenderWindow.hpp>
@@ -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);