Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,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.

With ``boxvideo`` enabled and ``--sub-use-margins=no``, subtitles are
already confined to the video area and this option has no additional
Expand All @@ -423,11 +422,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.

``windowcontrols``
Default: auto (Show window controls if there is no window border)
Expand Down
6 changes: 5 additions & 1 deletion options/m_config_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ static int handle_set_opt_flags(struct m_config *config,
return M_OPT_INVALID;

// Check if this option isn't forbidden in the current mode
if ((flags & M_SETOPT_FROM_CONFIG_FILE) && (optflags & M_OPT_NOCFG)) {
if ((flags & M_SETOPT_FROM_CONFIG_FILE) &&
(optflags & (M_OPT_NOCFG | M_OPT_PRIVATE)))
{
MP_ERR(config, "The %s option can't be used in a config file.\n",
co->name);
return M_OPT_INVALID;
Expand Down Expand Up @@ -841,6 +843,8 @@ void m_config_print_option_list(const struct m_config *config, const char *name)
for (int i = 0; i < config->num_opts; i++) {
struct m_config_option *co = &sorted[i];
const struct m_option *opt = co->opt;
if (opt->flags & M_OPT_PRIVATE)
continue;
if (strcmp(name, "*") != 0 && !strstr(co->name, name))
continue;
MP_INFO(config, " %s%-30s", prefix, co->name);
Expand Down
6 changes: 5 additions & 1 deletion options/m_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,11 @@ char *format_file_size(int64_t size);
// Like M_OPT_TYPE_OPTIONAL_PARAM.
#define M_OPT_OPTIONAL_PARAM (UINT64_C(1) << 54)

static_assert(!(UPDATE_OPTS_MASK & M_OPT_OPTIONAL_PARAM), "");
// Option is private: forbidden in config files and hidden from --help listing.
// Can still be used as a property by builtin scripts.
#define M_OPT_PRIVATE (UINT64_C(1) << 53)

static_assert(!(UPDATE_OPTS_MASK & M_OPT_PRIVATE), "");

// These flags are used to describe special parser capabilities or behavior.

Expand Down
20 changes: 4 additions & 16 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -543,27 +543,15 @@ 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
mp.set_property_number(mopt[2], 0.0)
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()
Expand Down Expand Up @@ -617,8 +605,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
Expand Down
2 changes: 1 addition & 1 deletion sub/ass_mp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions sub/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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), .flags = M_OPT_PRIVATE},
{"align-x", OPT_CHOICE(align_x,
{"left", -1}, {"center", 0}, {"right", +1})},
{"align-y", OPT_CHOICE(align_y,
Expand Down
1 change: 1 addition & 0 deletions sub/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct osd_style_opts {
float spacing;
int margin_x;
int margin_y;
int margin_y_offset;
int align_x;
int align_y;
float blur;
Expand Down
Loading