mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-22 16:22:17 +00:00
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
66 lines
1.8 KiB
Text
66 lines
1.8 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
|
|
|
|
import { StyleMetrics } from "std-widgets.slint";
|
|
|
|
global Glop := {
|
|
property <int> hello: 42;
|
|
property <int> second: 88;
|
|
property <int> third: 102;
|
|
}
|
|
|
|
global DualBindingGlop := {
|
|
property third <=> Glop.third;
|
|
}
|
|
|
|
Widget := Rectangle {
|
|
property second <=> Glop.second;
|
|
}
|
|
|
|
TestCase := Rectangle {
|
|
// This is meant to test an alias to a native global.
|
|
// Unfortunately, this is only a native global with the Qt backend and not with the Test backend
|
|
property <length> alias_to_native <=> StyleMetrics.text_cursor_width;
|
|
property <int> alias_to_global <=> Glop.hello;
|
|
property <bool> test: alias_to_native == StyleMetrics.text_cursor_width && alias_to_global == 42 && indirect == 88;
|
|
property <int> indirect <=> widget.second;
|
|
property <int> direct: Glop.second;
|
|
property <int> dual <=> DualBindingGlop.third;
|
|
|
|
widget := Widget { }
|
|
}
|
|
|
|
/*
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
assert!(instance.get_test());
|
|
assert_eq!(instance.get_alias_to_global(), 42);
|
|
instance.set_alias_to_global(123);
|
|
assert_eq!(instance.get_alias_to_global(), 123);
|
|
assert_eq!(instance.get_indirect(), 88);
|
|
instance.set_indirect(99);
|
|
assert_eq!(instance.get_direct(), 99);
|
|
assert_eq!(instance.get_dual(), 102);
|
|
|
|
```
|
|
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert(instance.get_test());
|
|
assert_eq(instance.get_dual(), 102);
|
|
```
|
|
|
|
```js
|
|
let instance = new slint.TestCase({});
|
|
assert(instance.test);
|
|
assert.equal(instance.alias_to_global, 42);
|
|
instance.alias_to_global = 123;
|
|
assert.equal(instance.alias_to_global, 123);
|
|
assert.equal(instance.indirect, 88);
|
|
instance.indirect = 99;
|
|
assert.equal(instance.direct, 99);
|
|
assert.equal(instance.dual, 102);
|
|
```
|
|
|
|
*/
|