aboutsummaryrefslogtreecommitdiff
path: root/src/SearchBar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/SearchBar.cpp')
-rw-r--r--src/SearchBar.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index f790de8..b04a9a1 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -6,8 +6,8 @@
#include <assert.h>
const sf::Color text_placeholder_color(255, 255, 255, 100);
-const sf::Color front_color(34, 34, 34);
-const float background_margin_horizontal = 8.0f;
+const sf::Color front_color(55, 60, 68);
+const float background_margin_horizontal = 15.0f;
const float background_margin_vertical = 4.0f;
const float PADDING_HORIZONTAL = 50.0f;
const float padding_vertical = 20.0f;
@@ -23,6 +23,7 @@ namespace QuickMedia {
caret_visible(true),
text(placeholder, font, 18),
autocomplete_text("", font, 18),
+ background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10),
placeholder_str(placeholder),
show_placeholder(true),
updated_search(false),
@@ -35,9 +36,10 @@ namespace QuickMedia {
text.setFillColor(text_placeholder_color);
autocomplete_text.setFillColor(text_placeholder_color);
background.setFillColor(front_color);
+ //background.setCornersRadius(5);
background_shadow.setFillColor(sf::Color(23, 25, 27));
//background_shadow.setPosition(background.getPosition() + sf::Vector2f(5.0f, 5.0f));
- shade.setFillColor(sf::Color(0, 85, 119));
+ shade.setFillColor(sf::Color(55, 60, 68));
//background.setOutlineThickness(1.0f);
//background.setOutlineColor(sf::Color(13, 15, 17));
if(plugin_logo && plugin_logo->getNativeHandle() != 0)
@@ -52,7 +54,7 @@ namespace QuickMedia {
}
if(draw_shadow)
window.draw(background_shadow);
- window.draw(shade);
+ //window.draw(shade);
window.draw(background);
// TODO: Render starting from the character after text length
window.draw(autocomplete_text);
@@ -61,13 +63,13 @@ namespace QuickMedia {
sf::Text masked_text(std::move(masked_str), *text.getFont(), text.getCharacterSize());
masked_text.setPosition(text.getPosition());
window.draw(masked_text);
- caret.setPosition(masked_text.findCharacterPos(masked_text.getString().getSize()));
+ caret.setPosition(masked_text.findCharacterPos(masked_text.getString().getSize()) + sf::Vector2f(0.0f, 2.0f));
} else {
window.draw(text);
if(show_placeholder || text.getString().isEmpty())
- caret.setPosition(text.getPosition() - sf::Vector2f(2.0f, 0.0f));
+ caret.setPosition(text.getPosition() - sf::Vector2f(2.0f, 0.0f) + sf::Vector2f(0.0f, 2.0f));
else
- caret.setPosition(text.findCharacterPos(text.getString().getSize()));
+ caret.setPosition(text.findCharacterPos(text.getString().getSize()) + sf::Vector2f(0.0f, 2.0f));
}
if(caret_visible)
@@ -124,7 +126,7 @@ namespace QuickMedia {
background.setSize(sf::Vector2f(width, rect_height));
shade.setSize(sf::Vector2f(window_size.x, padding_vertical + rect_height + padding_vertical));
- caret.setSize(sf::Vector2f(2.0f, text.getCharacterSize() + 8.0f));
+ caret.setSize(sf::Vector2f(2.0f, text.getCharacterSize() + 2.0f));
background_shadow.setSize(sf::Vector2f(window_size.x, 5.0f));
background.setPosition(offset_x, padding_vertical + vertical_pos);
@@ -242,6 +244,10 @@ namespace QuickMedia {
}
}
+ void SearchBar::set_background_color(sf::Color color) {
+ background.setFillColor(color);
+ }
+
void SearchBar::clear_autocomplete_if_text_not_substring() {
const sf::String &text_str = text.getString();
const sf::String &autocomplete_str = autocomplete_text.getString();