mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-25 03:52:45 +01:00
A modal cover shows and absorbs from its first pass
The cover's egui area had no size on its first show, so egui made that pass a hidden sizing pass: no scrim and no absorbed hits. The discard pass every container layer used to ask on its first show hid this; without it the opening frame published no cover, and a modal's drag strips over the title bar came a frame late. The cover area is seeded at its screen rect before its first pass, as container layers are.
This commit is contained in:
1 parent
3b45620977
commit
c8fe2cf860
1 file changed
+7
-3
@@ -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<Rect> = 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 };
|
||||
|
||||
Reference in new issue
Block a user