slint/tests/cases/callbacks/functions.slint
2022-12-22 00:26:27 -08:00

51 lines
1 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
global G := {
property <string> hello: "hello";
function meh(w: string) -> string {
return hello + " " + w;
}
}
SubCompo := Rectangle {
public pure function hello() -> color { red }
}
TestCase := Rectangle {
property <int> c: 100000;
private property <int> one: 1 + Math.round((x / 1px) - (y / 1px));
function foo() {}
function the_function(a: int, b: int) -> int { foo(); a + b + c + one }
if true : Rectangle {
background: the_function(1, 2) > 3 ? blue: sc.hello();
}
sc := SubCompo {
}
property <bool> test: the_function(4500, 20) == 104521 && G.meh("world") == "hello world" && sc.hello() == Colors.red;
}
/*
```rust
let instance = TestCase::new();
assert!(instance.get_test());
```
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(instance.get_test());
```
```js
var instance = new slint.TestCase();
assert(instance.test);
```
*/