From 18467b4cd333ab0b7aa10b1c1acd83942c583e60 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 3 Jul 2020 16:55:19 +0200 Subject: Add tab autocomplete for youtube --- include/SearchBar.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/SearchBar.hpp') 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; // Return true to consume the search (clear the search field) using TextSubmitCallback = std::function; - using TextBeginTypingCallback = std::function; + using AutocompleteRequestCallback = std::function; 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; -- cgit v1.2.3