fix(pagination): balance window_back=1line, safety_h=0.96, recalc_height=-45
This commit is contained in:
@@ -6,7 +6,7 @@ use crate::theme::{self, BgType, Theme};
|
|||||||
pub fn recalculate_pages(book: &mut Book, font_size: f32, line_height: f32, panel_width: f32, panel_height: f32, style: &StyleProfile) {
|
pub fn recalculate_pages(book: &mut Book, font_size: f32, line_height: f32, panel_width: f32, panel_height: f32, style: &StyleProfile) {
|
||||||
let char_width = font_size * 1.0;
|
let char_width = font_size * 1.0;
|
||||||
let safety_w = 0.95;
|
let safety_w = 0.95;
|
||||||
let safety_h = 0.98;
|
let safety_h = 0.96;
|
||||||
let chars_per_line = if char_width > 0.0 {
|
let chars_per_line = if char_width > 0.0 {
|
||||||
((panel_width / char_width) * safety_w).max(1.0) as usize
|
((panel_width / char_width) * safety_w).max(1.0) as usize
|
||||||
} else {
|
} else {
|
||||||
@@ -155,7 +155,7 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
|||||||
// 在工具条之后、进度条之前用当前可用高度重新分页
|
// 在工具条之后、进度条之前用当前可用高度重新分页
|
||||||
let panel_size = ui.available_size();
|
let panel_size = ui.available_size();
|
||||||
let recalc_width = (panel_size.x - 48.0).max(100.0);
|
let recalc_width = (panel_size.x - 48.0).max(100.0);
|
||||||
let recalc_height = (panel_size.y - 40.0).max(200.0);
|
let recalc_height = (panel_size.y - 45.0).max(200.0);
|
||||||
recalculate_pages(book, style.font_size, style.line_height(), recalc_width, recalc_height, style);
|
recalculate_pages(book, style.font_size, style.line_height(), recalc_width, recalc_height, style);
|
||||||
|
|
||||||
// --- Bottom progress bar ---
|
// --- Bottom progress bar ---
|
||||||
@@ -425,7 +425,7 @@ pub fn calculate_pages(text: &str, chars_per_line: usize, lines_per_page: usize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if line_count >= lines_per_page && i > page_start {
|
if line_count >= lines_per_page && i > page_start {
|
||||||
let window_back = (chars_per_line / 2).max(3);
|
let window_back = chars_per_line.max(3);
|
||||||
let search_start = page_start.max(i.saturating_sub(window_back));
|
let search_start = page_start.max(i.saturating_sub(window_back));
|
||||||
let mut split = i;
|
let mut split = i;
|
||||||
for j in (search_start..i).rev() {
|
for j in (search_start..i).rev() {
|
||||||
|
|||||||
Reference in New Issue
Block a user