pub struct TextLayoutState { /* private fields */ }Expand description
Shared text layout state used by text-based views.
This type owns the base layout plus any derived overflow layout used for wrapping, alignment, or ellipsis handling. It is intended to be shared by text-oriented views such as labels, rich text, and text inputs.
Implementations§
Source§impl TextLayoutState
impl TextLayoutState
Sourcepub fn set_text(
&mut self,
text: &str,
attrs_list: AttrsList,
text_align: Option<Alignment>,
)
pub fn set_text( &mut self, text: &str, attrs_list: AttrsList, text_align: Option<Alignment>, )
Replaces the base text, attributes, and alignment for this state.
Sourcepub fn set_text_overflow(&mut self, text_overflow: TextOverflow)
pub fn set_text_overflow(&mut self, text_overflow: TextOverflow)
Sets the overflow behavior used when finalizing constrained layouts.
Sourcepub fn get_effective_text_layout(&self) -> Option<&TextLayout>
pub fn get_effective_text_layout(&self) -> Option<&TextLayout>
Returns the layout that should currently be painted.
This prefers a derived overflow/alignment layout when one is active.
Sourcepub fn with_effective_text_layout<O>(
&self,
with: impl FnOnce(&TextLayout) -> O,
) -> O
pub fn with_effective_text_layout<O>( &self, with: impl FnOnce(&TextLayout) -> O, ) -> O
Runs with on the effective layout, falling back to an empty layout.
Sourcepub fn selection_rects_for_selection(
&self,
selection: &TextSelection,
text_origin: Point,
f: impl FnMut(Rect),
)
pub fn selection_rects_for_selection( &self, selection: &TextSelection, text_origin: Point, f: impl FnMut(Rect), )
Iterates selection rectangles for a Parley selection in view coordinates.
Sourcepub fn selection_rects_for_byte_range(
&self,
start: usize,
end: usize,
text_origin: Point,
f: impl FnMut(Rect),
)
pub fn selection_rects_for_byte_range( &self, start: usize, end: usize, text_origin: Point, f: impl FnMut(Rect), )
Iterates selection rectangles for a byte range in view coordinates.
Sourcepub fn centered_text_origin(&self, content_rect: Rect) -> Point
pub fn centered_text_origin(&self, content_rect: Rect) -> Point
Returns the origin that vertically centers the effective layout in content_rect.
Sourcepub fn clear_overflow_state(&mut self)
pub fn clear_overflow_state(&mut self)
Clears any cached derived overflow/alignment layout.
Sourcepub fn get_text_layout(&self) -> Option<&TextLayout>
pub fn get_text_layout(&self) -> Option<&TextLayout>
Returns the base text layout before overflow-specific derivation.
Sourcepub fn compute_overflow_size(
&mut self,
width_constraint: Option<f32>,
text_overflow: TextOverflow,
) -> Size
pub fn compute_overflow_size( &mut self, width_constraint: Option<f32>, text_overflow: TextOverflow, ) -> Size
Computes the size the text would occupy under the given width constraint.
This does not mutate the currently visible effective layout.
Sourcepub fn finalize_for_width(&mut self, final_width: f32)
pub fn finalize_for_width(&mut self, final_width: f32)
Finalizes the effective layout for the given width.
This updates the cached derived layout used for painting and emits a
TextOverflowChanged event when the overflowing state changes.
Trait Implementations§
Source§impl Clone for TextLayoutState
impl Clone for TextLayoutState
Source§fn clone(&self) -> TextLayoutState
fn clone(&self) -> TextLayoutState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for TextLayoutState
impl !Send for TextLayoutState
impl !Sync for TextLayoutState
impl !UnwindSafe for TextLayoutState
impl Freeze for TextLayoutState
impl Unpin for TextLayoutState
impl UnsafeUnpin for TextLayoutState
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§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>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§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.§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.§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