auto handle late init call(and error report) with element creation queue

This commit is contained in:
Michael Freno
2025-12-13 01:54:30 -05:00
parent c069b2be22
commit 6fe452ef97
5 changed files with 232 additions and 7 deletions

View File

@@ -20,6 +20,14 @@ local Context = {
_zIndexOrderedElements = {}, -- Array of elements sorted by z-index (lowest to highest)
-- Focus management guard
_settingFocus = false,
initialized = false,
-- Initialization state tracking
---@type "uninitialized"|"initializing"|"ready"
_initState = "uninitialized",
---@type table[] Queue of {props: ElementProps, callback: function(element)|nil}
_initQueue = {},
}
---@return number, number -- scaleX, scaleY

View File

@@ -194,7 +194,7 @@ function Element.new(props)
if elementMode == nil then
elementMode = Element._Context._immediateMode and "immediate" or "retained"
end
-- If retained mode and has an ID, check if element already exists in parent's children
if elementMode == "retained" and props.id and props.id ~= "" and props.parent then
-- Check if this element already exists in parent's restored children
@@ -292,7 +292,7 @@ function Element.new(props)
-- Track whether ID was auto-generated (before ID assignment)
local idWasAutoGenerated = not props.id or props.id == ""
-- Auto-generate ID if not provided (for all elements)
if idWasAutoGenerated then
self.id = Element._StateManager.generateID(props, props.parent)
@@ -524,7 +524,7 @@ function Element.new(props)
return false
end
end
self.border = {
top = normalizeBorderValue(props.border.top),
right = normalizeBorderValue(props.border.right),
@@ -1065,7 +1065,7 @@ function Element.new(props)
end
tempHeight = 0
end
-- Get scaled 9-patch content padding from ThemeManager
local scaledPadding = self._themeManager:getScaledContentPadding(tempWidth, tempHeight)
if scaledPadding then