slint/tests/cases/layout/path.60
2021-08-17 22:38:16 +02:00

116 lines
2.8 KiB
Text

/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
TestCase := Rectangle {
Path {
x: 300phx;
y: 300phx;
commands: "M 100 300 Q 150 50 250 150 C 250 300 300 300 300 450 A 50 50 0 1 0 450 450 L 550 300";
stroke: black;
stroke_width: 2px;
}
PathLayout {
x: 300phx;
y: 300phx;
commands: "M 100 300 Q 150 50 250 150 C 250 300 300 300 300 450 A 50 50 0 1 0 450 450 L 550 300";
Text {
text: "First item on path";
color: black;
}
Text {
text: "Second item on path";
color: black;
}
Text {
text: "Third item on path";
color: black;
}
}
PathLayout {
commands: "M 0 0 L 100 100";
item1 := Rectangle {
width: 2phx;
height: 2phx;
background: red;
}
item2 := Rectangle {
width: 2phx;
height: 2phx;
background: blue;
}
item3 := Rectangle {
width: 2phx;
height: 2phx;
background: green;
}
}
property <bool> test1 : item1.x == item1.y && item2.x == item2.y && item3.x == item3.y;
property <bool> test2 : item1.x < item2.x + 20phx && item2.x < item3.x + 20phx;
property <bool> test3 : item1.x == -1phx;
property <bool> test4 : item3.x == 99phx;
// No items should not crash
PathLayout {
commands: "M 0 0 L 100 100";
}
// Single Item is in the middle
PathLayout {
commands: "M 0 0 L 100 100";
single_item := Rectangle {
width: 2phx;
height: 2phx;
background: yellow;
}
}
property <bool> test5 : single_item.x == item2.x && single_item.y == item2.y;
property <bool> test: test1 && test2 && test3 && test4 && test5;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test1());
assert(instance.get_test2());
assert(instance.get_test3());
assert(instance.get_test4());
assert(instance.get_test5());
```
```rust
let instance = TestCase::new();
assert!(instance.get_test1());
assert!(instance.get_test2());
assert!(instance.get_test3());
assert!(instance.get_test4());
assert!(instance.get_test5());
```
```js
var instance = new sixtyfps.TestCase({});
assert(instance.test1);
assert(instance.test2);
assert(instance.test3);
assert(instance.test4);
assert(instance.test5);
```
*/