Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/virt/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@ use std::time::{Duration, Instant};

pub struct UserInterface {
start_time: Instant,
user_presence_level: Level,
inner: Option<Box<dyn platform::UserInterface + Sync + Send>>,
}

impl UserInterface {
pub fn new() -> Self {
Self {
start_time: Instant::now(),
user_presence_level: Level::Normal,
inner: None,
}
}

pub fn set_inner(&mut self, inner: impl Into<Box<dyn platform::UserInterface + Sync + Send>>) {
self.inner = Some(inner.into());
pub fn set_user_presence_level(&mut self, level: Level) {
self.user_presence_level = level;
}

pub fn set_inner(&mut self, inner: Box<dyn platform::UserInterface + Sync + Send>) {
self.inner = Some(inner);
}

pub fn take_inner(&mut self) -> Option<Box<dyn platform::UserInterface + Sync + Send>> {
Expand All @@ -34,7 +40,7 @@ impl platform::UserInterface for UserInterface {
self.inner
.as_mut()
.map(|inner| inner.check_user_presence())
.unwrap_or(Level::Normal)
.unwrap_or(self.user_presence_level)
}

fn set_status(&mut self, status: Status) {
Expand Down
Loading