diff --git a/gfx/list.lua b/gfx/list.lua index 497b2f4..c98f248 100644 --- a/gfx/list.lua +++ b/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 diff --git a/gfx/prop/children.lua b/gfx/prop/children.lua index 5389c99..4b8d70a 100644 --- a/gfx/prop/children.lua +++ b/gfx/prop/children.lua @@ -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)