mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-28 10:49:46 +00:00
Some checks are pending
autofix.ci / format_fix (push) Waiting to run
autofix.ci / lint_typecheck (push) Waiting to run
CI / wasm (push) Blocked by required conditions
CI / wasm_demo (push) Blocked by required conditions
CI / tree-sitter (push) Blocked by required conditions
CI / files-changed (push) Waiting to run
CI / build_and_test (ubuntu-22.04, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, macos-14, stable) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, 1.88) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, beta) (push) Blocked by required conditions
CI / build_and_test (--exclude ffmpeg --exclude gstreamer-player, windows-2022, stable) (push) Blocked by required conditions
CI / build_and_test (ubuntu-22.04, nightly) (push) Blocked by required conditions
CI / node_test (macos-14) (push) Blocked by required conditions
CI / node_test (ubuntu-22.04) (push) Blocked by required conditions
CI / node_test (windows-2022) (push) Blocked by required conditions
CI / python_test (macos-14) (push) Blocked by required conditions
CI / python_test (ubuntu-22.04) (push) Blocked by required conditions
CI / python_test (windows-2022) (push) Blocked by required conditions
CI / cpp_test_driver (macos-14) (push) Blocked by required conditions
CI / cpp_test_driver (ubuntu-22.04) (push) Blocked by required conditions
CI / cpp_test_driver (windows-2022) (push) Blocked by required conditions
CI / cpp_cmake (macos-14, 1.88) (push) Blocked by required conditions
CI / cpp_cmake (ubuntu-22.04, stable) (push) Blocked by required conditions
CI / cpp_cmake (windows-2022, nightly) (push) Blocked by required conditions
CI / mcu (pico-st7789, thumbv6m-none-eabi) (push) Blocked by required conditions
CI / mcu (pico2-st7789, thumbv8m.main-none-eabihf) (push) Blocked by required conditions
CI / mcu (stm32h735g, thumbv7em-none-eabihf) (push) Blocked by required conditions
CI / docs (push) Blocked by required conditions
CI / esp-idf-quick (push) Blocked by required conditions
CI / android (push) Blocked by required conditions
CI / miri (push) Blocked by required conditions
CI / test-figma-inspector (push) Blocked by required conditions
CI / cpp_package_test (push) Blocked by required conditions
CI / ffi_32bit_build (push) Blocked by required conditions
CI / vsce_build_test (push) Blocked by required conditions
CI / mcu-embassy (push) Blocked by required conditions
CI / updater_test (0.3.0) (push) Blocked by required conditions
CI / fmt_test (push) Blocked by required conditions
CI / material-components (push) Blocked by required conditions
This is to avoid reserving the `scale` property on every element which is a common property name
106 lines
3.9 KiB
Text
106 lines
3.9 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
|
|
|
|
export component TestCase {
|
|
in-out property <int> touch1;
|
|
in-out property <int> touch_double1;
|
|
|
|
in-out property <string> pointer-event-test;
|
|
|
|
in property <bool> enabled1 <=> area1.enabled;
|
|
out property <bool> pressed1 <=> area1.pressed;
|
|
out property <bool> has-hover1 <=> area1.has-hover;
|
|
|
|
|
|
width: 800px;
|
|
height: 600px;
|
|
|
|
Rectangle {
|
|
x: 0px;
|
|
y: 0px;
|
|
width: 50px;
|
|
height: 50px;
|
|
transform-scale-x: 200%;
|
|
transform-scale-y: 400%;
|
|
rotation-origin-x: 0px;
|
|
rotation-origin-y: 0px;
|
|
area1 := TouchArea {
|
|
clicked => {
|
|
pointer-event-test += "click:";
|
|
touch1+=1;
|
|
}
|
|
double-clicked => {
|
|
pointer-event-test += "double_click:";
|
|
touch_double1+=1;
|
|
}
|
|
pointer-event(e) => {
|
|
if (e.kind == PointerEventKind.cancel) {
|
|
pointer-event-test += "cancel,";
|
|
} else if (e.kind == PointerEventKind.up) {
|
|
pointer-event-test += "up.";
|
|
} else if (e.kind == PointerEventKind.down) {
|
|
pointer-event-test += "down.";
|
|
} else if (e.kind == PointerEventKind.move) {
|
|
pointer-event-test += "move.";
|
|
} else {
|
|
pointer-event-test += "err.";
|
|
}
|
|
if (e.button == PointerEventButton.right) {
|
|
pointer-event-test += "right";
|
|
} else if (e.button == PointerEventButton.left) {
|
|
pointer-event-test += "left";
|
|
} else if (e.button == PointerEventButton.middle) {
|
|
pointer-event-test += "middle";
|
|
} else if (e.button == PointerEventButton.back) {
|
|
pointer-event-test += "back";
|
|
} else if (e.button == PointerEventButton.forward) {
|
|
pointer-event-test += "forward";
|
|
} else if (e.button == PointerEventButton.other) {
|
|
pointer-event-test += "other";
|
|
} else {
|
|
pointer-event-test += "???";
|
|
}
|
|
if (e.modifiers.control) {
|
|
pointer-event-test += "(ctrl)";
|
|
}
|
|
if (e.modifiers.shift) {
|
|
pointer-event-test += "(shift)";
|
|
}
|
|
if (e.modifiers.meta) {
|
|
pointer-event-test += "(meta)";
|
|
}
|
|
if (e.modifiers.alt) {
|
|
pointer-event-test += "(alt)";
|
|
}
|
|
pointer-event-test += ":";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
```rust
|
|
use slint::private_unstable_api::re_exports::MouseCursor;
|
|
|
|
let instance = TestCase::new().unwrap();
|
|
|
|
/*let double_click = |x, y| {
|
|
slint_testing::send_mouse_click(&instance, x, y);
|
|
slint_testing::mock_elapsed_time(50);
|
|
slint_testing::send_mouse_click(&instance, x, y);
|
|
};*/
|
|
|
|
assert_eq!(slint_testing::access_testing_window(instance.window(), |window| window.mouse_cursor.get()), MouseCursor::Default);
|
|
assert_eq!(instance.get_touch1(), 0);
|
|
slint_testing::send_mouse_click(&instance, 1.0,1.0);
|
|
assert_eq!(instance.get_touch1(), 1);
|
|
slint_testing::send_mouse_click(&instance, 49.9,49.9);
|
|
assert_eq!(instance.get_touch1(), 2);
|
|
slint_testing::send_mouse_click(&instance, 99.9,199.9);
|
|
assert_eq!(instance.get_touch1(), 3);
|
|
slint_testing::send_mouse_click(&instance, 99.9,200.1);
|
|
slint_testing::send_mouse_click(&instance, 100.1,200.1);
|
|
slint_testing::send_mouse_click(&instance, 100.1,199.9);
|
|
assert_eq!(instance.get_touch1(), 3);
|
|
```
|
|
*/
|