From 8b5901000e9073d9ff6a3a86cd7c0e0172de7f5a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 22 Apr 2021 15:59:35 +0200 Subject: show num invites in tab (propagate page title update to tabs) --- src/QuickMedia.cpp | 6 ++++++ src/Tabs.cpp | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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) { -- cgit v1.2.3