summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-27 01:20:08 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-22 16:49:34 -0800
commit99ca495752d43095a1915826ffebc60b133f1549 (patch)
tree2e525f06febc03df2f2e875a05bdb1eb7b924185
parent7f98c343879b2d578e5c7096a118f51882a4ea8e (diff)
downloadmpv-iptv-menu-99ca495752d43095a1915826ffebc60b133f1549.tar.gz
mpv-iptv-menu-99ca495752d43095a1915826ffebc60b133f1549.tar.xz
automatic timed redraws on menus with dynamic datart
-rw-r--r--osd.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/osd.lua b/osd.lua
index e241d24..542a8ad 100644
--- a/osd.lua
+++ b/osd.lua
@@ -544,6 +544,11 @@ end
function mt:redraw(state)
self.redraw_time = os.time()
+ local next_redraw = math.huge
+ if self.redraw_timer then
+ self.redraw_timer:kill()
+ self.redraw_timer = nil
+ end
local out_titles = {}
local out_options = {}
@@ -598,6 +603,8 @@ function mt:redraw(state)
info.selected = true
out_max[#out_max+1] = self:option_icons(opt, info) .. str
+
+ next_redraw = math.min(next_redraw, opt._exp or math.huge)
end
self.out = {
@@ -622,6 +629,13 @@ function mt:redraw(state)
self:render()
self.needs_redraw = false
+
+ if next_redraw ~= math.huge then
+ local d = math.max(0.1, next_redraw - os.time())
+ self.redraw_timer = mp.add_timeout(d, function()
+ self:redraw(state)
+ end)
+ end
end
function mt:toggle_hidden()