Skip to content

Commit 8261c84

Browse files
authored
Finish Demo (#9763)
This fixes the ugly buttons and works around the opacity issue with rotation.
1 parent 783f740 commit 8261c84

File tree

2 files changed

+42
-14
lines changed

2 files changed

+42
-14
lines changed

examples/speedometer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- Copyright © SixtyFPS GmbH <[email protected]> ; SPDX-License-Identifier: MIT -->
2-
![Speedometer Screenshot](https://github.com/user-attachments/assets/bc3a6036-6fa7-4a1a-84ec-b0f16da663ef)
2+
![Speedometer Screenshot](https://github.com/user-attachments/assets/a5f19f43-9f36-443b-9e6d-cc6b504595e6)
33

44
# Speedometer demo
55

examples/speedometer/demo.slint

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
11
// Copyright © SixtyFPS GmbH <[email protected]>
22
// SPDX-License-Identifier: MIT
33

4-
import { Button, VerticalBox, HorizontalBox } from "std-widgets.slint";
54
import "./01 Digitall.ttf";
65

6+
component CarButton inherits Rectangle {
7+
callback clicked <=> touch-area.clicked;
8+
in property <string> text;
9+
property <angle> touch-animation: touch-area.pressed ? 180deg : 0deg;
10+
animate touch-animation { duration: 500ms; }
11+
property <angle> stop1: 67deg + touch-animation;
12+
property <angle> stop2: 121deg + touch-animation;
13+
property <angle> stop3: 167deg + touch-animation;
14+
property <angle> stop4: 256deg + touch-animation;
15+
property <angle> stop5: 302deg + touch-animation;
16+
property <angle> stop6: 351deg + touch-animation;
17+
18+
width: 80px;
19+
height: 30px;
20+
border-radius: 20px;
21+
border-width: 1px;
22+
border-color: @conic-gradient(#020414 stop1, #ff0000 stop2, #020414 stop3, #020414 stop4, #ff0000 stop5, #000000 stop6 );
23+
background: @linear-gradient(45deg + touch-animation, #000000 0%, #4d0404 100%);
24+
25+
label :=Text {
26+
text: text;
27+
font-family: "01 Digitall";
28+
font-size: 16px;
29+
color: touch-area.pressed ? #ff0404 : #ffffff;
30+
letter-spacing: 2px;
31+
}
32+
33+
touch-area := TouchArea {}
34+
}
35+
736
component MiniDot {
837
width: 0;
938
height: 0;
@@ -54,7 +83,6 @@ component KPHText {
5483
font-size: 18px;
5584
transform-rotation: -root.transform-rotation - 50deg;
5685
font-family: "01 Digitall";
57-
opacity: 0.9;
5886
horizontal-alignment: left;
5987
}
6088
}
@@ -131,8 +159,8 @@ export component MainWindow inherits Window {
131159
border-width: 1px;
132160
border-color: @conic-gradient(#020414 67.5deg, #ff0000 121deg, #020414 167deg, #020414 256deg, #ff0000 302deg, #000000 351deg);
133161
background: background-color;
134-
drop-shadow-blur: 30px;
135-
drop-shadow-color: #fe5a5a60;
162+
drop-shadow-blur: 25px;
163+
drop-shadow-color: #fe5a5a.with-alpha(0.4 + (0.2 * (speed / 260)));
136164

137165
Text {
138166
text: speed;
@@ -158,35 +186,35 @@ export component MainWindow inherits Window {
158186
}
159187
}
160188

161-
control-buttons := HorizontalBox {
162-
spacing: 10px;
189+
control-buttons := HorizontalLayout {
190+
spacing: 20px;
163191
alignment: center;
164192
height: 50px;
165-
y: 450px;
193+
y: 420px;
166194

167-
Button {
195+
CarButton {
168196
text: "STOP";
169197
clicked => {
170198
speed = 0;
171199
}
172200
}
173201

174-
Button {
175-
text: "CRUISE";
202+
CarButton {
203+
text: "DRIVE";
176204
clicked => {
177205
speed = 60;
178206
}
179207
}
180208

181-
Button {
209+
CarButton {
182210
text: "FAST";
183211
clicked => {
184212
speed = 120;
185213
}
186214
}
187215

188-
Button {
189-
text: "MAX";
216+
CarButton {
217+
text: "TURBO";
190218
clicked => {
191219
speed = 240;
192220
}

0 commit comments

Comments
 (0)