pub struct KeepVisible {
pub key: u64,
pub rect: Rect,
pub centre: bool,
}Expand description
A box a scroll region has been asked to keep in view, and which box it is.
A tab bar wider than its window is what this is for. Declared by the content through
Widget::keep_visible, carried on the region so it survives a repaint boundary
like everything else about the region, and acted on by
crate::Runtime::sync_visible.
Fields§
§key: u64Which box this is. The region acts when this changes and not otherwise: the box moves as the region scrolls, so a region chasing the box itself would pin the content in place and no finger could move it.
rect: RectThe box: in the declaring widget’s own coordinates when it comes back from
Widget::keep_visible, and in the frame’s — as it would sit at offset zero
— when it reaches the region.
At rest rather than where it is actually drawn, and that is the whole reason the answer can be trusted. A box recorded where it is drawn is a box whose position already contains the current offset, so the offset that would centre it can only be worked out relative to wherever the region happens to be — and on the first frame, before anything has been retained, there is no wherever to be relative to. Recorded at rest, the answer is absolute: the same number on the first frame and the hundredth.
centre: boolPut it in the middle of the window rather than merely inside it. What a tab bar wants: a selected tab flush against the edge reads as the end of the row. Clamped either way, so the first tab still rests at the start.