aboutsummaryrefslogtreecommitdiff
path: root/include/SearchBar.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-08-04 02:28:33 +0200
committerdec05eba <dec05eba@protonmail.com>2019-08-04 02:28:36 +0200
commit4b24638802385816fb5f90c95f175b30ae2398a8 (patch)
treeab6c7cbfd7d20c2065e160f6e8f20be02e4cc1b5 /include/SearchBar.hpp
parentd9fb89269fd30fa44d2b3728b9ae3c7b896a77d3 (diff)
Add youtube video playing, page navigation
Diffstat (limited to 'include/SearchBar.hpp')
-rw-r--r--include/SearchBar.hpp33
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