diff options
-rw-r--r-- | include/Tabs.hpp | 1 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 6 | ||||
-rw-r--r-- | src/Tabs.cpp | 4 |
3 files changed, 10 insertions, 1 deletions
diff --git a/include/Tabs.hpp b/include/Tabs.hpp index d899a61..ec5ab96 100644 --- a/include/Tabs.hpp +++ b/include/Tabs.hpp @@ -35,6 +35,7 @@ namespace QuickMedia { float tab_index_to_x_offset(int index); private: std::vector<sf::Text> tab_texts; + std::vector<std::string> tab_labels_utf8; RoundedRectangle background; sf::RectangleShape shade; int selected_tab = 0; diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 8d4dffb..eb82a54 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1726,6 +1726,12 @@ namespace QuickMedia { } } + for(size_t i = 0; i < tabs.size(); ++i) { + Tab &tab = tabs[i]; + if(tab.page) + ui_tabs.set_text(i, tab.page->get_title()); + } + window.clear(back_color); page_loop_render(window, tabs, selected_tab, tab_associated_data[selected_tab], json_chapters, ui_tabs); window.display(); diff --git a/src/Tabs.cpp b/src/Tabs.cpp index 4437472..01e5d2d 100644 --- a/src/Tabs.cpp +++ b/src/Tabs.cpp @@ -30,6 +30,7 @@ namespace QuickMedia { int Tabs::add_tab(const std::string &title) { tab_texts.push_back(sf::Text(title, *FontLoader::get_font(FontLoader::FontType::LATIN), tab_text_size)); + tab_labels_utf8.push_back(title); return tab_texts.size() - 1; } @@ -180,8 +181,9 @@ namespace QuickMedia { } void Tabs::set_text(int index, const std::string &text) { - if(index < 0 || index >= (int)tab_texts.size()) return; + if(index < 0 || index >= (int)tab_texts.size() || text == tab_labels_utf8[index]) return; tab_texts[index].setString(sf::String::fromUtf8(text.begin(), text.end())); + tab_labels_utf8[index] = text; } void Tabs::set_selected(int index) { |