mirror of https://github.com/mpv-player/mpv
osc: cleanup boxvideo margin handling
Make sure it gets properly reinitialized when needed. This is especially useful now that the OSC reacts to runtime option changes, which can change the layout too. This may call set_property_number() on the margin properties more often now, but since redundant option changes are ignored now, this shouldn't have any too bad effects.
This commit is contained in:
parent
12843dcea1
commit
6bf1a83057
|
@ -1677,6 +1677,8 @@ function osc_init()
|
||||||
-- stop seeking with the slider to prevent skipping files
|
-- stop seeking with the slider to prevent skipping files
|
||||||
state.active_element = nil
|
state.active_element = nil
|
||||||
|
|
||||||
|
osc_param.video_margins = {l = 0, r = 0, t = 0, b = 0}
|
||||||
|
|
||||||
elements = {}
|
elements = {}
|
||||||
|
|
||||||
-- some often needed stuff
|
-- some often needed stuff
|
||||||
|
@ -2034,30 +2036,6 @@ function osc_init()
|
||||||
--do something with the elements
|
--do something with the elements
|
||||||
prepare_elements()
|
prepare_elements()
|
||||||
|
|
||||||
if user_opts.boxvideo then
|
|
||||||
-- check whether any margin option has a non-default value
|
|
||||||
local margins_used = false
|
|
||||||
|
|
||||||
for _, opt in ipairs(margins_opts) do
|
|
||||||
if mp.get_property_number(opt[2], 0.0) ~= 0.0 then
|
|
||||||
margins_used = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if not margins_used then
|
|
||||||
local margins = osc_param.video_margins
|
|
||||||
for _, opt in ipairs(margins_opts) do
|
|
||||||
local v = margins[opt[1]]
|
|
||||||
if v ~= 0 then
|
|
||||||
mp.set_property_number(opt[2], v)
|
|
||||||
state.using_video_margins = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
reset_margins()
|
|
||||||
end
|
|
||||||
|
|
||||||
update_margins()
|
update_margins()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2073,6 +2051,31 @@ end
|
||||||
function update_margins()
|
function update_margins()
|
||||||
local margins = osc_param.video_margins
|
local margins = osc_param.video_margins
|
||||||
|
|
||||||
|
if user_opts.boxvideo then
|
||||||
|
-- check whether any margin option has a non-default value
|
||||||
|
local margins_used = false
|
||||||
|
|
||||||
|
if not state.using_video_margins then
|
||||||
|
for _, opt in ipairs(margins_opts) do
|
||||||
|
if mp.get_property_number(opt[2], 0.0) ~= 0.0 then
|
||||||
|
margins_used = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not margins_used then
|
||||||
|
for _, opt in ipairs(margins_opts) do
|
||||||
|
local v = margins[opt[1]]
|
||||||
|
if (v ~= 0) or state.using_video_margins then
|
||||||
|
mp.set_property_number(opt[2], v)
|
||||||
|
state.using_video_margins = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
reset_margins()
|
||||||
|
end
|
||||||
|
|
||||||
-- Don't report margins if it's visible only temporarily. At least for
|
-- Don't report margins if it's visible only temporarily. At least for
|
||||||
-- console.lua this makes no sense.
|
-- console.lua this makes no sense.
|
||||||
if (not state.osc_visible) or (get_hidetimeout() >= 0) then
|
if (not state.osc_visible) or (get_hidetimeout() >= 0) then
|
||||||
|
|
Loading…
Reference in New Issue