diff options
Diffstat (limited to 'include/SearchBar.hpp')
-rw-r--r-- | include/SearchBar.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp new file mode 100644 index 0000000..c9f75f0 --- /dev/null +++ b/include/SearchBar.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <SFML/Graphics/RenderWindow.hpp> +#include <SFML/Graphics/Font.hpp> +#include <SFML/Graphics/Text.hpp> +#include <SFML/Graphics/RectangleShape.hpp> +#include <functional> + +namespace QuickMedia { + using TextUpdateCallback = std::function<void(const sf::String &text)>; + using TextSubmitCallback = std::function<void(const sf::String &text)>; + + class SearchBar { + public: + SearchBar(sf::Font &font); + void draw(sf::RenderWindow &window); + void update(); + void onWindowResize(const sf::Vector2f &window_size); + void onTextEntered(sf::Uint32 codepoint); + void clear(); + + float getBottom() const; + + TextUpdateCallback onTextUpdateCallback; + TextSubmitCallback onTextSubmitCallback; + private: + sf::Text text; + sf::RectangleShape background; + bool show_placeholder; + bool updated_search; + sf::Clock time_since_search_update; + }; +}
\ No newline at end of file |