mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 22:31:14 +00:00

Otherwise some used struct might not be found, and they can cause compilation failure in the generated C++ or Rust code Fixes #549
67 lines
2.1 KiB
Text
67 lines
2.1 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 */
|
|
//include_path: ../../helper_components
|
|
|
|
import { StyleMetrics } from "sixtyfps_widgets.60";
|
|
import { ExportedGlobal as ReexportedGlobal } from "export_globals.60";
|
|
|
|
struct MyStruct := { x:int, y: int, }
|
|
|
|
global InternalGlobal := {
|
|
property <int> hello: 42;
|
|
property <MyStruct> my_struct;
|
|
callback sum(int, int)->int;
|
|
}
|
|
|
|
export { InternalGlobal as PublicGlobal }
|
|
export { ReexportedGlobal }
|
|
|
|
TestCase := Rectangle {
|
|
property <bool> test_global_prop_value: InternalGlobal.hello == 100;
|
|
property <int> test_call_callback: InternalGlobal.sum(6, 4);
|
|
}
|
|
|
|
/*
|
|
```rust
|
|
let instance = TestCase::new();
|
|
assert!(!instance.get_test_global_prop_value());
|
|
assert_eq!(PublicGlobal::get(&instance).get_hello(), 42);
|
|
instance.global::<PublicGlobal>().set_hello(100);
|
|
assert!(instance.get_test_global_prop_value());
|
|
|
|
assert_eq!(ReexportedGlobal::get(&instance).get_foo(), 44);
|
|
|
|
instance.global::<PublicGlobal>().on_sum(|a, b| a + b);
|
|
assert_eq!(instance.get_test_call_callback(), 10);
|
|
assert_eq!(instance.global::<PublicGlobal>().invoke_sum(4, 5), 9);
|
|
```
|
|
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert(!instance.get_test_global_prop_value());
|
|
assert_eq(instance.global<PublicGlobal>().get_hello(), 42);
|
|
instance.global<PublicGlobal>().set_hello(100);
|
|
assert(instance.get_test_global_prop_value());
|
|
|
|
assert_eq(instance.global<ReexportedGlobal>().get_foo(), 44);
|
|
|
|
instance.global<PublicGlobal>().on_sum([](int a, int b) { return a + b; });
|
|
assert_eq(instance.get_test_call_callback(), 10);
|
|
assert_eq(instance.global<PublicGlobal>().invoke_sum(4, 5), 9);
|
|
```
|
|
|
|
```js
|
|
let instance = new sixtyfps.TestCase({});
|
|
assert(!instance.test_global_prop_value);
|
|
// TODO
|
|
```
|
|
|
|
*/
|