summaryrefslogtreecommitdiff
path: root/osd.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-28 00:36:35 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-28 00:36:35 -0800
commite3f3ef7e681890e2b7c20ad54177856a178e581f (patch)
tree2e525f06febc03df2f2e875a05bdb1eb7b924185 /osd.lua
parent0c101e327fce492c7b712cd3bf51d2af72e203ae (diff)
downloadmpv-iptv-menu-e3f3ef7e681890e2b7c20ad54177856a178e581f.tar.gz
mpv-iptv-menu-e3f3ef7e681890e2b7c20ad54177856a178e581f.tar.xz
automatic timed redraws on menus with dynamic data
Diffstat (limited to 'osd.lua')
-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()