feat(ui): enhance OSD with progress %, playback icon, and dark background

This commit is contained in:
accusys
2026-03-19 01:48:33 +08:00
parent 643accfc92
commit dbcd7ba5e9

View File

@@ -424,16 +424,29 @@ fn run(config: &Config) -> Result<()> {
if let Some(ref f) = font { if let Some(ref f) = font {
let time_str = format_time(player_state.current_time_ms); let time_str = format_time(player_state.current_time_ms);
let duration_str = format_time(player_state.duration_ms); let duration_str = format_time(player_state.duration_ms);
let play_icon = if player_state.playback == PlaybackState::Playing {
""
} else {
""
};
let progress_pct = if player_state.total_frames > 0 {
(player_state.current_frame as f64 / player_state.total_frames as f64 * 100.0)
as u32
} else {
0
};
let line1 = format!( let line1 = format!(
"{} / {} Frame: {}/{} {:.1}fps", "{} {:>5} / {} ({:>3}%) Frame {:>6} / {:>6} {:.2}fps",
play_icon,
time_str, time_str,
duration_str, duration_str,
progress_pct,
player_state.current_frame, player_state.current_frame,
player_state.total_frames, player_state.total_frames,
player_state.fps player_state.fps
); );
let line2 = format!( let line2 = format!(
"[S]ub {} [Y]olo {} [C]hunks [M]ute [+/-]Zoom{:.1}x [F]ullscreen [`]Reset", "[S]ub {} [Y]olo {} [C]hunks [M]ute Zoom{:.1}x [F]ullscreen [`]Reset",
if player_state.show_subtitle { if player_state.show_subtitle {
"ON" "ON"
} else { } else {
@@ -449,6 +462,13 @@ fn run(config: &Config) -> Result<()> {
{ {
if let Ok(tex_label) = texture_creator.create_texture_from_surface(&surface) { if let Ok(tex_label) = texture_creator.create_texture_from_surface(&surface) {
let rect = Rect::new(10, 10, surface.width(), surface.height()); let rect = Rect::new(10, 10, surface.width(), surface.height());
canvas.set_draw_color(sdl2::pixels::Color::RGBA(0, 0, 0, 150));
let _ = canvas.fill_rect(Rect::new(
5,
5,
surface.width() + 10,
surface.height() + 10,
));
canvas.copy(&tex_label, None, Some(rect)).ok(); canvas.copy(&tex_label, None, Some(rect)).ok();
} }
} }
@@ -458,6 +478,13 @@ fn run(config: &Config) -> Result<()> {
{ {
if let Ok(tex_label) = texture_creator.create_texture_from_surface(&surface) { if let Ok(tex_label) = texture_creator.create_texture_from_surface(&surface) {
let rect = Rect::new(10, 30, surface.width(), surface.height()); let rect = Rect::new(10, 30, surface.width(), surface.height());
canvas.set_draw_color(sdl2::pixels::Color::RGBA(0, 0, 0, 150));
let _ = canvas.fill_rect(Rect::new(
5,
25,
surface.width() + 10,
surface.height() + 10,
));
canvas.copy(&tex_label, None, Some(rect)).ok(); canvas.copy(&tex_label, None, Some(rect)).ok();
} }
} }