move uidev dashboard to dash-frontend crate
11
Cargo.lock
generated
@@ -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",
|
||||
|
||||
@@ -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]
|
||||
|
||||
8
dash-frontend/.editorconfig
Normal 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
@@ -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"
|
||||
|
Before Width: | Height: | Size: 150 B After Width: | Height: | Size: 150 B |
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
|
Before Width: | Height: | Size: 702 B After Width: | Height: | Size: 702 B |
|
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 248 B After Width: | Height: | Size: 248 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 257 B After Width: | Height: | Size: 257 B |
|
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 296 B |
|
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 270 B |
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 291 B |
|
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 281 B |
|
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 234 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 281 B |
|
Before Width: | Height: | Size: 281 B After Width: | Height: | Size: 281 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 344 B After Width: | Height: | Size: 344 B |
|
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 165 B |
|
Before Width: | Height: | Size: 664 B After Width: | Height: | Size: 664 B |
|
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 411 B |
|
Before Width: | Height: | Size: 219 B After Width: | Height: | Size: 219 B |
|
Before Width: | Height: | Size: 996 B After Width: | Height: | Size: 996 B |
|
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 290 B |
|
Before Width: | Height: | Size: 358 B After Width: | Height: | Size: 358 B |
|
Before Width: | Height: | Size: 300 B After Width: | Height: | Size: 300 B |
|
Before Width: | Height: | Size: 267 B After Width: | Height: | Size: 267 B |
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 450 B |
|
Before Width: | Height: | Size: 676 B After Width: | Height: | Size: 676 B |
|
Before Width: | Height: | Size: 560 B After Width: | Height: | Size: 560 B |
|
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 311 B |
|
Before Width: | Height: | Size: 348 B After Width: | Height: | Size: 348 B |
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 277 B |
|
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 225 B |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 493 B After Width: | Height: | Size: 493 B |
|
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 405 B After Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 458 B After Width: | Height: | Size: 458 B |
|
Before Width: | Height: | Size: 323 B After Width: | Height: | Size: 323 B |
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
|
Before Width: | Height: | Size: 382 B After Width: | Height: | Size: 382 B |
|
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 583 B |
|
Before Width: | Height: | Size: 232 B After Width: | Height: | Size: 232 B |
|
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 408 B |
|
Before Width: | Height: | Size: 434 B After Width: | Height: | Size: 434 B |
|
Before Width: | Height: | Size: 595 B After Width: | Height: | Size: 595 B |
|
Before Width: | Height: | Size: 908 B After Width: | Height: | Size: 908 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 404 B After Width: | Height: | Size: 404 B |
8
dash-frontend/assets/gui/theme.xml
Normal 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>
|
||||
1
dash-frontend/assets/lang/en.json
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
2
dash-frontend/rustfmt.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
tab_spaces = 2
|
||||
hard_tabs = true
|
||||
12
dash-frontend/src/assets.rs
Normal 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
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -14,3 +14,4 @@ wgui = { path = "../wgui/" }
|
||||
winit = "0.30.10"
|
||||
vulkano = { workspace = true }
|
||||
vulkano-shaders = { workspace = true }
|
||||
dash-frontend = { path = "../dash-frontend/" }
|
||||
|
||||
@@ -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)?),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use wgui::layout::Layout;
|
||||
|
||||
pub mod testbed_any;
|
||||
pub mod testbed_dashboard;
|
||||
pub mod testbed_generic;
|
||||
|
||||
pub trait Testbed {
|
||||
|
||||
25
uidev/src/testbed/testbed_dashboard.rs
Normal 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()
|
||||
}
|
||||
}
|
||||