This commit is contained in:
Michael Freno
2025-11-13 20:50:18 -05:00
parent 3373d43b1b
commit 7e69e7f544
2 changed files with 22 additions and 14 deletions

View File

@@ -731,7 +731,6 @@ function Element.new(props)
-- Check if we should use 9-patch content padding for auto-sizing -- Check if we should use 9-patch content padding for auto-sizing
local use9PatchPadding = false local use9PatchPadding = false
local ninePatchContentPadding = nil local ninePatchContentPadding = nil
local tempPadding = nil
if self._themeManager:hasThemeComponent() then if self._themeManager:hasThemeComponent() then
local component = self._themeManager:getComponent() local component = self._themeManager:getComponent()
if component and component._ninePatchData and component._ninePatchData.contentPadding then if component and component._ninePatchData and component._ninePatchData.contentPadding then
@@ -749,10 +748,20 @@ function Element.new(props)
then then
use9PatchPadding = true use9PatchPadding = true
ninePatchContentPadding = component._ninePatchData.contentPadding ninePatchContentPadding = component._ninePatchData.contentPadding
end
end
end
-- First, resolve padding using temporary dimensions
-- For auto-sized elements, this is content width; for explicit sizing, this is border-box width
local tempPadding
if use9PatchPadding then
-- Get scaled 9-patch content padding from ThemeManager
local scaledPadding = self._themeManager:getScaledContentPadding(tempWidth, tempHeight) local scaledPadding = self._themeManager:getScaledContentPadding(tempWidth, tempHeight)
if scaledPadding then if scaledPadding then
tempPadding = scaledPadding tempPadding = scaledPadding
else else
-- Fallback if scaling fails
tempPadding = { tempPadding = {
left = ninePatchContentPadding.left, left = ninePatchContentPadding.left,
top = ninePatchContentPadding.top, top = ninePatchContentPadding.top,
@@ -760,10 +769,9 @@ function Element.new(props)
bottom = ninePatchContentPadding.bottom, bottom = ninePatchContentPadding.bottom,
} }
end end
end else
tempPadding = Units.resolveSpacing(props.padding, self.width, self.height) tempPadding = Units.resolveSpacing(props.padding, self.width, self.height)
end end
end
-- Margin percentages are relative to parent's dimensions (CSS spec) -- Margin percentages are relative to parent's dimensions (CSS spec)
local parentWidth = self.parent and self.parent.width or viewportWidth local parentWidth = self.parent and self.parent.width or viewportWidth

View File

@@ -485,7 +485,7 @@ function LayoutEngine:layoutChildren()
-- Vertical layout: main axis is Y, cross axis is X -- Vertical layout: main axis is Y, cross axis is X
-- Position child at border box (x, y represents top-left including padding) -- Position child at border box (x, y represents top-left including padding)
-- Add reservedMainStart and top margin to account for absolutely positioned siblings and margins -- Add reservedMainStart and top margin to account for absolutely positioned siblings and margins
child.y = element.y + element.padding.top + reservedMainStart + currentMainPos + child.margin.top child.y = self.element.y + self.element.padding.top + reservedMainStart + currentMainPos + child.margin.top
-- BORDER-BOX MODEL: Use border-box dimensions for alignment calculations -- BORDER-BOX MODEL: Use border-box dimensions for alignment calculations
local childBorderBoxWidth = child:getBorderBoxWidth() local childBorderBoxWidth = child:getBorderBoxWidth()