ConstructEssentials

i'm really out of ideas how to name another struct name with function parameters. Well, here we go - essentials.
This commit is contained in:
Aleksander
2025-10-11 11:26:25 +02:00
parent ce8cd3bce7
commit 200d5223d3
11 changed files with 90 additions and 78 deletions

View File

@@ -16,6 +16,7 @@ use crate::{
struct OpenedWindow {
layout_tasks: LayoutTasks,
widget: WidgetPair,
content: WidgetPair,
#[allow(dead_code)]
state: ParserState,
@@ -34,6 +35,10 @@ struct State {
#[derive(Clone)]
pub struct WguiWindow(Rc<RefCell<State>>);
pub struct OnContentData {
pub widget: WidgetPair,
}
pub struct WguiWindowParams<'a> {
pub position: Vec2,
pub globals: WguiGlobals,
@@ -52,7 +57,7 @@ impl WguiWindow {
self.0.borrow_mut().opened_window = None;
}
pub fn open(&mut self, params: WguiWindowParams) -> anyhow::Result<()> {
pub fn open(&mut self, params: &mut WguiWindowParams) -> anyhow::Result<()> {
// close previous one if it's already open
self.close();
@@ -74,7 +79,7 @@ impl WguiWindow {
let state = parser::parse_from_assets(
&parser::ParseDocumentParams {
globals: params.globals,
globals: params.globals.clone(),
path: XML_PATH,
extra: Default::default(),
},
@@ -92,19 +97,20 @@ impl WguiWindow {
})
});
let button = state.fetch_component_as::<ComponentButton>("button").unwrap();
button.on_click(Box::new(move |_common, _e| {
log::info!("click");
Ok(())
}));
let content = state.fetch_widget(&params.layout.state, "content")?;
self.0.borrow_mut().opened_window = Some(OpenedWindow {
widget,
state,
layout_tasks: params.layout.tasks.clone(),
content,
});
Ok(())
}
pub fn get_content(&self) -> WidgetPair {
let state = self.0.borrow_mut();
state.opened_window.as_ref().unwrap().content.clone()
}
}