dotfiles/multimedia/.config/mpv/scripts/uosc/elements/WindowBorder.lua

36 lines
1.2 KiB
Lua
Raw Permalink Normal View History

2024-04-20 07:27:09 +00:00
local Element = require('elements/Element')
2023-05-23 13:31:17 +00:00
---@class WindowBorder : Element
local WindowBorder = class(Element)
function WindowBorder:new() return Class.new(self) --[[@as WindowBorder]] end
function WindowBorder:init()
2024-04-20 07:27:09 +00:00
Element.init(self, 'window_border', {render_order = 9999})
2023-05-23 13:31:17 +00:00
self.size = 0
2024-04-20 07:27:09 +00:00
self:decide_enabled()
2023-05-23 13:31:17 +00:00
end
function WindowBorder:decide_enabled()
self.enabled = options.window_border_size > 0 and not state.fullormaxed and not state.border
2024-04-20 07:27:09 +00:00
self.size = self.enabled and round(options.window_border_size * state.scale) or 0
2023-05-23 13:31:17 +00:00
end
function WindowBorder:on_prop_border() self:decide_enabled() end
2024-04-20 07:27:09 +00:00
function WindowBorder:on_prop_title_bar() self:decide_enabled() end
2023-05-23 13:31:17 +00:00
function WindowBorder:on_prop_fullormaxed() self:decide_enabled() end
2024-04-20 07:27:09 +00:00
function WindowBorder:on_options() self:decide_enabled() end
2023-05-23 13:31:17 +00:00
function WindowBorder:render()
if self.size > 0 then
local ass = assdraw.ass_new()
local clip = '\\iclip(' .. self.size .. ',' .. self.size .. ',' ..
(display.width - self.size) .. ',' .. (display.height - self.size) .. ')'
ass:rect(0, 0, display.width + 1, display.height + 1, {
2024-04-20 07:27:09 +00:00
color = bg, clip = clip, opacity = config.opacity.border,
2023-05-23 13:31:17 +00:00
})
return ass
end
end
return WindowBorder