Skip to main content

Paragraph

Trait Paragraph 

pub trait Paragraph: Sized + Default {
Show 26 methods // Required methods fn with_text(text: Text<&str>) -> Self; fn with_spans<Link>(text: Text<&[Span<'_, Link>]>) -> Self; fn resize(&mut self, new_bounds: Size); fn compare(&self, text: Text<()>) -> Difference; fn size(&self) -> Pixels; fn hint_factor(&self) -> Option<f32>; fn font(&self) -> Font; fn line_height(&self) -> LineHeight; fn align_x(&self) -> Alignment; fn align_y(&self) -> Vertical; fn wrapping(&self) -> Wrapping; fn ellipsis(&self) -> Ellipsis; 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 select(&mut self, start: Point, end: Point, target: Target); fn select_all(&mut self); fn deselect(&mut self); fn selection(&self) -> &[Rectangle]; fn copy(&mut self) -> Option<String>; // Provided methods fn hit_glyph(&self, point: Point) -> bool { ... } fn min_width(&self) -> f32 { ... } fn min_height(&self) -> f32 { ... }
}
Available on crate feature advanced only.
Expand description

A text paragraph.

Required Methods§

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

Creates a new Paragraph laid out with the given Text.

fn with_spans<Link>(text: Text<&[Span<'_, Link>]>) -> 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<()>) -> 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 hint_factor(&self) -> Option<f32>

Returns the hint factor of the Paragraph.

fn font(&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 ellipsis(&self) -> Ellipsis

Returns the Ellipsis 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 select(&mut self, start: Point, end: Point, target: Target)

Selects the text between the given positions.

The positions are relative to the origin of the Paragraph. start is the position where the selection began, while end is its final position. The Target determines how the selection is expanded around these positions.

fn select_all(&mut self)

Selects all the text of the Paragraph.

fn deselect(&mut self)

Deselects any selected text.

fn selection(&self) -> &[Rectangle]

Returns the regions of the current selection of the Paragraph.

Each Rectangle corresponds to a line of the selection.

fn copy(&mut self) -> Option<String>

Returns the current selected text of the Paragraph.

Provided Methods§

fn hit_glyph(&self, point: Point) -> bool

Tests whether the provided point is inside the boundaries of a glyph in the Paragraph.

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 ()

§

fn with_text(_text: Text<&str>)

§

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

§

fn resize(&mut self, _new_bounds: Size)

§

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

§

fn hint_factor(&self) -> Option<f32>

§

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 ellipsis(&self) -> Ellipsis

§

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 select(&mut self, _start: Point, _end: Point, _target: Target)

§

fn select_all(&mut self)

§

fn deselect(&mut self)

§

fn selection(&self) -> &[Rectangle]

§

fn copy(&mut self) -> Option<String>

§

impl Paragraph for Paragraph

§

fn with_text(text: Text<&str>) -> Paragraph

§

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

§

fn resize(&mut self, new_bounds: Size)

§

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

§

fn hint_factor(&self) -> Option<f32>

§

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 ellipsis(&self) -> Ellipsis

§

fn shaping(&self) -> Shaping

§

fn bounds(&self) -> Size

§

fn min_bounds(&self) -> Size

§

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

§

fn hit_glyph(&self, point: Point) -> bool

§

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

§

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

§

fn select(&mut self, start: Point, end: Point, target: Target)

§

fn select_all(&mut self)

§

fn deselect(&mut self)

§

fn selection(&self) -> &[Rectangle]

§

fn copy(&mut self) -> Option<String>

Implementors§