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
4Sub := Rectangle {
5 width: 25%;
6 height: 35%;
7}
8
9TestCase := Rectangle {
10 width: 600phx;
11 inner_rect := Rectangle {
12 width: 50%;
13 inner_inner := Sub { }
14 }
15 property<length> test_length: inner_rect.width;
16 property<length> test_inner_inner_length: inner_inner.width;
17
18
19 height: 200phx;
20 property<percent> controller: 10%;
21 inner_rect_2 := Rectangle {
22 height: parent.controller;
23 }
24 property<length> controlled_test_length: inner_rect_2.height;
25}
26
27
28/*
29
30```cpp
31auto handle = TestCase::create();
32const TestCase &instance = *handle;
33assert_eq(instance.get_test_length(), 300.);
34assert_eq(instance.get_test_inner_inner_length(), 300. / 4.);
35
36assert_eq(instance.get_controlled_test_length(), 20.);
37instance.set_controller(50);
38assert_eq(instance.get_controlled_test_length(), 100.);
39
40```
41
42
43```rust
44let instance = TestCase::new().unwrap();
45assert_eq!(instance.get_test_length(), 300.);
46assert_eq!(instance.get_test_inner_inner_length(), 300. / 4.);
47
48assert_eq!(instance.get_controlled_test_length(), 20.);
49instance.set_controller(50.);
50assert_eq!(instance.get_controlled_test_length(), 100.);
51```
52
53```js
54var instance = new slint.TestCase({});
55assert.equal(instance.test_length, 300.);
56assert.equal(instance.test_inner_inner_length, 300. / 4.);
57
58assert.equal(instance.controlled_test_length, 20.);
59instance.controller = 50.;
60assert.equal(instance.controlled_test_length, 100.);
61```
62
63*/
64