-
Notifications
You must be signed in to change notification settings - Fork 10
/
row.lua
50 lines (38 loc) · 1.13 KB
/
row.lua
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--[=[
@within Plasma
@function row
@tag widgets
@param options {padding: Vector2}
@param children () -> () -- Children
Lays out children horizontally
]=]
local Runtime = require(script.Parent.Parent.Runtime)
local automaticSize = require(script.Parent.Parent.automaticSize)
return Runtime.widget(function(options, fn)
if type(options) == "function" and fn == nil then
fn = options
options = {}
end
if options.padding then
if type(options.padding) == "number" then
options.padding = UDim.new(0, options.padding)
end
else
options.padding = UDim.new(0, 10)
end
local refs = Runtime.useInstance(function(ref)
local Frame = Instance.new("Frame")
Frame.BackgroundTransparency = 1
local UIListLayout = Instance.new("UIListLayout")
UIListLayout.SortOrder = Enum.SortOrder.LayoutOrder
UIListLayout.FillDirection = Enum.FillDirection.Horizontal
UIListLayout.Padding = options.padding
UIListLayout.Parent = Frame
ref.frame = Frame
automaticSize(Frame)
return Frame
end)
local frame = refs.frame
frame.UIListLayout.HorizontalAlignment = options.alignment or Enum.HorizontalAlignment.Left
Runtime.scope(fn)
end)