From 5465c09cd108e37720dbad139de98bdcf5dfe8bf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 19 Apr 2021 16:13:55 +0200 Subject: Move tab code to separate class, fix upload time missing for certain manga plugins, fix touch room click messed up --- include/Tabs.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 include/Tabs.hpp (limited to 'include/Tabs.hpp') diff --git a/include/Tabs.hpp b/include/Tabs.hpp new file mode 100644 index 0000000..d5aa5b6 --- /dev/null +++ b/include/Tabs.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include "../external/RoundedRectangleShape.hpp" +#include +#include +#include +#include + +namespace sf { + class Event; + class RenderWindow; +} + +namespace QuickMedia { + class Tabs { + public: + Tabs(sf::Color shade_color = sf::Color(33, 37, 44)); + + static float get_height(); + static float get_shade_height(); + + // Returns the id (index) of the tab. The ids start from 0 + int add_tab(const std::string &title); + void on_event(sf::Event &event); + void draw(sf::RenderWindow &window, sf::Vector2f pos, float width); + + void set_text(int index, const std::string &text); + + void set_selected(int index); + int get_selected() const; + + std::function on_change_tab = nullptr; + private: + float tab_index_to_x_offset(int index); + private: + std::vector tab_texts; + sf::RoundedRectangleShape background; + sf::RectangleShape shade; + int selected_tab = 0; + float scroll = 0.0f; + float width_per_tab = 0.0f; + float tab_background_width = 0.0f; + float container_width = 0.0f; + int tab_offset = 0; + sf::Color shade_color; + }; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2