From 6c5ab63bec8f156266ab56888c8dea2043f7e4c9 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Sun, 30 Nov 2025 18:01:52 +0900 Subject: [PATCH] watch & edit to use theme.xml; device batteries --- wgui/src/parser/mod.rs | 47 +++++-- wlx-overlay-s/src/assets/gui/edit.xml | 15 +- wlx-overlay-s/src/assets/gui/theme.xml | 15 +- wlx-overlay-s/src/assets/gui/watch.xml | 77 ++++++----- wlx-overlay-s/src/assets/watch/hmd.svg | 42 +++++- wlx-overlay-s/src/backend/input.rs | 7 +- wlx-overlay-s/src/backend/openvr/input.rs | 5 +- wlx-overlay-s/src/backend/openvr/mod.rs | 5 +- wlx-overlay-s/src/backend/openxr/input.rs | 9 +- wlx-overlay-s/src/backend/openxr/mod.rs | 5 +- wlx-overlay-s/src/gui/panel/mod.rs | 20 +-- wlx-overlay-s/src/overlays/watch.rs | 159 +++++++++++++++++----- wlx-overlay-s/src/windowing/manager.rs | 14 +- 13 files changed, 304 insertions(+), 116 deletions(-) diff --git a/wgui/src/parser/mod.rs b/wgui/src/parser/mod.rs index 3954850..cc81c1d 100644 --- a/wgui/src/parser/mod.rs +++ b/wgui/src/parser/mod.rs @@ -8,7 +8,7 @@ mod widget_rectangle; mod widget_sprite; use crate::{ - assets::{AssetPath, AssetPathOwned, normalize_path}, + assets::{normalize_path, AssetPath, AssetPathOwned}, components::{Component, ComponentWeak}, drawing::{self}, globals::WguiGlobals, @@ -545,11 +545,14 @@ fn parse_tag_include( parent_id: WidgetID, attribs: &[AttribPair], ) -> anyhow::Result<()> { + let mut path = None; + let mut optional = false; + for pair in attribs { #[allow(clippy::single_match)] match pair.attrib.as_ref() { - "src" => { - let new_path = { + "src" | "src_ext" | "src_internal" => { + path = Some({ let this = &file.path.clone(); let include: &str = &pair.value; let buf = this.get_path_buf(); @@ -557,17 +560,21 @@ fn parse_tag_include( new_path.push(include); let new_path = normalize_path(&new_path); - match this { - AssetPathOwned::WguiInternal(_) => AssetPathOwned::WguiInternal(new_path), - AssetPathOwned::BuiltIn(_) => AssetPathOwned::BuiltIn(new_path), - AssetPathOwned::Filesystem(_) => AssetPathOwned::Filesystem(new_path), + match pair.attrib.as_ref() { + "src" => match this { + AssetPathOwned::WguiInternal(_) => AssetPathOwned::WguiInternal(new_path), + AssetPathOwned::BuiltIn(_) => AssetPathOwned::BuiltIn(new_path), + AssetPathOwned::Filesystem(_) => AssetPathOwned::Filesystem(new_path), + }, + "src_ext" => AssetPathOwned::Filesystem(new_path), + "src_internal" => AssetPathOwned::WguiInternal(new_path), + _ => unreachable!(), } - }; - let new_path_ref = new_path.as_ref(); - let (new_file, node_layout) = get_doc_from_asset_path(ctx, new_path_ref)?; - parse_document_root(&new_file, ctx, parent_id, node_layout)?; - - return Ok(()); + }); + } + "optional" => { + let mut optional_i32 = 0; + optional = parse_check_i32(&pair.value, &mut optional_i32) && optional_i32 == 1; } _ => { print_invalid_attrib(pair.attrib.as_ref(), pair.value.as_ref()); @@ -575,6 +582,20 @@ fn parse_tag_include( } } + let Some(path) = path else { + log::warn!("include tag with no source! specify either: src, src_ext, src_internal"); + return Ok(()); + }; + let path_ref = path.as_ref(); + match get_doc_from_asset_path(ctx, path_ref) { + Ok((new_file, node_layout)) => parse_document_root(&new_file, ctx, parent_id, node_layout)?, + Err(e) => { + if !optional { + return Err(e); + } + } + } + Ok(()) } diff --git a/wlx-overlay-s/src/assets/gui/edit.xml b/wlx-overlay-s/src/assets/gui/edit.xml index 885de48..6029fc1 100644 --- a/wlx-overlay-s/src/assets/gui/edit.xml +++ b/wlx-overlay-s/src/assets/gui/edit.xml @@ -1,37 +1,42 @@ + +
- +
diff --git a/wlx-overlay-s/src/assets/gui/theme.xml b/wlx-overlay-s/src/assets/gui/theme.xml index 550aa60..3d60eb7 100644 --- a/wlx-overlay-s/src/assets/gui/theme.xml +++ b/wlx-overlay-s/src/assets/gui/theme.xml @@ -8,5 +8,18 @@ + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/wlx-overlay-s/src/assets/gui/watch.xml b/wlx-overlay-s/src/assets/gui/watch.xml index 5273fe1..baf9ec5 100644 --- a/wlx-overlay-s/src/assets/gui/watch.xml +++ b/wlx-overlay-s/src/assets/gui/watch.xml @@ -1,4 +1,6 @@ + + @@ -15,30 +17,26 @@ + margin="2" overflow="hidden" box_sizing="border_box" + border_color="~color_accent_translucent" border="2" round="8" color="~color_accent_5" color2="~color_accent_1" gradient="vertical" + align_items="center" justify_content="center" /> - - + + -
- -
- - - - - - -
-
+
+
+ + + + + + +
+ +