summaryrefslogtreecommitdiffstats
path: root/.config/mpv/scripts/uosc_shared/elements/Curtain.lua
diff options
context:
space:
mode:
authorJoe <bousset.rudy@gmail.com>2023-01-31 21:13:10 +0100
committerJoe <bousset.rudy@gmail.com>2023-01-31 21:13:10 +0100
commitae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f (patch)
tree7341031ed0f84167350e95f48397761ef6544ad9 /.config/mpv/scripts/uosc_shared/elements/Curtain.lua
parentfbsd merge (diff)
parentup (diff)
downloaddotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.gz
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.bz2
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.xz
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.tar.zst
dotfiles-bsd-ae83bf5ca77c4cb3b6f219456e92d4c5e0f8fc9f.zip
Merge branch 'master' of gitjoe.xyz:dotfiles-bsd
Diffstat (limited to '')
-rw-r--r--.config/mpv/scripts/uosc_shared/elements/Curtain.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/.config/mpv/scripts/uosc_shared/elements/Curtain.lua b/.config/mpv/scripts/uosc_shared/elements/Curtain.lua
new file mode 100644
index 0000000..99b9f14
--- /dev/null
+++ b/.config/mpv/scripts/uosc_shared/elements/Curtain.lua
@@ -0,0 +1,35 @@
+local Element = require('uosc_shared/elements/Element')
+
+---@class Curtain : Element
+local Curtain = class(Element)
+
+function Curtain:new() return Class.new(self) --[[@as Curtain]] end
+function Curtain:init()
+ Element.init(self, 'curtain', {ignores_menu = true})
+ self.opacity = 0
+ ---@type string[]
+ self.dependents = {}
+end
+
+---@param id string
+function Curtain:register(id)
+ self.dependents[#self.dependents + 1] = id
+ if #self.dependents == 1 then self:tween_property('opacity', self.opacity, 1) end
+end
+
+---@param id string
+function Curtain:unregister(id)
+ self.dependents = itable_filter(self.dependents, function(item) return item ~= id end)
+ if #self.dependents == 0 then self:tween_property('opacity', self.opacity, 0) end
+end
+
+function Curtain:render()
+ if self.opacity == 0 or options.curtain_opacity == 0 then return end
+ local ass = assdraw.ass_new()
+ ass:rect(0, 0, display.width, display.height, {
+ color = '000000', opacity = options.curtain_opacity * self.opacity,
+ })
+ return ass
+end
+
+return Curtain