pub struct Textbox {
pub text: String,
pub position: Vec2,
pub size: Vec2,
pub font_id: u32,
pub font_size: f32,
pub color: Color,
pub background_color: Option<Color>,
pub padding: f32,
pub typewriter: Option<TypewriterState>,
}Expand description
a textbox component for rendering text on screen.
contains the text content, position, size, font settings, and optional typewriter animation state.
Fields§
§text: Stringthe full text content.
position: Vec2position on screen (top-left corner).
size: Vec2size of the textbox area.
font_id: u32font handle id (references a loaded font).
font_size: f32font size in pixels.
color: Colortext color.
background_color: Option<Color>background color (none for transparent).
padding: f32padding inside the textbox.
typewriter: Option<TypewriterState>current typewriter state (none if fully visible).
Implementations§
Source§impl Textbox
impl Textbox
Sourcepub fn set_font(&mut self, font_id: u32, font_size: f32) -> &mut Self
pub fn set_font(&mut self, font_id: u32, font_size: f32) -> &mut Self
set the font for this textbox.
Sourcepub fn set_background(&mut self, color: Color) -> &mut Self
pub fn set_background(&mut self, color: Color) -> &mut Self
set the background color.
Sourcepub fn set_padding(&mut self, padding: f32) -> &mut Self
pub fn set_padding(&mut self, padding: f32) -> &mut Self
set the padding.
Sourcepub fn start_typewriter(&mut self, interval: f32)
pub fn start_typewriter(&mut self, interval: f32)
start the typewriter animation.
interval is the time in seconds between each character reveal.
Sourcepub fn update_typewriter(&mut self, delta: f32) -> bool
pub fn update_typewriter(&mut self, delta: f32) -> bool
update the typewriter animation by the given delta time. returns true if the animation is still in progress.
Sourcepub fn skip_typewriter(&mut self)
pub fn skip_typewriter(&mut self)
skip the typewriter animation and show all text.
Sourcepub fn visible_text(&self) -> &str
pub fn visible_text(&self) -> &str
get the currently visible text (for typewriter animation).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Textbox
impl RefUnwindSafe for Textbox
impl Send for Textbox
impl Sync for Textbox
impl Unpin for Textbox
impl UnsafeUnpin for Textbox
impl UnwindSafe for Textbox
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> ConditionalSend for Twhere
T: Send,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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