pub struct PageGeometer {
pub page_size: LogicalSize,
pub page_margins: PageMargins,
pub header_height: f32,
pub footer_height: f32,
pub current_y: f32,
}Expand description
Manages the infinite canvas coordinate system with page boundaries.
The PageGeometer tracks page dimensions and provides utilities for:
- Determining which page a Y coordinate falls on
- Calculating the next page start position
- Checking if content crosses page boundaries
Fields§
§page_size: LogicalSizeTotal height of each page (including margins, headers, footers)
page_margins: PageMarginsContent area margins (space reserved at top/bottom of each page)
header_height: f32Height reserved for page header (if any)
Height reserved for page footer (if any)
current_y: f32Current Y position on the infinite canvas
Implementations§
Source§impl PageGeometer
impl PageGeometer
Sourcepub fn new(page_size: LogicalSize, margins: PageMargins) -> Self
pub fn new(page_size: LogicalSize, margins: PageMargins) -> Self
Create a new PageGeometer for paged layout.
Create with header and footer space reserved.
Sourcepub fn content_height(&self) -> f32
pub fn content_height(&self) -> f32
Get the usable content height per page (page height minus margins/headers/footers).
Sourcepub fn content_width(&self) -> f32
pub fn content_width(&self) -> f32
Get the usable content width per page (page width minus left/right margins).
Sourcepub fn page_for_y(&self, y: f32) -> usize
pub fn page_for_y(&self, y: f32) -> usize
Calculate which page a given Y coordinate falls on (0-indexed).
Negative Y values are clamped to page 0.
Sourcepub fn page_content_start_y(&self, page_index: usize) -> f32
pub fn page_content_start_y(&self, page_index: usize) -> f32
Get the Y coordinate where a page’s content area starts.
Sourcepub fn page_content_end_y(&self, page_index: usize) -> f32
pub fn page_content_end_y(&self, page_index: usize) -> f32
Get the Y coordinate where a page’s content area ends.
Sourcepub fn dead_zone_height(&self) -> f32
pub fn dead_zone_height(&self) -> f32
Get the height of the “dead zone” between pages (footer + margin + header of next page).
Sourcepub fn next_page_start_y(&self, current_y: f32) -> f32
pub fn next_page_start_y(&self, current_y: f32) -> f32
Calculate the Y coordinate where the NEXT page’s content starts from a given position.
Sourcepub fn crosses_page_break(&self, start_y: f32, end_y: f32) -> bool
pub fn crosses_page_break(&self, start_y: f32, end_y: f32) -> bool
Check if a range [start_y, end_y) crosses a page boundary.
Sourcepub fn remaining_on_page(&self, y: f32) -> f32
pub fn remaining_on_page(&self, y: f32) -> f32
Get remaining space on the current page from a given Y position.
Sourcepub fn can_fit(&self, y: f32, height: f32) -> bool
pub fn can_fit(&self, y: f32, height: f32) -> bool
Check if content of given height can fit starting at Y position.
Sourcepub fn page_break_offset(&self, y: f32, height: f32) -> f32
pub fn page_break_offset(&self, y: f32, height: f32) -> f32
Calculate the additional Y offset needed to push content to the next page. Returns 0 if content fits on current page.
Sourcepub fn page_count(&self, total_content_height: f32) -> usize
pub fn page_count(&self, total_content_height: f32) -> usize
Get the number of pages needed to contain content ending at Y.
Trait Implementations§
Source§impl Clone for PageGeometer
impl Clone for PageGeometer
Source§fn clone(&self) -> PageGeometer
fn clone(&self) -> PageGeometer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PageGeometer
impl RefUnwindSafe for PageGeometer
impl Send for PageGeometer
impl Sync for PageGeometer
impl Unpin for PageGeometer
impl UnsafeUnpin for PageGeometer
impl UnwindSafe for PageGeometer
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
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>
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>
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