]> git.nihav.org Git - nihav-player.git/blobdiff - videoplayer/src/osd.rs
videoplayer: allow custom scaling
[nihav-player.git] / videoplayer / src / osd.rs
index 0262c8e97428de0d70f1337666c0280691aac37a..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() {
@@ -645,6 +659,86 @@ const OSD_GLYPHS: &[Glyph] = &[
             0b_0000000000000000
         ],
     },
+    Glyph {
+        width:  7,
+        sym:    '.',
+        bits:   [
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000011100,
+            0b_0000000000011100,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000
+        ],
+        mask:   [
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000011100,
+            0b_0000000000111110,
+            0b_0000000000111110,
+            0b_0000000000011100,
+            0b_0000000000000000,
+            0b_0000000000000000
+        ],
+    },
+    Glyph {
+        width:  12,
+        sym:    'x',
+        bits:   [
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000001110011100,
+            0b_0000000111111000,
+            0b_0000000011110000,
+            0b_0000000011110000,
+            0b_0000000111111000,
+            0b_0000001110011100,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000
+        ],
+        mask:   [
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000000000000000,
+            0b_0000001110011100,
+            0b_0000011111111110,
+            0b_0000011111111110,
+            0b_0000001111111100,
+            0b_0000001111111100,
+            0b_0000011111111110,
+            0b_0000011111111110,
+            0b_0000001110011100,
+            0b_0000000000000000,
+            0b_0000000000000000
+        ],
+    },
     Glyph {
         width:  12,
         sym:    ' ',