fix(pagination): recalc pages before progress bar using current available height
This commit is contained in:
@@ -152,6 +152,12 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
||||
});
|
||||
});
|
||||
|
||||
// 在工具条之后、进度条之前用当前可用高度重新分页
|
||||
let panel_size = ui.available_size();
|
||||
let recalc_width = (panel_size.x - 48.0).max(100.0);
|
||||
let recalc_height = (panel_size.y - 60.0).max(200.0);
|
||||
recalculate_pages(book, style.font_size, style.line_height(), recalc_width, recalc_height);
|
||||
|
||||
// --- Bottom progress bar ---
|
||||
let total_pages = if *current_section < book.sections.len() {
|
||||
let p = &book.sections[*current_section].pages;
|
||||
@@ -224,10 +230,7 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user