aboutsummaryrefslogtreecommitdiff
path: root/src/SearchBar.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-02-17 19:18:19 +0100
committerdec05eba <dec05eba@protonmail.com>2022-02-17 19:18:34 +0100
commit02e029ed40f801e0710b09062069e7083cd30b93 (patch)
treeb3bd567ad0c03074064d62d32a876920aa58fab4 /src/SearchBar.cpp
parentd4cd63129ae5dff8fd69525424e0f8cb9ae1a905 (diff)
Add local anime tracking. Check readme for more info about local_anime config
Diffstat (limited to 'src/SearchBar.cpp')
-rw-r--r--src/SearchBar.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index 6d790ad..71e662e 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -8,16 +8,19 @@
#include <mglpp/system/Utf8.hpp>
#include <mglpp/graphics/Texture.hpp>
#include <mglpp/window/Window.hpp>
-#include <cmath>
#include <assert.h>
// TODO: Use a seperate placeholder mgl::Text instead of switching the text to placeholder text....
namespace QuickMedia {
- static const float background_margin_horizontal = std::floor(15.0f * get_config().scale * get_config().spacing_scale);
- static const float padding_top_default = std::floor(10.0f * get_config().scale * get_config().spacing_scale);
- static const float padding_bottom_default = std::floor(15.0f * get_config().scale * get_config().spacing_scale);
- static const float background_margin_vertical = std::floor(4.0f * get_config().scale * get_config().spacing_scale);
+ static float floor(float v) {
+ return (int)v;
+ }
+
+ static const float background_margin_horizontal = floor(15.0f * get_config().scale);
+ static const float padding_top_default = floor(10.0f * get_config().scale * get_config().spacing_scale);
+ static const float padding_bottom_default = floor(15.0f * get_config().scale * get_config().spacing_scale);
+ static const float background_margin_vertical = floor(4.0f * get_config().scale * get_config().spacing_scale);
static const int character_size = get_config().search.font_size * get_config().scale * get_config().font_scale;
SearchBar::SearchBar(mgl::Texture *plugin_logo, mgl::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked) :
@@ -73,7 +76,7 @@ namespace QuickMedia {
} else {
window.draw(text);
if(show_placeholder || text.get_string().empty())
- caret.set_position(text.get_position() - mgl::vec2f(2.0f, 0.0f) + mgl::vec2f(0.0f, character_size * 0.4f));
+ caret.set_position(text.get_position() + mgl::vec2f(0.0f, character_size * 0.4f));
else
caret.set_position(text.find_character_pos(text.get_string().size()) + mgl::vec2f(0.0f, character_size * 0.4f));
}
@@ -156,30 +159,30 @@ namespace QuickMedia {
draw_logo = false;
float font_height = character_size + 7.0f;
- float rect_height = std::floor(font_height + background_margin_vertical * 2.0f);
+ float rect_height = floor(font_height + background_margin_vertical * 2.0f);
float offset_x;
if(draw_logo) {
- float one_line_height = std::floor(character_size + 8.0f + background_margin_vertical * 2.0f);
+ float one_line_height = floor(character_size + 8.0f + background_margin_vertical * 2.0f);
auto texture_size = plugin_logo_sprite.get_texture()->get_size();
mgl::vec2f texture_size_f(texture_size.x, texture_size.y);
mgl::vec2f new_size = wrap_to_size(texture_size_f, mgl::vec2f(200.0f, one_line_height));
plugin_logo_sprite.set_scale(get_ratio(texture_size_f, new_size));
plugin_logo_sprite.set_position(mgl::vec2f(pos.x + padding_x, pos.y + padding_top + rect_height * 0.5f - plugin_logo_sprite.get_texture()->get_size().y * plugin_logo_sprite.get_scale().y * 0.5f));
- offset_x = padding_x + new_size.x + std::floor(10.0f * get_config().spacing_scale);
+ offset_x = padding_x + new_size.x + floor(10.0f * get_config().spacing_scale);
} else {
offset_x = padding_x;
}
- const float width = std::floor(size.x - offset_x - padding_x);
+ const float width = floor(size.x - offset_x - padding_x);
background.set_size(mgl::vec2f(width, rect_height));
shade.set_size(mgl::vec2f(size.x, padding_top + rect_height + padding_bottom));
- caret.set_size(vec2f_floor(2.0f * get_config().scale, character_size + std::floor(2.0f * get_config().scale)));
+ caret.set_size(vec2f_floor(2.0f * get_config().scale, character_size + floor(2.0f * get_config().scale)));
background.set_position(mgl::vec2f(pos.x + offset_x, pos.y + padding_top));
shade.set_position(pos);
- mgl::vec2f font_position(std::floor(pos.x + offset_x + background_margin_horizontal), std::floor(pos.y + padding_top + background_margin_vertical - character_size * 0.3f));
+ mgl::vec2f font_position(floor(pos.x + offset_x + background_margin_horizontal), floor(pos.y + padding_top + background_margin_vertical - character_size * 0.3f));
text.set_position(font_position);
}
@@ -288,7 +291,7 @@ namespace QuickMedia {
float SearchBar::getBottomWithoutShadow() const {
float font_height = character_size + 7.0f;
- return std::floor(font_height + background_margin_vertical * 2.0f + padding_top + padding_bottom);
+ return floor(font_height + background_margin_vertical * 2.0f + padding_top + padding_bottom);
}
std::string SearchBar::get_text() const {