1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
use crate::cache::CacheMessage;
use crate::frame::{Frame, PixelFormat};
use crate::player::Player;
use crate::progress_bar::ProgressBar;
use crate::viewport::ViewportState;
use eframe::egui;
use std::sync::mpsc;
/// Status bar component that receives updates from cache via messages
pub struct StatusBar {
message_rx: mpsc::Receiver<CacheMessage>,
pub current_message: String,
cached_count: usize,
total_count: usize,
progress_bar: ProgressBar,
}
impl StatusBar {
pub fn new(rx: mpsc::Receiver<CacheMessage>) -> Self {
Self {
message_rx: rx,
current_message: String::new(),
cached_count: 0,
total_count: 0,
progress_bar: ProgressBar::new(150.0, 10.0), // 150px wide, 10px tall
}
}
/// Read messages from channel and update status
pub fn update(&mut self, ctx: &egui::Context) {
let mut has_updates = false;
while let Ok(msg) = self.message_rx.try_recv() {
match msg {
CacheMessage::LoadProgress {
cached_count,
total_count,
} => {
self.cached_count = cached_count;
self.total_count = total_count;
self.progress_bar.set_progress(cached_count, total_count);
}
CacheMessage::FrameLoaded => {
// Individual frame loaded - will be followed by LoadProgress
}
}
has_updates = true;
}
if has_updates {
ctx.request_repaint();
}
}
/// Render status bar at bottom of screen
pub fn render(
&self,
ctx: &egui::Context,
frame: Option<&Frame>,
player: &Player,
viewport_state: &ViewportState,
render_time_ms: f32,
) {
egui::TopBottomPanel::bottom("status_bar").show(ctx, |ui| {
ui.horizontal(|ui| {
// Filename
if let Some(frame) = frame {
if let Some(path) = frame.file() {
if let Some(filename) = path.file_name().and_then(|n| n.to_str()) {
ui.monospace(filename);
} else {
ui.monospace("---");
}
} else {
ui.monospace("No file");
}
} else {
ui.monospace("No file");
}
ui.separator();
// Resolution
if let Some(img) = frame {
ui.monospace(format!("{:>4}x{:<4}", img.width(), img.height()));
} else {
ui.monospace(" 0x0 ");
}
ui.separator();
// Pixel format
if let Some(img) = frame {
ui.monospace(Self::format_pixel_format(img.pixel_format()));
} else {
ui.monospace("---");
}
ui.separator();
// Zoom
ui.monospace(format!("{:>6.1}%", viewport_state.zoom * 100.0));
ui.separator();
// FPS (show play FPS if different from base)
if player.is_playing && (player.fps_play - player.fps_base).abs() > 0.01 {
ui.monospace(format!("{:>5.1}▶", player.fps_play));
} else {
ui.monospace(format!("{:>5.1}", player.fps_base));
}
ui.separator();
// Memory usage
let (used_bytes, max_bytes) = player.cache.mem();
let used_mb = used_bytes / 1024 / 1024;
let max_mb = max_bytes / 1024 / 1024;
ui.monospace(format!("{}M/{}M", used_mb, max_mb));
ui.separator();
// Progress bar for loading
self.progress_bar.render(ui);
ui.separator();
// Render time
ui.monospace(format!("{:.1}ms", render_time_ms));
// Status message (if any)
if !self.current_message.is_empty() {
ui.separator();
ui.monospace(&self.current_message);
}
});
});
}
/// Format pixel format for display
fn format_pixel_format(format: PixelFormat) -> &'static str {
match format {
PixelFormat::Rgba8 => "RGBA u8",
PixelFormat::RgbaF16 => "RGBA f16",
PixelFormat::RgbaF32 => "RGBA f32",
}
}
}