diff --git a/wgui/src/event.rs b/wgui/src/event.rs index 9f6988c..7f67b1c 100644 --- a/wgui/src/event.rs +++ b/wgui/src/event.rs @@ -133,4 +133,4 @@ pub enum EventListener { MousePress(MousePressCallback), MouseRelease(MouseReleaseCallback), InternalStateChange(InternalStateChangeCallback), -} \ No newline at end of file +} diff --git a/wgui/src/renderer_vk/context.rs b/wgui/src/renderer_vk/context.rs index b8e94ad..0709689 100644 --- a/wgui/src/renderer_vk/context.rs +++ b/wgui/src/renderer_vk/context.rs @@ -101,7 +101,7 @@ impl SharedContext { return Ok(key); } } - log::debug!("Initializing SharedAtlas for pixel scale {pixel_scale:.1}"); + log::debug!("Initializing SharedAtlas for pixel scale {pixel_scale:.2}"); let text_atlas = TextAtlas::new(self.text_pipeline.clone())?; Ok(self.atlas_map.insert(SharedAtlas { text_atlas, @@ -143,7 +143,7 @@ impl Context { resolution: [u32; 2], pixel_scale: f32, ) -> anyhow::Result<()> { - if (self.pixel_scale - pixel_scale).abs() < f32::EPSILON { + if (self.pixel_scale - pixel_scale).abs() > f32::EPSILON { self.pixel_scale = pixel_scale; self.shared_ctx_key = shared.atlas_for_pixel_scale(pixel_scale)?; } diff --git a/wgui/src/renderer_vk/text/mod.rs b/wgui/src/renderer_vk/text/mod.rs index a165fc7..c3a012e 100644 --- a/wgui/src/renderer_vk/text/mod.rs +++ b/wgui/src/renderer_vk/text/mod.rs @@ -38,7 +38,7 @@ pub(crate) const DEFAULT_METRICS: Metrics = Metrics::new( pub struct TextStyle { pub size: Option, pub line_height: Option, - pub color: Option, // TODO: should this be hex? + pub color: Option, pub style: Option, pub weight: Option, pub align: Option, diff --git a/wgui/src/widget/mod.rs b/wgui/src/widget/mod.rs index d912c52..4ebb555 100644 --- a/wgui/src/widget/mod.rs +++ b/wgui/src/widget/mod.rs @@ -80,7 +80,7 @@ impl WidgetState { (data, obj) } - fn new(obj: Box) -> anyhow::Result { + fn new(obj: Box) -> anyhow::Result { Ok(Self { data: WidgetData { hovered: 0, @@ -374,4 +374,4 @@ impl WidgetState { } EventResult::Pass } -} \ No newline at end of file +} diff --git a/wlx-overlay-s/src/gui/panel.rs b/wlx-overlay-s/src/gui/panel.rs index 93df630..bb02199 100644 --- a/wlx-overlay-s/src/gui/panel.rs +++ b/wlx-overlay-s/src/gui/panel.rs @@ -8,6 +8,7 @@ use wgui::{ MouseUpEvent, MouseWheelEvent, }, layout::Layout, + parser::ParserResult, renderer_vk::context::Context as WguiContext, }; @@ -33,19 +34,25 @@ pub struct GuiPanel { } impl GuiPanel { - pub fn new_from_template(app: &mut AppState, path: &str) -> anyhow::Result { - let (layout, _state) = + pub fn new_from_template( + app: &mut AppState, + path: &str, + ) -> anyhow::Result<(Self, ParserResult)> { + let (layout, parser_result) = wgui::parser::new_layout_from_assets(Box::new(gui::asset::GuiAsset {}), path)?; let context = WguiContext::new(&mut app.wgui_shared, 1.0)?; let mut timestep = Timestep::new(); timestep.set_tps(60.0); - Ok(Self { - layout, - context, - timestep, - }) + Ok(( + Self { + layout, + context, + timestep, + }, + parser_result, + )) } pub fn new_blank(app: &mut AppState) -> anyhow::Result { diff --git a/wlx-overlay-s/src/overlays/anchor.rs b/wlx-overlay-s/src/overlays/anchor.rs index abf5c6d..94bd3d0 100644 --- a/wlx-overlay-s/src/overlays/anchor.rs +++ b/wlx-overlay-s/src/overlays/anchor.rs @@ -11,7 +11,7 @@ pub fn create_anchor(app: &mut AppState) -> anyhow::Result> where O: Default, { - let panel = GuiPanel::new_from_template(app, "gui/anchor.xml")?; + let (panel, _) = GuiPanel::new_from_template(app, "gui/anchor.xml")?; Ok(OverlayData { state: OverlayState { diff --git a/wlx-overlay-s/src/overlays/watch.rs b/wlx-overlay-s/src/overlays/watch.rs index 3e2386a..15b12b0 100644 --- a/wlx-overlay-s/src/overlays/watch.rs +++ b/wlx-overlay-s/src/overlays/watch.rs @@ -20,7 +20,13 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result> where O: Default, { - let mut panel = GuiPanel::new_blank(app)?; + let (mut panel, parser) = GuiPanel::new_from_template(app, "gui/watch.xml")?; + + for (id, widget) in parser.ids.iter() { + if id.starts_with("clock") {} + } + + if let Ok(clock) = parser.require_by_id("clock0") {} let (_, _) = panel.layout.add_child( panel.layout.root_widget,