diff --git a/rhubarb/src/tools/ProgressBar.cpp b/rhubarb/src/tools/ProgressBar.cpp index 5ba39d2..4f913d7 100644 --- a/rhubarb/src/tools/ProgressBar.cpp +++ b/rhubarb/src/tools/ProgressBar.cpp @@ -46,21 +46,25 @@ void ProgressBar::updateLoop() { if (clearOnDestruction) { updateText(""); } else { - update(); + update(false); } } -void ProgressBar::update() { +void ProgressBar::update(bool showSpinner) { const int blockCount = 20; const string animation = "|/-\\"; int progressBlockCount = static_cast(currentProgress * blockCount); const double epsilon = 0.0001; int percent = static_cast(currentProgress * 100 + epsilon); + const string spinner = showSpinner + ? string(1, animation[animationIndex++ % animation.size()]) + : ""; string text = fmt::format("[{0}{1}] {2:3}% {3}", string(progressBlockCount, '#'), string(blockCount - progressBlockCount, '-'), percent, - animation[animationIndex++ % animation.size()]); + spinner + ); updateText(text); } diff --git a/rhubarb/src/tools/ProgressBar.h b/rhubarb/src/tools/ProgressBar.h index 2dd5f7a..347b330 100644 --- a/rhubarb/src/tools/ProgressBar.h +++ b/rhubarb/src/tools/ProgressBar.h @@ -22,7 +22,7 @@ public: private: void updateLoop(); - void update(); + void update(bool showSpinner = true); void updateText(const std::string& text); std::future updateLoopFuture;