1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: MIT
3
4import { LineEdit, Button, Slider, HorizontalBox, VerticalBox } from "std-widgets.slint";
5
6export component MainWindow inherits Window {
7 in-out property <duration> total-time: slider.value * 1s;
8 in-out property <duration> elapsed-time;
9
10 callback tick(duration);
11 tick(passed-time) => {
12 root.elapsed-time += passed-time;
13 root.elapsed-time = min(root.elapsed-time, root.total-time);
14 }
15
16 VerticalBox {
17 HorizontalBox {
18 padding-left: 0;
19 Text { text: "Elapsed Time:"; }
20 Rectangle {
21 min-width: 200px;
22 max-height: 30px;
23 background: gray;
24 Rectangle {
25 x:0;
26 height: 100%;
27 width: parent.width * (root.elapsed-time/root.total-time);
28 background: lightblue;
29 }
30 }
31 }
32 Text{
33 text: (root.total-time / 1s) + "s";
34 }
35 HorizontalBox {
36 padding-left: 0;
37 Text {
38 text: "Duration:";
39 vertical-alignment: center;
40 }
41 slider := Slider {
42 maximum: 30s / 1s;
43 value: 10s / 1s;
44 changed(new-duration) => {
45 root.total-time = new-duration * 1s;
46 root.elapsed-time = min(root.elapsed-time, root.total-time);
47 }
48 }
49 }
50 Button {
51 text: "Reset";
52 clicked => {
53 root.elapsed-time = 0
54 }
55 }
56 }
57}
58