aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/SearchBar.hpp1
-rw-r--r--src/SearchBar.cpp11
2 files changed, 10 insertions, 2 deletions
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index 8265ef0..9efbf9c 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -46,6 +46,7 @@ namespace QuickMedia {
sf::RectangleShape background;
sf::RectangleShape background_shadow;
sf::RectangleShape shade;
+ sf::RectangleShape caret;
sf::Sprite plugin_logo_sprite;
std::string placeholder_str;
bool show_placeholder;
diff --git a/src/SearchBar.cpp b/src/SearchBar.cpp
index d96172a..803eaee 100644
--- a/src/SearchBar.cpp
+++ b/src/SearchBar.cpp
@@ -20,14 +20,14 @@ namespace QuickMedia {
onAutocompleteRequestCallback(nullptr),
text_autosearch_delay(0),
autocomplete_search_delay(0),
- text(placeholder, font, 18),
+ text(placeholder, font, 18),
autocomplete_text("", font, 18),
placeholder_str(placeholder),
show_placeholder(true),
updated_search(false),
updated_autocomplete(false),
draw_logo(false),
- needs_update(false)
+ needs_update(true)
{
text.setFillColor(text_placeholder_color);
autocomplete_text.setFillColor(text_placeholder_color);
@@ -54,6 +54,12 @@ namespace QuickMedia {
// TODO: Render starting from the character after text length
window.draw(autocomplete_text);
window.draw(text);
+ if(show_placeholder || text.getString().isEmpty())
+ caret.setPosition(text.getPosition() - sf::Vector2f(2.0f, 0.0f));
+ else
+ caret.setPosition(text.findCharacterPos(text.getString().getSize()));
+
+ window.draw(caret);
if(draw_logo)
window.draw(plugin_logo_sprite);
}
@@ -105,6 +111,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.getLocalBounds().height + 12.0f));
background_shadow.setSize(sf::Vector2f(window_size.x, 5.0f));
background.setPosition(offset_x, padding_vertical);