Iterate over children as normal
This commit is contained in:
parent
dd04c0c449
commit
2b24904c6f
11
gfx/list.lua
11
gfx/list.lua
@ -10,14 +10,15 @@ function List:adjustPositions(from)
|
||||
local vertical = self:isVertical()
|
||||
local newDims = 1
|
||||
local getDim = vertical and function(e) return e:getHeight() end or function(e) return e:getWidth() end
|
||||
for _,element in self:_iterateChildren{ to = from } do
|
||||
newDims = newDims + getDim(element)
|
||||
local children = self:_children()
|
||||
for i=1,from-1 do
|
||||
newDims = newDims + getDim(children[i])
|
||||
end
|
||||
|
||||
local setDim = vertical and function(e, dim) e:setY(dim) end or function(e, dim) e:setX(dim) end
|
||||
for _, element in self:_iterateChildren{ from = from } do
|
||||
setDim(element, newDims)
|
||||
newDims = newDims + getDim(element)
|
||||
for i=from,#children do
|
||||
setDim(children[i], newDims)
|
||||
newDims = newDims + getDim(children[i])
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -6,15 +6,19 @@ local Children = Prop:new{ defaultState = {}, uid = "CHILDREN" }
|
||||
function Children:with(elementType)
|
||||
local propSelf = self
|
||||
function elementType:_iterateChildren(opts)
|
||||
return ipairs(propSelf:getState(self))
|
||||
return ipairs(self:_children())
|
||||
end
|
||||
|
||||
function elementType:_children()
|
||||
return propSelf:getState(self)
|
||||
end
|
||||
|
||||
function elementType:childCount()
|
||||
return #propSelf:getState(self)
|
||||
return #self:_children()
|
||||
end
|
||||
|
||||
function elementType:_childAt(index)
|
||||
return propSelf:getState(self)[elementType:_validChildIndex(index)]
|
||||
return self:_children()[elementType:_validChildIndex(index)]
|
||||
end
|
||||
|
||||
function elementType:_validChildIndex(from)
|
||||
|
Loading…
x
Reference in New Issue
Block a user