1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/7guis"#]
2// Copyright © SixtyFPS GmbH <info@slint.dev>
3// SPDX-License-Identifier: MIT
4
5import { LineEdit, Button, Slider, StandardListView, VerticalBox } from "std-widgets.slint";
6
7struct Circle { x: length, y: length, d: length }
8
9export component MainWindow inherits Window {
10 in property <[Circle]> model;
11 in property <bool> undoable: false;
12 in property <bool> redoable: false;
13
14 callback undo_clicked();
15 callback redo_clicked();
16 callback background_clicked(length,length);
17 callback circle_resized(int, length);
18
19 private property <int> clicked-idx: -1;
20 private property <Circle> selected-circle;
21
22 preferred-width: 500px;
23 preferred-height: 400px;
24
25 VerticalBox {
26 HorizontalLayout {
27 alignment: center;
28 spacing: 12px;
29
30 Button {
31 text: "Undo";
32 enabled <=> root.undoable;
33 clicked => { root.undo-clicked() }
34 }
35 Button {
36 text: "Redo";
37 enabled <=> root.redoable;
38 clicked => { root.redo-clicked() }
39 }
40 }
41 Rectangle {
42 background: white;
43 border-color: black;
44 border-width: 2px;
45 clip: true;
46
47 TouchArea {
48 clicked => {
49 root.background_clicked(self.pressed_x, self.pressed_y);
50 }
51
52 width: 100%;
53 height: 100%;
54 }
55
56 for circle[idx] in root.model : Rectangle {
57 background: root.clicked-idx == idx ? gray : white;
58 border-color: black;
59 border-width: 2px;
60 border-radius: self.width / 2;
61 height: self.width;
62 width: circle.d;
63 x: circle.x - self.width/2;
64 y: circle.y - self.height/2;
65
66 TouchArea {
67 clicked => {
68 root.selected-circle = circle;
69 root.clicked-idx = idx;
70 }
71
72 height: 100%;
73 width: 100%;
74 }
75 }
76 }
77 }
78
79 if (root.clicked-idx != -1) : TouchArea {
80 clicked => { root.clicked-idx = -1; }
81
82 height: 100%;
83 width: 100%;
84 }
85
86 if (root.clicked-idx != -1) : Rectangle {
87 background: lightgray;
88 height: 30%;
89 width: 70%;
90 x: (parent.width - self.width) / 2;
91 y: parent.height - self.height - parent.height * 5%;
92
93 TouchArea {
94 height: 100%;
95 width: 100%;
96 }
97
98 VerticalBox {
99 Text {
100 text: "Adjust diameter of circle at (" + root.selected-circle.x / 1px + ", " + root.selected-circle.y / 1px + ").";
101 wrap: word-wrap;
102 }
103
104 Slider {
105 changed(diameter) => {
106 root.circle_resized(root.clicked-idx, diameter *1px);
107 }
108
109 minimum: 4;
110 maximum: 100;
111 value: root.selected-circle.d / 1px;
112 }
113 }
114 }
115}
116}
117