Add OperationView::new

This commit is contained in:
Hanno Braun 2024-12-10 18:38:54 +01:00
parent 091ebce436
commit 78f911b8d0
2 changed files with 8 additions and 4 deletions

View File

@ -11,10 +11,7 @@ use winit::{
use crate::{geometry::OpsLog, render::Renderer, ui::OperationView}; use crate::{geometry::OpsLog, render::Renderer, ui::OperationView};
pub fn run(ops: OpsLog) -> anyhow::Result<()> { pub fn run(ops: OpsLog) -> anyhow::Result<()> {
let mut ops = OperationView { let mut ops = OperationView::new(ops);
ops_log: ops,
selected: 0,
};
ops.select_last(); ops.select_last();
let event_loop = EventLoop::new()?; let event_loop = EventLoop::new()?;

View File

@ -6,6 +6,13 @@ pub struct OperationView {
} }
impl OperationView { impl OperationView {
pub fn new(operation: OpsLog) -> Self {
Self {
ops_log: operation,
selected: 0,
}
}
pub fn select_last(&mut self) { pub fn select_last(&mut self) {
self.selected = self.ops_log.operations.len().saturating_sub(1); self.selected = self.ops_log.operations.len().saturating_sub(1);
} }