Updated
This commit is contained in:
parent
f0d81507e7
commit
91ac899e76
134 changed files with 29248 additions and 114 deletions
29
.config/mpv/scripts/uosc/elements/ManagedButton.lua
Normal file
29
.config/mpv/scripts/uosc/elements/ManagedButton.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
local Button = require('elements/Button')
|
||||
|
||||
---@alias ManagedButtonProps {name: string; anchor_id?: string; render_order?: number}
|
||||
|
||||
---@class ManagedButton : Button
|
||||
local ManagedButton = class(Button)
|
||||
|
||||
---@param id string
|
||||
---@param props ManagedButtonProps
|
||||
function ManagedButton:new(id, props) return Class.new(self, id, props) --[[@as ManagedButton]] end
|
||||
---@param id string
|
||||
---@param props ManagedButtonProps
|
||||
function ManagedButton:init(id, props)
|
||||
---@type string | table | nil
|
||||
self.command = nil
|
||||
|
||||
Button.init(self, id, table_assign({}, props, {on_click = function() execute_command(self.command) end}))
|
||||
|
||||
self:register_disposer(buttons:subscribe(props.name, function(data) self:update(data) end))
|
||||
end
|
||||
|
||||
function ManagedButton:update(data)
|
||||
for _, prop in ipairs({'icon', 'active', 'badge', 'command', 'tooltip'}) do
|
||||
self[prop] = data[prop]
|
||||
end
|
||||
self.is_clickable = self.command ~= nil
|
||||
end
|
||||
|
||||
return ManagedButton
|
||||
Loading…
Add table
Add a link
Reference in a new issue