fix scaling, refactors
This commit is contained in:
@@ -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<Self> {
|
||||
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<Self> {
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn create_anchor<O>(app: &mut AppState) -> anyhow::Result<OverlayData<O>>
|
||||
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 {
|
||||
|
||||
@@ -20,7 +20,13 @@ pub fn create_watch<O>(app: &mut AppState) -> anyhow::Result<OverlayData<O>>
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user