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
4component Item {
5 callback pointer-event <=> touch.pointer-event;
6 touch := TouchArea {}
7}
8
9component Issue3148 {
10 out property <length> result;
11 Item {
12 x: 42px;
13 pointer-event => {
14 debug(self.absolute-position.x - root.absolute-position.x);
15 }
16 init => {
17 result = self.absolute-position.x - root.absolute-position.x
18 }
19 }
20}
21
22export component TestCase {
23 width: 500phx;
24 height: 500phx;
25
26 property <bool> simple-inner-ok: simple-inner.absolute-position.x == 40phx && simple-inner.absolute-position.y == 60phx;
27 Rectangle {
28 x: 10phx;
29 y: 20phx;
30
31 simple-inner := Rectangle {
32 x: 30phx;
33 y: 40phx;
34 }
35 }
36 empty1 := Rectangle {
37 Rectangle {
38 empty2 := Rectangle {
39
40 }
41 }
42 }
43 xxx := Issue3148 { width: 50%; }
44 out property <bool> test: simple-inner-ok && xxx.result == 42px && empty1.absolute-position == empty2.absolute-position;
45 out property <Point> coords <=> simple-inner.absolute-position;
46}
47
48/*
49```rust
50let instance = TestCase::new().unwrap();
51assert!(instance.get_test());
52let pos: slint::LogicalPosition = instance.get_coords();
53assert_eq!(pos.x, 40.);
54assert_eq!(pos.y, 60.);
55```
56
57```cpp
58auto handle = TestCase::create();
59const TestCase &instance = *handle;
60assert(instance.get_test());
61slint::LogicalPosition pos = instance.get_coords();
62assert_eq(pos.x, 40);
63assert_eq(pos.y, 60);
64```
65
66```js
67let instance = new slint.TestCase({});
68assert(instance.test, 1);
69assert.deepEqual(instance.coords, { x: 40, y: 60});
70```
71
72*/
73