From c7367a6a4d329243262b81d630ea6a0e30daaf87 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Thu, 6 Feb 2025 23:16:14 +0100 Subject: [PATCH] green progress bar if have all --- src/chat_gui/contact_list.hpp | 2 ++ src/chat_gui/theme.cpp | 3 +++ src/chat_gui4.cpp | 20 ++++++++++++++------ src/start_screen.cpp | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/chat_gui/contact_list.hpp b/src/chat_gui/contact_list.hpp index c284054..2180f71 100644 --- a/src/chat_gui/contact_list.hpp +++ b/src/chat_gui/contact_list.hpp @@ -18,6 +18,8 @@ enum class ThemeCol_Contact { unread_muted, icon_backdrop, + + ft_have_all, }; void renderAvatar( diff --git a/src/chat_gui/theme.cpp b/src/chat_gui/theme.cpp index 2476435..c79d3bb 100644 --- a/src/chat_gui/theme.cpp +++ b/src/chat_gui/theme.cpp @@ -53,6 +53,9 @@ Theme getDefaultThemeDark(void) { t.setColor({0.0f, 0.0f, 0.0f, 0.4f}); + // TODO: add base ft? -> PlotHistogram + t.setColor({0.35f, 0.84f, 0.22f, 1.0f}); + return t; } diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 9c955a4..c4e735d 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -1092,6 +1092,8 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { return; } + const bool local_have_all = o.all_of(); + ImGui::BeginGroup(); #if 0 @@ -1115,7 +1117,7 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { // TODO: missing other states ImGui::TextUnformatted("running"); } - if (o.all_of()) { + if (local_have_all) { ImGui::SameLine(); ImGui::TextUnformatted("(have all)"); } @@ -1123,7 +1125,7 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { // if in offered state // paused, never started if ( - !o.all_of() && + !local_have_all && //reg.all_of(e) && o.all_of() && // TODO: how does restarting a broken/incomplete transfer look like? @@ -1154,7 +1156,7 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { // hacky const auto* fts = o.try_get(); if (fts != nullptr && o.any_of()) { - const bool upload = o.all_of() && fts->total_down <= 0; + const bool upload = local_have_all && fts->total_down <= 0; const int64_t total_size = o.all_of() ? @@ -1210,8 +1212,11 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f); } + if (local_have_all) { + ImGui::PushStyleColor(ImGuiCol_PlotHistogram, _theme.getColor()); + } if ( - (!upload && !o.all_of() && o.all_of()) || + (!upload && !local_have_all && o.all_of()) || (upload && o.all_of()) ) { ImGui::BeginGroup(); @@ -1261,6 +1266,9 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { overlay_buf ); } + if (local_have_all) { + ImGui::PopStyleColor(); + } } else { // infinite scrolling progressbar fallback ImGui::TextUnformatted(" ??"); @@ -1382,7 +1390,7 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { ImGui::Separator(); // TODO: better way to dif up/down - if (!o.all_of()) { + if (!local_have_all) { if (ImGui::BeginMenu("dowload priority")) { using Priority = ObjComp::Ephemeral::File::DownloadPriority::Priority; auto& p_comp = o.get_or_emplace(); @@ -1420,7 +1428,7 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { ImGui::Separator(); } - if (ImGui::BeginMenu("forward", o.all_of())) { + if (ImGui::BeginMenu("forward", local_have_all)) { for (const auto& c : _cr.view()) { // filter if (_cr.any_of(c)) { diff --git a/src/start_screen.cpp b/src/start_screen.cpp index 788384d..b06829f 100644 --- a/src/start_screen.cpp +++ b/src/start_screen.cpp @@ -370,7 +370,7 @@ Screen* StartScreen::render(float, bool&) { if (ImGui::Checkbox("local discovery", &value)) { _conf.set("tox", "local_discovery_enabled", value); } - ImGui::SetItemTooltip("Perform broadcasts in your local networks to fine other peers.\nOnly meaningful if udp is enabled."); + ImGui::SetItemTooltip("Perform broadcasts in your local networks to find other peers.\nOnly meaningful if udp is enabled."); } ImGui::SeparatorText("tcp relay server");