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
function BarChart.new()
local self = setmetatable({}, BarChart):__init()
self.class = BarChart
return self
end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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