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,
pub scale_factor: f32,
/* private fields */
}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§scale_factor: f32Device pixel ratio passed to shapers and rasterizers. Layout is always stored in logical pixels; this only affects precision (physical ppem) and glyph bitmap resolution.
Implementations§
Source§impl FlowLayout
impl FlowLayout
pub fn new() -> Self
Sourcepub fn add_table(
&mut self,
registry: &FontRegistry,
params: &TableLayoutParams,
available_width: f32,
)
pub fn add_table( &mut self, registry: &FontRegistry, params: &TableLayoutParams, available_width: f32, )
Add a table to the flow at the current y position.
Sourcepub fn add_frame(
&mut self,
registry: &FontRegistry,
params: &FrameLayoutParams,
available_width: f32,
)
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.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear all layout state. Call before rebuilding from a new FlowSnapshot.
Sourcepub fn apply_paint_spans_for(
&mut self,
spans_by_block: HashMap<usize, Vec<PaintSpan>>,
)
pub fn apply_paint_spans_for( &mut self, spans_by_block: HashMap<usize, Vec<PaintSpan>>, )
Replace the paint-only color overlay for the whole flow.
spans_by_block maps block_id → its disjoint paint spans (from
text_document’s extract_paint_spans). Every block is re-derived from
its captured base, so colors/decorations change but glyph positions,
advances, line breaks, and heights do NOT — no reshape, no reflow.
Blocks absent from the map reset to base colors.
Sourcepub fn apply_block_paint_spans(
&mut self,
block_id: usize,
spans: &[PaintSpan],
) -> bool
pub fn apply_block_paint_spans( &mut self, block_id: usize, spans: &[PaintSpan], ) -> bool
Apply (or clear, when spans is empty) the paint overlay for a single
block, re-derived from its base. Returns false if block_id has no
captured base.
Sourcepub fn add_block(
&mut self,
registry: &FontRegistry,
params: &BlockLayoutParams,
available_width: f32,
)
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.
Sourcepub fn layout_blocks(
&mut self,
registry: &FontRegistry,
block_params: Vec<BlockLayoutParams>,
available_width: f32,
)
pub fn layout_blocks( &mut self, registry: &FontRegistry, block_params: Vec<BlockLayoutParams>, available_width: f32, )
Lay out a sequence of blocks vertically.
Sourcepub fn relayout_block(
&mut self,
registry: &FontRegistry,
params: &BlockLayoutParams,
available_width: f32,
)
pub fn relayout_block( &mut self, registry: &FontRegistry, params: &BlockLayoutParams, available_width: f32, )
Update a single block’s layout and shift subsequent items if height changed.
Finds the block in top-level blocks, table cells, or frames, re-layouts it, and propagates any height delta to subsequent flow items.