mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-19 03:28:52 +00:00
Make the slider change the amplitude of the graph, and the pitch and yaw can be changed by dragging the graph
55 lines
1.9 KiB
Text
55 lines
1.9 KiB
Text
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
|
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
|
|
|
import { Slider, GroupBox, HorizontalBox, VerticalBox } from "sixtyfps_widgets.60";
|
|
|
|
export MainWindow := Window {
|
|
title: "SixtyFPS Plotter Integration Example";
|
|
preferred-width: 800px;
|
|
preferred-height: 600px;
|
|
|
|
callback render_plot(float /* pitch */, float /* yaw */, float /* amplitude */) -> image;
|
|
|
|
property <float> pitch: 0.15;
|
|
property <float> yaw: 0.5;
|
|
|
|
VerticalBox {
|
|
Text {
|
|
font-size: 20px;
|
|
text: "2D Gaussian PDF";
|
|
horizontal-alignment: center;
|
|
}
|
|
Image {
|
|
source: root.render_plot(pitch, yaw, amplitude-slider.value / 10);
|
|
touch := TouchArea {
|
|
property <float> pressed-pitch;
|
|
property <float> pressed-yaw;
|
|
pointer-event(event) => {
|
|
if (event.button == PointerEventButton.left && event.kind == PointerEventKind.down) {
|
|
pressed-pitch = root.pitch;
|
|
pressed-yaw = root.yaw;
|
|
}
|
|
}
|
|
moved => {
|
|
if (enabled && pressed) {
|
|
pitch = pressed-pitch + (touch.mouse-y - touch.pressed-y) / height * 3.14;
|
|
yaw = pressed-yaw - (touch.mouse-x - touch.pressed-x) / width * 3.14;
|
|
}
|
|
}
|
|
mouse-cursor: pressed ? MouseCursor.grabbing : MouseCursor.grab;
|
|
}
|
|
}
|
|
HorizontalBox {
|
|
Text {
|
|
text: "Amplitude:";
|
|
font-weight: 600;
|
|
vertical-alignment: center;
|
|
}
|
|
amplitude-slider := Slider {
|
|
minimum: 0;
|
|
maximum: 100;
|
|
value: 50;
|
|
}
|
|
}
|
|
}
|
|
}
|