Skip to content

Commit

Permalink
osc.lua: add option to enable fade-in effect
Browse files Browse the repository at this point in the history
Introduced a new `fadein` option to control the fade-in effect for the OSC.
The default value is `no`, which disables fade-in. This option allows users
to enable a fade-in effect when the OSC appears. Updated documentation
accordingly.
  • Loading branch information
vbalien authored and kasper93 committed Dec 10, 2024
1 parent 8d76ff7 commit e2014fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes/osc-fadein.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add `osc-fadein` script-opt
7 changes: 6 additions & 1 deletion DOCS/man/osc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,12 @@ Configurable Options
``fadeduration``
Default: 200

Duration of fade out in ms, 0 = no fade
Duration of fade effects in ms, 0 = no fade.

``fadein``
Default: no

Enable fade-in.

``title``
Default: ${!playlist-count==1:[${playlist-pos-1}/${playlist-count}] }${media-title}
Expand Down
15 changes: 11 additions & 4 deletions player/lua/osc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ local user_opts = {
hidetimeout = 500, -- duration in ms until the OSC hides if no
-- mouse movement. enforced non-negative for the
-- user, but internally negative is "always-on".
fadeduration = 200, -- duration of fade out in ms, 0 = no fade
fadeduration = 200, -- duration of fade out (and fade in, if enabled) in ms, 0 = no fade
fadein = false, -- whether to enable fade-in effect
deadzonesize = 0.5, -- size of deadzone
minmousemove = 0, -- minimum amount of pixels the mouse has to
-- move between ticks to make the OSC show up
Expand Down Expand Up @@ -2111,9 +2112,15 @@ local function show_osc()
--remember last time of invocation (mouse move)
state.showtime = mp.get_time()

osc_visible(true)

if user_opts.fadeduration > 0 then
if user_opts.fadeduration <= 0 then
osc_visible(true)
elseif user_opts.fadein then
if not state.osc_visible then
state.anitype = "in"
request_tick()
end
else
osc_visible(true)
state.anitype = nil
end
end
Expand Down

0 comments on commit e2014fb

Please sign in to comment.