aboutsummaryrefslogtreecommitdiff
path: root/src/SearchBar.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-06-21 06:25:13 +0200
committerdec05eba <dec05eba@protonmail.com>2021-06-21 06:25:17 +0200
commit933ceeabb339cdf0583a8687528941593381a268 (patch)
treee3963cd74eb726a63f6e91f2f22f485fac65084a /src/SearchBar.cpp
parentd137dcfa6dd248ffa94e58e7aef4487682bc12dc (diff)
Add color themeing, (Theme.hpp/Theme.cpp) and the env var QM_THEME
Diffstat (limited to 'src/SearchBar.cpp')
-rw-r--r--src/SearchBar.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index 3fd2296..0634ae8 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -1,4 +1,5 @@
#include "../include/SearchBar.hpp"
+#include "../include/Theme.hpp"
#include "../include/Scale.hpp"
#include "../include/ResourceLoader.hpp"
#include "../include/Utils.hpp"
@@ -10,8 +11,6 @@
// TODO: Use a seperate placeholder sf::Text instead of switching the text to placeholder text....
-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 = 10.0f + std::floor(5.0f * QuickMedia::get_ui_scale());
static const float padding_top_default = std::floor(10.0f * QuickMedia::get_ui_scale());
static const float padding_bottom_default = std::floor(15.0f * QuickMedia::get_ui_scale());
@@ -28,7 +27,7 @@ namespace QuickMedia {
caret_visible(true),
text(placeholder, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale())),
autocomplete_text("", *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale())),
- background(sf::Vector2f(1.0f, 1.0f), 10.0f, front_color, rounded_rectangle_shader),
+ background(sf::Vector2f(1.0f, 1.0f), 10.0f, get_current_theme().selected_color, rounded_rectangle_shader),
placeholder_str(placeholder),
show_placeholder(true),
updated_search(false),
@@ -44,9 +43,9 @@ namespace QuickMedia {
{
padding_top = padding_top_default;
padding_bottom = padding_bottom_default;
- text.setFillColor(text_placeholder_color);
- autocomplete_text.setFillColor(text_placeholder_color);
- shade.setFillColor(sf::Color(33, 37, 44));
+ text.setFillColor(get_current_theme().placeholder_text_color);
+ autocomplete_text.setFillColor(get_current_theme().placeholder_text_color);
+ shade.setFillColor(get_current_theme().shade_color);
if(plugin_logo && plugin_logo->getNativeHandle() != 0)
plugin_logo_sprite.setTexture(*plugin_logo, true);
}
@@ -201,7 +200,7 @@ namespace QuickMedia {
if(str.getSize() == 0) {
show_placeholder = true;
text.setString(placeholder_str);
- text.setFillColor(text_placeholder_color);
+ text.setFillColor(get_current_theme().placeholder_text_color);
autocomplete_text.setString("");
} else {
clear_autocomplete_if_text_not_substring();
@@ -235,7 +234,7 @@ namespace QuickMedia {
return;
show_placeholder = true;
text.setString(placeholder_str);
- text.setFillColor(text_placeholder_color);
+ text.setFillColor(get_current_theme().placeholder_text_color);
autocomplete_text.setString("");
needs_update = true;
updated_search = false;
@@ -267,7 +266,7 @@ namespace QuickMedia {
updated_autocomplete = true;
time_since_search_update.restart();
backspace_pressed = false;
- if(str[str.getSize() - 1] == '\n')
+ if(text_to_add.find('\n') != std::string::npos)
needs_update = true;
}