summaryrefslogtreecommitdiffstats
path: root/player/lua
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-22 12:38:41 +0100
committerwm4 <wm4@nowhere>2019-12-22 12:44:26 +0100
commit6bf1a830574e84012c44920584fd72f7ad9a55af (patch)
treea85e728ed493647be84799af7aa39100d96f588d /player/lua
parent12843dcea10f2b474aa7ffdee007999caad77762 (diff)
downloadmpv-6bf1a830574e84012c44920584fd72f7ad9a55af.tar.bz2
mpv-6bf1a830574e84012c44920584fd72f7ad9a55af.tar.xz
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.
Diffstat (limited to 'player/lua')
-rw-r--r--player/lua/osc.lua43
1 files changed, 23 insertions, 20 deletions
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 8c2d93b635..8196574372 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -1677,6 +1677,8 @@ function osc_init()
-- stop seeking with the slider to prevent skipping files
state.active_element = nil
+ osc_param.video_margins = {l = 0, r = 0, t = 0, b = 0}
+
elements = {}
-- some often needed stuff
@@ -2034,21 +2036,37 @@ function osc_init()
--do something with the elements
prepare_elements()
+ update_margins()
+end
+
+function reset_margins()
+ if state.using_video_margins then
+ for _, opt in ipairs(margins_opts) do
+ mp.set_property_number(opt[2], 0.0)
+ end
+ state.using_video_margins = false
+ end
+end
+
+function update_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
- for _, opt in ipairs(margins_opts) do
- if mp.get_property_number(opt[2], 0.0) ~= 0.0 then
- margins_used = true
+ 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
- local margins = osc_param.video_margins
for _, opt in ipairs(margins_opts) do
local v = margins[opt[1]]
- if v ~= 0 then
+ if (v ~= 0) or state.using_video_margins then
mp.set_property_number(opt[2], v)
state.using_video_margins = true
end
@@ -2058,21 +2076,6 @@ function osc_init()
reset_margins()
end
- update_margins()
-end
-
-function reset_margins()
- if state.using_video_margins then
- for _, opt in ipairs(margins_opts) do
- mp.set_property_number(opt[2], 0.0)
- end
- state.using_video_margins = false
- end
-end
-
-function update_margins()
- local margins = osc_param.video_margins
-
-- Don't report margins if it's visible only temporarily. At least for
-- console.lua this makes no sense.
if (not state.osc_visible) or (get_hidetimeout() >= 0) then