pub struct FragmentationState {
pub current_page: usize,
pub current_page_y: f32,
pub available_height: f32,
pub page_content_height: f32,
pub margins_top: f32,
pub margins_bottom: f32,
pub total_pages: usize,
}Expand description
State tracked during layout for fragmentation. This is created at the start of paged layout and updated as nodes are laid out.
Fields§
§current_page: usizeCurrent page being laid out (0-indexed)
current_page_y: f32Y position on current page (relative to page content area)
available_height: f32Available height remaining on current page
page_content_height: f32Full page content height
margins_top: f32Page margins (not yet used, but needed for future)
margins_bottom: f32§total_pages: usizeTotal number of pages so far
Implementations§
Source§impl FragmentationState
impl FragmentationState
Sourcepub fn new(
page_content_height: f32,
margins_top: f32,
margins_bottom: f32,
) -> Self
pub fn new( page_content_height: f32, margins_top: f32, margins_bottom: f32, ) -> Self
Create a new fragmentation state for paged layout.
Sourcepub fn can_fit(&self, height: f32) -> bool
pub fn can_fit(&self, height: f32) -> bool
Check if content of the given height can fit on the current page.
Sourcepub fn would_fit_on_empty_page(&self, height: f32) -> bool
pub fn would_fit_on_empty_page(&self, height: f32) -> bool
Check if content would fit on an empty page.
Sourcepub fn advance_page(&mut self)
pub fn advance_page(&mut self)
Advance to the next page.
Sourcepub fn page_for_y(&self, y: f32) -> usize
pub fn page_for_y(&self, y: f32) -> usize
Calculate which page a Y position belongs to.
Sourcepub fn page_y_offset(&self, page: usize) -> f32
pub fn page_y_offset(&self, page: usize) -> f32
Calculate the Y offset for a given page (to convert to page-relative coordinates).
Trait Implementations§
Source§impl Clone for FragmentationState
impl Clone for FragmentationState
Source§fn clone(&self) -> FragmentationState
fn clone(&self) -> FragmentationState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FragmentationState
impl RefUnwindSafe for FragmentationState
impl Send for FragmentationState
impl Sync for FragmentationState
impl Unpin for FragmentationState
impl UnwindSafe for FragmentationState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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