Skip to main content

FlowLayout

Struct FlowLayout 

Source
pub struct FlowLayout {
    pub blocks: HashMap<usize, BlockLayout>,
    pub tables: HashMap<usize, TableLayout>,
    pub frames: HashMap<usize, FrameLayout>,
    pub flow_order: Vec<FlowItem>,
    pub content_height: f32,
    pub viewport_width: f32,
    pub viewport_height: f32,
    pub cached_max_content_width: f32,
}

Fields§

§blocks: HashMap<usize, BlockLayout>§tables: HashMap<usize, TableLayout>§frames: HashMap<usize, FrameLayout>§flow_order: Vec<FlowItem>§content_height: f32§viewport_width: f32§viewport_height: f32§cached_max_content_width: f32

Implementations§

Source§

impl FlowLayout

Source

pub fn new() -> Self

Source

pub fn add_table( &mut self, registry: &FontRegistry, params: &TableLayoutParams, available_width: f32, )

Add a table to the flow at the current y position.

Source

pub fn add_frame( &mut self, registry: &FontRegistry, params: &FrameLayoutParams, available_width: f32, )

Add a frame to the flow.

  • Inline: placed in normal flow, advances content_height.
  • FloatLeft: placed at current y, x=0. Does not advance content_height (surrounding content wraps around it).
  • FloatRight: placed at current y, x=available_width - frame_width.
  • Absolute: placed at (margin_left, margin_top) from document origin. Does not affect flow at all.
Source

pub fn clear(&mut self)

Clear all layout state. Call before rebuilding from a new FlowSnapshot.

Source

pub fn add_block( &mut self, registry: &FontRegistry, params: &BlockLayoutParams, available_width: f32, )

Add a single block to the flow at the current y position.

Source

pub fn layout_blocks( &mut self, registry: &FontRegistry, block_params: Vec<BlockLayoutParams>, available_width: f32, )

Lay out a sequence of blocks vertically.

Source

pub fn relayout_block( &mut self, registry: &FontRegistry, params: &BlockLayoutParams, available_width: f32, )

Update a single block’s layout and shift subsequent blocks if the position or height changed.

If the block’s top margin changed, its y position is recomputed using margin collapsing with the previous block. Subsequent items are shifted by the resulting delta.

Trait Implementations§

Source§

impl Default for FlowLayout

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.