Added Window Header and minor tweaks

This commit is contained in:
2026-03-10 13:18:28 +01:00
parent 20393f3f70
commit 8faa56c522
4 changed files with 371 additions and 364 deletions

View File

@@ -123,335 +123,230 @@ export component AppWindow inherits Window {
background: Palette.bg-secondary; background: Palette.bg-secondary;
horizontal-stretch: 1; horizontal-stretch: 1;
vertical-stretch: 1; vertical-stretch: 1;
Rectangle { DataWindow {
width: parent.width / 3; x: 0;
height: parent.height / 2; y: 0;
x: 0px; data1: [
y: 0px; { label: "Engine Temp", value: 97, unit: " °C" },
DataWindow { { label: "Engine RPM", value: 2573, unit: " RPM" },
data1: [ { label: "Engine Map", value: 7, unit: "" },
{ label: "Engine Temp", value: 97, unit: " °C" }, { label: "Fuel Rate", value: 0.62, unit: " L/h" },
{ label: "Engine RPM", value: 2573, unit: " RPM" }, { label: "Injector PW", value: 2.7, unit: " ms" },
{ label: "Engine Map", value: 7, unit: "" }, { label: "Ignition Adv", value: 21, unit: " °" },
{ label: "Fuel Rate", value: 0.62, unit: " L/h" }, ];
{ label: "Injector PW", value: 2.7, unit: " ms" }, data2: [
{ label: "Ignition Adv", value: 21, unit: " °" }, { label: "GPS Speed", value: 38.9, unit: " km/h" },
]; { label: "GPS Satellites", value: 14, unit: "" },
data2: [ { label: "Tank Pressure", value: 101.7, unit: " kPa" },
{ label: "GPS Speed", value: 38.9, unit: " km/h" }, { label: "Air Temp", value: 24, unit: " °C" },
{ label: "GPS Satellites", value: 14, unit: "" }, { label: "Humidity", value: 42, unit: " %" },
{ label: "Tank Pressure", value: 101.7, unit: " kPa" }, { label: "Barometric", value: 1012, unit: " hPa" }
{ label: "Air Temp", value: 24, unit: " °C" }, ];
{ label: "Humidity", value: 42, unit: " %" },
{ label: "Barometric", value: 1012, unit: " hPa" }
];
}
} }
Rectangle { MapWindow {
width: 2 * parent.width / 3; x: 512px;
height: 2 * parent.height / 3; y: 0;
x: parent.width / 3; data-min: 2200;
y: 0px; data-max: 9400;
MapWindow { name: "Config 1 - Injection Period";
data-min: 2200; map-axis: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
data-max: 12000; rpm-axis: [
name: "MAP 1"; 250,
map-axis: [ 500,
0.0, 750,
0.0667, 1000,
0.1333, 1250,
0.2, 1500,
0.2667, 1750,
0.3333, 2000,
0.4, 2250,
0.4667, 2500,
0.5333, 2750,
0.6, 3000,
0.6667, 3250,
0.7333, 3500,
0.8, 3750,
0.8667, 4000
0.9333, ];
1.0 data: [
]; 2200,
rpm-axis: [ 2300,
250, 2400,
500, 2500,
750, 2600,
1000, 2700,
1250, 2800,
1500, 2900,
1750, 3000,
2000, 3100,
2250, 3200,
2500, 3300,
2750, 3400,
3000, 3500,
3250, 3600,
3500, 3700,
3750, 2400,
4000 2500,
]; 2600,
data: [ 2700,
2200, 2800,
2300, 3000,
2400, 3200,
2500, 3400,
2600, 3600,
2700, 3800,
2800, 4000,
2900, 4200,
3000, 4400,
3100, 4600,
3200, 4800,
3300, 5000,
3400, 2600,
3500, 2800,
3600, 3000,
3700, 3200,
2400, 3400,
2500, 3600,
2600, 3800,
2700, 4000,
2800, 4200,
3000, 4400,
3200, 4600,
3400, 4800,
3600, 5000,
3800, 5200,
4000, 5400,
4200, 5600,
4400, 2800,
4600, 3000,
4800, 3200,
5000, 3400,
2600, 3600,
2800, 3800,
3000, 4000,
3200, 4300,
3400, 4600,
3600, 4900,
3800, 5200,
4000, 5500,
4200, 5800,
4400, 6100,
4600, 6400,
4800, 6700,
5000, 3000,
5200, 3200,
5400, 3400,
5600, 3600,
2800, 3800,
3000, 4100,
3200, 4400,
3400, 4700,
3600, 5000,
3800, 5300,
4000, 5600,
4300, 5900,
4600, 6200,
4900, 6500,
5200, 6800,
5500, 7100,
5800, 3300,
6100, 3500,
6400, 3700,
6700, 3900,
3000, 4200,
3200, 4500,
3400, 4800,
3600, 5100,
3800, 5400,
4100, 5700,
4400, 6000,
4700, 6300,
5000, 6600,
5300, 6900,
5600, 7200,
5900, 7500,
6200, 3600,
6500, 3800,
6800, 4000,
7100, 4200,
3300, 4500,
3500, 4800,
3700, 5100,
3900, 5400,
4200, 5700,
4500, 6000,
4800, 6300,
5100, 6600,
5400, 6900,
5700, 7200,
6000, 7500,
6300, 7800,
6600, 3900,
6900, 4100,
7200, 4300,
7500, 4600,
3600, 4900,
3800, 5200,
4000, 5500,
4200, 5800,
4500, 6100,
4800, 6400,
5100, 6700,
5400, 7000,
5700, 7300,
6000, 7600,
6300, 7900,
6600, 8200,
6900, 4200,
7200, 4400,
7500, 4700,
7800, 5000,
3900, 5300,
4100, 5600,
4300, 5900,
4600, 6200,
4900, 6500,
5200, 6800,
5500, 7100,
5800, 7400,
6100, 7700,
6400, 8000,
6700, 8300,
7000, 8600,
7300, 4600,
7600, 4800,
7900, 5100,
8200, 5400,
4200, 5700,
4400, 6000,
4700, 6300,
5000, 6600,
5300, 6900,
5600, 7200,
5900, 7500,
6200, 7800,
6500, 8100,
6800, 8400,
7100, 8700,
7400, 9000,
7700, 5000,
8000, 5200,
8300, 5500,
8600, 5800,
4600, 6100,
4800, 6400,
5100, 6700,
5400, 7000,
5700, 7300,
6000, 7600,
6300, 7900,
6600, 8200,
6900, 8500,
7200, 8800,
7500, 9100,
7800, 9400,
8100, ];
8400,
8700,
9000,
5000,
5200,
5500,
5800,
6100,
6400,
6700,
7000,
7300,
7600,
7900,
8200,
8500,
8800,
9100,
9400,
5400,
5600,
5900,
6200,
6500,
6800,
7100,
7400,
7700,
8000,
8300,
8600,
8900,
9200,
9500,
9800,
5800,
6000,
6300,
6600,
6900,
7200,
7500,
7800,
8100,
8400,
8700,
9000,
9300,
9600,
9900,
10200,
6200,
6500,
6800,
7100,
7400,
7700,
8000,
8300,
8600,
8900,
9200,
9500,
9800,
10100,
10400,
10700,
6800,
7100,
7400,
7700,
8000,
8300,
8600,
8900,
9200,
9500,
9800,
10100,
10400,
10700,
11000,
11300,
7400,
7700,
8000,
8300,
8600,
8900,
9200,
9500,
9800,
10100,
10400,
10700,
11000,
11300,
11600,
12000
];
}
} }
} }

View File

@@ -2,6 +2,7 @@
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com> // Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import { Palette } from "../palette.slint"; import { Palette } from "../palette.slint";
import { WindowHeader } from "window-header.slint";
struct DataItem { struct DataItem {
label: string, label: string,
value: float, value: float,
@@ -10,11 +11,7 @@ struct DataItem {
component DataColumn { component DataColumn {
in property <[DataItem]> data; in property <[DataItem]> data;
preferred-width: 100%;
preferred-height: 100%;
HorizontalLayout { HorizontalLayout {
width: 100%;
height: 100%;
VerticalLayout { VerticalLayout {
alignment: center; alignment: center;
@@ -54,44 +51,61 @@ component DataColumn {
export component DataWindow { export component DataWindow {
in property <[DataItem]> data1; in property <[DataItem]> data1;
in property <[DataItem]> data2; in property <[DataItem]> data2;
preferred-width: 100%;
preferred-height: 100%;
HorizontalLayout { HorizontalLayout {
padding: 12px; padding: 12px;
Rectangle { Rectangle {
area := TouchArea { area := TouchArea {
mouse-cursor: pointer; mouse-cursor: pointer;
} }
background: Palette.bg-main; background: Palette.bg-main;
border-color: area.has-hover ? Palette.border-focus : Palette.border;
border-width: 2px;
border-radius: 8px; border-radius: 8px;
drop-shadow-color: black; drop-shadow-color: black;
drop-shadow-offset-x: 6px; drop-shadow-offset-x: 6px;
drop-shadow-offset-y: 6px; drop-shadow-offset-y: 6px;
drop-shadow-blur: 10px; drop-shadow-blur: 10px;
HorizontalLayout { width: 500px;
DataColumn { vertical-stretch: 1;
data: data1; VerticalLayout {
visible: true;
alignment: start;
WindowHeader {
title: "Data";
} }
HorizontalLayout { HorizontalLayout {
height: 100%; padding-left: 10px;
width: 1px; padding-right: 10px;
padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
Rectangle { alignment: space-between;
DataColumn {
width: 218px;
data: data1;
}
HorizontalLayout {
vertical-stretch: 1;
width: 21px;
padding: 10px; padding: 10px;
width: 1px; Rectangle {
background: Palette.bg-secondary; width: 1px;
background: Palette.border;
}
}
DataColumn {
width: 218px;
data: data2;
} }
} }
}
DataColumn { Rectangle {
data: data2; background: transparent;
} border-color: area.has-hover ? Palette.border-focus : Palette.border;
border-width: 2px;
border-radius: 8px;
vertical-stretch: 1;
} }
} }
} }

View File

@@ -2,6 +2,7 @@
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com> // Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
import { Palette } from "../palette.slint"; import { Palette } from "../palette.slint";
import { WindowHeader } from "window-header.slint";
export component MapWindow { export component MapWindow {
in property <[float]> data; in property <[float]> data;
in property <[float]> rpm-axis; in property <[float]> rpm-axis;
@@ -9,8 +10,6 @@ export component MapWindow {
in property <float> data-min; in property <float> data-min;
in property <float> data-max; in property <float> data-max;
in property <string> name; in property <string> name;
preferred-width: 100%;
preferred-height: 100%;
VerticalLayout { VerticalLayout {
padding: 12px; padding: 12px;
@@ -20,8 +19,6 @@ export component MapWindow {
} }
background: Palette.bg-main; background: Palette.bg-main;
border-color: area.has-hover ? Palette.border-focus : Palette.border;
border-width: 2px;
border-radius: 8px; border-radius: 8px;
drop-shadow-color: black; drop-shadow-color: black;
drop-shadow-offset-x: 6px; drop-shadow-offset-x: 6px;
@@ -29,25 +26,59 @@ export component MapWindow {
drop-shadow-blur: 10px; drop-shadow-blur: 10px;
VerticalLayout { VerticalLayout {
HorizontalLayout { WindowHeader {
alignment: center; title: name;
padding-top: 6px;
Text {
text: name;
font-size: 20px;
color: Palette.text-primary;
}
} }
GridLayout { GridLayout {
width: 100%;
padding: 6px; padding: 6px;
vertical-stretch: 1; vertical-stretch: 1;
Rectangle {
border-color: black;
border-width: 1px;
width: 60px;
height: 60px;
col: 0;
row: 0;
clip: true;
Rectangle {
height: 2 * (parent.height);
width: 2px;
background: white;
transform-rotation: -45deg;
}
Text {
text: "RPM";
font-size: 14px;
color: Palette.text-primary;
transform-origin: { x: self.width / 2, y: self.height / 2 };
transform-rotation: 45deg;
x: parent.width / 2 + 18px * sin(45deg) - self.width / 2;
y: parent.height / 2 - 18px * sin(45deg) - self.height / 2;
}
Text {
text: "Map";
font-size: 14px;
color: Palette.text-primary;
transform-origin: { x: self.width / 2, y: self.height / 2 };
transform-rotation: 45deg;
x: parent.width / 2 - 18px * sin(45deg) - self.width / 2;
y: parent.height / 2 + 18px * sin(45deg) - self.height / 2;
}
}
for i in rpm-axis.length: Rectangle { for i in rpm-axis.length: Rectangle {
border-color: black; border-color: black;
border-width: 1px; border-width: 1px;
width: (parent.width - 2 * parent.padding) / (rpm-axis.length + 1); width: 60px;
height: 60px;
property <int> r: 0; property <int> r: 0;
property <int> c: mod(i, rpm-axis.length) + 1; property <int> c: mod(i, rpm-axis.length) + 1;
@@ -64,7 +95,8 @@ export component MapWindow {
for i in map-axis.length: Rectangle { for i in map-axis.length: Rectangle {
border-color: black; border-color: black;
border-width: 1px; border-width: 1px;
width: (parent.width - 2 * parent.padding) / (rpm-axis.length + 1); width: 60px;
height: 30px;
property <int> r: i + 1; property <int> r: i + 1;
property <int> c: 0; property <int> c: 0;
@@ -82,7 +114,8 @@ export component MapWindow {
border-color: black; border-color: black;
border-width: 1px; border-width: 1px;
background: hsv((240deg - ((data[i] - data-min) / (data-max - data-min)) * 240deg), 0.8, 0.80); background: hsv((240deg - ((data[i] - data-min) / (data-max - data-min)) * 240deg), 0.8, 0.80);
width: (parent.width - 2 * parent.padding) / (rpm-axis.length + 1); width: 60px;
height: 30px;
property <int> r: i / rpm-axis.length + 1; property <int> r: i / rpm-axis.length + 1;
property <int> c: mod(i, rpm-axis.length) + 1; property <int> c: mod(i, rpm-axis.length) + 1;
@@ -99,6 +132,14 @@ export component MapWindow {
} }
} }
} }
Rectangle {
background: transparent;
border-color: area.has-hover ? Palette.border-focus : Palette.border;
border-width: 2px;
border-radius: 8px;
vertical-stretch: 1;
}
} }
} }
} }

View File

@@ -0,0 +1,57 @@
// Copyright (C) 2026 Hector van der Aa <hector@h3cx.dev>
// Copyright (C) 2026 Association Exergie <association.exergie@gmail.com>
// SPDX-License-Identifier: GPL-3.0-or-later
import { Palette } from "../palette.slint";
export component WindowHeader {
in property <string> title;
HorizontalLayout {
horizontal-stretch: 1;
Rectangle {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
background: Palette.border;
HorizontalLayout {
VerticalLayout {
alignment: center;
padding-left: 6px;
Rectangle {
vertical-stretch: 1;
Text {
text: title;
color: Palette.text-primary;
horizontal-alignment: center;
font-size: 14px;
}
}
}
Rectangle {
horizontal-stretch: 1;
}
HorizontalLayout {
padding: 4px;
Rectangle {
width: 12px;
height: 12px;
background: Palette.warning;
border-radius: self.width / 2;
y: (parent.height - self.height) / 2;
}
}
HorizontalLayout {
padding: 4px;
Rectangle {
width: 12px;
height: 12px;
background: Palette.error;
border-radius: self.width / 2;
y: (parent.height - self.height) / 2;
}
}
}
}
}
}