-
Notifications
You must be signed in to change notification settings - Fork 3.3k
osc.lua: use private options to control SUB/OSD offset #17555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking "Sign up for GitHub", you agree to our terms of service and privacy statement. We'll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+35
-28
Merged
osc.lua: use private options to control SUB/OSD offset #17555
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3134,6 +3134,16 @@ Subtitles | |
|
|
||
| Default: 34 | ||
|
|
||
|
``--sub-margin-y-offset= |
||
| 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= |
||
| 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= |
||
| 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= |
||
| Control to which corner of the screen OSD should be | ||
| aligned to (default: ``left``). | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -409,12 +409,11 @@ Configurable Options | |
| option, margins are only applied when ``visibility`` is set to ``always``. | ||
|
|
||
| ``sub_margins`` | ||
| Default: yes | ||
| Default: no | ||
|
|
||
| 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 | ||
|
|
@@ -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. Uses ``--osd-margin-y-offset`` to apply the adjustment. | ||
|
|
||
| ``windowcontrols`` | ||
| Default: auto (Show window controls if there is no window border) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,7 @@ local user_opts = { | |
| boxmaxchars = 80, -- title crop threshold for box layout | ||
| boxvideo = false, -- apply osc_param.video_margins to video | ||
| dynamic_margins = false, -- update margins dynamically with OSC visibility | ||
| sub_margins = true, -- adjust sub-margin-y to not overlap with OSC | ||
| sub_margins = false, -- adjust sub-margin-y to not overlap with OSC | ||
| osd_margins = true, -- adjust osd-margin-y to not overlap with OSC | ||
| windowcontrols = "auto", -- whether to show window controls | ||
| windowcontrols_alignment = "right", -- which side to show window controls on | ||
|
|
@@ -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() | ||
|
|
@@ -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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.