48 lines
1.0 KiB
Rust
48 lines
1.0 KiB
Rust
use crate::{assets, testbed::Testbed};
|
|
use glam::Vec2;
|
|
use wgui::{
|
|
event::EventListenerCollection,
|
|
globals::WguiGlobals,
|
|
layout::{Layout, LayoutParams},
|
|
parser::{ParseDocumentParams, ParserState},
|
|
};
|
|
|
|
pub struct TestbedAny {
|
|
pub layout: Layout,
|
|
|
|
#[allow(dead_code)]
|
|
state: ParserState,
|
|
}
|
|
|
|
impl TestbedAny {
|
|
pub fn new(name: &str, listeners: &mut EventListenerCollection<(), ()>) -> anyhow::Result<Self> {
|
|
let path = format!("gui/{name}.xml");
|
|
|
|
let globals = WguiGlobals::new(Box::new(assets::Asset {}))?;
|
|
|
|
let (layout, state) = wgui::parser::new_layout_from_assets(
|
|
listeners,
|
|
&ParseDocumentParams {
|
|
globals,
|
|
path: &path,
|
|
extra: Default::default(),
|
|
},
|
|
&LayoutParams::default(),
|
|
)?;
|
|
Ok(Self { layout, state })
|
|
}
|
|
}
|
|
|
|
impl Testbed for TestbedAny {
|
|
fn update(&mut self, width: f32, height: f32, timestep_alpha: f32) -> anyhow::Result<()> {
|
|
self
|
|
.layout
|
|
.update(Vec2::new(width, height), timestep_alpha)?;
|
|
Ok(())
|
|
}
|
|
|
|
fn layout(&mut self) -> &mut Layout {
|
|
&mut self.layout
|
|
}
|
|
}
|