slint/tests/cases/elements/listview.60
2021-08-13 11:57:56 +02:00

64 lines
1.9 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 */
import { ListView } from "sixtyfps_widgets.60";
TestCase := Window {
width: 400px;
height: 540px;
property <string> value;
listview := ListView {
for data in [
{ text: "Blue", color: #0000ff, bg: #eeeeee},
{ text: "Red", color: #ff0000, bg: #eeeeee},
{ text: "Green", color: #00ff00, bg: #eeeeee},
{ text: "Yellow", color: #ffff00, bg: #222222 },
{ text: "Black", color: #000000, bg: #eeeeee },
{ text: "White", color: #ffffff, bg: #222222 },
{ text: "Magenta", color: #ff00ff, bg: #eeeeee },
{ text: "Cyan", color: #00ffff, bg: #222222 },
] : delegate := Rectangle {
background: @linear-gradient(90deg, data.bg,data.bg.brighter(0.5));
HorizontalLayout {
text_Name := Text {
height: 100px;
text: data.text;
color: data.color;
font_size: 20px ;
}
}
TouchArea { clicked => { value = data.text; } }
}
}
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
sixtyfps::testing::send_mouse_click(&instance, 5., 205.);
assert_eq(instance.get_value(), "Green");
```
```rust
let instance = TestCase::new();
sixtyfps::testing::send_mouse_click(&instance, 5., 205.);
assert_eq!(instance.get_value(), "Green");
```
```js
var instance = new sixtyfps.TestCase();
instance.send_mouse_click(5., 205.);
assert.equal(instance.value, "Green");
```
*/