Adjust List child position calculation

This commit is contained in:
Gabriel Tofvesson 2024-10-04 01:15:39 +02:00
parent e985bcba63
commit 691b73337c

View File

@ -5,15 +5,15 @@ local List = Element:new{
}
local function adjustPositions(elements, vertical, from)
local newDims = 0
local newDims = 1
local getDim = vertical and function(e) return e:getHeight() end or function(e) return e:getWidth() end
for i=1,from-1 do
newDims = newDims + getDim(elements[i])
end
local setDim = vertical and function(e, dim) e:setPos(0, dim) end or function(e, dim) e:setPos(dim, 0) end
local setDim = vertical and function(e, dim) e:setPos(1, dim) end or function(e, dim) e:setPos(dim, 1) end
for i=from,#elements do
setDim(elements[i])
setDim(elements[i], newDims)
newDims = newDims + getDim(elements[i])
end
end