feat: add settings toggle button to hide/show toolbar buttons
This commit is contained in:
@@ -280,6 +280,9 @@ pub fn reading_view(
|
|||||||
let sidebar_tab_id = ui.make_persistent_id("sidebar_tab");
|
let sidebar_tab_id = ui.make_persistent_id("sidebar_tab");
|
||||||
let mut sidebar_tab: usize = ui.data_mut(|d| *d.get_temp_mut_or_default::<usize>(sidebar_tab_id));
|
let mut sidebar_tab: usize = ui.data_mut(|d| *d.get_temp_mut_or_default::<usize>(sidebar_tab_id));
|
||||||
|
|
||||||
|
let settings_visible_id = ui.make_persistent_id("settings_visible");
|
||||||
|
let mut settings_visible: bool = ui.data_mut(|d| *d.get_temp_mut_or_default::<bool>(settings_visible_id));
|
||||||
|
|
||||||
if *sidebar_open {
|
if *sidebar_open {
|
||||||
egui::SidePanel::left("toc_sidebar")
|
egui::SidePanel::left("toc_sidebar")
|
||||||
.resizable(true)
|
.resizable(true)
|
||||||
@@ -325,6 +328,11 @@ pub fn reading_view(
|
|||||||
ui.label(format!("《{}》", &book.title));
|
ui.label(format!("《{}》", &book.title));
|
||||||
ui.label(format!("[{}]", book.layout.label()));
|
ui.label(format!("[{}]", book.layout.label()));
|
||||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||||
|
let toggle_label = if settings_visible { "⚙ ▲" } else { "⚙" };
|
||||||
|
if ui.button(toggle_label).on_hover_text("显示/隐藏设置").clicked() {
|
||||||
|
settings_visible = !settings_visible;
|
||||||
|
}
|
||||||
|
if settings_visible {
|
||||||
let (theme_icon, theme_hint) = match theme {
|
let (theme_icon, theme_hint) = match theme {
|
||||||
Theme::Dark => ("🌞", "切换到浅色主题"),
|
Theme::Dark => ("🌞", "切换到浅色主题"),
|
||||||
Theme::Light => ("🌙", "切换到夜间主题"),
|
Theme::Light => ("🌙", "切换到夜间主题"),
|
||||||
@@ -377,6 +385,7 @@ egui::ComboBox::from_id_salt("bg_type_selector")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
if ui.button("☰").on_hover_text("打开/关闭目录").clicked() {
|
if ui.button("☰").on_hover_text("打开/关闭目录").clicked() {
|
||||||
*sidebar_open = !*sidebar_open;
|
*sidebar_open = !*sidebar_open;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user