LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

FlowLayoutElement

Description
Horizontal flow layouting element for simple cases.
Parent
BoxLayoutElement
Functions

invalidateLayout

Description
Definition
invalidateLayout()
Code
27function FlowLayoutElement:invalidateLayout(ignoreVisibility)
28 local totalWidth = 0
29 for _, element in pairs(self.elements) do
30 if self:getIsElementIncluded(element, ignoreVisibility) then
31 totalWidth = totalWidth + element.size[1] + element.margin[1] + element.margin[3]
32 end
33 end
34
35 local posX = 0
36 if self.alignmentX == FlowLayoutElement.ALIGN_CENTER then
37 posX = self.size[1]*0.5 - totalWidth*0.5
38 elseif self.alignmentX == FlowLayoutElement.ALIGN_RIGHT then
39 posX = self.size[1] - totalWidth
40 end
41
42 for _, element in pairs(self.elements) do
43 if self:getIsElementIncluded(element, ignoreVisibility) then
44 posX = posX + element.margin[1]
45 local posY = element.margin[4]
46 if self.alignmentY == FlowLayoutElement.ALIGN_MIDDLE then
47 posY = self.size[2]*0.5 - element.size[2]*0.5
48 elseif self.alignmentY == FlowLayoutElement.ALIGN_TOP then
49 posY = self.size[2] - element.size[2]
50 end
51
52 element:setPosition(posX, posY)
53 posX = posX + element.size[1] + element.margin[3]
54 end
55 end
56end

new

Description
Definition
new()
Code
16function FlowLayoutElement:new(target, custom_mt)
17 local self = BoxLayoutElement:new(target, custom_mt or FlowLayoutElement_mt)
18
19 self.alignmentX = BoxLayoutElement.ALIGN_LEFT
20 self.alignmentY = BoxLayoutElement.ALIGN_BOTTOM
21
22 return self
23end