]> git.nihav.org Git - nihav-player.git/commitdiff
videoplayer: allow diplaying time indefinitely long
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 1 Sep 2023 16:50:06 +0000 (18:50 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 1 Sep 2023 16:50:06 +0000 (18:50 +0200)
videoplayer/src/main.rs
videoplayer/src/osd.rs

index 3126b19da9614bc87b8d37507d76ce87fdae4157..56c311237ff6cf06aeb0ec6171bb4907d9f5b81a 100644 (file)
@@ -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();
+                        }
                     },
                     _ => {},
                 };
index 1dfff4217764b34de005560031de045af33f0b25..f2dd24d34447badb94cece20530f02f5f7b47a62 100644 (file)
@@ -9,6 +9,7 @@ pub struct OSD {
     text:           Vec<u8>,
     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() {