fix(pagination): recalculate with exact text_rect dims inside CentralPanel, validate current_page
This commit is contained in:
@@ -60,11 +60,6 @@ pub fn reading_view(
|
|||||||
|
|
||||||
let colors = theme::reader_colors(theme);
|
let colors = theme::reader_colors(theme);
|
||||||
|
|
||||||
// 工具栏之前预估文本区尺寸完成分页(扣除边距 48px + 工具条 ~60px)
|
|
||||||
let panel_size = ui.available_size();
|
|
||||||
let est_width = (panel_size.x - 48.0).max(100.0);
|
|
||||||
let est_height = (panel_size.y - 60.0).max(200.0);
|
|
||||||
recalculate_pages(book, style.font_size, style.line_height(), est_width, est_height);
|
|
||||||
let has_bookmark = bookmarks.iter().any(|b| b.section == *current_section && b.page == *current_page);
|
let has_bookmark = bookmarks.iter().any(|b| b.section == *current_section && b.page == *current_page);
|
||||||
|
|
||||||
// --- Sidebar (TOC + Bookmarks) ---
|
// --- Sidebar (TOC + Bookmarks) ---
|
||||||
@@ -229,6 +224,17 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
|||||||
egui::vec2((rect.width() - inset * 2.0).max(100.0), rect.height()),
|
egui::vec2((rect.width() - inset * 2.0).max(100.0), rect.height()),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 用实际文本区宽高重新分页(包含侧边栏、工具条等已占空间后的精确值)
|
||||||
|
recalculate_pages(book, style.font_size, style.line_height(), text_rect.width(), text_rect.height());
|
||||||
|
|
||||||
|
// 确保 current_page 在新分页后仍在有效范围内
|
||||||
|
if let Some(section) = book.sections.get(*current_section) {
|
||||||
|
let max_page = section.pages.len().saturating_sub(2);
|
||||||
|
if *current_page > max_page {
|
||||||
|
*current_page = max_page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(section) = book.sections.get(*current_section) {
|
if let Some(section) = book.sections.get(*current_section) {
|
||||||
if *current_page < section.pages.len().saturating_sub(1) {
|
if *current_page < section.pages.len().saturating_sub(1) {
|
||||||
let start = section.pages[*current_page];
|
let start = section.pages[*current_page];
|
||||||
|
|||||||
Reference in New Issue
Block a user