1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: MIT |
3 | |
4 | import { AppFonts, AppImages } from "../style/styles.slint" ; |
5 | |
6 | export global BusyLayerController { |
7 | out property<bool> is-busy: false; |
8 | |
9 | property<int> busy-counter: 0; |
10 | |
11 | public function set-busy() { |
12 | busy-counter += 1; |
13 | |
14 | // updating only when real change happen to avoid: |
15 | // https://github.com/slint-ui/slint/issues/5209 |
16 | if (!root.is-busy) { |
17 | root.is-busy = true; |
18 | } |
19 | } |
20 | public function unset-busy() { |
21 | busy-counter -= 1; |
22 | |
23 | // updating only when real change happen to avoid: |
24 | // https://github.com/slint-ui/slint/issues/5209 |
25 | if (root.is-busy && busy-counter == 0) { |
26 | root.is-busy = false; |
27 | } |
28 | } |
29 | } |
30 | |
31 | export component BusyLayer inherits Rectangle { |
32 | Rectangle { |
33 | background: black; |
34 | opacity: 0.75; |
35 | } |
36 | |
37 | Image { |
38 | width: 75px; |
39 | height: 75px; |
40 | image-fit: contain; |
41 | |
42 | source: AppImages.refresh; |
43 | colorize: white.darker(15%); |
44 | |
45 | rotation-angle: Math.mod(animation-tick() / 3.25ms, 360) * 1deg; |
46 | } |
47 | |
48 | // touch blocker |
49 | TouchArea {} |
50 | } |
51 | |