pub struct CaptionBlock {
pub text: WispText,
pub background_color: Color,
pub corner_radius_ndc: f32,
pub padding_ndc: f32,
pub width_ndc: f32,
pub text_resolution_px: (u32, u32),
}Expand description
Builder for a wrapped caption block with a rounded-rect background.
Fields§
§text: WispTextThe caption’s content.
background_color: ColorBackground fill (e.g. semi-transparent black for legibility).
corner_radius_ndc: f32Background corner radius in local NDC.
padding_ndc: f32Padding inside the background, in local NDC (uniform on all four sides).
width_ndc: f32Total width the background should occupy in local NDC. The
text wraps to width_ndc - 2 × padding_ndc.
text_resolution_px: (u32, u32)Texture resolution used to rasterize the text. Higher = sharper glyphs but more GPU memory + cache cost.
Implementations§
Source§impl CaptionBlock
impl CaptionBlock
Sourcepub fn from_text(text: WispText) -> Self
pub fn from_text(text: WispText) -> Self
Construct a default block with text only — defaults match the in-app caption style (semi-transparent dark background, small rounded corners, ample padding).
Sourcepub fn with_background(self, color: Color) -> Self
pub fn with_background(self, color: Color) -> Self
Builder — replace the background color.
Sourcepub fn with_radius(self, radius_ndc: f32) -> Self
pub fn with_radius(self, radius_ndc: f32) -> Self
Builder — replace the corner radius.
Sourcepub fn with_padding(self, padding_ndc: f32) -> Self
pub fn with_padding(self, padding_ndc: f32) -> Self
Builder — replace the padding.
Sourcepub fn with_width(self, width_ndc: f32) -> Self
pub fn with_width(self, width_ndc: f32) -> Self
Builder — replace the total width.
Sourcepub fn with_style(self, style: WispTextStyle) -> Self
pub fn with_style(self, style: WispTextStyle) -> Self
Builder — replace the style on the inner text.
Sourcepub fn layout(
&self,
app: &Application,
pipeline: &TextTexturePipeline,
) -> CaptionLayout
pub fn layout( &self, app: &Application, pipeline: &TextTexturePipeline, ) -> CaptionLayout
Layout the caption. Measures the text inside width_ndc - 2*padding, sizes the background, and produces a
CaptionLayout ready to be attached to a container.
Trait Implementations§
Source§impl Clone for CaptionBlock
impl Clone for CaptionBlock
Source§fn clone(&self) -> CaptionBlock
fn clone(&self) -> CaptionBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CaptionBlock
impl Debug for CaptionBlock
Auto Trait Implementations§
impl Freeze for CaptionBlock
impl RefUnwindSafe for CaptionBlock
impl Send for CaptionBlock
impl Sync for CaptionBlock
impl Unpin for CaptionBlock
impl UnsafeUnpin for CaptionBlock
impl UnwindSafe for CaptionBlock
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more§impl<T> Pointable for T
impl<T> Pointable for T
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().