1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 10:02:17 +00:00

osc: add toggle for forced-only subs

This commit is contained in:
rcombs 2021-06-25 02:36:31 -05:00 committed by sfan5
parent d8bd1c35ef
commit 945d7c1eda

View File

@ -1314,6 +1314,11 @@ layouts["box"] = function ()
{x = posX - pos_offsetX, y = bigbtnrowY, an = 7, w = 70, h = 18}
lo.style = osc_styles.smallButtonsL
lo = add_layout("tog_forced_only")
lo.geometry =
{x = posX - pos_offsetX + 70, y = bigbtnrowY - 1, an = 7, w = 25, h = 18}
lo.style = osc_styles.smallButtonsL
lo = add_layout("tog_fs")
lo.geometry =
{x = posX+pos_offsetX - 25, y = bigbtnrowY, an = 4, w = 25, h = 25}
@ -1622,6 +1627,12 @@ function bar_layout(direction)
lo.geometry = geo
lo.style = osc_styles.smallButtonsBar
-- Forced-subs-only button
geo = { x = geo.x - geo.w - padX, y = geo.y, an = geo.an, w = geo.w, h = geo.h }
lo = add_layout("tog_forced_only")
lo.geometry = geo
lo.style = osc_styles.smallButtonsBar
-- Track selection buttons
geo = { x = geo.x - tsW - padX, y = geo.y, an = geo.an, w = tsW, h = geo.h }
lo = add_layout("cy_sub")
@ -1959,6 +1970,32 @@ function osc_init()
ne.eventresponder["shift+mbtn_left_down"] =
function () show_message(get_tracklist("sub"), 2) end
-- tog_forced_only
local tog_forced_only = new_element("tog_forced_only", "button")
ne = tog_forced_only
ne.content = function ()
sub_codec = mp.get_property("current-tracks/sub/codec")
if (sub_codec ~= "dvd_subtitle" and sub_codec ~= "hdmv_pgs_subtitle") then
return ""
end
local base_a = tog_forced_only.layout.alpha
local alpha = base_a[1]
if not mp.get_property_bool("sub-forced-only-cur") then
alpha = 255
end
local ret = assdraw.ass_new()
ret:append("[")
ass_append_alpha(ret, {[1] = alpha, [2] = 1, [3] = base_a[3], [4] = base_a[4]}, 0)
ret:append("F")
ass_append_alpha(ret, base_a, 0)
ret:append("]")
return ret.text
end
ne.eventresponder["mbtn_left_up"] = function ()
mp.set_property_bool("sub-forced-only", (not mp.get_property_bool("sub-forced-only-cur")))
end
--tog_fs
ne = new_element("tog_fs", "button")
ne.content = function ()