diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-07-03 16:55:19 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-03 16:55:19 +0200 |
commit | 18467b4cd333ab0b7aa10b1c1acd83942c583e60 (patch) | |
tree | beb77bd217a9530bd2ed057f67a5412ba3f8a1e3 /include | |
parent | 2d796243ad157f52d33a5b9d4f449e3845cf1649 (diff) |
Add tab autocomplete for youtube
Diffstat (limited to 'include')
-rw-r--r-- | include/SearchBar.hpp | 10 |
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; |