wgui: Separate user and wgui assets, topmost widgets (poc)

This commit is contained in:
Aleksander
2025-10-05 13:48:58 +02:00
parent 71d7d50e35
commit 3dff9c5882
32 changed files with 442 additions and 151 deletions

View File

@@ -1,10 +1,11 @@
use std::{cell::RefCell, rc::Rc, sync::Arc};
use button::setup_custom_button;
use glam::{vec2, Affine2, Vec2};
use glam::{Affine2, Vec2, vec2};
use label::setup_custom_label;
use vulkano::{command_buffer::CommandBufferUsage, image::view::ImageView};
use wgui::{
assets::AssetPath,
drawing,
event::{
Event as WguiEvent, EventListenerCollection, InternalStateChangeEvent, ListenerHandleVec,
@@ -21,7 +22,7 @@ use crate::{
backend::input::{Haptics, PointerHit, PointerMode},
graphics::{CommandBuffers, ExtentExt},
state::AppState,
windowing::backend::{ui_transform, FrameMeta, OverlayBackend, ShouldRender},
windowing::backend::{FrameMeta, OverlayBackend, ShouldRender, ui_transform},
};
use super::{timer::GuiTimer, timestep::Timestep};
@@ -72,7 +73,7 @@ impl<S> GuiPanel<S> {
let doc_params = wgui::parser::ParseDocumentParams {
globals: app.wgui_globals.clone(),
path,
path: AssetPath::BuiltIn(path),
extra: wgui::parser::ParseDocumentExtra {
on_custom_attribs: Some(Box::new({
let custom_elems = custom_elems.clone();

View File

@@ -1,8 +1,9 @@
use std::{collections::HashMap, rc::Rc};
use glam::{vec2, vec3, Affine3A, Mat4, Quat, Vec2, Vec3};
use glam::{Affine3A, Mat4, Quat, Vec2, Vec3, vec2, vec3};
use wgui::{
animation::{Animation, AnimationEasing},
assets::AssetPath,
drawing::Color,
event::{self, CallbackMetadata, EventListenerKind},
layout::LayoutParams,
@@ -19,14 +20,14 @@ use wgui::{
use crate::{
gui::panel::GuiPanel,
state::AppState,
subsystem::hid::{XkbKeymap, ALT, CTRL, META, SHIFT, SUPER},
subsystem::hid::{ALT, CTRL, META, SHIFT, SUPER, XkbKeymap},
windowing::window::{OverlayWindowConfig, OverlayWindowState, Positioning},
};
use super::{
handle_press, handle_release,
KEYBOARD_NAME, KeyButtonData, KeyState, KeyboardBackend, KeyboardState, handle_press,
handle_release,
layout::{self, AltModifier, KeyCapType},
KeyButtonData, KeyState, KeyboardBackend, KeyboardState, KEYBOARD_NAME,
};
const BACKGROUND_PADDING: f32 = 4.;
@@ -54,7 +55,7 @@ pub fn create_keyboard(
let mut panel = GuiPanel::new_blank(app, state)?;
let (background, _) = panel.layout.add_child(
panel.layout.root_widget,
panel.layout.content_root_widget,
WidgetRectangle::create(WidgetRectangleParams {
color: wgui::drawing::Color::new(0., 0., 0., 0.6),
round: WLength::Units(4.0),
@@ -75,7 +76,7 @@ pub fn create_keyboard(
let parse_doc_params = wgui::parser::ParseDocumentParams {
globals: app.wgui_globals.clone(),
path: "gui/keyboard.xml",
path: AssetPath::BuiltIn("gui/keyboard.xml"),
extra: Default::default(),
};

View File

@@ -5,7 +5,7 @@ use std::{
time::Instant,
};
use glam::{vec3, Affine3A, Quat, Vec3};
use glam::{Affine3A, Quat, Vec3, vec3};
use idmap_derive::IntegerId;
use serde::{Deserialize, Serialize};
use wgui::{
@@ -28,8 +28,8 @@ use crate::{
gui::panel::GuiPanel,
state::{AppState, LeftRight},
windowing::{
window::{OverlayWindowConfig, OverlayWindowState, Positioning},
OverlaySelector, Z_ORDER_TOAST,
window::{OverlayWindowConfig, OverlayWindowState, Positioning},
},
};
@@ -144,8 +144,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
Positioning::FollowHead { lerp: 0.1 },
),
DisplayMethod::Watch => {
let mut watch_pos =
Vec3::from(app.session.config.watch_pos) + vec3(-0.005, -0.05, 0.02);
let mut watch_pos = app.session.config.watch_pos + vec3(-0.005, -0.05, 0.02);
let mut watch_rot = app.session.config.watch_rot;
let relative_to = match app.session.config.watch_hand {
LeftRight::Left => Positioning::FollowHand { hand: 0, lerp: 1.0 },
@@ -172,7 +171,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
let (rect, _) = panel
.layout
.add_child(
panel.layout.root_widget,
panel.layout.content_root_widget,
WidgetRectangle::create(WidgetRectangleParams {
color: parse_color_hex("#1e2030").unwrap(),
border_color: parse_color_hex("#5e7090").unwrap(),