Hide all Area:s and Window:s the first frame to hide first-frame-jitters (#2385)
This commit is contained in:
parent
0b2d56cff0
commit
3ba39c3022
1 changed files with 9 additions and 17 deletions
|
@ -192,11 +192,12 @@ pub(crate) struct Prepared {
|
||||||
move_response: Response,
|
move_response: Response,
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
drag_bounds: Option<Rect>,
|
drag_bounds: Option<Rect>,
|
||||||
/// Set the first frame of new windows with anchors.
|
|
||||||
|
/// We always make windows invisible the first frame to hide "first-frame-jitters".
|
||||||
///
|
///
|
||||||
/// This is so that we use the first frame to calculate the window size,
|
/// This is so that we use the first frame to calculate the window size,
|
||||||
/// and then can correctly position the window the next frame,
|
/// and then can correctly position the window and its contents the next frame,
|
||||||
/// without having one frame where the window is positioned in the wrong place.
|
/// without having one frame where the window is wrongly positioned or sized.
|
||||||
temporarily_invisible: bool,
|
temporarily_invisible: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,24 +243,15 @@ impl Area {
|
||||||
});
|
});
|
||||||
state.pos = new_pos.unwrap_or(state.pos);
|
state.pos = new_pos.unwrap_or(state.pos);
|
||||||
state.interactable = interactable;
|
state.interactable = interactable;
|
||||||
let mut temporarily_invisible = false;
|
|
||||||
|
|
||||||
if pivot != Align2::LEFT_TOP {
|
if pivot != Align2::LEFT_TOP {
|
||||||
if is_new {
|
state.pos.x -= pivot.x().to_factor() * state.size.x;
|
||||||
temporarily_invisible = true; // figure out the size first
|
state.pos.y -= pivot.y().to_factor() * state.size.y;
|
||||||
} else {
|
|
||||||
state.pos.x -= pivot.x().to_factor() * state.size.x;
|
|
||||||
state.pos.y -= pivot.y().to_factor() * state.size.y;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some((anchor, offset)) = anchor {
|
if let Some((anchor, offset)) = anchor {
|
||||||
if is_new {
|
let screen = ctx.available_rect();
|
||||||
temporarily_invisible = true; // figure out the size first
|
state.pos = anchor.align_size_within_rect(state.size, screen).min + offset;
|
||||||
} else {
|
|
||||||
let screen = ctx.available_rect();
|
|
||||||
state.pos = anchor.align_size_within_rect(state.size, screen).min + offset;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// interact right away to prevent frame-delay
|
// interact right away to prevent frame-delay
|
||||||
|
@ -319,7 +311,7 @@ impl Area {
|
||||||
move_response,
|
move_response,
|
||||||
enabled,
|
enabled,
|
||||||
drag_bounds,
|
drag_bounds,
|
||||||
temporarily_invisible,
|
temporarily_invisible: is_new,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue