slint/tests/cases/layout/nested_grid.60
2021-07-02 15:55:54 +02:00

69 lines
2.5 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 {
width: 300phx;
height: 300phx;
GridLayout {
spacing: 0phx;
padding: 0phx;
Row {
rect1 := Rectangle { background: red; horizontal-stretch: 2;}
}
Row {
rect2 := Rectangle { background: green; horizontal-stretch: 2; }
ig := GridLayout {
spacing: 4phx;
padding: 0phx;
rect3 := Rectangle { background: black; }
rect4 := Rectangle { background: blue; }
rect5 := Rectangle { background: red; row: 1; }
rect6 := Rectangle { background: green; }
}
}
}
property <bool> rect1_pos_ok: rect1.x == 0phx && rect1.y == 0phx && rect1.width == 148phx && rect1.height == 148phx;
property <bool> rect2_pos_ok: rect2.x == 0phx && rect2.y == 148phx && rect2.width == 148phx && rect2.height == 152phx;
property <bool> rect3_pos_ok: ig.x + rect3.x == 148phx && ig.y + rect3.y == 148phx && rect3.width == 74phx && rect3.height == 74phx;
property <bool> rect4_pos_ok: ig.x + rect4.x == 226phx && ig.y + rect4.y == 148phx && rect4.width == 74phx && rect4.height == 74phx;
property <bool> rect5_pos_ok: ig.x + rect5.x == 148phx && ig.y + rect5.y == 226phx && rect5.width == 74phx && rect5.height == 74phx;
property <bool> rect6_pos_ok: ig.x + rect6.x == 226phx && ig.y + rect6.y == 226phx && rect6.width == 74phx && rect6.height == 74phx;
property <bool> test: rect1_pos_ok && rect2_pos_ok && rect3_pos_ok && rect4_pos_ok && rect5_pos_ok && rect6_pos_ok;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_rect1_pos_ok());
assert(instance.get_rect2_pos_ok());
assert(instance.get_rect3_pos_ok());
assert(instance.get_rect4_pos_ok());
assert(instance.get_rect5_pos_ok());
assert(instance.get_rect6_pos_ok());
```
```rust
let instance = TestCase::new();
assert!(instance.get_rect1_pos_ok());
assert!(instance.get_rect2_pos_ok());
assert!(instance.get_rect3_pos_ok());
assert!(instance.get_rect4_pos_ok());
assert!(instance.get_rect5_pos_ok());
assert!(instance.get_rect6_pos_ok());
```
*/