summaryrefslogtreecommitdiff
path: root/osd.lua
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-12 23:34:53 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-12 23:34:53 -0800
commit3c84dd08f36c8368ea7371c1d3f152f1dda6cb71 (patch)
treea6129ca7395f4c6f18f0a64da1f7d7b1fbf60ddc /osd.lua
parent206f73ed62003dba5041348f17433b1b3fe70174 (diff)
downloadmpv-iptv-menu-3c84dd08f36c8368ea7371c1d3f152f1dda6cb71.tar.gz
mpv-iptv-menu-3c84dd08f36c8368ea7371c1d3f152f1dda6cb71.tar.xz
add mouse support
Diffstat (limited to 'osd.lua')
-rw-r--r--osd.lua27
1 files changed, 15 insertions, 12 deletions
diff --git a/osd.lua b/osd.lua
index 72d56cb..d54362c 100644
--- a/osd.lua
+++ b/osd.lua
@@ -61,12 +61,8 @@ function mt:resize(w, h)
end
function mt:menu_lines(state)
- if state.depth > 1 then
- -- leaves an extra line for padding between titles and options
- return self.lines - state.depth
- else
- return self.lines
- end
+ -- leaves an extra line for padding between titles and options
+ return self.lines - state.depth - 1
end
function mt:menu_title(menu)
@@ -94,7 +90,7 @@ function mt:menu_title(menu)
str = colours.icon_sorted .. '⇅ ' .. col .. str
end
- return col .. ' » ' .. str
+ return col .. '» ' .. str
end
function mt:option_icons(opt, info)
@@ -364,12 +360,10 @@ function mt:redraw(state)
-- navigation which moves the viewport.
local out_max = {}
- if state.depth > 1 then
- for i = 2, state.depth do
- out[#out+1] = self:menu_title(state.menus[i])
- end
- out[#out+1] = ' ' -- space character for correct line height
+ for i = 1, state.depth do
+ out[#out+1] = self:menu_title(state.menus[i])
end
+ out[#out+1] = ' ' -- space character for correct line height
local menu = state:menu()
@@ -469,4 +463,13 @@ function mt:is_hidden()
return self.fg.hidden
end
+function mt:get_mouse_line(mpos)
+ local y = mpos.y / self.scale
+ local line = math.floor((y - self.padding) / config.font_size) + 1
+ if line < 1 or line > self.lines then
+ return
+ end
+ return line
+end
+
return osd