summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-19 00:44:14 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2026-01-19 00:44:14 -0800
commit3ad105d4d8b63fe34f8a1bd8d2d6b64924df831f (patch)
treee73db1d1ab4a62bdb62cc148cd392216359596c3
parentc244b3cd08a48a28d5a31ba5ddf86ee1669bd996 (diff)
downloadmpv-iptv-menu-3ad105d4d8b63fe34f8a1bd8d2d6b64924df831f.tar.gz
mpv-iptv-menu-3ad105d4d8b63fe34f8a1bd8d2d6b64924df831f.tar.xz
rename menu button
-rw-r--r--config.lua6
-rw-r--r--main.lua34
-rw-r--r--osd.lua30
3 files changed, 35 insertions, 35 deletions
diff --git a/config.lua b/config.lua
index 5ea72e6..d42e3b0 100644
--- a/config.lua
+++ b/config.lua
@@ -12,7 +12,7 @@ config.scroll_margin = 4
config.click_timeout = 0.5
config.click_dbl_time = 0.3
config.click_max_drift = 2
-config.toggle_button_timeout = 0.5
+config.menu_button_timeout = 1
config.bg_alpha = '44'
config.colours = {
@@ -36,8 +36,8 @@ config.colours = {
scrollbar_bg = '333333',
status_info = '55bbdd',
status_error = 'ff3333',
- toggle_button_fg = '000000',
- toggle_button_bg = '00cc00',
+ menu_button_fg = '000000',
+ menu_button_bg = '00cc00',
}
local script_dir = mp.get_script_directory()
diff --git a/main.lua b/main.lua
index 19a40f3..f36e50a 100644
--- a/main.lua
+++ b/main.lua
@@ -1280,15 +1280,15 @@ end
mp.set_key_bindings({
{'MBTN_LEFT', toggle_menu},
{'MBTN_LEFT_DBL'},
-}, 'toggle_button', 'force')
+}, 'menu_button', 'force')
local mouse_pos_time
local mouse_over_button_area = false
-local mouse_over_toggle_button = false
+local mouse_over_menu_button = false
local mouse_timer; mouse_timer = mp.add_periodic_timer(0.1, function()
if mouse_pos_time and
mp.get_time() - mouse_pos_time >
- config.toggle_button_timeout then
- osd:show_toggle_button(false)
+ config.menu_button_timeout then
+ osd:show_menu_button(false)
mouse_timer:kill()
end
end, true) -- disabled
@@ -1308,22 +1308,22 @@ mp.observe_property('mouse-pos', 'native', function(_, mpos)
local is_over = osd:mouse_over_button_area(mpos)
if is_over ~= mouse_over_button_area then
mouse_over_button_area = is_over
- osd:show_toggle_button(mouse_over_button_area)
- elseif mouse_over_button_area and osd.toggle_button.hidden then
- osd:show_toggle_button(true)
+ osd:show_menu_button(mouse_over_button_area)
+ elseif mouse_over_button_area and osd.menu_button.hidden then
+ osd:show_menu_button(true)
end
- local is_over = osd:mouse_over_toggle_button(mpos)
- if is_over ~= mouse_over_toggle_button then
- mouse_over_toggle_button = is_over
- if mouse_over_toggle_button then
- mp.enable_key_bindings('toggle_button')
+ local is_over = osd:mouse_over_menu_button(mpos)
+ if is_over ~= mouse_over_menu_button then
+ mouse_over_menu_button = is_over
+ if mouse_over_menu_button then
+ mp.enable_key_bindings('menu_button')
else
- mp.disable_key_bindings('toggle_button')
+ mp.disable_key_bindings('menu_button')
end
end
- if mouse_over_button_area and not mouse_over_toggle_button then
+ if mouse_over_button_area and not mouse_over_menu_button then
mouse_timer:resume()
else
mouse_timer:kill()
@@ -1345,10 +1345,10 @@ mp.observe_property('osd-dimensions', 'native', function(_, val)
-- do nothing, a click would trigger the button regardless of mouse
-- position. since we cannot get the new mouse position, we instead
-- treat all resizes as moving the mouse off the button.
- osd:show_toggle_button(false)
+ osd:show_menu_button(false)
mouse_over_button_area = false
- mouse_over_toggle_button = false
- mp.disable_key_bindings('toggle_button')
+ mouse_over_menu_button = false
+ mp.disable_key_bindings('menu_button')
mouse_timer:kill()
end)
diff --git a/osd.lua b/osd.lua
index 796c3b3..2cd1be2 100644
--- a/osd.lua
+++ b/osd.lua
@@ -39,7 +39,7 @@ function osd.new(init)
local t = setmetatable({
fg = mp.create_osd_overlay('ass-events'),
bg = mp.create_osd_overlay('ass-events'),
- toggle_button = mp.create_osd_overlay('ass-events'),
+ menu_button = mp.create_osd_overlay('ass-events'),
width = 0,
height = 0,
scale = 1,
@@ -47,8 +47,8 @@ function osd.new(init)
padding = math.floor((720 - (lines * config.font_size)) / 2),
}, mt)
t.bg.z = -1
- t.toggle_button.z = 1
- t.toggle_button.hidden = true
+ t.menu_button.z = 1
+ t.menu_button.hidden = true
for k, v in pairs(init or {}) do
t[k] = v
@@ -79,15 +79,15 @@ function mt:resize(w, h)
}
coords.x2 = coords.x1 + sz
coords.y2 = coords.y1 + sz
- self.toggle_button_coords = coords
+ self.menu_button_coords = coords
- self.toggle_button.data =
+ self.menu_button.data =
'{\\pos(' .. coords.x1 .. ',' .. coords.y1 .. ')}' ..
- colours.toggle_button_bg .. draw_rect(0, 0, sz, sz) .. '\n' ..
+ colours.menu_button_bg .. draw_rect(0, 0, sz, sz) .. '\n' ..
'{\\q2\\fs' .. sz .. '\\bord0\\an5\\pos(' ..
coords.x1 + sz/2 .. ',' .. coords.y1 + sz/2 ..')}' ..
- colours.toggle_button_fg .. '≡'
- self.toggle_button:update()
+ colours.menu_button_fg .. '≡'
+ self.menu_button:update()
end
function mt:set_status(msg, level, no_dirty)
@@ -613,30 +613,30 @@ function mt:mouse_over_button_area(mpos)
return y < self.padding + (2 * config.font_size)
end
-function mt:mouse_over_toggle_button(mpos)
+function mt:mouse_over_menu_button(mpos)
if not mpos.hover then
return false
end
local x = mpos.x / self.scale
local y = mpos.y / self.scale
- local coords = self.toggle_button_coords
+ local coords = self.menu_button_coords
return coords and
x > coords.x1 and x < coords.x2 and
y > coords.y1 and y < coords.y2
end
-function mt:show_toggle_button(bool)
- if self.toggle_button.hidden ~= bool then
+function mt:show_menu_button(bool)
+ if self.menu_button.hidden ~= bool then
return
end
- self.toggle_button.hidden = not bool
- self.toggle_button:update()
+ self.menu_button.hidden = not bool
+ self.menu_button:update()
end
function mt:measure_width(str)
- local e = self.toggle_button
+ local e = self.menu_button
local data = e.data
local hidden = e.hidden
e.hidden = true