Some checks failed
rust-ci / checks (push) Has been cancelled
- Rust workspace: 7 library crates, icenetd CLI, icenet-city (Slint GUI) - Sim: fix false Delivered after a route cut, derive traffic class from payload size, per-link airtime slots (link capacity, queueing) - Docs: single docs/STATUS.md for all figures, remove v0.2/egui leftovers, drop unimplemented seed claims, uncheck store-and-forward - License: LGPL-3.0-or-later (LICENSE, LICENSES/GPL-3.0.txt)
206 lines
8.6 KiB
Text
206 lines
8.6 KiB
Text
// A desktop-only city topology editor; all networking logic stays in Rust crates.
|
|
import { Button, ScrollView } from "std-widgets.slint";
|
|
|
|
export struct UiNode {
|
|
id: int,
|
|
label: string,
|
|
px: float,
|
|
py: float,
|
|
online: bool,
|
|
}
|
|
|
|
export struct UiLink {
|
|
ax: float,
|
|
ay: float,
|
|
bx: float,
|
|
by: float,
|
|
title: string,
|
|
enabled: bool,
|
|
highlighted: bool,
|
|
color: color,
|
|
}
|
|
|
|
export component CityWindow inherits Window {
|
|
title: "ICE-NET City Lab | Slint";
|
|
preferred-width: 1140px;
|
|
preferred-height: 760px;
|
|
background: #0c131b;
|
|
|
|
in property <[UiNode]> nodes;
|
|
in property <[UiLink]> links;
|
|
in property <[string]> messages;
|
|
in property <string> clock;
|
|
in property <string> from-label;
|
|
in property <string> to-label;
|
|
in property <string> role-label;
|
|
in property <string> link-label;
|
|
in property <string> export-status;
|
|
|
|
callback send-text();
|
|
callback send-photo();
|
|
callback export-csv();
|
|
callback export-json();
|
|
callback next-from();
|
|
callback next-to();
|
|
callback next-role();
|
|
callback next-link-kind();
|
|
callback add-node();
|
|
callback connect-nodes();
|
|
callback toggle-node(int);
|
|
callback toggle-link(int);
|
|
callback drag-start(int, float, float);
|
|
callback drag-move(float, float);
|
|
callback drag-end();
|
|
callback advance(int);
|
|
callback reset-city();
|
|
|
|
HorizontalLayout {
|
|
padding: 16px;
|
|
spacing: 14px;
|
|
side := Rectangle {
|
|
width: 295px;
|
|
background: #172533;
|
|
border-radius: 12px;
|
|
VerticalLayout {
|
|
padding: 14px;
|
|
spacing: 9px;
|
|
Text { text: "ICE-NET / CITY LAB"; color: #6de0cb; font-size: 20px; font-weight: 700; }
|
|
Text { text: "Offline graph simulation • no real radio"; color: #adc0ce; font-size: 12px; }
|
|
Rectangle { height: 1px; background: #344557; }
|
|
Text { text: "ROUTE"; color: #6de0cb; font-size: 13px; font-weight: 700; }
|
|
Button { text: "From: " + root.from-label; clicked => { root.next-from(); } }
|
|
Button { text: "To: " + root.to-label; clicked => { root.next-to(); } }
|
|
HorizontalLayout {
|
|
spacing: 5px;
|
|
Button { text: "Text (128 B)"; clicked => { root.send-text(); } }
|
|
Button { text: "Photo (5 MiB)"; clicked => { root.send-photo(); } }
|
|
}
|
|
Rectangle { height: 1px; background: #344557; }
|
|
Text { text: "TOPOLOGY EDITOR"; color: #6de0cb; font-size: 13px; font-weight: 700; }
|
|
Button { text: root.role-label; clicked => { root.next-role(); } }
|
|
Button { text: "Add device"; clicked => { root.add-node(); } }
|
|
Button { text: root.link-label; clicked => { root.next-link-kind(); } }
|
|
Button { text: "Connect selected devices"; clicked => { root.connect-nodes(); } }
|
|
Text { text: "DEVICES (CLICK TO TOGGLE)"; color: #b5c9d5; font-size: 12px; }
|
|
ScrollView {
|
|
height: 92px;
|
|
VerticalLayout {
|
|
spacing: 3px;
|
|
for node in root.nodes: Button {
|
|
text: node.label + (node.online ? " [ON]" : " [OFF]");
|
|
clicked => { root.toggle-node(node.id); }
|
|
}
|
|
}
|
|
}
|
|
Text { text: "LINKS (CLICK TO TOGGLE)"; color: #b5c9d5; font-size: 12px; }
|
|
ScrollView {
|
|
height: 82px;
|
|
VerticalLayout {
|
|
spacing: 3px;
|
|
for edge[index] in root.links: Button {
|
|
text: edge.title + (edge.enabled ? " ON" : " OFF");
|
|
clicked => { root.toggle-link(index); }
|
|
}
|
|
}
|
|
}
|
|
Text { text: root.clock; color: #adc0ce; font-size: 12px; }
|
|
HorizontalLayout {
|
|
spacing: 5px;
|
|
Button { text: "+1 sec"; clicked => { root.advance(1000); } }
|
|
Button { text: "+1 min"; clicked => { root.advance(60000); } }
|
|
Button { text: "Reset"; clicked => { root.reset-city(); } }
|
|
}
|
|
HorizontalLayout {
|
|
spacing: 5px;
|
|
Button { text: "Export CSV"; clicked => { root.export-csv(); } }
|
|
Button { text: "Export JSON"; clicked => { root.export-json(); } }
|
|
}
|
|
Text { text: root.export-status; color: #6de0cb; font-size: 11px; }
|
|
}
|
|
}
|
|
content := Rectangle {
|
|
background: #17212e;
|
|
border-radius: 12px;
|
|
VerticalLayout {
|
|
padding: 16px;
|
|
spacing: 12px;
|
|
Text { text: "Network topology"; color: #e7f3f8; font-size: 21px; font-weight: 600; }
|
|
Text { text: "Drag nodes. Thick links show the last selected route."; color: #9cb2c6; }
|
|
graph := Rectangle {
|
|
height: 355px;
|
|
background: #101c29;
|
|
border-radius: 8px;
|
|
for edge in root.links: Path {
|
|
width: 100%;
|
|
height: 100%;
|
|
viewbox-x: 0;
|
|
viewbox-y: 0;
|
|
viewbox-width: parent.width / 1px;
|
|
viewbox-height: parent.height / 1px;
|
|
stroke: edge.highlighted ? #ffffff : edge.color;
|
|
stroke-width: edge.highlighted ? 4px : 2px;
|
|
MoveTo { x: edge.ax; y: edge.ay; }
|
|
LineTo { x: edge.bx; y: edge.by; }
|
|
}
|
|
for node in root.nodes: Rectangle {
|
|
x: (node.px - 17.0) * 1px;
|
|
y: (node.py - 17.0) * 1px;
|
|
width: 34px;
|
|
height: 34px;
|
|
border-radius: 17px;
|
|
background: node.online ? #235b66 : #35404c;
|
|
border-color: node.online ? #72d0e2 : #78808a;
|
|
border-width: 2px;
|
|
Text {
|
|
text: node.id;
|
|
color: #ffffff;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
}
|
|
TouchArea {
|
|
mouse-cursor: pointer;
|
|
pointer-event(event) => {
|
|
if (event.kind == PointerEventKind.down) {
|
|
root.drag-start(node.id,
|
|
(self.absolute-position.x + self.mouse-x) / 1px,
|
|
(self.absolute-position.y + self.mouse-y) / 1px);
|
|
} else if (event.kind == PointerEventKind.up) {
|
|
root.drag-end();
|
|
}
|
|
}
|
|
moved => {
|
|
if (self.pressed) {
|
|
root.drag-move(
|
|
(self.absolute-position.x + self.mouse-x) / 1px,
|
|
(self.absolute-position.y + self.mouse-y) / 1px);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Text { text: "Message log"; color: #e7f3f8; font-size: 17px; font-weight: 600; }
|
|
ScrollView {
|
|
VerticalLayout {
|
|
spacing: 6px;
|
|
for line in root.messages: Rectangle {
|
|
height: 28px;
|
|
background: #233242;
|
|
border-radius: 5px;
|
|
Text {
|
|
x: 9px;
|
|
text: line;
|
|
color: #d8e4ed;
|
|
vertical-alignment: center;
|
|
font-size: 12px;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Text { text: "Synthetic transmission estimates; not an RF model or a live network.";
|
|
color: #91aabd; font-size: 11px; }
|
|
}
|
|
}
|
|
}
|
|
}
|