From a3fb10f0fd4d06c4d88026628aae2b9109774464 Mon Sep 17 00:00:00 2001 From: Kenny Shields Date: Sat, 16 Aug 2014 14:35:26 -0400 Subject: [PATCH] Fix nested list positioning issues --- objects/internal/scrollable/scrollbody.lua | 12 ++++++------ objects/list.lua | 12 ++++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/objects/internal/scrollable/scrollbody.lua b/objects/internal/scrollable/scrollbody.lua index 417617f..1eec5ce 100644 --- a/objects/internal/scrollable/scrollbody.lua +++ b/objects/internal/scrollable/scrollbody.lua @@ -135,23 +135,23 @@ function newobject:update(dt) end end + self:CheckHover() + local parent = self.parent local base = loveframes.base local update = self.Update local internals = self.internals + for k, v in ipairs(internals) do + v:update(dt) + end + -- move to parent if there is a parent if parent ~= base then self.x = parent.x + self.staticx self.y = parent.y + self.staticy end - self:CheckHover() - - for k, v in ipairs(internals) do - v:update(dt) - end - if update then update(self, dt) end diff --git a/objects/list.lua b/objects/list.lua index 8cea958..283098e 100644 --- a/objects/list.lua +++ b/objects/list.lua @@ -60,6 +60,8 @@ function newobject:update(dt) end end + self:CheckHover() + local internals = self.internals local children = self.children local display = self.display @@ -74,10 +76,12 @@ function newobject:update(dt) self.y = self.parent.y + self.staticy end - self:CheckHover() - for k, v in ipairs(internals) do v:update(dt) + for _, p in pairs(self:GetParents()) do + v.x = v.x - (p.offsetx or 0) + v.y = v.y - (p.offsety or 0) + end end local x = self.x @@ -92,6 +96,10 @@ function newobject:update(dt) v:SetClickBounds(x, y, width, height) v.x = (v.parent.x + v.staticx) - offsetx v.y = (v.parent.y + v.staticy) - offsety + for _, p in pairs(self:GetParents()) do + v.x = v.x - (p.offsetx or 0) + v.y = v.y - (p.offsety or 0) + end if display == "vertical" then if v.lastheight ~= v.height then self:CalculateSize()