mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
85 lines
2.1 KiB
Text
85 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 */
|
|
TestCase := Rectangle {
|
|
property <bool> toggle: { return false; }
|
|
property <int> value: {
|
|
if (toggle) {
|
|
return 42;
|
|
}
|
|
return 100;
|
|
}
|
|
property <float> value2: {
|
|
return 100;
|
|
}
|
|
|
|
callback test_signal;
|
|
property <bool> block_signal;
|
|
property <bool> signal_handled;
|
|
test_signal => {
|
|
if (block_signal) {
|
|
return;
|
|
}
|
|
signal_handled = true;
|
|
}
|
|
|
|
property<bool> test: { return value2 == value; return false; }
|
|
}
|
|
/*
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
assert_eq(instance.get_value(), 100);
|
|
assert(instance.get_test());
|
|
instance.set_toggle(true);
|
|
assert_eq(instance.get_value(), 42);
|
|
|
|
instance.invoke_test_signal();
|
|
assert(instance.get_signal_handled());
|
|
|
|
instance.set_signal_handled(false);
|
|
instance.set_block_signal(true);
|
|
instance.invoke_test_signal();
|
|
assert(!instance.get_signal_handled());
|
|
```
|
|
|
|
```rust
|
|
let instance = TestCase::new();
|
|
assert_eq!(instance.get_value(), 100);
|
|
assert!(instance.get_test());
|
|
instance.set_toggle(true);
|
|
assert_eq!(instance.get_value(), 42);
|
|
|
|
instance.invoke_test_signal();
|
|
assert!(instance.get_signal_handled());
|
|
|
|
instance.set_signal_handled(false);
|
|
instance.set_block_signal(true);
|
|
instance.invoke_test_signal();
|
|
assert!(!instance.get_signal_handled());
|
|
```
|
|
|
|
|
|
```js
|
|
var instance = new sixtyfps.TestCase({});
|
|
assert.equal(instance.value, 100);
|
|
assert(instance.test);
|
|
instance.toggle = (true);
|
|
assert.equal(instance.value, 42);
|
|
|
|
instance.test_signal();
|
|
assert(instance.signal_handled);
|
|
|
|
instance.signal_handled = (false);
|
|
instance.block_signal = (true);
|
|
instance.test_signal();
|
|
assert(!instance._signal_handled);
|
|
```
|
|
|
|
*/
|