Fixed animation

Fixed eventsystem not registering its parent events
This commit is contained in:
Robert Jelic
2025-04-14 02:39:54 +02:00
parent bd62debc32
commit b91031afbc
28 changed files with 30 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ BarChart.__index = BarChart
--- @private --- @private
function BarChart.new() function BarChart.new()
local self = setmetatable({}, BarChart):__init() local self = setmetatable({}, BarChart):__init()
self.class = BarChart
return self return self
end end

View File

@@ -6,7 +6,6 @@ local uuid = require("libraries/utils").uuid
--- @class BaseElement : PropertySystem --- @class BaseElement : PropertySystem
local BaseElement = setmetatable({}, PropertySystem) local BaseElement = setmetatable({}, PropertySystem)
BaseElement.__index = BaseElement BaseElement.__index = BaseElement
BaseElement._events = {}
--- @property type string BaseElement The type identifier of the element --- @property type string BaseElement The type identifier of the element
BaseElement.defineProperty(BaseElement, "type", {default = {"BaseElement"}, type = "string", setter=function(self, value) BaseElement.defineProperty(BaseElement, "type", {default = {"BaseElement"}, type = "string", setter=function(self, value)
@@ -72,6 +71,7 @@ end
--- @private --- @private
function BaseElement.new() function BaseElement.new()
local self = setmetatable({}, BaseElement):__init() local self = setmetatable({}, BaseElement):__init()
self.class = BaseElement
return self return self
end end
@@ -93,7 +93,7 @@ function BaseElement:init(props, basalt)
local currentClass = getmetatable(self).__index local currentClass = getmetatable(self).__index
local events = {} local events = {}
currentClass = self currentClass = self.class
while currentClass do while currentClass do
if type(currentClass) == "table" and currentClass._eventConfigs then if type(currentClass) == "table" and currentClass._eventConfigs then

View File

@@ -57,6 +57,7 @@ end})
--- @private --- @private
function BaseFrame.new() function BaseFrame.new()
local self = setmetatable({}, BaseFrame):__init() local self = setmetatable({}, BaseFrame):__init()
self.class = BaseFrame
return self return self
end end

View File

@@ -167,6 +167,7 @@ end})
--- @private --- @private
function BigFont.new() function BigFont.new()
local self = setmetatable({}, BigFont):__init() local self = setmetatable({}, BigFont):__init()
self.class = BigFont
self.set("width", 16) self.set("width", 16)
self.set("height", 3) self.set("height", 3)
self.set("z", 5) self.set("z", 5)

View File

@@ -19,6 +19,7 @@ Button.defineEvent(Button, "mouse_up")
--- @private --- @private
function Button.new() function Button.new()
local self = setmetatable({}, Button):__init() local self = setmetatable({}, Button):__init()
self.class = Button
self.set("width", 10) self.set("width", 10)
self.set("height", 3) self.set("height", 3)
self.set("z", 5) self.set("z", 5)

View File

@@ -45,6 +45,7 @@ end
--- @protected --- @protected
function Checkbox:init(props, basalt) function Checkbox:init(props, basalt)
VisualElement.init(self, props, basalt) VisualElement.init(self, props, basalt)
self.class = Checkbox
self.set("type", "Checkbox") self.set("type", "Checkbox")
end end

View File

@@ -91,6 +91,7 @@ end
--- @private --- @private
function Container.new() function Container.new()
local self = setmetatable({}, Container):__init() local self = setmetatable({}, Container):__init()
self.class = Container
return self return self
end end

View File

@@ -19,6 +19,7 @@ Display.__index = Display
--- @private --- @private
function Display.new() function Display.new()
local self = setmetatable({}, Display):__init() local self = setmetatable({}, Display):__init()
self.class = Display
self.set("width", 25) self.set("width", 25)
self.set("height", 8) self.set("height", 8)
self.set("z", 5) self.set("z", 5)

View File

@@ -31,6 +31,7 @@ Dropdown.defineProperty(Dropdown, "dropSymbol", {default = "\31", type = "string
--- @private --- @private
function Dropdown.new() function Dropdown.new()
local self = setmetatable({}, Dropdown):__init() local self = setmetatable({}, Dropdown):__init()
self.class = Dropdown
self.set("width", 16) self.set("width", 16)
self.set("height", 1) self.set("height", 1)
self.set("z", 8) self.set("z", 8)

View File

@@ -246,6 +246,7 @@ end
--- @private --- @private
function Flexbox.new() function Flexbox.new()
local self = setmetatable({}, Flexbox):__init() local self = setmetatable({}, Flexbox):__init()
self.class = Flexbox
self.set("width", 12) self.set("width", 12)
self.set("height", 6) self.set("height", 6)
self.set("background", colors.blue) self.set("background", colors.blue)

View File

@@ -26,6 +26,7 @@ Frame.defineProperty(Frame, "draggingMap", {default = {{x=1, y=1, width="width",
--- @private --- @private
function Frame.new() function Frame.new()
local self = setmetatable({}, Frame):__init() local self = setmetatable({}, Frame):__init()
self.class = Frame
self.set("width", 12) self.set("width", 12)
self.set("height", 6) self.set("height", 6)
self.set("background", colors.gray) self.set("background", colors.gray)

View File

@@ -33,6 +33,7 @@ Graph.defineProperty(Graph, "series", {default = {}, type = "table", canTriggerR
--- @private --- @private
function Graph.new() function Graph.new()
local self = setmetatable({}, Graph):__init() local self = setmetatable({}, Graph):__init()
self.class = Graph
return self return self
end end

View File

@@ -31,6 +31,7 @@ Image.combineProperties(Image, "offset", "offsetX", "offsetY")
--- @private --- @private
function Image.new() function Image.new()
local self = setmetatable({}, Image):__init() local self = setmetatable({}, Image):__init()
self.class = Image
self.set("width", 12) self.set("width", 12)
self.set("height", 6) self.set("height", 6)
self.set("background", colors.black) self.set("background", colors.black)

View File

@@ -40,6 +40,7 @@ Input.defineEvent(Input, "char")
--- @private --- @private
function Input.new() function Input.new()
local self = setmetatable({}, Input):__init() local self = setmetatable({}, Input):__init()
self.class = Input
self.set("width", 8) self.set("width", 8)
self.set("z", 3) self.set("z", 3)
return self return self

View File

@@ -36,6 +36,7 @@ end})
--- @private --- @private
function Label.new() function Label.new()
local self = setmetatable({}, Label):__init() local self = setmetatable({}, Label):__init()
self.class = Label
self.set("z", 3) self.set("z", 3)
self.set("foreground", colors.black) self.set("foreground", colors.black)
self.set("backgroundEnabled", false) self.set("backgroundEnabled", false)

View File

@@ -27,6 +27,7 @@ LineChart.__index = LineChart
--- @private --- @private
function LineChart.new() function LineChart.new()
local self = setmetatable({}, LineChart):__init() local self = setmetatable({}, LineChart):__init()
self.class = LineChart
return self return self
end end

View File

@@ -30,6 +30,7 @@ List.defineEvent(List, "mouse_scroll")
--- @private --- @private
function List.new() function List.new()
local self = setmetatable({}, List):__init() local self = setmetatable({}, List):__init()
self.class = List
self.set("width", 16) self.set("width", 16)
self.set("height", 8) self.set("height", 8)
self.set("z", 5) self.set("z", 5)

View File

@@ -18,6 +18,7 @@ Menu.defineProperty(Menu, "separatorColor", {default = colors.gray, type = "colo
--- @private --- @private
function Menu.new() function Menu.new()
local self = setmetatable({}, Menu):__init() local self = setmetatable({}, Menu):__init()
self.class = Menu
self.set("width", 30) self.set("width", 30)
self.set("height", 1) self.set("height", 1)
self.set("background", colors.gray) self.set("background", colors.gray)

View File

@@ -128,6 +128,7 @@ end
--- @private --- @private
function Program.new() function Program.new()
local self = setmetatable({}, Program):__init() local self = setmetatable({}, Program):__init()
self.class = Program
self.set("z", 5) self.set("z", 5)
self.set("width", 30) self.set("width", 30)
self.set("height", 12) self.set("height", 12)

View File

@@ -25,6 +25,7 @@ ProgressBar.defineProperty(ProgressBar, "direction", {default = "right", type =
--- @private --- @private
function ProgressBar.new() function ProgressBar.new()
local self = setmetatable({}, ProgressBar):__init() local self = setmetatable({}, ProgressBar):__init()
self.class = ProgressBar
self.set("width", 25) self.set("width", 25)
self.set("height", 3) self.set("height", 3)
return self return self

View File

@@ -49,6 +49,7 @@ Scrollbar.defineEvent(Scrollbar, "mouse_scroll")
--- @private --- @private
function Scrollbar.new() function Scrollbar.new()
local self = setmetatable({}, Scrollbar):__init() local self = setmetatable({}, Scrollbar):__init()
self.class = Scrollbar
self.set("width", 1) self.set("width", 1)
self.set("height", 10) self.set("height", 10)
return self return self

View File

@@ -28,6 +28,7 @@ Slider.defineEvent(Slider, "mouse_up")
--- @private --- @private
function Slider.new() function Slider.new()
local self = setmetatable({}, Slider):__init() local self = setmetatable({}, Slider):__init()
self.class = Slider
self.set("width", 8) self.set("width", 8)
self.set("height", 1) self.set("height", 1)
self.set("backgroundEnabled", false) self.set("backgroundEnabled", false)

View File

@@ -18,6 +18,7 @@ Switch.defineEvent(Switch, "mouse_up")
--- @private --- @private
function Switch.new() function Switch.new()
local self = setmetatable({}, Switch):__init() local self = setmetatable({}, Switch):__init()
self.class = Switch
self.set("width", 2) self.set("width", 2)
self.set("height", 1) self.set("height", 1)
self.set("z", 5) self.set("z", 5)

View File

@@ -48,6 +48,7 @@ Table.defineEvent(Table, "mouse_scroll")
--- @private --- @private
function Table.new() function Table.new()
local self = setmetatable({}, Table):__init() local self = setmetatable({}, Table):__init()
self.class = Table
self.set("width", 30) self.set("width", 30)
self.set("height", 10) self.set("height", 10)
self.set("z", 5) self.set("z", 5)

View File

@@ -36,6 +36,7 @@ TextBox.defineEvent(TextBox, "mouse_scroll")
--- @private --- @private
function TextBox.new() function TextBox.new()
local self = setmetatable({}, TextBox):__init() local self = setmetatable({}, TextBox):__init()
self.class = TextBox
self.set("width", 20) self.set("width", 20)
self.set("height", 10) self.set("height", 10)
return self return self

View File

@@ -37,6 +37,7 @@ Tree.defineEvent(Tree, "mouse_scroll")
--- @private --- @private
function Tree.new() function Tree.new()
local self = setmetatable({}, Tree):__init() local self = setmetatable({}, Tree):__init()
self.class = Tree
self.set("width", 30) self.set("width", 30)
self.set("height", 10) self.set("height", 10)
self.set("z", 5) self.set("z", 5)

View File

@@ -114,6 +114,7 @@ local max, min = math.max, math.min
--- @private --- @private
function VisualElement.new() function VisualElement.new()
local self = setmetatable({}, VisualElement):__init() local self = setmetatable({}, VisualElement):__init()
self.class = VisualElement
return self return self
end end

View File

@@ -265,6 +265,7 @@ function Animation:event(event, timerId)
if #remaining > 0 then if #remaining > 0 then
self.timer = os.startTimer(0.05) self.timer = os.startTimer(0.05)
end end
return true
end end
end end
@@ -416,13 +417,12 @@ Animation.registerAnimation("scrollText", {
local VisualElement = {hooks={}} local VisualElement = {hooks={}}
---@private ---@private
function VisualElement.hooks.dispatchEvent(self, event, ...) function VisualElement.hooks.handleEvent(self, event, ...)
if event == "timer" then if event == "timer" then
local animation = self.get("animation") local animation = self.get("animation")
if animation then if animation then
animation:event(event, ...) animation:event(event, ...)
end end
return true
end end
end end