aboutsummaryrefslogtreecommitdiff
path: root/include/SearchBar.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/SearchBar.hpp')
-rw-r--r--include/SearchBar.hpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index 7a6c483..6222da4 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -11,8 +11,8 @@ namespace QuickMedia {
using TextUpdateCallback = std::function<void(const sf::String &text)>;
// Return true to consume the search (clear the search field)
using TextSubmitCallback = std::function<bool(const sf::String &text)>;
-
using TextBeginTypingCallback = std::function<void()>;
+ using AutocompleteRequestCallback = std::function<std::string(const sf::String &text)>;
class SearchBar {
public:
@@ -24,6 +24,7 @@ namespace QuickMedia {
void clear();
void append_text(const std::string &text_to_add);
bool is_cursor_at_start_of_line() const;
+ void set_to_autocomplete();
float getBottom() const;
float getBottomWithoutShadow() const;
@@ -31,15 +32,22 @@ namespace QuickMedia {
TextUpdateCallback onTextUpdateCallback;
TextSubmitCallback onTextSubmitCallback;
TextBeginTypingCallback onTextBeginTypingCallback;
+ AutocompleteRequestCallback onAutocompleteRequestCallback;
int text_autosearch_delay;
+ int autocomplete_search_delay;
+ private:
+ void clear_autocomplete_if_text_not_substring();
+ void clear_autocomplete_if_last_char_not_substr();
private:
sf::Text text;
+ sf::Text autocomplete_text;
sf::RectangleShape background;
sf::RectangleShape background_shadow;
sf::RectangleShape shade;
sf::Sprite plugin_logo_sprite;
bool show_placeholder;
bool updated_search;
+ bool updated_autocomplete;
bool draw_logo;
bool needs_update;
sf::Clock time_since_search_update;