proper toast sizing
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
<include src="theme.xml" />
|
||||
|
||||
<elements>
|
||||
<div interactable="0" flex_direction="column">
|
||||
<rectangle height="100%" padding="4" box_sizing="content_box" flex_wrap="wrap" flex_direction="row" gap="4" color="#000000c0" border_color="~color_accent" border="2" round="8" justify_content="space_between">
|
||||
<div flex_direction="row" padding="4" align_items="center" justify_content="center">
|
||||
<label text="" id="toast_title" weight="bold" />
|
||||
<div interactable="0" >
|
||||
<rectangle padding="4" box_sizing="content_box" flex_wrap="wrap" flex_direction="row" gap="4" color="#000000c0" border_color="~color_accent" border="2" round="8" justify_content="space_between">
|
||||
<div width="100%" padding="4">
|
||||
<label text="toast title" id="toast_title" weight="bold" />
|
||||
</div>
|
||||
<div flex_direction="row" flex_wrap="wrap" padding="4" align_items="center" justify_content="center" id="toolbox">
|
||||
<label text="" id="toast_body" />
|
||||
<div width="100%" height="100%" padding="4" flex_wrap="wrap">
|
||||
<label text="toast body goes here" id="toast_body" />
|
||||
</div>
|
||||
</rectangle>
|
||||
</div>
|
||||
|
||||
@@ -102,7 +102,6 @@ impl Toast {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
||||
let current_method = app
|
||||
.session
|
||||
@@ -112,7 +111,10 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
||||
.unwrap_or(ToastDisplayMethod::Hide);
|
||||
|
||||
let (spawn_point, spawn_rotation, positioning) = match current_method {
|
||||
ToastDisplayMethod::Hide => return None,
|
||||
ToastDisplayMethod::Hide => {
|
||||
log::debug!("Not showing toast: filtered out");
|
||||
return None;
|
||||
}
|
||||
ToastDisplayMethod::Center => (
|
||||
vec3(0., -0.2, -0.5),
|
||||
Quat::IDENTITY,
|
||||
@@ -168,7 +170,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
||||
Ok(())
|
||||
});
|
||||
|
||||
let panel = GuiPanel::new_from_template(
|
||||
let mut panel = GuiPanel::new_from_template(
|
||||
app,
|
||||
"gui/toast.xml",
|
||||
(),
|
||||
@@ -177,8 +179,11 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.inspect_err(|e| log::error!("Could not create toast: {e:?}"))
|
||||
.ok()?;
|
||||
|
||||
panel.update_layout().context("layout update failed").ok()?;
|
||||
|
||||
Some(OverlayWindowConfig {
|
||||
name: TOAST_NAME.clone(),
|
||||
default_state: OverlayWindowState {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use glam::Affine3A;
|
||||
use idmap::IdMap;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use std::sync::Arc;
|
||||
use wgui::{
|
||||
font_config::WguiFontConfig, gfx::WGfx, globals::WguiGlobals,
|
||||
|
||||
@@ -189,10 +189,12 @@ where
|
||||
}
|
||||
OverlayTask::Create(sel, f) => {
|
||||
let None = self.mut_by_selector(&sel) else {
|
||||
log::debug!("Could not create {sel:?}: exists");
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
let Some(overlay_config) = f(app) else {
|
||||
log::debug!("Could not create {sel:?}: empty config");
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
@@ -209,6 +211,7 @@ where
|
||||
&& o.birthframe < FRAME_COUNTER.load(Ordering::Relaxed)
|
||||
{
|
||||
if let Some(o) = self.remove_by_selector(&sel, app) {
|
||||
log::debug!("Dropping overlay {}", o.config.name);
|
||||
self.dropped_overlays.push_back(o);
|
||||
}
|
||||
}
|
||||
@@ -346,7 +349,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_by_selector(
|
||||
fn remove_by_selector(
|
||||
&mut self,
|
||||
selector: &OverlaySelector,
|
||||
app: &mut AppState,
|
||||
@@ -411,6 +414,7 @@ impl<T> OverlayWindowManager<T> {
|
||||
}
|
||||
|
||||
if overlay.config.show_on_spawn {
|
||||
log::debug!("activating {} due to show_on_spawn", overlay.config.name);
|
||||
overlay.config.activate(app);
|
||||
}
|
||||
let ret_val = self.overlays.insert(overlay);
|
||||
|
||||
Reference in New Issue
Block a user