feat: 响应式分页引擎 - 基于egui Galley精确测量替代字符计数

This commit is contained in:
2026-05-16 12:11:26 +08:00
parent 4add295bfa
commit af03d18470
4 changed files with 296 additions and 190 deletions

View File

@@ -179,12 +179,18 @@ pub struct TocEntry {
pub children: Vec<TocEntry>,
}
#[derive(Debug, Clone)]
pub struct ContentBlock {
pub text: String,
pub is_heading: bool,
}
#[derive(Debug, Clone)]
pub struct Section {
pub title: String,
pub content: String,
/// Populated by pagination algorithm (pre-computed char offsets for page boundaries)
pub pages: Vec<usize>,
pub blocks: Vec<ContentBlock>,
pub page_block_ranges: Vec<(usize, usize)>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -253,7 +259,8 @@ pub fn load_epub(path: impl AsRef<Path>) -> Result<Book, String> {
sections.push(Section {
title,
content: text,
pages: Vec::new(),
blocks: Vec::new(),
page_block_ranges: Vec::new(),
});
}