diff --git a/crates/ui-contract/src/runtime/egui/areas.rs b/crates/ui-contract/src/runtime/egui/areas.rs index de412613f..0f8a761d9 100644 --- a/crates/ui-contract/src/runtime/egui/areas.rs +++ b/crates/ui-contract/src/runtime/egui/areas.rs @@ -254,6 +254,11 @@ pub(crate) struct CoverLayer { /// left unpainted and unabsorbed, and the four bands around it paint and absorb. pub(crate) fn show_cover_layer(ctx: &Context, cover: CoverLayer) { let CoverLayer { id, tier, screen, scrim, through, absorbs } = cover; + // A cover shows over its whole screen from its first pass: with no size egui would make that pass a hidden sizing + // pass, which paints no scrim and absorbs nothing. + if layer_rect(ctx, id).is_none() { + seed_area(ctx, layer_of(tier, id), screen.min, screen.size()); + } let covered: Vec = match through.map(|through| through.intersect(screen)).filter(|through| through.is_positive()) { Some(clear) => bands(screen, clear).into_iter().filter(|band| band.is_positive()).collect(), None => vec![screen], @@ -388,9 +393,8 @@ pub fn layer_order() -> LayerOrder { } } -/// Gives a container layer's area a size before its first pass, so egui runs no hidden sizing pass for it. That pass -/// shows no body, so nothing would be measured in it; the layer's first pass is a real one that records the sizes -/// the discard pass places by. +/// Gives a layer's area a size before its first pass, so egui runs no hidden sizing pass for it. That pass shows and +/// absorbs nothing, so nothing would be measured in it; the layer's first pass is a real one. pub(crate) fn seed_area(ctx: &Context, layer: LayerId, at: Pos2, room: Vec2) { let state = egui::AreaState { pivot_pos: Some(at), pivot: egui::Align2::LEFT_TOP, size: Some(room), interactable: false, last_became_visible_at: None };