forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.slint
57 lines (53 loc) · 1.65 KB
/
timer.slint
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
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT
import { LineEdit, Button, Slider, HorizontalBox, VerticalBox } from "std-widgets.slint";
export component MainWindow inherits Window {
in-out property <duration> total-time: slider.value * 1s;
in-out property <duration> elapsed-time;
callback tick(duration);
tick(passed-time) => {
root.elapsed-time += passed-time;
root.elapsed-time = min(root.elapsed-time, root.total-time);
}
VerticalBox {
HorizontalBox {
padding-left: 0;
Text { text: "Elapsed Time:"; }
Rectangle {
min-width: 200px;
max-height: 30px;
background: gray;
Rectangle {
x:0;
height: 100%;
width: parent.width * (root.elapsed-time/root.total-time);
background: lightblue;
}
}
}
Text{
text: (root.total-time / 1s) + "s";
}
HorizontalBox {
padding-left: 0;
Text {
text: "Duration:";
vertical-alignment: center;
}
slider := Slider {
maximum: 30s / 1s;
value: 10s / 1s;
changed(new-duration) => {
root.total-time = new-duration * 1s;
root.elapsed-time = min(root.elapsed-time, root.total-time);
}
}
}
Button {
text: "Reset";
clicked => {
root.elapsed-time = 0
}
}
}
}