Skip to main content

PlatformParagraphLayout

Trait PlatformParagraphLayout 

Source
pub trait PlatformParagraphLayout: Send + Sync {
    // Required methods
    fn source(&self) -> &str;
    fn font_size(&self) -> Pixels;
    fn size(&self) -> Size<Pixels>;
    fn runs(&self) -> &[ShapedRun];
    fn hit_test(&self, point: Point<Pixels>) -> Result<ParagraphPosition>;
    fn caret_bounds(
        &self,
        position: ParagraphPosition,
    ) -> Result<Bounds<Pixels>>;
    fn move_visual(
        &self,
        position: ParagraphPosition,
        direction: VisualDirection,
    ) -> Result<ParagraphPosition>;
    fn selection_bounds(
        &self,
        anchor: ParagraphPosition,
        focus: ParagraphPosition,
    ) -> Result<Vec<Bounds<Pixels>>>;
}
Expand description

Immutable paragraph paint and interaction data, all in paragraph-local pixels.

Glyph positions include their line baseline, measured from the paragraph top. Glyph indices remain logical UTF-8 offsets even when paint order is visual.

Required Methods§

Source

fn source(&self) -> &str

Original unmodified source.

Source

fn font_size(&self) -> Pixels

Logical font size shared by every run in this initial interface.

Source

fn size(&self) -> Size<Pixels>

Paragraph layout size, including its allocated wrapping width.

Source

fn runs(&self) -> &[ShapedRun]

Resolved faces/glyphs in visual paint order; never requested descriptor IDs.

Source

fn hit_test(&self, point: Point<Pixels>) -> Result<ParagraphPosition>

Find a logical boundary at a local point.

Source

fn caret_bounds(&self, position: ParagraphPosition) -> Result<Bounds<Pixels>>

A one-pixel caret; invalid positions return an error.

Source

fn move_visual( &self, position: ParagraphPosition, direction: VisualDirection, ) -> Result<ParagraphPosition>

Move to a neighboring visual cluster boundary.

Source

fn selection_bounds( &self, anchor: ParagraphPosition, focus: ParagraphPosition, ) -> Result<Vec<Bounds<Pixels>>>

Possibly discontiguous selection rectangles.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§