pub struct AlignmentDirectional {
pub x_start: f32,
pub y: f32,
}Expand description
A directional anchor: the horizontal axis is expressed start → end
rather than left → right. x_start = -1 hugs the start edge (left in LTR,
right in RTL), +1 the end edge. Resolved into a physical Alignment at
render time from the reading direction — the anchor follows the text without the
caller ever testing which way it runs.
Fields§
§x_start: f32Start-to-end fraction: -1 (start) … 0 (centre) … +1 (end).
y: f32Vertical fraction: -1 (top) … +1 (bottom).
Implementations§
Source§impl AlignmentDirectional
impl AlignmentDirectional
Sourcepub const TOP_CENTER: Self
pub const TOP_CENTER: Self
Hugs the top edge, centred horizontally.
Sourcepub const CENTER_START: Self
pub const CENTER_START: Self
Hugs the start edge, centred vertically.
Sourcepub const CENTER_END: Self
pub const CENTER_END: Self
Hugs the end edge, centred vertically.
Sourcepub const BOTTOM_START: Self
pub const BOTTOM_START: Self
Hugs the bottom-start corner (bottom-left in LTR, bottom-right in RTL).
Sourcepub const BOTTOM_CENTER: Self
pub const BOTTOM_CENTER: Self
Hugs the bottom edge, centred horizontally.
Sourcepub const BOTTOM_END: Self
pub const BOTTOM_END: Self
Hugs the bottom-end corner (bottom-right in LTR, bottom-left in RTL).
Sourcepub const fn new(x_start: f32, y: f32) -> Self
pub const fn new(x_start: f32, y: f32) -> Self
A directional (x_start, y) anchor, with fractions in [-1, 1].
Sourcepub fn resolve(self, direction: TextDirection) -> Alignment
pub fn resolve(self, direction: TextDirection) -> Alignment
Resolves to a physical anchor: in RTL, start maps to right (x is
mirrored); in LTR, start is left (x unchanged). y never depends on it.