1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
3
4import { Button } from "std-widgets.slint";
5
6// Test case for manual visual verification that layering does not pessimize the
7// output, and to have a compile-time verification that the lowering to the Layer
8// element compiles.
9
10MyLayer := Rectangle {
11 cache-rendering-hint: true;
12 background: red;
13 for i in 1000: Rectangle {
14 cache-rendering-hint: i == 8;
15 background: blue;
16 drop-shadow-blur: 10px;
17 drop-shadow-offset-x: 5px;
18 drop-shadow-offset-y: 5px;
19 drop-shadow-color: green;
20 Text {
21 text: "Many text items over each other";
22 }
23 }
24}
25
26export TestCase := Window {
27 preferred-width: 800px;
28 preferred-height: 600px;
29 background: white;
30
31 VerticalLayout {
32
33 Button {
34 text: "Press me to start the animation and check that it is smooth.";
35 clicked => {
36 layered.place_to_the_right = true;
37 }
38 }
39
40 Rectangle {
41
42 // This will be a layer
43 layered := MyLayer {
44 width: 200px;
45 height: 100px;
46
47 property <bool> place_to_the_right;
48 states [
49 right when place_to_the_right: {
50 x: 200px;
51 }
52 left when !place_to_the_right: {
53 x: 10px;
54 }
55 ]
56
57 animate x {
58 duration: 15s;
59 }
60 }
61 }
62 }
63}
64