-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeedback.cpp
59 lines (51 loc) · 1.31 KB
/
Feedback.cpp
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
55
56
57
58
59
#include "Feedback.h"
#include "utils.h"
Feedback::Feedback(nana::form& f) : label(f), blink(std::chrono::milliseconds{125}), blinkcounter(0), insist(false), fm(f) {
blink.elapse([=] {
blinkcounter += 1;
if (blinkcounter < 16 || blinkcounter % 2 == 1) {
caption(currentmsg);
}
else {
caption("");
}
if (insist) {
if (blinkcounter == 33) {
blink.stop();
}
}
else {
if (blinkcounter == 32) {
blink.stop();
}
}
});
}
void Feedback::Success(const std::string& msg) {
currentmsg = "<bold green size = 16>" + msg + "< / >";
blinkcounter = 0;
insist = false;
blink.start();
if (!nana::API::focus_window()) {
TrayMessage(fm.native_handle(), "Success!", msg);
}
}
void Feedback::Error(const std::string& msg, bool critical) {
currentmsg = "<bold red>" + msg + "< / >";
if (critical) {
caption(currentmsg);
}
else {
blinkcounter = 0;
insist = false;
blink.start();
}
if (!nana::API::focus_window()) {
TrayMessage(fm.native_handle(), "Error", msg);
}
}
void Feedback::InsistOnLastError() {
blinkcounter = 16;
insist = true;
blink.start();
}