forked from FAForever/fa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolumnlayout.lua
More file actions
26 lines (23 loc) · 1.02 KB
/
columnlayout.lua
File metadata and controls
26 lines (23 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
local LayoutHelpers = import('/lua/maui/layouthelpers.lua')
local Group = import('/lua/maui/group.lua').Group
--- A Group for arranging controls horizontally in fixed-width columns.
ColumnLayout = Class(Group) {
--- Create a new ColumnLayout
--
-- @param positions A list of values representing the x co-ordinate of the leftmost pixel of
-- each column.
-- @param widths A list of values representing the width of each column.
__init = function(self, parent, positions, widths)
Group.__init(self, parent)
self.positions = positions
self.widths = widths
self.numChildren = 0
end,
--- Add a control to the group, inserting it into the next available column.
AddChild = function(self, control)
self.numChildren = self.numChildren + 1
LayoutHelpers.SetWidth(control, self.widths[self.numChildren])
LayoutHelpers.AtLeftIn(control, self, self.positions[self.numChildren])
LayoutHelpers.AtVerticalCenterIn(control, self, 1)
end
}