Eliya/src/Utils/ProgressBar.h

39 lines
905 B
C++

//
// Created by versustune on 23.02.20.
//
#ifndef ELIYA_PROGRESSBAR_H
#define ELIYA_PROGRESSBAR_H
#include <string>
#include <chrono>
class ProgressBar {
private:
long ticks, maxTicks, showAfterTicks, lastIcon = 0;
bool isUnlimited = false, isFinished = false, finishedDraw = false;
std::string name;
std::chrono::steady_clock::time_point start_time;
std::string unlimitedChars = "|/-\\";
bool runThread = false;
public:
ProgressBar(std::string name, int maxTicks, int showAfterTicks);
~ProgressBar();
void start();
void update();
void setFinished(bool isThread);
void tick();
bool isDone() const;
void setMaxTicks(int newMaxTicks);
void runInThread();
void startThread();
protected:
void renderNormal();
void renderUnknown();
void convertTime(std::stringstream & stream, double seconds);
};
#endif //ELIYA_PROGRESSBAR_H