-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlProgressBar.cpp
More file actions
54 lines (41 loc) · 1.45 KB
/
ControlProgressBar.cpp
File metadata and controls
54 lines (41 loc) · 1.45 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
54
#include "ControlProgressBar.h"
#include <iostream>
ControlProgressBar::ControlProgressBar(FileManager &subject, unsigned int widht, unsigned int height) :
window(sf::VideoMode(widht, height), "", sf::Style::Close), subject(subject) {
auto desktop = sf::VideoMode::getDesktopMode();
std::cout << "X" << desktop.width / 2 - window.getSize().x / 2 << std::endl;
std::cout << "Y" << desktop.height / 2 - window.getSize().y / 2 << std::endl;
window.setPosition(sf::Vector2i(desktop.width / 2 - window.getSize().x / 2,
desktop.height / 2 - window.getSize().y / 2));
}
int ControlProgressBar::init() {
window.setTitle("Download: press ENTER");
window.clear();
window.display();
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed)
if (event.key.code == sf::Keyboard::Enter)
return run();
}
}
return 0;
}
int ControlProgressBar::run() {
window.clear();
window.setTitle("Progress Bar");
subject.downloadFiles();
if (subject.tCaricato()) {
window.setTitle("");
window.clear();
window.display();
}
return 0;
}
ControlProgressBar::~ControlProgressBar() {}
sf::RenderWindow &ControlProgressBar::getWindow() {
return window;
}