Skip to content

Commit

Permalink
feat: apply margin to osd-margin-y
Browse files Browse the repository at this point in the history
The margins were already set for `osc-margins` and
`user-data/osc/margins`, but osd messages have their own properties
`osd-margin-y` and `osd-margin-x`.
Offsetting `osd-margin-y` by our margin prevents overlap of osd messages
with the GUI.
  • Loading branch information
christoph-heinrich committed Apr 5, 2023
1 parent 8d85068 commit d5c66f9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/uosc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ config = {
-- native rendering frequency could not be detected
render_delay = 1 / 60,
font = mp.get_property('options/osd-font'),
osd_margin = mp.get_property('osd-margin-y'),
osd_alignment = mp.get_property('osd-align-y'),
types = {
video = split(options.video_types, ' *, *'),
audio = split(options.audio_types, ' *, *'),
Expand Down Expand Up @@ -478,7 +480,12 @@ function update_margins()
state.margin_bottom = bottom

utils.shared_script_property_set('osc-margins', string.format('%f,%f,%f,%f', 0, 0, top, bottom))
mp.set_property_native("user-data/osc/margins", { l = 0, r = 0, t = top, b = bottom })
mp.set_property_native('user-data/osc/margins', { l = 0, r = 0, t = top, b = bottom })

local osd_margin = 0
if config.osd_alignment == 'bottom' then osd_margin = round(bottom * 720)
elseif config.osd_alignment == 'top' then osd_margin = round(top * 720) end
mp.set_property_native('osd-margin-y', osd_margin + config.osd_margin)
end
function create_state_setter(name, callback)
return function(_, value)
Expand Down

0 comments on commit d5c66f9

Please sign in to comment.