fix: replace profile cycle button with ComboBox for instant style switching
This commit is contained in:
@@ -26,7 +26,7 @@ pub struct ReaderAction {
|
||||
pub toggle_theme: bool,
|
||||
pub toggle_bookmark: bool,
|
||||
pub toggle_kraft_bg: bool,
|
||||
pub cycle_profile: bool,
|
||||
pub switch_to_profile: Option<String>,
|
||||
pub page_next: bool,
|
||||
pub page_prev: bool,
|
||||
}
|
||||
@@ -42,13 +42,14 @@ pub fn reading_view(
|
||||
_file_path: &str,
|
||||
kraft_texture: Option<&egui::TextureHandle>,
|
||||
use_kraft_bg: bool,
|
||||
profile_names: &[String],
|
||||
) -> ReaderAction {
|
||||
let mut action = ReaderAction {
|
||||
go_back: false,
|
||||
toggle_theme: false,
|
||||
toggle_bookmark: false,
|
||||
toggle_kraft_bg: false,
|
||||
cycle_profile: false,
|
||||
switch_to_profile: None,
|
||||
page_next: false,
|
||||
page_prev: false,
|
||||
};
|
||||
@@ -98,12 +99,17 @@ pub fn reading_view(
|
||||
if ui.button("A⁺").on_hover_text("放大字体").clicked() {
|
||||
style.font_size = (style.font_size + 2.0).min(48.0);
|
||||
}
|
||||
if ui.button(&style.name)
|
||||
.on_hover_text(format!("样式: {} (点击切换)", style.name))
|
||||
.clicked()
|
||||
{
|
||||
action.cycle_profile = true;
|
||||
}
|
||||
egui::ComboBox::from_id_salt("profile_selector")
|
||||
.width(110.0)
|
||||
.selected_text(&style.name)
|
||||
.show_ui(ui, |ui| {
|
||||
for name in profile_names {
|
||||
let selected = *name == style.name;
|
||||
if ui.selectable_label(selected, name).clicked() {
|
||||
action.switch_to_profile = Some(name.clone());
|
||||
}
|
||||
}
|
||||
});
|
||||
let kraft_icon = if use_kraft_bg { "📄" } else { "📋" };
|
||||
if ui.button(kraft_icon).on_hover_text("牛皮纸背景").clicked() {
|
||||
action.toggle_kraft_bg = true;
|
||||
|
||||
Reference in New Issue
Block a user