diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-05 21:07:11 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-08-05 21:07:14 +0200 |
commit | b894f0b2283a4fcd42fc41f9517b16d623ae3adb (patch) | |
tree | bca95c9bcf3947886fd85d1759cb8349a563bfd2 /include | |
parent | 2b294258bbc89f1b49554468022a035782e49074 (diff) |
Add thumbnails for manganelo
Diffstat (limited to 'include')
-rw-r--r-- | include/Body.hpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/Body.hpp b/include/Body.hpp new file mode 100644 index 0000000..c27ecf0 --- /dev/null +++ b/include/Body.hpp @@ -0,0 +1,48 @@ +#pragma once + +#include <SFML/Graphics/Font.hpp> +#include <SFML/Graphics/Text.hpp> +#include <SFML/Graphics/Texture.hpp> +#include <SFML/Graphics/RenderWindow.hpp> + +namespace QuickMedia { + class BodyItem { + public: + BodyItem(const std::string &_title): title(_title), visible(true) { + + } + + std::string title; + std::string url; + std::string thumbnail_url; + bool visible; + }; + + class Body { + public: + Body(sf::Font &font); + + // Select previous item, ignoring invisible items + void select_previous_item(); + + // Select next item, ignoring invisible items + void select_next_item(); + void reset_selected(); + void clear_items(); + + BodyItem* get_selected() const; + + void clamp_selection(); + void draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size); + static bool string_find_case_insensitive(const std::string &str, const std::string &substr); + + // TODO: Make this actually fuzzy... Right now it's just a case insensitive string find. + // TODO: Highlight the part of the text that matches the search + void filter_search_fuzzy(const std::string &text); + + sf::Text title_text; + int selected_item; + std::vector<std::unique_ptr<BodyItem>> items; + std::vector<std::unique_ptr<sf::Texture>> item_thumbnail_textures; + }; +}
\ No newline at end of file |