From 59e4ce5c35e7e5a73d61e7111e8d4f07d63b7056 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 4 Jun 2021 19:22:04 +0200 Subject: Add grid view --- include/Tabs.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include/Tabs.hpp') diff --git a/include/Tabs.hpp b/include/Tabs.hpp index ec5ab96..f7c3054 100644 --- a/include/Tabs.hpp +++ b/include/Tabs.hpp @@ -13,6 +13,8 @@ namespace sf { } namespace QuickMedia { + class Body; + class Tabs { public: Tabs(sf::Shader *rounded_rectangle_shader, sf::Color shade_color = sf::Color(33, 37, 44)); @@ -21,7 +23,7 @@ namespace QuickMedia { static float get_shade_height(); // Returns the id (index) of the tab. The ids start from 0 - int add_tab(const std::string &title); + int add_tab(const std::string &title, Body *body); void on_event(sf::Event &event); void draw(sf::RenderWindow &window, sf::Vector2f pos, float width); @@ -32,10 +34,15 @@ namespace QuickMedia { std::function on_change_tab = nullptr; private: + void move_selected_tab(int new_tab); float tab_index_to_x_offset(int index); private: - std::vector tab_texts; - std::vector tab_labels_utf8; + struct Tab { + sf::Text text; + std::string label_utf8; // TODO: Remove + Body *body; + }; + std::vector tabs; RoundedRectangle background; sf::RectangleShape shade; int selected_tab = 0; -- cgit v1.2.3