mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
135 lines
3.2 KiB
Text
135 lines
3.2 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
|
|
|
|
ExtraComponent := Rectangle {
|
|
for x in [{a: "0"}, {a: "1"}] : Text { text: x.a; }
|
|
}
|
|
|
|
|
|
Extra2 := Rectangle {
|
|
property<int> top_level;
|
|
property<int> value;
|
|
callback update_value;
|
|
for aaa[r] in [[10, top_level], [2, 3]] : blah := Rectangle {
|
|
width: parent.width;
|
|
height: root.height;
|
|
property <int> some_value: 1000;
|
|
for bb[l] in aaa : TouchArea {
|
|
property <int> some_value: 1515;
|
|
width: 10phx;
|
|
height: 10phx;
|
|
x: r*10phx;
|
|
y: l*10phx;
|
|
clicked => {
|
|
root.value += bb + blah.some_value;
|
|
update_value();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
export TestCase := Rectangle {
|
|
width: 100phx;
|
|
height: 100phx;
|
|
background: white;
|
|
property<float> top_level: 42;
|
|
property<int> value: 0;
|
|
|
|
for pp[idx] in 5: Rectangle {
|
|
s := Rectangle {
|
|
property<length> within: 88phx;
|
|
x: 2phx * idx;
|
|
y: 200phx * pp;
|
|
width: s.within;
|
|
height: root.top_level * 1phx;
|
|
for nested in [1phx] : Rectangle {
|
|
x : s.width + root.top_level * 1phx + nested;
|
|
}
|
|
}
|
|
}
|
|
|
|
for pp[idx] in [1,3,2]: Rectangle {
|
|
x: idx * 1phx;
|
|
y: 25phx * pp;
|
|
}
|
|
|
|
for pp[idx] in ["1","3","2"]: Rectangle {
|
|
x: idx * 1phx;
|
|
Text { text: pp; }
|
|
}
|
|
|
|
for pp in [{a: 12, b: "aa", c: {a: #00f}}, {a: 13, b: "cc", c: { a: #f00}}]: Text {
|
|
x: pp.a * 1phx;
|
|
text: pp.b;
|
|
color: pp.c.a;
|
|
ExtraComponent {
|
|
}
|
|
}
|
|
Extra2 {
|
|
width: parent.width;
|
|
height: root.height;
|
|
top_level: root.top_level;
|
|
update_value => {
|
|
root.value = self.value;
|
|
}
|
|
}
|
|
|
|
property<[{a: int}]> m;
|
|
for x in m : TouchArea {
|
|
width: parent.width;
|
|
height: root.height;
|
|
clicked => {
|
|
root.value = x.a;
|
|
}
|
|
}
|
|
|
|
// issue #2977
|
|
for v in value + value : Text { text: v; }
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
```cpp
|
|
auto handle = TestCase::create();
|
|
const TestCase &instance = *handle;
|
|
|
|
slint_testing::send_mouse_click(&instance, 5., 5.);
|
|
assert_eq(instance.get_value(), 1010);
|
|
|
|
slint_testing::send_mouse_click(&instance, 15., 15.);
|
|
assert_eq(instance.get_value(), 2013);
|
|
|
|
slint_testing::send_mouse_click(&instance, 5., 15.);
|
|
assert_eq(instance.get_value(), 3000+13+42);
|
|
```
|
|
|
|
|
|
```rust
|
|
let instance = TestCase::new().unwrap();
|
|
|
|
slint_testing::send_mouse_click(&instance, 5., 5.);
|
|
assert_eq!(instance.get_value(), 1010);
|
|
|
|
slint_testing::send_mouse_click(&instance, 15., 15.);
|
|
assert_eq!(instance.get_value(), 2013);
|
|
|
|
slint_testing::send_mouse_click(&instance, 5., 15.);
|
|
assert_eq!(instance.get_value(), 3000+13+42);
|
|
|
|
```
|
|
|
|
```js
|
|
var instance = new slint.TestCase();
|
|
slintlib.private_api.send_mouse_click(instance, 5., 5.);
|
|
assert.equal(instance.value, 1010);
|
|
|
|
instance.cond1 = true;
|
|
slintlib.private_api.send_mouse_click(instance, 15., 15.);
|
|
assert.equal(instance.value, 2013);
|
|
|
|
instance.cond1 = false;
|
|
slintlib.private_api.send_mouse_click(instance, 5., 15.);
|
|
assert.equal(instance.value, 3000+13+42);
|
|
```
|
|
*/
|