summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/osc.rst20
-rw-r--r--player/lua/osc.lua48
2 files changed, 67 insertions, 1 deletions
diff --git a/DOCS/man/osc.rst b/DOCS/man/osc.rst
index 5ff77409dd..d8a82a0ee7 100644
--- a/DOCS/man/osc.rst
+++ b/DOCS/man/osc.rst
@@ -321,6 +321,26 @@ Configurable Options
default is conservative to allow wide fonts to be used without overflow.
However, with many common fonts a bigger number can be used. YMMV.
+``boxvideo``
+ Default: no
+
+ Whether to overlay the osc over the video (``no``), or to box the video
+ within the areas not covered by the osc (``yes``). If this option is set,
+ the osc may overwrite the ``--video-margin-ratio-*`` options, even if the
+ user has set them. (It will not overwrite them if all of them are set to
+ default values.)
+
+ Currently, this is supported for the ``bottombar`` layout only. The other
+ layouts do not change if this option is set.
+
+ The border is static and appears even if the OSC is configured to appear
+ only on mouse interaction. If the OSC is invisible, the border is simply
+ filled with the background color (black by default).
+
+ This currently still makes the OSC overlap with subtitles (if the
+ ``--sub-use-margins`` option is set to ``yes``, the default). This may be
+ fixed later.
+
Script Commands
~~~~~~~~~~~~~~~
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 2be2169040..ac0d619e1c 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -44,6 +44,7 @@ local user_opts = {
timems = false, -- display timecodes with milliseconds?
visibility = "auto", -- only used at init to set visibility_mode(...)
boxmaxchars = 80, -- title crop threshold for box layout
+ boxvideo = false, -- apply osc_param.video_margins to video
}
-- read_options may modify hidetimeout, so save the original default value in
@@ -62,6 +63,9 @@ local osc_param = { -- calculated by osc_init()
display_aspect = 1,
unscaled_y = 0,
areas = {},
+ video_margins = {
+ l = 0, r = 0, t = 0, b = 0, -- left/right/top/bottom
+ },
}
local osc_styles = {
@@ -108,6 +112,7 @@ local state = {
input_enabled = true,
showhide_enabled = false,
dmx_cache = 0,
+ using_video_margins = false,
}
@@ -117,6 +122,13 @@ local state = {
-- Helperfunctions
--
+local margins_opts = {
+ {"l", "video-margin-ratio-left"},
+ {"r", "video-margin-ratio-right"},
+ {"t", "video-margin-ratio-top"},
+ {"b", "video-margin-ratio-bottom"},
+}
+
-- scale factor for translating between real and virtual ASS coordinates
function get_virt_scale_factor()
local w, h = mp.get_osd_size()
@@ -1408,6 +1420,8 @@ layouts["bottombar"] = function()
lo.slider.tooltip_an = 5
lo.slider.stype = user_opts["seekbarstyle"]
lo.slider.rtype = user_opts["seekrangestyle"]
+
+ osc_param.video_margins.b = osc_geo.h / osc_param.playresy
end
layouts["topbar"] = function()
@@ -1998,9 +2012,40 @@ function osc_init()
--do something with the elements
prepare_elements()
-end
+ 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
+
+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
--
-- Other important stuff
@@ -2386,6 +2431,7 @@ end
validate_user_opts()
+mp.register_event("shutdown", reset_margins)
mp.register_event("start-file", request_init)
mp.register_event("tracks-changed", request_init)
mp.observe_property("playlist", nil, request_init)