Add OpsLog::selected

This commit is contained in:
Hanno Braun 2024-11-25 22:55:19 +01:00
parent 090262c7db
commit e1e7e55e7b
2 changed files with 5 additions and 3 deletions

View File

@ -106,9 +106,7 @@ impl ApplicationHandler for App {
window.request_redraw();
}
WindowEvent::RedrawRequested => {
if let Some(selected) =
self.ops.operations.get(self.ops.selected)
{
if let Some(selected) = self.ops.selected() {
if let Err(err) = renderer.render(selected, &self.ops) {
eprintln!("Render error: {err}");
}

View File

@ -64,6 +64,10 @@ impl OpsLog {
pub fn select_previous(&mut self) {
self.selected = self.selected.saturating_sub(1);
}
pub fn selected(&self) -> Option<&dyn Operation> {
self.operations.get(self.selected).map(|op| op as &_)
}
}
impl fmt::Display for OpsLog {