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 x and y property of a Rectangle with opacity are consistent
5
6export component TestCase {
7
8 width: 100px;
9 height: 100px;
10
11
12 r1 := Rectangle {
13 x: 20px;
14 y: 15px;
15 width: 12px;
16 height: 5px;
17 opacity: 0.5;
18 background: red;
19 TouchArea {
20 clicked => {
21 root.clicked = (self.absolute-position.y + self.mouse-y) / 1px;
22 r1.y += 50px;
23 }
24 }
25 }
26
27 in-out property xx <=> r1.x;
28 out property<int> clicked;
29
30 out property <bool> test:
31 r1.x == 20px && r1.y == 15px;
32}
33
34/*
35```cpp
36auto handle = TestCase::create();
37const TestCase &instance = *handle;
38assert(instance.get_test());
39```
40
41
42```rust
43let instance = TestCase::new().unwrap();
44assert!(instance.get_test());
45
46slint_testing::send_mouse_click(&instance, 21., 16.);
47assert_eq!(instance.get_clicked(), 16);
48instance.set_xx(80.);
49slint_testing::send_mouse_click(&instance, 81., 66.);
50assert_eq!(instance.get_clicked(), 66);
51```
52
53```js
54var instance = new slint.TestCase({});
55assert(instance.test);
56```
57*/
58