| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | |
| 4 | component MyLayout inherits HorizontalLayout { |
| 5 | Rectangle { |
| 6 | width: 20phx; |
| 7 | background: red; |
| 8 | } |
| 9 | @children |
| 10 | Rectangle { |
| 11 | width: 10phx; |
| 12 | background: red; |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | component MyLayout2 inherits MyLayout { |
| 17 | Rectangle { |
| 18 | width: 2phx; |
| 19 | background: orange; |
| 20 | } |
| 21 | @children |
| 22 | Rectangle { |
| 23 | width: 1phx; |
| 24 | background: orange; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | component MyLayout3 inherits MyLayout { |
| 29 | Rectangle { |
| 30 | width: 2phx; |
| 31 | background: green; |
| 32 | } |
| 33 | Rectangle { |
| 34 | width: 1phx; |
| 35 | background: green; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | |
| 40 | |
| 41 | export component TestCase inherits Window { |
| 42 | width: 300phx; |
| 43 | height: 200phx; |
| 44 | |
| 45 | VerticalLayout { |
| 46 | |
| 47 | MyLayout { |
| 48 | rect1 := Rectangle { |
| 49 | background: black; |
| 50 | } |
| 51 | } |
| 52 | MyLayout2 { |
| 53 | rect2 := Rectangle { |
| 54 | background: black; |
| 55 | } |
| 56 | } |
| 57 | MyLayout3 { |
| 58 | rect3 := Rectangle { |
| 59 | background: black; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | out property <bool> rect1_pos_ok: rect1.x == 20phx && rect1.width == 300phx - 30phx; |
| 66 | out property <bool> rect2_pos_ok: rect2.x == 22phx && rect2.width == 300phx - 33phx; |
| 67 | out property <bool> rect3_pos_ok: rect3.x == 23phx && rect3.width == 300phx - 33phx; |
| 68 | out property <bool> test: rect1_pos_ok && rect2_pos_ok && rect3_pos_ok; |
| 69 | } |
| 70 | /* |
| 71 | ```cpp |
| 72 | auto handle = TestCase::create(); |
| 73 | const TestCase &instance = *handle; |
| 74 | assert(instance.get_test()); |
| 75 | ``` |
| 76 | |
| 77 | |
| 78 | ```rust |
| 79 | let instance = TestCase::new().unwrap(); |
| 80 | assert!(instance.get_test()); |
| 81 | ``` |
| 82 | */ |
| 83 | |