From 5a268da11a915fdfb4697a0b4b9a4f0203b520c9 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 1 Sep 2023 18:50:06 +0200 Subject: [PATCH] videoplayer: allow diplaying time indefinitely long --- videoplayer/src/main.rs | 6 +++++- videoplayer/src/osd.rs | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/videoplayer/src/main.rs b/videoplayer/src/main.rs index 3126b19..56c3112 100644 --- a/videoplayer/src/main.rs +++ b/videoplayer/src/main.rs @@ -523,7 +523,11 @@ impl Player { self.vcontrol.try_send_video(PktSendEvent::HurryUp); }, Keycode::O => { - self.osd.toggle(); + if keymod.contains(Mod::RSHIFTMOD) || keymod.contains(Mod::LSHIFTMOD) { + self.osd.toggle_perm(); + } else { + self.osd.toggle(); + } }, _ => {}, }; diff --git a/videoplayer/src/osd.rs b/videoplayer/src/osd.rs index 1dfff42..f2dd24d 100644 --- a/videoplayer/src/osd.rs +++ b/videoplayer/src/osd.rs @@ -9,6 +9,7 @@ pub struct OSD { text: Vec, text_stride: usize, duration: u64, + perm: bool, } impl OSD { @@ -20,12 +21,25 @@ impl OSD { } pub fn set_duration(&mut self, duration: u64) { self.duration = duration; } pub fn toggle(&mut self) { + if self.perm { + self.perm = false; + self.time = None; + return; + } if self.time.is_none() { self.time = Some(Instant::now()); } else { self.time = None; } } + pub fn toggle_perm(&mut self) { + if !self.perm { + self.perm = true; + } else { + self.perm = false; + self.time = None; + } + } pub fn update(&mut self) { if let Some(time) = self.time { if time.elapsed().as_millis() > 3000 { @@ -33,7 +47,7 @@ impl OSD { } } } - pub fn is_active(&self) -> bool { self.time.is_some() } + pub fn is_active(&self) -> bool { self.time.is_some() || self.perm } pub fn prepare(&mut self, ts: u64) { self.update(); if !self.is_active() { -- 2.39.5