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,7 +1,7 @@
use std::{cell::RefCell, rc::Rc};
use button::setup_custom_button;
use glam::{Affine2, Vec2, vec2};
use glam::{vec2, Affine2, Vec2};
use label::setup_custom_label;
use wgui::{
assets::AssetPath,
@@ -15,7 +15,7 @@ use wgui::{
layout::{Layout, LayoutParams, WidgetID},
parser::{CustomAttribsInfoOwned, ParserState},
renderer_vk::context::Context as WguiContext,
widget::{EventResult, label::WidgetLabel, rectangle::WidgetRectangle},
widget::{label::WidgetLabel, rectangle::WidgetRectangle, EventResult},
};
use wlx_common::timestep::Timestep;
@@ -24,7 +24,7 @@ use crate::{
state::AppState,
subsystem::hid::WheelDelta,
windowing::backend::{
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender, ui_transform,
ui_transform, FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender,
},
};
@@ -96,7 +96,7 @@ impl<S: 'static> GuiPanel<S> {
let doc_params = wgui::parser::ParseDocumentParams {
globals: app.wgui_globals.clone(),
path: AssetPath::BuiltIn(path),
path: AssetPath::FileOrBuiltIn(path),
extra: wgui::parser::ParseDocumentExtra {
on_custom_attribs: Some(Box::new({
let custom_elems = custom_elems.clone();

View File

@@ -1,6 +1,6 @@
use std::{collections::HashMap, rc::Rc};
use glam::{Affine3A, FloatExt, Mat4, Quat, Vec2, Vec3, vec2, vec3};
use glam::{vec2, vec3, Affine3A, FloatExt, Mat4, Quat, Vec2, Vec3};
use wgui::{
animation::{Animation, AnimationEasing},
assets::AssetPath,
@@ -11,10 +11,10 @@ use wgui::{
renderer_vk::util,
taffy::{self, prelude::length},
widget::{
EventResult,
div::WidgetDiv,
rectangle::{WidgetRectangle, WidgetRectangleParams},
util::WLength,
EventResult,
},
};
use wlx_common::windowing::{OverlayWindowState, Positioning};
@@ -22,14 +22,14 @@ use wlx_common::windowing::{OverlayWindowState, Positioning};
use crate::{
gui::panel::GuiPanel,
state::AppState,
subsystem::hid::{ALT, CTRL, META, SHIFT, SUPER, XkbKeymap},
subsystem::hid::{XkbKeymap, ALT, CTRL, META, SHIFT, SUPER},
windowing::window::OverlayWindowConfig,
};
use super::{
KEYBOARD_NAME, KeyButtonData, KeyState, KeyboardBackend, KeyboardState, handle_press,
handle_release,
handle_press, handle_release,
layout::{self, AltModifier, KeyCapType},
KeyButtonData, KeyState, KeyboardBackend, KeyboardState, KEYBOARD_NAME,
};
const BACKGROUND_PADDING: f32 = 16.0;
@@ -83,7 +83,7 @@ pub fn create_keyboard(
let parse_doc_params = wgui::parser::ParseDocumentParams {
globals,
path: AssetPath::BuiltIn("gui/keyboard.xml"),
path: AssetPath::FileOrBuiltIn("gui/keyboard.xml"),
extra: Default::default(),
};

View File

@@ -24,7 +24,7 @@ use crate::subsystem::osc::OscSender;
use crate::{
backend::{input::InputState, task::TaskContainer},
config::load_general_config,
config_io,
config_io::{self, get_config_file_path},
graphics::WGfxExtras,
gui,
subsystem::{audio::AudioOutput, input::HidWrapper},
@@ -85,6 +85,7 @@ impl AppState {
);
let wgui_shared = WSharedContext::new(gfx.clone())?;
let theme = session.config.theme_path.clone();
Ok(Self {
session,
@@ -103,6 +104,7 @@ impl AppState {
Box::new(gui::asset::GuiAsset {}),
wgui::globals::Defaults::default(),
&WguiFontConfig::default(),
get_config_file_path(&*theme),
)?,
#[cfg(feature = "osc")]