Trait Paragraph

pub trait Paragraph: Sized + Default {
    type Font: Copy + PartialEq;

Show 23 methods // Required methods fn with_text(text: Text<&str, Self::Font>) -> Self; fn with_spans<Link>( text: Text<&[Span<'_, Link, Self::Font>], Self::Font>, ) -> Self; fn resize(&mut self, new_bounds: Size); fn compare(&self, text: Text<(), Self::Font>) -> Difference; fn size(&self) -> Pixels; fn font(&self) -> Self::Font; fn line_height(&self) -> LineHeight; fn align_x(&self) -> Alignment; fn align_y(&self) -> Vertical; fn wrapping(&self) -> Wrapping; fn shaping(&self) -> Shaping; fn bounds(&self) -> Size; fn min_bounds(&self) -> Size; fn hit_test(&self, point: Point) -> Option<Hit>; fn hit_span(&self, point: Point) -> Option<usize>; fn span_bounds(&self, index: usize) -> Vec<Rectangle>; fn grapheme_position(&self, line: usize, index: usize) -> Option<Point>; fn ellipsize(&self) -> Ellipsize; // Provided methods fn cursor_position( &self, _line: usize, _byte_index: usize, _affinity: Affinity, ) -> Option<Point> { ... } fn highlight( &self, _line: usize, _start: (usize, Affinity), _end: (usize, Affinity), ) -> Vec<Rectangle> { ... } fn is_rtl(&self, _line: usize) -> Option<bool> { ... } fn min_width(&self) -> f32 { ... } fn min_height(&self) -> f32 { ... }
}
Expand description

A text paragraph.

Required Associated Types§

type Font: Copy + PartialEq

The font of this Paragraph.

Required Methods§

fn with_text(text: Text<&str, Self::Font>) -> Self

Creates a new Paragraph laid out with the given Text.

fn with_spans<Link>( text: Text<&[Span<'_, Link, Self::Font>], Self::Font>, ) -> Self

Creates a new Paragraph laid out with the given Text.

fn resize(&mut self, new_bounds: Size)

Lays out the Paragraph with some new boundaries.

fn compare(&self, text: Text<(), Self::Font>) -> Difference

Compares the Paragraph with some desired Text and returns the Difference.

fn size(&self) -> Pixels

Returns the text size of the Paragraph in Pixels.

fn font(&self) -> Self::Font

Returns the font of the Paragraph.

fn line_height(&self) -> LineHeight

Returns the LineHeight of the Paragraph.

fn align_x(&self) -> Alignment

Returns the horizontal alignment of the Paragraph.

fn align_y(&self) -> Vertical

Returns the vertical alignment of the Paragraph.

fn wrapping(&self) -> Wrapping

Returns the Wrapping strategy of the Paragraph>

fn shaping(&self) -> Shaping

Returns the Shaping strategy of the Paragraph>

fn bounds(&self) -> Size

Returns the available bounds used to layout the Paragraph.

fn min_bounds(&self) -> Size

Returns the minimum boundaries that can fit the contents of the Paragraph.

fn hit_test(&self, point: Point) -> Option<Hit>

Tests whether the provided point is within the boundaries of the Paragraph, returning information about the nearest character.

fn hit_span(&self, point: Point) -> Option<usize>

Tests whether the provided point is within the boundaries of a Span in the Paragraph, returning the index of the Span that was hit.

fn span_bounds(&self, index: usize) -> Vec<Rectangle>

Returns all bounds for the provided Span index of the Paragraph. A Span can have multiple bounds for each line it’s on.

fn grapheme_position(&self, line: usize, index: usize) -> Option<Point>

Returns the distance to the given grapheme index in the Paragraph.

fn ellipsize(&self) -> Ellipsize

Returns the Ellipsize strategy of the Paragraph>

Provided Methods§

fn cursor_position( &self, _line: usize, _byte_index: usize, _affinity: Affinity, ) -> Option<Point>

Returns the visual position of a cursor at the given byte index and Affinity.

fn highlight( &self, _line: usize, _start: (usize, Affinity), _end: (usize, Affinity), ) -> Vec<Rectangle>

Returns highlight rectangles for a text selection. For mixed BiDi text, this may return multiple rectangles.

fn is_rtl(&self, _line: usize) -> Option<bool>

Returns true if the line is RTL, false for LTR.

fn min_width(&self) -> f32

Returns the minimum width that can fit the contents of the Paragraph.

fn min_height(&self) -> f32

Returns the minimum height that can fit the contents of the Paragraph.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl Paragraph for ()

§

type Font = Font

§

fn with_text(_text: Text<&str>)

§

fn with_spans<Link>( _text: Text<&[Span<'_, Link, <() as Paragraph>::Font>], <() as Paragraph>::Font>, )

§

fn resize(&mut self, _new_bounds: Size)

§

fn compare(&self, _text: Text<()>) -> Difference

§

fn size(&self) -> Pixels

§

fn font(&self) -> Font

§

fn line_height(&self) -> LineHeight

§

fn align_x(&self) -> Alignment

§

fn align_y(&self) -> Vertical

§

fn wrapping(&self) -> Wrapping

§

fn shaping(&self) -> Shaping

§

fn grapheme_position(&self, _line: usize, _index: usize) -> Option<Point>

§

fn bounds(&self) -> Size

§

fn min_bounds(&self) -> Size

§

fn hit_test(&self, _point: Point) -> Option<Hit>

§

fn hit_span(&self, _point: Point) -> Option<usize>

§

fn span_bounds(&self, _index: usize) -> Vec<Rectangle>

§

fn min_width(&self) -> f32

§

fn min_height(&self) -> f32

§

fn ellipsize(&self) -> Ellipsize

Implementors§