Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fca8da1c1 |
@@ -34,16 +34,20 @@ local function flexObjectPlugin(base, basalt)
|
|||||||
return self
|
return self
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getSize = function(self)
|
getSize = function(self, internalCall)
|
||||||
return baseWidth, baseHeight
|
if internalCall then
|
||||||
|
return baseWidth, baseHeight
|
||||||
|
else
|
||||||
|
return base:getSize()
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getWidth = function(self)
|
getWidth = function(self, internalCall)
|
||||||
return baseWidth
|
return internalCall and baseWidth or base:getWidth()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
getHeight = function(self)
|
getHeight = function(self, internalCall)
|
||||||
return baseHeight
|
return internalCall and baseHeight or base:getHeight()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
setSize = function(self, width, height, rel, internalCall)
|
setSize = function(self, width, height, rel, internalCall)
|
||||||
@@ -91,7 +95,7 @@ return function(name, basalt)
|
|||||||
for _,v in pairs(children)do
|
for _,v in pairs(children)do
|
||||||
if(sortedChildren[index]==nil)then sortedChildren[index]={offset=1} end
|
if(sortedChildren[index]==nil)then sortedChildren[index]={offset=1} end
|
||||||
|
|
||||||
local childHeight = direction == "row" and v:getHeight() or v:getWidth()
|
local childHeight = direction == "row" and v:getHeight(true) or v:getWidth(true)
|
||||||
if childHeight > lineSize then
|
if childHeight > lineSize then
|
||||||
lineSize = childHeight
|
lineSize = childHeight
|
||||||
end
|
end
|
||||||
@@ -123,19 +127,19 @@ return function(name, basalt)
|
|||||||
index = index + 1
|
index = index + 1
|
||||||
sortedChildren[index] = {offset=lineOffset}
|
sortedChildren[index] = {offset=lineOffset}
|
||||||
else
|
else
|
||||||
local objSize = direction == "row" and v:getWidth() or v:getHeight()
|
local objSize = direction == "row" and v:getWidth(true) or v:getHeight(true)
|
||||||
if(objSize+usedSize<=maxSize) then
|
if(objSize+usedSize<=maxSize) then
|
||||||
table.insert(sortedChildren[index], v)
|
table.insert(sortedChildren[index], v)
|
||||||
usedSize = usedSize + objSize + spacing
|
usedSize = usedSize + objSize + spacing
|
||||||
else
|
else
|
||||||
lineOffset = lineOffset + lineSize + spacing
|
lineOffset = lineOffset + lineSize + spacing
|
||||||
lineSize = direction == "row" and v:getHeight() or v:getWidth()
|
lineSize = direction == "row" and v:getHeight(true) or v:getWidth(true)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
usedSize = objSize + spacing
|
usedSize = objSize + spacing
|
||||||
sortedChildren[index] = {offset=lineOffset, v}
|
sortedChildren[index] = {offset=lineOffset, v}
|
||||||
end
|
end
|
||||||
|
|
||||||
local childHeight = direction == "row" and v:getHeight() or v:getWidth()
|
local childHeight = direction == "row" and v:getHeight(true) or v:getWidth(true)
|
||||||
if childHeight > lineSize then
|
if childHeight > lineSize then
|
||||||
lineSize = childHeight
|
lineSize = childHeight
|
||||||
end
|
end
|
||||||
@@ -178,7 +182,7 @@ return function(name, basalt)
|
|||||||
end
|
end
|
||||||
|
|
||||||
child:setPosition(currentX, children.offset or 1)
|
child:setPosition(currentX, children.offset or 1)
|
||||||
child:setSize(childWidth, child:getHeight(), false, true)
|
child:setSize(childWidth, child:getHeight(true), false, true)
|
||||||
currentX = currentX + childWidth + spacing
|
currentX = currentX + childWidth + spacing
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -255,7 +259,7 @@ return function(name, basalt)
|
|||||||
local flexGrow = child:getFlexGrow()
|
local flexGrow = child:getFlexGrow()
|
||||||
local flexShrink = child:getFlexShrink()
|
local flexShrink = child:getFlexShrink()
|
||||||
|
|
||||||
local baseHeight = child:getFlexBasis() ~= 0 and child:getFlexBasis() or child:getHeight()
|
local baseHeight = child:getFlexBasis() ~= 0 and child:getFlexBasis() or child:getHeight(true)
|
||||||
if totalFlexGrow > 0 then
|
if totalFlexGrow > 0 then
|
||||||
childHeight = baseHeight + flexGrow / totalFlexGrow * remainingSpace
|
childHeight = baseHeight + flexGrow / totalFlexGrow * remainingSpace
|
||||||
else
|
else
|
||||||
@@ -306,7 +310,7 @@ return function(name, basalt)
|
|||||||
local numSpaces = #children + 1
|
local numSpaces = #children + 1
|
||||||
local totalChildHeight = 0
|
local totalChildHeight = 0
|
||||||
for _, child in ipairs(children) do
|
for _, child in ipairs(children) do
|
||||||
totalChildHeight = totalChildHeight + child:getHeight()
|
totalChildHeight = totalChildHeight + child:getHeight(true)
|
||||||
end
|
end
|
||||||
local totalSpace = containerHeight - totalChildHeight
|
local totalSpace = containerHeight - totalChildHeight
|
||||||
local offset = math.floor(totalSpace / numSpaces)
|
local offset = math.floor(totalSpace / numSpaces)
|
||||||
@@ -316,7 +320,7 @@ return function(name, basalt)
|
|||||||
for _, child in ipairs(children) do
|
for _, child in ipairs(children) do
|
||||||
local x, y = child:getPosition()
|
local x, y = child:getPosition()
|
||||||
child:setPosition(x, currentY)
|
child:setPosition(x, currentY)
|
||||||
currentY = currentY + child:getHeight() + offset + (remaining > 0 and 1 or 0)
|
currentY = currentY + child:getHeight(true) + offset + (remaining > 0 and 1 or 0)
|
||||||
remaining = remaining > 0 and remaining - 1 or 0
|
remaining = remaining > 0 and remaining - 1 or 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user