#[non_exhaustive]pub enum Align {
Left,
Center,
Right,
}Expand description
Horizontal alignment of one line of text within the columns it’s rendered into.
A builder knob on the single-line text widgets (Text,
PrintLine) and on the titles of Panel
and Modal. Text widgets default to Left (their
long-standing behavior); panel/modal titles default to Center (theirs).
A plain re-export of retroglyph_core::layout::HAlign, not a separate type: core::align
needs nothing from the egc feature, so there’s no reason for widgets to keep its own
copy of the enum or of offset’s formula.
Interoperates directly with Surface::print_aligned
and TextLayout, no conversion needed.
Horizontal alignment within a bounded rectangle.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Left
Align text to the left edge (default).
Center
Centre text horizontally.
Right
Align text to the right edge.
Implementations§
Source§impl HAlign
impl HAlign
Sourcepub const fn offset(self, area_width: u16, content_width: u16) -> u16
pub const fn offset(self, area_width: u16, content_width: u16) -> u16
The left offset, in columns, at which a content_width-column line should start within
an area_width-column area for this alignment.
Saturates at 0 when the content is wider than the area, so the caller clips from the
left edge rather than underflowing.