Skip to main content

FragmentationLayoutContext

Struct FragmentationLayoutContext 

Source
pub struct FragmentationLayoutContext {
Show 15 fields pub page_size: LogicalSize, pub margins: PageMargins, pub template: PageTemplate, pub current_page: usize, pub current_y: f32, pub available_height: f32, pub page_content_height: f32, pub break_inside_avoid_depth: usize, pub orphans: u32, pub widows: u32, pub fragments: Vec<PageFragment>, pub counter: PageCounter, pub defaults: FragmentationDefaults, pub break_points: Vec<BreakPoint>, pub avoid_break_before_next: bool,
}
Expand description

Context for fragmentation-aware layout

Fields§

§page_size: LogicalSize

Page size (including margins)

§margins: PageMargins

Content area margins

§template: PageTemplate

Page template for headers/footers

§current_page: usize

Current page being laid out (0-indexed)

§current_y: f32

Y position on current page (0 = top of content area)

§available_height: f32

Available height remaining on current page

§page_content_height: f32

Page content height (without margins and headers/footers)

§break_inside_avoid_depth: usize

Accumulated break-inside: avoid depth from ancestors

§orphans: u32

Current orphans setting (inherited)

§widows: u32

Current widows setting (inherited)

§fragments: Vec<PageFragment>

All page fragments generated so far

§counter: PageCounter

Page counter for headers/footers

§defaults: FragmentationDefaults

Fragmentation defaults (smart behavior settings)

§break_points: Vec<BreakPoint>

Break points encountered during layout

§avoid_break_before_next: bool

Whether to avoid break before next box

Implementations§

Source§

impl FragmentationLayoutContext

Source

pub fn new(page_size: LogicalSize, margins: PageMargins) -> Self

Create a new fragmentation context for paged layout

Source

pub fn with_template(self, template: PageTemplate) -> Self

Create context with a page template

Source

pub fn with_defaults(self, defaults: FragmentationDefaults) -> Self

Create context with custom defaults

Source

pub fn content_origin(&self) -> LogicalPosition

Get the content area origin for the current page

Source

pub fn content_size(&self) -> LogicalSize

Get the content area size for the current page

Source

pub fn use_space(&mut self, height: f32)

Use space on the current page

Source

pub fn can_fit(&self, height: f32) -> bool

Check if content of given height can fit on current page

Source

pub fn would_fit_on_empty_page(&self, height: f32) -> bool

Check if content would fit on an empty page

Source

pub fn advance_page(&mut self)

Advance to the next page

Source

pub fn advance_to_left_page(&mut self)

Advance to a left (even) page

Source

pub fn advance_to_right_page(&mut self)

Advance to a right (odd) page

Source

pub fn enter_avoid_break(&mut self)

Enter a box with break-inside: avoid

Source

pub fn exit_avoid_break(&mut self)

Exit a box with break-inside: avoid

Source

pub fn set_avoid_break_before_next(&mut self)

Set flag to avoid break before next content

Source

pub fn add_fragment(&mut self, fragment: PageFragment)

Add a page fragment

Source

pub fn page_count(&self) -> usize

Get the total number of pages so far

Source

pub fn set_total_pages(&mut self, total: usize)

Set total page count (for “Page X of Y” footers)

Source

pub fn into_display_lists(self) -> Vec<DisplayList>

Convert fragments to display lists (one per page)

Source

pub fn generate_page_chrome(&self, page_index: usize) -> Vec<DisplayListItem>

Generate header/footer display list items for a specific page

Trait Implementations§

Source§

impl Debug for FragmentationLayoutContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool