osc.lua: use dedicated options to control SUB/OSD offset
There is concern that with certain user options or script the value of
`{sub,osd}-margin-y` value may be persisted or overwrite user option
when it's changed while OSD is visible and offset is applied.
Fix this by using dedicated option.
This commit is contained in:
1 parent
3a09e793b9
commit
0f37c2abef
6 files changed
+33
-26
No files matched your search
@@ -3134,6 +3134,16 @@ Subtitles
|
||||
|
||||
Default: 34
|
||||
|
||||
``--sub-margin-y-offset=<size>``
|
||||
Additional vertical offset added to the subtitle margin, in scaled pixels.
|
||||
This is added on top of ``--sub-margin-y``.
|
||||
|
||||
This is intended for dynamic margin adjustments at runtime (e.g. by
|
||||
scripts like the OSC to avoid subtitle/UI overlap). For persistent
|
||||
settings, use ``--sub-margin-y`` instead.
|
||||
|
||||
Default: 0
|
||||
|
||||
``--sub-align-x=<left|center|right>``
|
||||
Control to which corner of the screen text subtitles should be
|
||||
aligned to (default: ``center``).
|
||||
@@ -4816,6 +4826,16 @@ OSD
|
||||
|
||||
Default: 16
|
||||
|
||||
``--osd-margin-y-offset=<size>``
|
||||
Additional vertical offset added to the OSD margin, in scaled pixels.
|
||||
This is added on top of ``--osd-margin-y``.
|
||||
|
||||
This is intended for dynamic margin adjustments at runtime (e.g. by
|
||||
scripts like the OSC to avoid OSD/UI overlap). For persistent settings,
|
||||
use ``--osd-margin-y`` instead.
|
||||
|
||||
Default: 0
|
||||
|
||||
``--osd-align-x=<left|center|right>``
|
||||
Control to which corner of the screen OSD should be
|
||||
aligned to (default: ``left``).
|
||||
|
||||
+6
-9
@@ -412,10 +412,9 @@ Configurable Options
|
||||
``sub_margins``
|
||||
Default: yes
|
||||
|
||||
Whether to adjust ``--sub-margin-y`` so that subtitles do not overlap
|
||||
with the OSC. The offset is derived from the bottom OSC margin and added
|
||||
on top of the current ``--sub-margin-y`` value. Requires
|
||||
``dynamic_margins`` or ``visibility=always`` to take effect.
|
||||
Whether to adjust the subtitle margin so that subtitles do not overlap
|
||||
with the OSC. Requires ``dynamic_margins`` or ``visibility=always`` to
|
||||
take effect. Uses ``--sub-margin-y-offset`` to apply the adjustment.
|
||||
|
||||
With ``boxvideo`` enabled and ``--sub-use-margins=no``, subtitles are
|
||||
already confined to the video area and this option has no additional
|
||||
@@ -424,11 +423,9 @@ Configurable Options
|
||||
``osd_margins``
|
||||
Default: yes
|
||||
|
||||
Whether to adjust ``--osd-margin-y`` so that OSD text does not overlap
|
||||
with the OSC. The offset is derived from the top OSC margin (including
|
||||
window controls when present) and added on top of the current
|
||||
``--osd-margin-y`` value. Requires ``dynamic_margins`` or
|
||||
``visibility=always`` to take effect.
|
||||
Whether to adjust the OSD margin so that OSD text does not overlap
|
||||
with the OSC. Requires ``dynamic_margins`` or ``visibility=always`` to
|
||||
take effect. Uses ``--osd-margin-y-offset`` to apply the adjustment.
|
||||
|
||||
``windowcontrols``
|
||||
Default: auto (Show window controls if there is no window border/title-bar)
|
||||
|
||||
+4
-16
@@ -544,18 +544,6 @@ local function cache_enabled()
|
||||
return state.cache_state and #state.cache_state["seekable-ranges"] > 0
|
||||
end
|
||||
|
||||
local function set_margin_offset(prop, offset)
|
||||
if offset > 0 then
|
||||
if not state[prop] then
|
||||
state[prop] = mp.get_property_number(prop)
|
||||
end
|
||||
mp.set_property_number(prop, state[prop] + offset)
|
||||
elseif state[prop] then
|
||||
mp.set_property_number(prop, state[prop])
|
||||
state[prop] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function reset_margins()
|
||||
if state.using_video_margins then
|
||||
for _, mopt in ipairs(margins_opts) do
|
||||
@@ -563,8 +551,8 @@ local function reset_margins()
|
||||
end
|
||||
state.using_video_margins = false
|
||||
end
|
||||
set_margin_offset("sub-margin-y", 0)
|
||||
set_margin_offset("osd-margin-y", 0)
|
||||
mp.set_property_number("sub-margin-y-offset", 0)
|
||||
mp.set_property_number("osd-margin-y-offset", 0)
|
||||
end
|
||||
|
||||
local function update_margins()
|
||||
@@ -618,8 +606,8 @@ local function update_margins()
|
||||
end
|
||||
return margin * osc_param.playresy
|
||||
end
|
||||
set_margin_offset("sub-margin-y", get_margin("sub"))
|
||||
set_margin_offset("osd-margin-y", get_margin("osd"))
|
||||
mp.set_property_number("sub-margin-y-offset", get_margin("sub"))
|
||||
mp.set_property_number("osd-margin-y-offset", get_margin("osd"))
|
||||
|
||||
mp.set_property_native("user-data/osc/margins", margins)
|
||||
end
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ void mp_ass_set_style(ASS_Style *style, double res_y,
|
||||
style->Spacing = opts->spacing * scale;
|
||||
style->MarginL = opts->margin_x * scale;
|
||||
style->MarginR = style->MarginL;
|
||||
style->MarginV = opts->margin_y * scale;
|
||||
style->MarginV = (opts->margin_y + opts->margin_y_offset) * scale;
|
||||
style->ScaleX = 1.;
|
||||
style->ScaleY = 1.;
|
||||
style->Alignment = 1 + (opts->align_x + 1) + (opts->align_y + 2) % 3 * 4;
|
||||
|
||||
@@ -60,6 +60,7 @@ static const m_option_t style_opts[] = {
|
||||
{"spacing", OPT_FLOAT(spacing), M_RANGE(-10, 10)},
|
||||
{"margin-x", OPT_INT(margin_x), M_RANGE(0, INT_MAX)},
|
||||
{"margin-y", OPT_INT(margin_y), M_RANGE(0, INT_MAX)},
|
||||
{"margin-y-offset", OPT_INT(margin_y_offset)},
|
||||
{"align-x", OPT_CHOICE(align_x,
|
||||
{"left", -1}, {"center", 0}, {"right", +1})},
|
||||
{"align-y", OPT_CHOICE(align_y,
|
||||
|
||||
Reference in new issue
Block a user