feat: add kraft paper tiled background texture for comfortable reading
This commit is contained in:
@@ -25,6 +25,7 @@ pub struct ReaderAction {
|
||||
pub go_back: bool,
|
||||
pub toggle_theme: bool,
|
||||
pub toggle_bookmark: bool,
|
||||
pub toggle_kraft_bg: bool,
|
||||
pub page_next: bool,
|
||||
pub page_prev: bool,
|
||||
}
|
||||
@@ -38,11 +39,14 @@ pub fn reading_view(
|
||||
font_size: &mut f32,
|
||||
theme: &Theme,
|
||||
_file_path: &str,
|
||||
kraft_texture: Option<&egui::TextureHandle>,
|
||||
use_kraft_bg: bool,
|
||||
) -> ReaderAction {
|
||||
let mut action = ReaderAction {
|
||||
go_back: false,
|
||||
toggle_theme: false,
|
||||
toggle_bookmark: false,
|
||||
toggle_kraft_bg: false,
|
||||
page_next: false,
|
||||
page_prev: false,
|
||||
};
|
||||
@@ -91,6 +95,10 @@ pub fn reading_view(
|
||||
if ui.button("A⁺").on_hover_text("放大字体").clicked() {
|
||||
*font_size = (*font_size + 2.0).min(48.0);
|
||||
}
|
||||
let kraft_icon = if use_kraft_bg { "📄" } else { "📋" };
|
||||
if ui.button(kraft_icon).on_hover_text("牛皮纸背景").clicked() {
|
||||
action.toggle_kraft_bg = true;
|
||||
}
|
||||
if ui.button("☰").on_hover_text("打开/关闭目录").clicked() {
|
||||
*sidebar_open = !*sidebar_open;
|
||||
}
|
||||
@@ -163,6 +171,13 @@ pub fn reading_view(
|
||||
let available = ui.available_size();
|
||||
let (rect, response) = ui.allocate_at_least(available, egui::Sense::click());
|
||||
|
||||
// Draw kraft paper background if enabled
|
||||
if use_kraft_bg {
|
||||
if let Some(tex) = kraft_texture {
|
||||
crate::texture::draw_tiled_bg(ui.painter(), rect, tex);
|
||||
}
|
||||
}
|
||||
|
||||
// Add reading margins (inset)
|
||||
let inset = 24.0;
|
||||
let text_rect = egui::Rect::from_min_size(
|
||||
|
||||
Reference in New Issue
Block a user