FileOrBuiltIn asset paths, theming support

This commit is contained in:
galister
2025-12-11 01:09:49 +09:00
parent cb0831223a
commit 1724d39697
13 changed files with 90 additions and 63 deletions

View File

@@ -1,3 +1,5 @@
use std::path::PathBuf;
use crate::{
assets,
testbed::{Testbed, TestbedUpdateParams},
@@ -21,7 +23,7 @@ pub struct TestbedAny {
impl TestbedAny {
pub fn new(name: &str) -> anyhow::Result<Self> {
let path = if name.ends_with(".xml") {
AssetPath::Filesystem(name)
AssetPath::FileOrBuiltIn(name)
} else {
AssetPath::BuiltIn(&format!("gui/{name}.xml"))
};
@@ -30,6 +32,7 @@ impl TestbedAny {
Box::new(assets::Asset {}),
wgui::globals::Defaults::default(),
&WguiFontConfig::default(),
PathBuf::new(), // cwd
)?;
let (layout, state) = wgui::parser::new_layout_from_assets(

View File

@@ -1,4 +1,4 @@
use std::{cell::RefCell, collections::VecDeque, rc::Rc};
use std::{cell::RefCell, collections::VecDeque, path::PathBuf, rc::Rc};
use crate::{
assets,
@@ -8,9 +8,9 @@ use glam::Vec2;
use wgui::{
assets::AssetPath,
components::{
Component,
button::{ButtonClickCallback, ComponentButton},
checkbox::ComponentCheckbox,
Component,
},
drawing::Color,
event::StyleSetRequest,
@@ -80,6 +80,7 @@ impl TestbedGeneric {
Box::new(assets::Asset {}),
wgui::globals::Defaults::default(),
&WguiFontConfig::default(),
PathBuf::new(), // cwd
)?;
let extra = ParseDocumentExtra {