-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressBar.cpp
More file actions
53 lines (40 loc) · 1.7 KB
/
ProgressBar.cpp
File metadata and controls
53 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "ProgressBar.h"
ProgressBar::ProgressBar(FileManager &fileManager_, sf::RenderWindow *w, std::string type,
unsigned int x, unsigned int y, sf::Color color) :
fileManager(fileManager_), type(std::move(type)), window(w), maxWidth(300), maxHeight(20), numNotify(0){
fileManager.attach(this);
rectangleShape.setPosition(sf::Vector2f(x, y));
rectangleShape.setFillColor(color);
}
ProgressBar::~ProgressBar() {
fileManager.detach(this);
}
void ProgressBar::update() {
numNotify++;
if (type == "file") {
std::cout << "update file" << std::endl;
rectangleShape.setSize(
sf::Vector2f((maxWidth * fileManager.getFileCaricati()) / fileManager.getFileTotali(), maxHeight));
std::cout << (maxWidth * fileManager.getFileCaricati()) / fileManager.getFileTotali() << " " << maxHeight
<< std::endl;
window->draw(rectangleShape);
window->display();
}
if (type == "byte") {
std::cout << "update byte" << std::endl;
rectangleShape.setPosition(sf::Vector2f(0, 30));
rectangleShape.setSize(sf::Vector2f(300, 40));//40
rectangleShape.setFillColor(sf::Color::Black);
window->draw(rectangleShape);
rectangleShape.setFillColor(sf::Color::Blue);
rectangleShape.setSize(
sf::Vector2f((maxWidth * fileManager.getByteCaricati()) / fileManager.getTotBit(), maxHeight));
std::cout << (maxWidth * fileManager.getByteCaricati()) / fileManager.getTotBit() << " " << maxHeight
<< std::endl;
}
window->draw(rectangleShape);
window->display();
}
int ProgressBar::getNumNotify() const {
return numNotify;
}