move uidev dashboard to dash-frontend crate

This commit is contained in:
Aleksander
2025-09-13 12:16:38 +02:00
parent 3f76dbe9cc
commit 1d8f8aca3e
75 changed files with 130 additions and 2 deletions

11
Cargo.lock generated
View File

@@ -1361,6 +1361,16 @@ dependencies = [
"syn 2.0.103",
]
[[package]]
name = "dash-frontend"
version = "0.1.0"
dependencies = [
"anyhow",
"glam",
"rust-embed",
"wgui",
]
[[package]]
name = "dasp_sample"
version = "0.11.0"
@@ -5121,6 +5131,7 @@ name = "uidev"
version = "0.1.0"
dependencies = [
"anyhow",
"dash-frontend",
"glam",
"log",
"rust-embed",

View File

@@ -10,7 +10,7 @@ inherits = "release"
debug = true
[workspace]
members = ["uidev", "wgui", "wlx-overlay-s", "wlx-capture"]
members = ["uidev", "wgui", "wlx-overlay-s", "wlx-capture", "dash-frontend"]
resolver = "3"
[workspace.dependencies]

View File

@@ -0,0 +1,8 @@
root = true
[*.rs]
indent_style = tab
indent_size = 2
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false

10
dash-frontend/Cargo.toml Normal file
View File

@@ -0,0 +1,10 @@
[package]
name = "dash-frontend"
version = "0.1.0"
edition = "2024"
[dependencies]
anyhow.workspace = true
wgui = { path = "../wgui/" }
glam = { workspace = true }
rust-embed = "8.7.2"

View File

Before

Width:  |  Height:  |  Size: 150 B

After

Width:  |  Height:  |  Size: 150 B

View File

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

View File

Before

Width:  |  Height:  |  Size: 702 B

After

Width:  |  Height:  |  Size: 702 B

View File

Before

Width:  |  Height:  |  Size: 293 B

After

Width:  |  Height:  |  Size: 293 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 248 B

After

Width:  |  Height:  |  Size: 248 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 258 B

After

Width:  |  Height:  |  Size: 258 B

View File

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 257 B

View File

Before

Width:  |  Height:  |  Size: 257 B

After

Width:  |  Height:  |  Size: 257 B

View File

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 296 B

View File

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 270 B

View File

Before

Width:  |  Height:  |  Size: 291 B

After

Width:  |  Height:  |  Size: 291 B

View File

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 281 B

View File

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 234 B

View File

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

View File

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 281 B

View File

Before

Width:  |  Height:  |  Size: 281 B

After

Width:  |  Height:  |  Size: 281 B

View File

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

View File

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 279 B

View File

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 344 B

View File

Before

Width:  |  Height:  |  Size: 165 B

After

Width:  |  Height:  |  Size: 165 B

View File

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 664 B

View File

Before

Width:  |  Height:  |  Size: 411 B

After

Width:  |  Height:  |  Size: 411 B

View File

Before

Width:  |  Height:  |  Size: 219 B

After

Width:  |  Height:  |  Size: 219 B

View File

Before

Width:  |  Height:  |  Size: 996 B

After

Width:  |  Height:  |  Size: 996 B

View File

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 290 B

View File

Before

Width:  |  Height:  |  Size: 358 B

After

Width:  |  Height:  |  Size: 358 B

View File

Before

Width:  |  Height:  |  Size: 300 B

After

Width:  |  Height:  |  Size: 300 B

View File

Before

Width:  |  Height:  |  Size: 267 B

After

Width:  |  Height:  |  Size: 267 B

View File

Before

Width:  |  Height:  |  Size: 450 B

After

Width:  |  Height:  |  Size: 450 B

View File

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

View File

Before

Width:  |  Height:  |  Size: 560 B

After

Width:  |  Height:  |  Size: 560 B

View File

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 148 B

View File

Before

Width:  |  Height:  |  Size: 311 B

After

Width:  |  Height:  |  Size: 311 B

View File

Before

Width:  |  Height:  |  Size: 348 B

After

Width:  |  Height:  |  Size: 348 B

View File

Before

Width:  |  Height:  |  Size: 277 B

After

Width:  |  Height:  |  Size: 277 B

View File

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 225 B

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 493 B

After

Width:  |  Height:  |  Size: 493 B

View File

Before

Width:  |  Height:  |  Size: 131 B

After

Width:  |  Height:  |  Size: 131 B

View File

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 405 B

View File

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 458 B

View File

Before

Width:  |  Height:  |  Size: 323 B

After

Width:  |  Height:  |  Size: 323 B

View File

Before

Width:  |  Height:  |  Size: 308 B

After

Width:  |  Height:  |  Size: 308 B

View File

Before

Width:  |  Height:  |  Size: 382 B

After

Width:  |  Height:  |  Size: 382 B

View File

Before

Width:  |  Height:  |  Size: 583 B

After

Width:  |  Height:  |  Size: 583 B

View File

Before

Width:  |  Height:  |  Size: 232 B

After

Width:  |  Height:  |  Size: 232 B

View File

Before

Width:  |  Height:  |  Size: 408 B

After

Width:  |  Height:  |  Size: 408 B

View File

Before

Width:  |  Height:  |  Size: 434 B

After

Width:  |  Height:  |  Size: 434 B

View File

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View File

Before

Width:  |  Height:  |  Size: 908 B

After

Width:  |  Height:  |  Size: 908 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

Before

Width:  |  Height:  |  Size: 404 B

After

Width:  |  Height:  |  Size: 404 B

View File

@@ -0,0 +1,8 @@
<layout>
<theme>
<var key="menu_dark" value="#0A0A0ACC" />
<var key="background_dark" value="#0d131acc" />
<var key="background_light" value="#244179aa" />
<var key="bottom_panel" value="#141e28" />
</theme>
</layout>

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1,2 @@
tab_spaces = 2
hard_tabs = true

View File

@@ -0,0 +1,12 @@
#[derive(rust_embed::Embed)]
#[folder = "assets/"]
pub struct Asset;
impl wgui::assets::AssetProvider for Asset {
fn load_from_path(&mut self, path: &str) -> anyhow::Result<Vec<u8>> {
match Asset::get(path) {
Some(data) => Ok(data.data.to_vec()),
None => anyhow::bail!("embedded file {} not found", path),
}
}
}

48
dash-frontend/src/lib.rs Normal file
View File

@@ -0,0 +1,48 @@
use glam::Vec2;
use wgui::{
event::EventListenerCollection,
globals::WguiGlobals,
layout::Layout,
parser::{ParseDocumentParams, ParserState},
};
mod assets;
pub struct Frontend {
pub layout: Layout,
#[allow(dead_code)]
state: ParserState,
}
pub struct FrontendParams<'a> {
pub listeners: &'a mut EventListenerCollection<(), ()>,
}
impl Frontend {
pub fn new(params: FrontendParams) -> anyhow::Result<Self> {
let globals = WguiGlobals::new(Box::new(assets::Asset {}))?;
let (layout, state) = wgui::parser::new_layout_from_assets(
params.listeners,
&ParseDocumentParams {
globals,
path: "gui/dashboard.xml",
extra: Default::default(),
},
)?;
Ok(Self { layout, state })
}
pub fn update(&mut self, width: f32, height: f32, timeste_alpha: f32) -> anyhow::Result<()> {
self
.layout
.update(Vec2::new(width, height), timeste_alpha)?;
Ok(())
}
pub fn get_layout(&mut self) -> &mut Layout {
&mut self.layout
}
}

View File

@@ -14,3 +14,4 @@ wgui = { path = "../wgui/" }
winit = "0.30.10"
vulkano = { workspace = true }
vulkano-shaders = { workspace = true }
dash-frontend = { path = "../dash-frontend/" }

View File

@@ -32,7 +32,7 @@ use winit::{
keyboard::{KeyCode, PhysicalKey},
};
use crate::testbed::testbed_generic::TestbedGeneric;
use crate::testbed::{testbed_dashboard::TestbedDashboard, testbed_generic::TestbedGeneric};
mod assets;
mod profiler;
@@ -61,6 +61,7 @@ fn load_testbed(
) -> anyhow::Result<Box<dyn Testbed>> {
let name = std::env::var("TESTBED").unwrap_or_default();
Ok(match name.as_str() {
"dashboard" => Box::new(TestbedDashboard::new(listeners)?),
"" => Box::new(TestbedGeneric::new(listeners)?),
_ => Box::new(TestbedAny::new(&name, listeners)?),
})

View File

@@ -1,6 +1,7 @@
use wgui::layout::Layout;
pub mod testbed_any;
pub mod testbed_dashboard;
pub mod testbed_generic;
pub trait Testbed {

View File

@@ -0,0 +1,25 @@
use crate::testbed::Testbed;
use wgui::{event::EventListenerCollection, layout::Layout};
pub struct TestbedDashboard {
frontend: dash_frontend::Frontend,
}
impl TestbedDashboard {
pub fn new(listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
Ok(Self {
frontend: dash_frontend::Frontend::new(dash_frontend::FrontendParams { listeners })?,
})
}
}
impl Testbed for TestbedDashboard {
fn update(&mut self, width: f32, height: f32, timestep_alpha: f32) -> anyhow::Result<()> {
self.frontend.update(width, height, timestep_alpha)?;
Ok(())
}
fn layout(&mut self) -> &mut Layout {
self.frontend.get_layout()
}
}