Skip to main content

TextGeometry

Trait TextGeometry 

Source
pub trait TextGeometry {
    // Required methods
    fn caret_rect(&self, index: usize) -> Rect;
    fn selection_rects(&self, range: Range<usize>) -> Vec<Rect>;
    fn hit_test(&self, point: Point) -> usize;
}
Expand description

Caret, selection and hit-test geometry for one laid-out text.

Required Methods§

Source

fn caret_rect(&self, index: usize) -> Rect

The caret rectangle for a byte index into the text.

§Arguments
  • index - A byte index; values past the end of the text give the caret at the end.
§Returns

A one-pixel-wide rectangle as tall as the line.

Source

fn selection_rects(&self, range: Range<usize>) -> Vec<Rect>

The rectangles covering a selection, one or more per line.

§Arguments
  • range - The selected bytes of the text.
§Returns

The rectangles to fill (several per line for mixed-direction text); empty for an empty range.

Source

fn hit_test(&self, point: Point) -> usize

The byte index of the caret position nearest a point.

§Arguments
  • point - A point relative to the top-left corner of the laid-out text.
§Returns

A byte index on a character boundary of the text.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§