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 | |
4 | Sub := Rectangle { |
5 | width: 25%; |
6 | height: 35%; |
7 | } |
8 | |
9 | TestCase := 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 |
31 | auto handle = TestCase::create(); |
32 | const TestCase &instance = *handle; |
33 | assert_eq(instance.get_test_length(), 300.); |
34 | assert_eq(instance.get_test_inner_inner_length(), 300. / 4.); |
35 | |
36 | assert_eq(instance.get_controlled_test_length(), 20.); |
37 | instance.set_controller(50); |
38 | assert_eq(instance.get_controlled_test_length(), 100.); |
39 | |
40 | ``` |
41 | |
42 | |
43 | ```rust |
44 | let instance = TestCase::new().unwrap(); |
45 | assert_eq!(instance.get_test_length(), 300.); |
46 | assert_eq!(instance.get_test_inner_inner_length(), 300. / 4.); |
47 | |
48 | assert_eq!(instance.get_controlled_test_length(), 20.); |
49 | instance.set_controller(50.); |
50 | assert_eq!(instance.get_controlled_test_length(), 100.); |
51 | ``` |
52 | |
53 | ```js |
54 | var instance = new slint.TestCase({}); |
55 | assert.equal(instance.test_length, 300.); |
56 | assert.equal(instance.test_inner_inner_length, 300. / 4.); |
57 | |
58 | assert.equal(instance.controlled_test_length, 20.); |
59 | instance.controller = 50.; |
60 | assert.equal(instance.controlled_test_length, 100.); |
61 | ``` |
62 | |
63 | */ |
64 | |