Skip to main content

BlockVisualInfo

Struct BlockVisualInfo 

Source
#[non_exhaustive]
pub struct BlockVisualInfo { pub block_id: usize, pub x: f32, pub content_x: f32, pub marker_x: Option<f32>, pub marker_width: f32, pub y: f32, pub height: f32, }
Expand description

Visual position and size of a laid-out block.

Returned by crate::DocumentFlow::block_visual_info and, with the block’s lines, by crate::DocumentFlow::block_geometry.

Three x positions matter, and they are not the same:

  • x, the left edge of the column the block sits in;
  • content_x, where the block’s text starts, after its left margin and any list or paragraph indent;
  • marker_x, where its list or checkbox marker is drawn, in the indent area before the text.

Line rectangles returned by crate::DocumentFlow::block_geometry and crate::DocumentFlow::block_line_geometry are relative to content_x, not to x.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§block_id: usize

Block ID (matches BlockSnapshot::block_id).

§x: f32

X position of the left edge of the block’s column, relative to the document start, in pixels. It does not include the block’s own left margin or indent: a rectangle around the block’s text starts at content_x, and one that also covers the marker starts here.

Zero for a block in the document’s own column. A block inside a table cell or a frame has its own left origin: column 1 of a table does not start at the document’s left edge.

§content_x: f32

X position where the block’s text starts, relative to the document start, in pixels: x plus the block’s left margin and its list or paragraph indent. This is the origin of the x of every line rectangle and segment the line geometry reports for the block, and the origin the renderer paints glyphs from.

Equal to x for a block with no margin and no indent.

§marker_x: Option<f32>

X position of the block’s list or checkbox marker box, relative to the document start, in pixels, or None when the block has no marker.

The marker is drawn in the indent area just before the text, right-aligned with a small gap, and never left of the block’s left margin. When the indent is narrower than the marker, the marker starts at the left margin (x plus the margin) and its box overlaps the text. In a right-to-left block it is currently still drawn at the left.

§marker_width: f32

Advance width of the marker, in pixels; 0.0 when the block has no marker. The marker box is marker_x to marker_x + marker_width, on the block’s first line.

§y: f32

Y position of the block’s top edge relative to the document start, in pixels.

§height: f32

Total height of the block including margins, in pixels.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.