slint/tests/cases/layout/grid_within_for.slint
Aurindam Jana 3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00

60 lines
1.6 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
// Regression test for a panic in the compiler
TestCase := Rectangle {
width: 300phx;
height: 300phx;
property<int> value: 1;
for c[index] in [#f00, #00f, #0a0]: Rectangle {
y: index * height;
width: parent.width;
height: 100phx;
GridLayout {
Rectangle {
background: c;
TouchArea {
width: parent.width;
height: parent.height;
clicked => {
value += index;
}
}
}
}
}
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
slint_testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
slint_testing::send_mouse_click(&instance, 190., 190.);
assert_eq(instance.get_value(), 1+1);
slint_testing::send_mouse_click(&instance, 5., 290.);
assert_eq(instance.get_value(), 1+1+2);
```
```rust
let instance = TestCase::new().unwrap();
slint_testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout
slint_testing::send_mouse_click(&instance, 190., 190.);
assert_eq!(instance.get_value(), 1+1);
slint_testing::send_mouse_click(&instance, 5., 290.);
assert_eq!(instance.get_value(), 1+1+2);
```
// FIXME: JS test because layout are not computed
*/