diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-11 16:37:33 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-05-11 16:42:08 -0700 |
commit | a1925e39f9276270590f7a716ba34f1fe9ed65e4 (patch) | |
tree | dac5a6bcbbee8ab5d66e481fa4e104021d4a846c | |
parent | 206d79891e6895205ccdce626c9681a4a68d89e3 (diff) | |
download | mpv-iptv-menu-a1925e39f9276270590f7a716ba34f1fe9ed65e4.tar.gz mpv-iptv-menu-a1925e39f9276270590f7a716ba34f1fe9ed65e4.tar.xz |
dim empty groups
-rw-r--r-- | main.lua | 37 |
1 files changed, 30 insertions, 7 deletions
@@ -5,15 +5,19 @@ local utils = require('mp.utils') -- font size is in units of osd height, which is scaled to 720 local font_size = 20 local colours = { - default='{\\c}', + bg='{\\alpha&H44&\\c&H&}', + title='{\\c&999999&}', + option='{\\c}', group='{\\c&H99DDFF&}', + group_empty='{\\c&H446677&}', selected='{\\c&HFF00&}', - title='{\\c&999999&}', + selected_empty='{\\c&H337733&}', search_hl='{\\c&FFDD&}', + search_hl_empty='{\\c&8877&}', search_path='{\\c&666666&}', + search_path_empty='{\\c&444444&}', icon_playing='{\\c&HFF6633&}', icon_favourite='{\\c&HFF00FF&}', - bg='{\\alpha&H44&\\c&H&}', } local script_dir = mp.get_script_directory() @@ -108,6 +112,7 @@ local function load_section(section, name) v.type = 'group' v.group_type = 'series' v.id = section .. ':series:' .. v.series_id + v.lazy = true else v.type = 'stream' v.id = section .. ':stream:' .. v.stream_id @@ -127,6 +132,7 @@ local function load_data() id='favourites', parent_id='root', name='Favourites', + lazy=true, }) load_section('live', 'Live TV') @@ -169,12 +175,21 @@ local function update_osd() menu.view_top + osd_menu_lines() - 1, #menu.options) do local opt = menu.options[i] local str = opt.name - local col = colours.default + local col = colours.option local icons = '' + local is_empty = opt.type == 'group' and not opt.lazy and + #opt.children == 0 + if i == menu.cursor and not menu.search_active then col = colours.selected icons = col .. '› ' .. icons + + if is_empty then + col = colours.selected_empty + end + elseif is_empty then + col = colours.group_empty elseif opt.type == 'group' then col = colours.group end @@ -182,10 +197,15 @@ local function update_osd() if opt.matches then local buf = '' local n = 0 + local hl_col = colours.search_hl + if is_empty then + hl_col = colours.search_hl_empty + end + for _, match in ipairs(opt.matches) do buf = buf .. col .. str:sub(n + 1, match.start - 1) .. - colours.search_hl .. + hl_col .. str:sub(match.start, match.stop) n = match.stop end @@ -206,6 +226,9 @@ local function update_osd() if opt.path and #opt.path > 0 then local path = colours.search_path + if is_empty then + path = colours.search_path_empty + end for i = #opt.path, 1, -1 do local node = opt.path[i] path = path .. ' « [' .. node.name .. ']' @@ -444,8 +467,8 @@ local function search_menu_options_build(options, t, path) v.path = path t[v.type][#t[v.type]+1] = v - if v.type == 'group' and v.id ~= 'favourites' - and v.group_type ~= 'series' then + -- contents of lazy-loaded groups should not be searchable + if v.type == 'group' and not v.lazy then local path = copy_table(path) path[#path+1] = v search_menu_options_build( |