1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-09 08:27:18 +00:00

osc: don't hide playlist buttons, just disable

Having empty space before the title in layout=*bar looks worse
than the floating buttons in layout=box.

Also disable both playlist buttons selectively according to the
current position.
This commit is contained in:
Ricardo Constantino 2016-12-01 21:59:27 +00:00
parent a7a919f93f
commit 796b48b2a3
No known key found for this signature in database
GPG Key ID: EFD16019AE4FF531

View File

@ -1502,8 +1502,9 @@ function osc_init()
elements = {}
-- some often needed stuff
local pl_count = mp.get_property_number("playlist-count")
local pl_count = mp.get_property_number("playlist-count", 0)
local have_pl = (pl_count > 1)
local pl_pos = mp.get_property_number("playlist-pos", 0) + 1
local have_ch = (mp.get_property_number("chapters", 0) > 0)
local ne
@ -1523,8 +1524,8 @@ function osc_init()
ne.eventresponder["mouse_btn0_up"] = function ()
local title = mp.get_property_osd("media-title")
if (have_pl) then
local pl_pos = countone(mp.get_property_number("playlist-pos"))
title = "[" .. pl_pos .. "/" .. pl_count .. "] " .. title
title = string.format("[%d/%d] %s", countone(pl_pos - 1),
pl_count, title)
end
show_message(title)
end
@ -1538,7 +1539,7 @@ function osc_init()
ne = new_element("pl_prev", "button")
ne.content = "\238\132\144"
ne.visible = have_pl
ne.enabled = (pl_pos > 1)
ne.eventresponder["mouse_btn0_up"] =
function ()
mp.commandv("playlist-prev", "weak")
@ -1553,7 +1554,7 @@ function osc_init()
ne = new_element("pl_next", "button")
ne.content = "\238\132\129"
ne.visible = have_pl
ne.enabled = (have_pl) and (pl_pos < pl_count)
ne.eventresponder["mouse_btn0_up"] =
function ()
mp.commandv("playlist-next", "weak")