Skip to main content

clamp_label_offset

Function clamp_label_offset 

Source
pub fn clamp_label_offset(
    bbox: Rect,
    text_width: f32,
    offset: f32,
    h_align: Align,
) -> f32
Expand description

Clamp a block label’s horizontal offset so its text of width text_width stays within the block’s horizontal extent, given the label’s horizontal anchor — Align::Center for the title, Align::Min (left) for the type, Align::Max (right) for the tag. When the text is wider than the block the label is pinned flush to its anchored edge.