pub struct LayoutContainer {
pub x: f32,
pub y: f32,
pub col_gap: f32,
pub row_gap: f32,
pub rows: Vec<LayoutRow>,
pub visible: bool,
}Expand description
Positions a set of TextLabels as a stack of rows, so a HUD does
not have to hand-place every chip. Each row lays its labels out left to
right; rows stack top to bottom. The container owns the labels’ on-screen
position: the labels keep their own styling (font, colour, background,
padding) but their x/y are overwritten each frame.
Sizing is content-driven: a label is measured at its current text, so the layout reflows as live HUD values change width. A row with a single label sits on its own line beneath the previous row, which is how a wide chip (e.g. a multi-pass timing line) ends up spanning the width of the row above.
Labels referenced by cols are matched by name; a label whose font is not
loaded, or which is hidden, is skipped and reserves no space.
LayoutContainer {
x: 10.0,
y: 10.0,
col_gap: 6.0,
row_gap: 6.0,
..Default::default()
};Fields§
§x: f32Left edge of the container in window pixels.
y: f32Top edge of the container in window pixels.
col_gap: f32Pixels between adjacent labels in a row, measured between their background boxes.
row_gap: f32Pixels between adjacent rows, measured between their background boxes.
rows: Vec<LayoutRow>Rows of labels, top to bottom.
visible: boolWhen false, the container leaves its labels where they are instead of repositioning them.
Implementations§
Source§impl LayoutContainer
impl LayoutContainer
Sourcepub fn layout(
&self,
size_of: impl Fn(AssetId) -> Option<LabelBox>,
) -> Vec<LabelPlacement>
pub fn layout( &self, size_of: impl Fn(AssetId) -> Option<LabelBox>, ) -> Vec<LabelPlacement>
Resolve the text origin for every label in the container.
size_of returns a label’s measured box, or None to drop it from the
layout (unknown label, unloaded font, hidden). The result is pure
geometry: callers measure with their font metrics, this places the
boxes. Boxes within a row are laid edge-to-edge with col_gap between
them; rows are stacked with row_gap between them.
Sourcepub fn layout_into(
&self,
size_of: impl Fn(AssetId) -> Option<LabelBox>,
out: &mut Vec<LabelPlacement>,
)
pub fn layout_into( &self, size_of: impl Fn(AssetId) -> Option<LabelBox>, out: &mut Vec<LabelPlacement>, )
LayoutContainer::layout writing into a caller-owned buffer, so a
per-frame caller reuses its capacity. Clears out first.
Trait Implementations§
Source§impl Clone for LayoutContainer
impl Clone for LayoutContainer
Source§fn clone(&self) -> LayoutContainer
fn clone(&self) -> LayoutContainer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for LayoutContainer
impl Component for LayoutContainer
Source§const NAME: &'static str = "LayoutContainer"
const NAME: &'static str = "LayoutContainer"
Source§fn from_baked(bytes: &[u8]) -> Result<LayoutContainer, CnResult>
fn from_baked(bytes: &[u8]) -> Result<LayoutContainer, CnResult>
Source§fn inject_locator(&mut self, _locator: PayloadLocator)
fn inject_locator(&mut self, _locator: PayloadLocator)
Source§fn inject_name(&mut self, _id: AssetId)
fn inject_name(&mut self, _id: AssetId)
Source§impl ComponentSlot for LayoutContainer
impl ComponentSlot for LayoutContainer
Source§const DISCRIMINANT: u8
const DISCRIMINANT: u8
ComponentId.Source§fn slot(s: &ComponentStorage) -> &Column<LayoutContainer>
fn slot(s: &ComponentStorage) -> &Column<LayoutContainer>
Source§fn slot_mut(s: &mut ComponentStorage) -> &mut Column<LayoutContainer>
fn slot_mut(s: &mut ComponentStorage) -> &mut Column<LayoutContainer>
Source§impl Debug for LayoutContainer
impl Debug for LayoutContainer
Source§impl Default for LayoutContainer
impl Default for LayoutContainer
Source§fn default() -> LayoutContainer
fn default() -> LayoutContainer
Source§impl<'de> Deserialize<'de> for LayoutContainerwhere
LayoutContainer: Default,
impl<'de> Deserialize<'de> for LayoutContainerwhere
LayoutContainer: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayoutContainer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<LayoutContainer, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<LayoutContainer> for ComponentAsset
impl From<LayoutContainer> for ComponentAsset
Source§fn from(c: LayoutContainer) -> ComponentAsset
fn from(c: LayoutContainer) -> ComponentAsset
impl RuntimeComponent for LayoutContainer
Source§impl Serialize for LayoutContainer
impl Serialize for LayoutContainer
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for LayoutContainer
impl RefUnwindSafe for LayoutContainer
impl Send for LayoutContainer
impl Sync for LayoutContainer
impl Unpin for LayoutContainer
impl UnsafeUnpin for LayoutContainer
impl UnwindSafe for LayoutContainer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().