| 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 | // Test that the default geometry is taken from the right parent, even when some |
| 5 | //of visible or opacity or so are set |
| 6 | |
| 7 | export component TestCase { |
| 8 | in property <bool> condition: true; |
| 9 | Rectangle { |
| 10 | width: 10px; |
| 11 | height: 20px; |
| 12 | |
| 13 | invisible := Rectangle { |
| 14 | visible: condition; |
| 15 | background: blue; |
| 16 | } |
| 17 | |
| 18 | opaque := Rectangle { |
| 19 | opacity: 0.5; |
| 20 | background: red; |
| 21 | } |
| 22 | |
| 23 | clipped := Rectangle { |
| 24 | clip: condition; |
| 25 | background: yellow; |
| 26 | } |
| 27 | |
| 28 | shadowed := Rectangle { |
| 29 | drop-shadow-color: #00000054; |
| 30 | drop-shadow-blur: 8px; |
| 31 | background: pink; |
| 32 | } |
| 33 | |
| 34 | all := Rectangle { |
| 35 | visible: condition; |
| 36 | clip: condition; |
| 37 | opacity: 0.2; |
| 38 | drop-shadow-color: #00000054; |
| 39 | drop-shadow-blur: 8px; |
| 40 | background: orange; |
| 41 | } |
| 42 | |
| 43 | } |
| 44 | |
| 45 | out property <bool> test: |
| 46 | invisible.width == 10px && invisible.height == 20px && |
| 47 | opaque.width == 10px && opaque.height == 20px && |
| 48 | clipped.width == 10px && clipped.height == 20px && |
| 49 | shadowed.width == 10px && shadowed.height == 20px && |
| 50 | all.width == 10px && all.height == 20px; |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | ```cpp |
| 55 | auto handle = TestCase::create(); |
| 56 | const TestCase &instance = *handle; |
| 57 | assert(instance.get_test()); |
| 58 | ``` |
| 59 | |
| 60 | |
| 61 | ```rust |
| 62 | let instance = TestCase::new().unwrap(); |
| 63 | assert!(instance.get_test()); |
| 64 | ``` |
| 65 | |
| 66 | ```js |
| 67 | var instance = new slint.TestCase({}); |
| 68 | assert(instance.test); |
| 69 | ``` |
| 70 | */ |
| 71 | |