From dce42b866a18c3352263fbefe5540f7efe7846e5 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 20 Oct 2023 02:39:13 +0200 Subject: [PATCH] hack in extra decimal for progressbars --- src/chat_gui4.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 8fe466c8..ed47d173 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -2,6 +2,7 @@ #include "./file_selector.hpp" +#include #include #include #include @@ -545,9 +546,16 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { ImGui::TextUnformatted("down"); if (reg.all_of(e)) { ImGui::SameLine(); + + float fraction = float(reg.get(e).total) / reg.get(e).total_size; + + char overlay_buf[32]; + std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f); + ImGui::ProgressBar( - float(reg.get(e).total) / reg.get(e).total_size, - {-FLT_MIN, TEXT_BASE_HEIGHT} + fraction, + {-FLT_MIN, TEXT_BASE_HEIGHT}, + overlay_buf ); // TODO: numbers } @@ -559,9 +567,16 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) { ImGui::TextUnformatted(" up"); if (reg.all_of(e)) { ImGui::SameLine(); + + float fraction = float(reg.get(e).total) / reg.get(e).total_size; + + char overlay_buf[32]; + std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f); + ImGui::ProgressBar( - float(reg.get(e).total) / reg.get(e).total_size, - {-FLT_MIN, TEXT_BASE_HEIGHT} + fraction, + {-FLT_MIN, TEXT_BASE_HEIGHT}, + overlay_buf ); // TODO: numbers }