diff options
author | llyyr <llyyr.public@gmail.com> | 2023-08-27 20:52:41 +0530 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-08-27 16:28:24 +0000 |
commit | d0bc90780631f5dceec98da49c30a324cddf64df (patch) | |
tree | a65e0f03f6a7c8128fa0df7b10309ce6ea37c804 /player/lua/osc.lua | |
parent | 83019062183547a39f4061066187a6e66fe8866b (diff) | |
download | mpv-d0bc90780631f5dceec98da49c30a324cddf64df.tar.bz2 mpv-d0bc90780631f5dceec98da49c30a324cddf64df.tar.xz |
osc: only add sub forced-only toggle to layout for DVD/PGS subs
Fixes: 945d7c1eda47c97c4bfba884fb21f398a64b2289
Previously, we would have a button with empty string added to the layout
for non DVD/PGS subtitles. This would cause there to be an invisible
button present that would take up space and could still be clicked
despite being invisible when the current subtitle track was not DVD/PGS.
The idea was that the button would be invisible for regular subtitle
tracks, and be visible as "[ ]"/"[F]" for DVD/PGS subtitle tracks.
This commit modifies the bar and box layouts to only add this button if
the current subtitle track is DVD/PGS. This results in there no longer
being an invisible button, and also prevents it from taking up space.
The button is added to layout as before when the current subtitle track
is DVD/PGS, matching the same logic as before.
Diffstat (limited to 'player/lua/osc.lua')
-rw-r--r-- | player/lua/osc.lua | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 875ad2cc3e..be0b8783ae 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -1315,10 +1315,13 @@ 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 = + sub_codec = mp.get_property("current-tracks/sub/codec") + if (sub_codec == "dvd_subtitle" or sub_codec == "hdmv_pgs_subtitle") then + 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.style = osc_styles.smallButtonsL + end lo = add_layout("tog_fs") lo.geometry = @@ -1627,10 +1630,13 @@ function bar_layout(direction) 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 + sub_codec = mp.get_property("current-tracks/sub/codec") + if (sub_codec == "dvd_subtitle" or sub_codec == "hdmv_pgs_subtitle") then + 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 + end -- Track selection buttons geo = { x = geo.x - tsW - padX, y = geo.y, an = geo.an, w = tsW, h = geo.h } @@ -1971,13 +1977,8 @@ function osc_init() -- 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 |