Initial Commit
This commit is contained in:
12
.cargo/config.toml
Normal file
12
.cargo/config.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[target.x86_64-pc-windows-msvc]
|
||||||
|
# Increase default stack size to avoid running out of stack
|
||||||
|
# space in debug builds. The size matches Linux's default.
|
||||||
|
rustflags = [
|
||||||
|
"-C", "link-arg=/STACK:8000000"
|
||||||
|
]
|
||||||
|
[target.aarch64-pc-windows-msvc]
|
||||||
|
# Increase default stack size to avoid running out of stack
|
||||||
|
# space in debug builds. The size matches Linux's default.
|
||||||
|
rustflags = [
|
||||||
|
"-C", "link-arg=/STACK:8000000"
|
||||||
|
]
|
||||||
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Generated by Cargo
|
||||||
|
# will have compiled files and executables
|
||||||
|
/target/
|
||||||
|
|
||||||
|
# Alternative VCS systems
|
||||||
|
/.jj/
|
||||||
|
/.hg/
|
||||||
|
/.pijul/
|
||||||
|
|
||||||
|
# These are backup files generated by rustfmt
|
||||||
|
**/*.rs.bk
|
||||||
|
.vscode/
|
||||||
|
*.code-workspace
|
||||||
6345
Cargo.lock
generated
Normal file
6345
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "telemetrix"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
slint = "1.14.1"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
slint-build = "1.14.1"
|
||||||
3
build.rs
Normal file
3
build.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
slint_build::compile("ui/app-window.slint").expect("Slint build failed");
|
||||||
|
}
|
||||||
22
src/main.rs
Normal file
22
src/main.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// Prevent console window in addition to Slint window in Windows release builds when, e.g., starting the app via file manager. Ignored on other platforms.
|
||||||
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||||
|
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
slint::include_modules!();
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let ui = AppWindow::new()?;
|
||||||
|
|
||||||
|
ui.on_request_increase_value({
|
||||||
|
let ui_handle = ui.as_weak();
|
||||||
|
move || {
|
||||||
|
let ui = ui_handle.unwrap();
|
||||||
|
ui.set_counter(ui.get_counter() + 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.run()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
196
ui/app-window.slint
Normal file
196
ui/app-window.slint
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
import { VerticalBox, Button } from "std-widgets.slint";
|
||||||
|
import { Palette } from "palette.slint";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
component StatusBadge {
|
||||||
|
in property <string> label;
|
||||||
|
in property <brush> color;
|
||||||
|
|
||||||
|
horizontal-stretch: 0;
|
||||||
|
HorizontalLayout {
|
||||||
|
spacing: 6px;
|
||||||
|
Rectangle {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
background: color;
|
||||||
|
border-radius: self.width / 2;
|
||||||
|
y: (parent.height - self.height) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: label;
|
||||||
|
color: Palette.text-primary;
|
||||||
|
vertical-alignment: center;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
component MenuButton {
|
||||||
|
in property <string> text;
|
||||||
|
callback clicked;
|
||||||
|
|
||||||
|
height: 28px;
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
border-width: 2px;
|
||||||
|
border-color: Palette.brand;
|
||||||
|
|
||||||
|
background: area.pressed ? Palette.brand.darker(0.3) : area.has-hover ? Palette.bg-hover : Palette.bg-main;
|
||||||
|
|
||||||
|
HorizontalLayout {
|
||||||
|
padding-left: 12px;
|
||||||
|
padding-right: 12px;
|
||||||
|
|
||||||
|
Text {
|
||||||
|
text: root.text;
|
||||||
|
font-size: 14px;
|
||||||
|
color: Palette.text-primary;
|
||||||
|
vertical-alignment: center;
|
||||||
|
horizontal-alignment: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
area := TouchArea {
|
||||||
|
mouse-cursor: pointer;
|
||||||
|
|
||||||
|
clicked => {
|
||||||
|
root.clicked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export component AppWindow inherits Window {
|
||||||
|
title: "My App";
|
||||||
|
|
||||||
|
// Allow WM to resize normally
|
||||||
|
min-width: 400px;
|
||||||
|
min-height: 300px;
|
||||||
|
|
||||||
|
preferred-width: 900px;
|
||||||
|
preferred-height: 600px;
|
||||||
|
|
||||||
|
VerticalBox {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
spacing: 0;
|
||||||
|
padding: 0;
|
||||||
|
|
||||||
|
// Top bar
|
||||||
|
Rectangle {
|
||||||
|
height: 40px;
|
||||||
|
width: 100%;
|
||||||
|
background: Palette.bg-secondary;
|
||||||
|
|
||||||
|
HorizontalLayout {
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
spacing: 6px;
|
||||||
|
|
||||||
|
MenuButton {
|
||||||
|
text: "File";
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuButton {
|
||||||
|
text: "Edit";
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
horizontal-stretch: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuButton {
|
||||||
|
text: "Setting";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 100%;
|
||||||
|
height: 2px;
|
||||||
|
background: Palette.brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main content
|
||||||
|
Rectangle {
|
||||||
|
background: Palette.bg-main;
|
||||||
|
horizontal-stretch: 1;
|
||||||
|
vertical-stretch: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
width: 100%;
|
||||||
|
height: 2px;
|
||||||
|
background: Palette.brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
height: 32px;
|
||||||
|
background: Palette.bg-secondary;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
HorizontalLayout {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
padding-top: 6px;
|
||||||
|
padding-bottom: 6px;
|
||||||
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
|
spacing: 20px;
|
||||||
|
|
||||||
|
StatusBadge {
|
||||||
|
label: "LoRa";
|
||||||
|
color: Palette.success;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusBadge {
|
||||||
|
label: "V-Link";
|
||||||
|
color: Palette.error;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
horizontal-stretch: 0;
|
||||||
|
height: parent.height - (2 * parent.padding-top);
|
||||||
|
width: 2px;
|
||||||
|
background: Palette.bg-main;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
horizontal-stretch: 1;
|
||||||
|
Text {
|
||||||
|
text: "ENGINE [WARNING] - High Engine Temperature";
|
||||||
|
font-size: 14px;
|
||||||
|
color: Palette.text-primary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
horizontal-stretch: 0;
|
||||||
|
height: parent.height - (2 * parent.padding-top);
|
||||||
|
width: 2px;
|
||||||
|
background: Palette.bg-main;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusBadge {
|
||||||
|
label: "Engine";
|
||||||
|
color: Palette.warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusBadge {
|
||||||
|
label: "ECU";
|
||||||
|
color: Palette.success;
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusBadge {
|
||||||
|
label: "Telemetry";
|
||||||
|
color: Palette.success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
ui/palette.slint
Normal file
24
ui/palette.slint
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
export global Palette {
|
||||||
|
|
||||||
|
// ---------- BRAND ----------
|
||||||
|
in property <color> brand: #f67a00;
|
||||||
|
|
||||||
|
// ---------- BACKGROUND ----------
|
||||||
|
in property <color> bg-main: #0f1115;
|
||||||
|
in property <color> bg-secondary: #3a3a3a;
|
||||||
|
in property <color> bg-panel: #171a1f;
|
||||||
|
in property <color> bg-hover: #1f232a;
|
||||||
|
|
||||||
|
// ---------- TEXT ----------
|
||||||
|
in property <color> text-primary: #ffffff;
|
||||||
|
in property <color> text-secondary: #a0a7b4;
|
||||||
|
in property <color> text-dim: #6b7280;
|
||||||
|
|
||||||
|
// ---------- STATES ----------
|
||||||
|
in property <color> success: #22c55e;
|
||||||
|
in property <color> warning: #f59e0b;
|
||||||
|
in property <color> error: #ef4444;
|
||||||
|
|
||||||
|
// ---------- BORDERS ----------
|
||||||
|
in property <color> border: #2a2f36;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user