diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-28 19:57:42 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-28 19:57:42 -0800 |
| commit | 5c23089356402017a396f6efbd6a0d547a6a26ac (patch) | |
| tree | 8c34a64799af7be6ab91161ce0119fb87ba32fb9 /osd.lua | |
| parent | b29af502c800131a34c38a74d6e7be8da259deb2 (diff) | |
| download | mpv-iptv-menu-5c23089356402017a396f6efbd6a0d547a6a26ac.tar.gz mpv-iptv-menu-5c23089356402017a396f6efbd6a0d547a6a26ac.tar.xz | |
add progress bar for active programmes
Diffstat (limited to 'osd.lua')
| -rw-r--r-- | osd.lua | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -202,6 +202,28 @@ function mt:option_icons(opt, info) return str end +function mt:draw_progress_bar(prog, fg, bg) + local pct = (self.redraw_time - prog.start) / (prog.stop - prog.start) + local offset = 0.15 * config.font_size + local h = 0.25 * config.font_size + local w = 2 * config.font_size + local filled = w * pct + + -- overlay fill over bg using negative coordinates, then backtrack + -- width of fill using \fsp on a zero-width space. this is needed + -- because ASS essentially advances a cursor by the width of any + -- rendered shape, as opposed to starting the next shape where the + -- previous one ended. we must rewind this cursor to avoid a gap the + -- width of fill before anything else that follows. + -- + -- the reason this is done in the first place is because simply placing + -- two rectangles next to one another results in a subpixel gap between + -- them, affecting both the rendered result and the computed bounds. + return bg .. draw_rect(0, -offset, w, h - offset) .. + fg .. draw_rect(-w, -offset, filled - w, h - offset) .. + '{\\fsp'..-filled..'}\xe2\x80\x8b{\\fsp0}' +end + function mt:option_text(opt, info) local str = opt.name local col = colour.option @@ -235,11 +257,23 @@ function mt:option_text(opt, info) str = col .. '[' .. str .. ']' end + if opt.programme and opt.type == 'programme' and opt.active then + str = str .. ' ' .. self:draw_progress_bar( + opt.programme, colour.progress_bar_epg_fg, + colour.progress_bar_epg_bg) + end + local opt_info = opt.info if opt_info and #opt_info > 0 then str = str .. colour.info .. ' (' .. asscape(opt_info) .. ')' end + if opt.programme and opt.type ~= 'programme' then + str = str .. ' ' .. self:draw_progress_bar( + opt.programme, colour.progress_bar_fg, + colour.progress_bar_bg) + end + return str end @@ -631,7 +665,7 @@ function mt:redraw(state) self.needs_redraw = false if next_redraw ~= math.huge then - local d = math.max(0.1, next_redraw - os.time()) + local d = math.min(10, math.max(0.1, next_redraw - os.time())) self.redraw_timer = mp.add_timeout(d, function() self:redraw(state) end) |
