Layout

Struct Layout 

Source
pub struct Layout<B: Brush> { /* private fields */ }
Expand description

Text layout.

Implementations§

Source§

impl<B: Brush> Layout<B>

Source

pub fn new() -> Self

Creates an empty layout.

Source

pub fn scale(&self) -> f32

Returns the scale factor provided when creating the layout.

Source

pub fn styles(&self) -> &[Style<B>]

Returns the style collection for the layout.

Source

pub fn width(&self) -> f32

Returns the width of the layout.

Source

pub fn full_width(&self) -> f32

Returns the width of the layout, including the width of any trailing whitespace.

Source

pub fn calculate_content_widths(&self) -> ContentWidths

Calculates the lower and upper bounds on the width of the layout. These are recalculated every time this method is called.

This method currently may not return the correct results for mixed-direction text.

Source

pub fn height(&self) -> f32

Returns the height of the layout.

Source

pub fn len(&self) -> usize

Returns the number of lines in the layout.

Source

pub fn is_empty(&self) -> bool

Returns true if the layout is empty.

Source

pub fn get(&self, index: usize) -> Option<Line<'_, B>>

Returns the line at the specified index.

Returns None if the index is out of bounds, i.e. if it’s not less than self.len().

Source

pub fn is_rtl(&self) -> bool

Returns true if the dominant direction of the layout is right-to-left.

Source

pub fn inline_boxes(&self) -> &[InlineBox]

Source

pub fn inline_boxes_mut(&mut self) -> &mut [InlineBox]

Source

pub fn lines(&self) -> impl Iterator<Item = Line<'_, B>> + '_ + Clone

Returns an iterator over the lines in the layout.

Source

pub fn break_lines(&mut self) -> BreakLines<'_, B>

Returns line breaker to compute lines for the layout.

Source

pub fn break_all_lines(&mut self, max_advance: Option<f32>)

Breaks all lines with the specified maximum advance.

Source

pub fn align( &mut self, container_width: Option<f32>, alignment: Alignment, options: AlignmentOptions, )

Apply alignment to the layout relative to the specified container width or full layout width.

You must perform line breaking prior to aligning, through Layout::break_lines or Layout::break_all_lines. If container_width is not specified, the layout’s Layout::width is used.

Trait Implementations§

Source§

impl<B: Clone + Brush> Clone for Layout<B>

Source§

fn clone(&self) -> Layout<B>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Brush> Default for Layout<B>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<B> Freeze for Layout<B>

§

impl<B> !RefUnwindSafe for Layout<B>

§

impl<B> Send for Layout<B>
where B: Send,

§

impl<B> Sync for Layout<B>
where B: Sync,

§

impl<B> Unpin for Layout<B>
where B: Unpin,

§

impl<B> !UnwindSafe for Layout<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.