Toasts fit the window; a sticky one can always be dismissed

Review: the text wrapped at the full width with the dismiss button after
it, so on a narrow window the toast spilled past the screen edge, and a
long notice could grow taller than the window and clip its button.
Toasts are now at most the window's width (and 360 points), the text
wraps in the width the button leaves and scrolls past a share of the
window's height, and long texture set names are shortened in the GPU
memory notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
AgapenordevandClaude Opus 5.5 committed 2026-11-02 01:50:07 +01:00
1 parent fd9768a28d
commit 8b3cd4db7f
2 files changed
+23 -4

No files matched your search

+16 -3
View File
@@ -483,6 +483,11 @@ fn toasts(app: &mut TextureCraftApp, ctx: &egui::Context) {
}
let tk = theme::Tokens::get(ctx);
let mut dismissed = None;
// Toasts fit the window: at most 360 points wide and, for their text, a part of its height
// (longer text scrolls), so a sticky toast's dismiss button always stays on screen.
let screen = ctx.content_rect().size();
let max_width = (screen.x - 52.0).clamp(120.0, 360.0);
let max_text_height = (screen.y * 0.35).clamp(48.0, 220.0);
egui::Area::new(egui::Id::unique("toasts")).anchor(egui::Align2::RIGHT_BOTTOM, egui::vec2(-16.0, -36.0)).show(ctx, |ui| {
for (i, t) in app.toasts.iter().enumerate() {
egui::Frame::NONE
@@ -492,10 +497,18 @@ fn toasts(app: &mut TextureCraftApp, ctx: &egui::Context) {
.shadow(ui.visuals().popup_shadow)
.inner_margin(egui::Margin::symmetric(10, 6))
.show(ui, |ui| {
ui.set_max_width(360.0);
ui.set_max_width(max_width);
let sticky = t.until.is_infinite();
ui.horizontal_top(|ui| {
ui.add(egui::Label::new(egui::RichText::new(&t.text).color(tk.text_strong)).wrap());
if t.until.is_infinite() && widgets::icon_button(ui, egui_phosphor::regular::X, i18n::tr("Dismiss"), false, 18.0).clicked() {
// The text wraps in the width the dismiss button leaves.
let width = if sticky { max_width - 28.0 } else { max_width };
ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
egui::ScrollArea::vertical().id_salt(("toast", i)).max_height(max_text_height).show(ui, |ui| {
ui.set_max_width(width);
ui.add(egui::Label::new(egui::RichText::new(&t.text).color(tk.text_strong)).wrap());
});
});
if sticky && widgets::icon_button(ui, egui_phosphor::regular::X, i18n::tr("Dismiss"), false, 18.0).clicked() {
dismissed = Some(i);
}
});
+7 -1
View File
@@ -118,7 +118,11 @@ fn gpu_report_toasts(app: &mut TextureCraftApp, reports: crate::gpu::GpuReports)
&[("name", one)],
),
many => {
let mut list = many.iter().take(MAX_NAMED_SETS).map(|n| format!("\"{n}\"")).collect::<Vec<_>>().join(", ");
let short = |n: &String| match n.char_indices().nth(MAX_NAME_CHARS) {
Some((cut, _)) => format!("\"{}...\"", &n[..cut]),
None => format!("\"{n}\""),
};
let mut list = many.iter().take(MAX_NAMED_SETS).map(short).collect::<Vec<_>>().join(", ");
if many.len() > MAX_NAMED_SETS {
list.push_str(", ...");
}
@@ -141,6 +145,8 @@ fn gpu_report_toasts(app: &mut TextureCraftApp, reports: crate::gpu::GpuReports)
/// Texture sets a GPU memory notice names before "...".
const MAX_NAMED_SETS: usize = 5;
/// Characters of a set name in that notice (long names are cut, with "...").
const MAX_NAME_CHARS: usize = 32;
/// This frame's scene sync (compositing and GPU uploads), run by the first view drawn, after
/// that view handled its input: a stroke shows in the frame it is painted, not the next.