diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-27 01:12:16 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-27 01:16:58 -0800 |
| commit | 82526665364389d92e0f2c33eba04678275863bb (patch) | |
| tree | 547f3a797b861e85c79bde7baf87fe5145c0396d /osd.lua | |
| parent | 1d2c82bfb4dcfd71045f2948bb320a94013971a5 (diff) | |
| download | mpv-iptv-menu-82526665364389d92e0f2c33eba04678275863bb.tar.gz mpv-iptv-menu-82526665364389d92e0f2c33eba04678275863bb.tar.xz | |
on-demand calculation and update of option info
Using metatables to calculate info strings on render, we can avoid
precomputing it for all options when generating the menu, making certain
menus open much faster. This also allows us to update dynamic info, e.g.
the currently programme, while the menu is open.
Diffstat (limited to 'osd.lua')
| -rw-r--r-- | osd.lua | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -235,8 +235,9 @@ function mt:option_text(opt, info) str = col .. '[' .. str .. ']' end - if opt.info and #opt.info > 0 then - str = str .. colour.info .. ' (' .. asscape(opt.info) .. ')' + local opt_info = opt.info + if opt_info and #opt_info > 0 then + str = str .. colour.info .. ' (' .. asscape(opt_info) .. ')' end return str @@ -542,6 +543,8 @@ function mt:render() end function mt:redraw(state) + self.redraw_time = os.time() + local out_titles = {} local out_options = {} @@ -574,15 +577,10 @@ function mt:redraw(state) #menu.options) do local opt = menu.options[i] - -- use real-time count for favourites - if opt.id == 'favourites' then - opt.info = tostring(#state.favourites) - end - local selected = i == menu.cursor and not menu.search_active local info = { selected = selected, - empty = (opt.type == 'group' and not opt.lazy and + empty = (opt.type == 'group' and opt.children and #opt.children == 0), playing = not not ( opt.id and opt.id == state.playing_id), |
