Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NewGuiRectAligner = function()
- return NewSceneNode() where
- Class = $RectAlignerClass
- end
- end
- GuiRectAlignerClass = $GuiRectAlignableClass.Copy() where
- HorizontalMode
- HorizontalPad
- VerticalMode
- VerticalPad
- RectAlignChildren = method()
- //scan children
- foreach Children() as node
- if not $node.$IsGuiRectAlignable then continue end
- childrenSize += $node.$Size
- childCount += 1
- end
- //get horizontal settings
- select $HorizontalMode
- case Left
- x = 0
- xAdvance = $HorizontalPad
- case Center
- x = ($Size.$x - $childrenSize.$x) / 2
- xAdvance = $HorizontalPad
- case Right
- x = $Size.$x - $childrenSize.$x
- xAdvance = $HorizontalPad
- case Justified
- x = 0
- if $childCount <= 1 then xAdvance = 0 else xAdvance = ($Size.$x - $childrenSize.$x) / ($childCount - 1) end
- end
- //get vertical settings
- select $VerticalMode
- case Top
- y = 0
- yStep = $VerticalPad
- case Center
- y = ($Size.$y - $childrenSize.$y) / 2
- yAdvance = $VerticalPad
- case Bottom
- y = $Size.$y - $childrenSize.$y
- yAdvance = $VerticalPad
- case Justified
- y = 0
- if $childCount <= 1 then yAdvance = 0 else yAdvance = ($Size.$y - $childrenSize.$y) / ($childCount - 1) end
- end
- position |$x,$y|
- advance = |$xAdvance,$yAdvance|
- //align
- foreach Children() as node
- if not $node.$IsGuiRectAlignable then continue end
- $node.Position = $position - $node.$Offset
- position += $node.$Size + $advance
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement