@quenty/iris 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -4
- package/LICENSE.md +2 -3
- package/README.md +2 -12
- package/package.json +7 -8
- package/src/Shared/Immediate/IrisImmediateInstall.lua +194 -0
- package/src/Shared/IrisUtils.lua +11 -0
- package/src/node_modules.project.json +1 -1
- package/test/default.project.json +1 -1
- package/src/Shared/Iris.lua +0 -702
- package/src/Shared/iris_API.lua +0 -231
- package/src/Shared/iris_Internal.lua +0 -923
- package/src/Shared/iris_PubTypes.lua +0 -44
- package/src/Shared/iris_Types.lua +0 -674
- package/src/Shared/iris_WidgetTypes.lua +0 -522
- package/src/Shared/iris_config.lua +0 -306
- package/src/Shared/iris_demoWindow.lua +0 -2148
- package/src/Shared/widgets/iris_Button.lua +0 -91
- package/src/Shared/widgets/iris_Checkbox.lua +0 -116
- package/src/Shared/widgets/iris_Combo.lua +0 -498
- package/src/Shared/widgets/iris_Format.lua +0 -141
- package/src/Shared/widgets/iris_Image.lua +0 -156
- package/src/Shared/widgets/iris_Input.lua +0 -1430
- package/src/Shared/widgets/iris_Menu.lua +0 -603
- package/src/Shared/widgets/iris_Plot.lua +0 -642
- package/src/Shared/widgets/iris_RadioButton.lua +0 -127
- package/src/Shared/widgets/iris_Root.lua +0 -148
- package/src/Shared/widgets/iris_Tab.lua +0 -334
- package/src/Shared/widgets/iris_Table.lua +0 -641
- package/src/Shared/widgets/iris_Text.lua +0 -133
- package/src/Shared/widgets/iris_Tree.lua +0 -291
- package/src/Shared/widgets/iris_Window.lua +0 -1158
- package/src/Shared/widgets/iris_widgets.lua +0 -487
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
--!nocheck
|
|
2
|
-
local Types = require(script.Parent.Parent.iris_Types)
|
|
3
|
-
|
|
4
|
-
return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
|
|
5
|
-
--stylua: ignore
|
|
6
|
-
Iris.WidgetConstructor("RadioButton", {
|
|
7
|
-
hasState = true,
|
|
8
|
-
hasChildren = false,
|
|
9
|
-
Args = {
|
|
10
|
-
["Text"] = 1,
|
|
11
|
-
["Index"] = 2,
|
|
12
|
-
},
|
|
13
|
-
Events = {
|
|
14
|
-
["selected"] = {
|
|
15
|
-
["Init"] = function(_thisWidget: Types.RadioButton) end,
|
|
16
|
-
["Get"] = function(thisWidget: Types.RadioButton)
|
|
17
|
-
return thisWidget.lastSelectedTick == Iris._cycleTick
|
|
18
|
-
end,
|
|
19
|
-
},
|
|
20
|
-
["unselected"] = {
|
|
21
|
-
["Init"] = function(_thisWidget: Types.RadioButton) end,
|
|
22
|
-
["Get"] = function(thisWidget: Types.RadioButton)
|
|
23
|
-
return thisWidget.lastUnselectedTick == Iris._cycleTick
|
|
24
|
-
end,
|
|
25
|
-
},
|
|
26
|
-
["active"] = {
|
|
27
|
-
["Init"] = function(_thisWidget: Types.RadioButton) end,
|
|
28
|
-
["Get"] = function(thisWidget: Types.RadioButton)
|
|
29
|
-
return thisWidget.state.index.value == thisWidget.arguments.Index
|
|
30
|
-
end,
|
|
31
|
-
},
|
|
32
|
-
["hovered"] = widgets.EVENTS.hover(function(thisWidget: Types.Widget)
|
|
33
|
-
return thisWidget.Instance
|
|
34
|
-
end),
|
|
35
|
-
},
|
|
36
|
-
Generate = function(thisWidget: Types.RadioButton)
|
|
37
|
-
local RadioButton = Instance.new("TextButton")
|
|
38
|
-
RadioButton.Name = "Iris_RadioButton"
|
|
39
|
-
RadioButton.AutomaticSize = Enum.AutomaticSize.XY
|
|
40
|
-
RadioButton.Size = UDim2.fromOffset(0, 0)
|
|
41
|
-
RadioButton.BackgroundTransparency = 1
|
|
42
|
-
RadioButton.BorderSizePixel = 0
|
|
43
|
-
RadioButton.Text = ""
|
|
44
|
-
RadioButton.AutoButtonColor = false
|
|
45
|
-
|
|
46
|
-
widgets.UIListLayout(RadioButton, Enum.FillDirection.Horizontal, UDim.new(0, Iris._config.ItemInnerSpacing.X)).VerticalAlignment = Enum.VerticalAlignment.Center
|
|
47
|
-
|
|
48
|
-
local buttonSize = Iris._config.TextSize + 2 * (Iris._config.FramePadding.Y - 1)
|
|
49
|
-
local Button = Instance.new("Frame")
|
|
50
|
-
Button.Name = "Button"
|
|
51
|
-
Button.Size = UDim2.fromOffset(buttonSize, buttonSize)
|
|
52
|
-
Button.BackgroundColor3 = Iris._config.FrameBgColor
|
|
53
|
-
Button.BackgroundTransparency = Iris._config.FrameBgTransparency
|
|
54
|
-
Button.Parent = RadioButton
|
|
55
|
-
|
|
56
|
-
widgets.UICorner(Button)
|
|
57
|
-
widgets.UIPadding(Button, Vector2.new(math.max(1, math.floor(buttonSize / 5)), math.max(1, math.floor(buttonSize / 5))))
|
|
58
|
-
|
|
59
|
-
local Circle = Instance.new("Frame")
|
|
60
|
-
Circle.Name = "Circle"
|
|
61
|
-
Circle.Size = UDim2.fromScale(1, 1)
|
|
62
|
-
Circle.BackgroundColor3 = Iris._config.CheckMarkColor
|
|
63
|
-
Circle.BackgroundTransparency = Iris._config.CheckMarkTransparency
|
|
64
|
-
widgets.UICorner(Circle)
|
|
65
|
-
|
|
66
|
-
Circle.Parent = Button
|
|
67
|
-
|
|
68
|
-
widgets.applyInteractionHighlights("Background", RadioButton, Button, {
|
|
69
|
-
Color = Iris._config.FrameBgColor,
|
|
70
|
-
Transparency = Iris._config.FrameBgTransparency,
|
|
71
|
-
HoveredColor = Iris._config.FrameBgHoveredColor,
|
|
72
|
-
HoveredTransparency = Iris._config.FrameBgHoveredTransparency,
|
|
73
|
-
ActiveColor = Iris._config.FrameBgActiveColor,
|
|
74
|
-
ActiveTransparency = Iris._config.FrameBgActiveTransparency,
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
widgets.applyButtonClick(RadioButton, function()
|
|
78
|
-
thisWidget.state.index:set(thisWidget.arguments.Index)
|
|
79
|
-
end)
|
|
80
|
-
|
|
81
|
-
local TextLabel = Instance.new("TextLabel")
|
|
82
|
-
TextLabel.Name = "TextLabel"
|
|
83
|
-
TextLabel.AutomaticSize = Enum.AutomaticSize.XY
|
|
84
|
-
TextLabel.BackgroundTransparency = 1
|
|
85
|
-
TextLabel.BorderSizePixel = 0
|
|
86
|
-
TextLabel.LayoutOrder = 1
|
|
87
|
-
|
|
88
|
-
widgets.applyTextStyle(TextLabel)
|
|
89
|
-
TextLabel.Parent = RadioButton
|
|
90
|
-
|
|
91
|
-
return RadioButton
|
|
92
|
-
end,
|
|
93
|
-
Update = function(thisWidget: Types.RadioButton)
|
|
94
|
-
local RadioButton = thisWidget.Instance :: TextButton
|
|
95
|
-
local TextLabel: TextLabel = RadioButton.TextLabel
|
|
96
|
-
|
|
97
|
-
TextLabel.Text = thisWidget.arguments.Text or "Radio Button"
|
|
98
|
-
if thisWidget.state then
|
|
99
|
-
thisWidget.state.index.lastChangeTick = Iris._cycleTick
|
|
100
|
-
Iris._widgets[thisWidget.type].UpdateState(thisWidget)
|
|
101
|
-
end
|
|
102
|
-
end,
|
|
103
|
-
Discard = function(thisWidget: Types.RadioButton)
|
|
104
|
-
thisWidget.Instance:Destroy()
|
|
105
|
-
widgets.discardState(thisWidget)
|
|
106
|
-
end,
|
|
107
|
-
GenerateState = function(thisWidget: Types.RadioButton)
|
|
108
|
-
if thisWidget.state.index == nil then
|
|
109
|
-
thisWidget.state.index = Iris._widgetState(thisWidget, "index", thisWidget.arguments.Index)
|
|
110
|
-
end
|
|
111
|
-
end,
|
|
112
|
-
UpdateState = function(thisWidget: Types.RadioButton)
|
|
113
|
-
local RadioButton = thisWidget.Instance :: TextButton
|
|
114
|
-
local Button = RadioButton.Button :: Frame
|
|
115
|
-
local Circle: Frame = Button.Circle
|
|
116
|
-
|
|
117
|
-
if thisWidget.state.index.value == thisWidget.arguments.Index then
|
|
118
|
-
-- only need to hide the circle
|
|
119
|
-
Circle.BackgroundTransparency = Iris._config.CheckMarkTransparency
|
|
120
|
-
thisWidget.lastSelectedTick = Iris._cycleTick + 1
|
|
121
|
-
else
|
|
122
|
-
Circle.BackgroundTransparency = 1
|
|
123
|
-
thisWidget.lastUnselectedTick = Iris._cycleTick + 1
|
|
124
|
-
end
|
|
125
|
-
end,
|
|
126
|
-
} :: Types.WidgetClass)
|
|
127
|
-
end
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
--!nocheck
|
|
2
|
-
local Types = require(script.Parent.Parent.iris_Types)
|
|
3
|
-
|
|
4
|
-
return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
|
|
5
|
-
local NumNonWindowChildren: number = 0
|
|
6
|
-
|
|
7
|
-
--stylua: ignore
|
|
8
|
-
Iris.WidgetConstructor("Root", {
|
|
9
|
-
hasState = false,
|
|
10
|
-
hasChildren = true,
|
|
11
|
-
Args = {},
|
|
12
|
-
Events = {},
|
|
13
|
-
Generate = function(_thisWidget: Types.Root)
|
|
14
|
-
local Root = Instance.new("Folder")
|
|
15
|
-
Root.Name = "Iris_Root"
|
|
16
|
-
|
|
17
|
-
local PseudoWindowScreenGui
|
|
18
|
-
if Iris._config.UseScreenGUIs then
|
|
19
|
-
PseudoWindowScreenGui = Instance.new("ScreenGui")
|
|
20
|
-
PseudoWindowScreenGui.ResetOnSpawn = false
|
|
21
|
-
PseudoWindowScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
|
22
|
-
PseudoWindowScreenGui.ScreenInsets = Iris._config.ScreenInsets
|
|
23
|
-
PseudoWindowScreenGui.IgnoreGuiInset = Iris._config.IgnoreGuiInset
|
|
24
|
-
PseudoWindowScreenGui.DisplayOrder = Iris._config.DisplayOrderOffset
|
|
25
|
-
else
|
|
26
|
-
PseudoWindowScreenGui = Instance.new("Frame")
|
|
27
|
-
PseudoWindowScreenGui.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
28
|
-
PseudoWindowScreenGui.Position = UDim2.fromScale(0.5, 0.5)
|
|
29
|
-
PseudoWindowScreenGui.Size = UDim2.fromScale(1, 1)
|
|
30
|
-
PseudoWindowScreenGui.BackgroundTransparency = 1
|
|
31
|
-
PseudoWindowScreenGui.ZIndex = Iris._config.DisplayOrderOffset
|
|
32
|
-
end
|
|
33
|
-
PseudoWindowScreenGui.Name = "PseudoWindowScreenGui"
|
|
34
|
-
PseudoWindowScreenGui.Parent = Root
|
|
35
|
-
|
|
36
|
-
local PopupScreenGui
|
|
37
|
-
if Iris._config.UseScreenGUIs then
|
|
38
|
-
PopupScreenGui = Instance.new("ScreenGui")
|
|
39
|
-
PopupScreenGui.ResetOnSpawn = false
|
|
40
|
-
PopupScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
|
41
|
-
PopupScreenGui.DisplayOrder = Iris._config.DisplayOrderOffset + 1024 -- room for 1024 regular windows before overlap
|
|
42
|
-
PopupScreenGui.ScreenInsets = Iris._config.ScreenInsets
|
|
43
|
-
PopupScreenGui.IgnoreGuiInset = Iris._config.IgnoreGuiInset
|
|
44
|
-
else
|
|
45
|
-
PopupScreenGui = Instance.new("Frame")
|
|
46
|
-
PopupScreenGui.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
47
|
-
PopupScreenGui.Position = UDim2.fromScale(0.5, 0.5)
|
|
48
|
-
PopupScreenGui.Size = UDim2.fromScale(1, 1)
|
|
49
|
-
PopupScreenGui.BackgroundTransparency = 1
|
|
50
|
-
PopupScreenGui.ZIndex = Iris._config.DisplayOrderOffset + 1024
|
|
51
|
-
end
|
|
52
|
-
PopupScreenGui.Name = "PopupScreenGui"
|
|
53
|
-
PopupScreenGui.Parent = Root
|
|
54
|
-
|
|
55
|
-
local TooltipContainer = Instance.new("Frame")
|
|
56
|
-
TooltipContainer.Name = "TooltipContainer"
|
|
57
|
-
TooltipContainer.AutomaticSize = Enum.AutomaticSize.XY
|
|
58
|
-
TooltipContainer.Size = UDim2.fromOffset(0, 0)
|
|
59
|
-
TooltipContainer.BackgroundTransparency = 1
|
|
60
|
-
TooltipContainer.BorderSizePixel = 0
|
|
61
|
-
|
|
62
|
-
widgets.UIListLayout(TooltipContainer, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.PopupBorderSize))
|
|
63
|
-
|
|
64
|
-
TooltipContainer.Parent = PopupScreenGui
|
|
65
|
-
|
|
66
|
-
local MenuBarContainer = Instance.new("Frame")
|
|
67
|
-
MenuBarContainer.Name = "MenuBarContainer"
|
|
68
|
-
MenuBarContainer.AutomaticSize = Enum.AutomaticSize.Y
|
|
69
|
-
MenuBarContainer.Size = UDim2.fromScale(1, 0)
|
|
70
|
-
MenuBarContainer.BackgroundTransparency = 1
|
|
71
|
-
MenuBarContainer.BorderSizePixel = 0
|
|
72
|
-
|
|
73
|
-
MenuBarContainer.Parent = PopupScreenGui
|
|
74
|
-
|
|
75
|
-
local PseudoWindow = Instance.new("Frame")
|
|
76
|
-
PseudoWindow.Name = "PseudoWindow"
|
|
77
|
-
PseudoWindow.AutomaticSize = Enum.AutomaticSize.XY
|
|
78
|
-
PseudoWindow.Size = UDim2.new(0, 0, 0, 0)
|
|
79
|
-
PseudoWindow.Position = UDim2.fromOffset(0, 22)
|
|
80
|
-
PseudoWindow.BackgroundTransparency = Iris._config.WindowBgTransparency
|
|
81
|
-
PseudoWindow.BackgroundColor3 = Iris._config.WindowBgColor
|
|
82
|
-
PseudoWindow.BorderSizePixel = Iris._config.WindowBorderSize
|
|
83
|
-
PseudoWindow.BorderColor3 = Iris._config.BorderColor
|
|
84
|
-
|
|
85
|
-
PseudoWindow.Selectable = false
|
|
86
|
-
PseudoWindow.SelectionGroup = true
|
|
87
|
-
PseudoWindow.SelectionBehaviorUp = Enum.SelectionBehavior.Stop
|
|
88
|
-
PseudoWindow.SelectionBehaviorDown = Enum.SelectionBehavior.Stop
|
|
89
|
-
PseudoWindow.SelectionBehaviorLeft = Enum.SelectionBehavior.Stop
|
|
90
|
-
PseudoWindow.SelectionBehaviorRight = Enum.SelectionBehavior.Stop
|
|
91
|
-
|
|
92
|
-
PseudoWindow.Visible = false
|
|
93
|
-
|
|
94
|
-
widgets.UIPadding(PseudoWindow, Iris._config.WindowPadding)
|
|
95
|
-
widgets.UIListLayout(PseudoWindow, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.ItemSpacing.Y))
|
|
96
|
-
|
|
97
|
-
PseudoWindow.Parent = PseudoWindowScreenGui
|
|
98
|
-
|
|
99
|
-
return Root
|
|
100
|
-
end,
|
|
101
|
-
Update = function(thisWidget: Types.Root)
|
|
102
|
-
if NumNonWindowChildren > 0 then
|
|
103
|
-
local Root = thisWidget.Instance :: any
|
|
104
|
-
local PseudoWindowScreenGui = Root.PseudoWindowScreenGui :: any
|
|
105
|
-
local PseudoWindow: Frame = PseudoWindowScreenGui.PseudoWindow
|
|
106
|
-
PseudoWindow.Visible = true
|
|
107
|
-
end
|
|
108
|
-
end,
|
|
109
|
-
Discard = function(thisWidget: Types.Root)
|
|
110
|
-
NumNonWindowChildren = 0
|
|
111
|
-
thisWidget.Instance:Destroy()
|
|
112
|
-
-- Clear so InputChanged tooltip relocate early-outs during ForceRefresh gap.
|
|
113
|
-
if Iris._rootInstance == thisWidget.Instance then
|
|
114
|
-
Iris._rootInstance = nil
|
|
115
|
-
end
|
|
116
|
-
end,
|
|
117
|
-
ChildAdded = function(thisWidget: Types.Root, thisChild: Types.Widget)
|
|
118
|
-
local Root = thisWidget.Instance :: any
|
|
119
|
-
|
|
120
|
-
if thisChild.type == "Window" then
|
|
121
|
-
return thisWidget.Instance
|
|
122
|
-
elseif thisChild.type == "Tooltip" then
|
|
123
|
-
return Root.PopupScreenGui.TooltipContainer
|
|
124
|
-
elseif thisChild.type == "MenuBar" then
|
|
125
|
-
return Root.PopupScreenGui.MenuBarContainer
|
|
126
|
-
else
|
|
127
|
-
local PseudoWindowScreenGui = Root.PseudoWindowScreenGui :: any
|
|
128
|
-
local PseudoWindow: Frame = PseudoWindowScreenGui.PseudoWindow
|
|
129
|
-
|
|
130
|
-
NumNonWindowChildren += 1
|
|
131
|
-
PseudoWindow.Visible = true
|
|
132
|
-
|
|
133
|
-
return PseudoWindow
|
|
134
|
-
end
|
|
135
|
-
end,
|
|
136
|
-
ChildDiscarded = function(thisWidget: Types.Root, thisChild: Types.Widget)
|
|
137
|
-
if thisChild.type ~= "Window" and thisChild.type ~= "Tooltip" and thisChild.type ~= "MenuBar" then
|
|
138
|
-
NumNonWindowChildren -= 1
|
|
139
|
-
if NumNonWindowChildren == 0 then
|
|
140
|
-
local Root = thisWidget.Instance :: any
|
|
141
|
-
local PseudoWindowScreenGui = Root.PseudoWindowScreenGui :: any
|
|
142
|
-
local PseudoWindow: Frame = PseudoWindowScreenGui.PseudoWindow
|
|
143
|
-
PseudoWindow.Visible = false
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end,
|
|
147
|
-
} :: Types.WidgetClass)
|
|
148
|
-
end
|
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
--!nocheck
|
|
2
|
-
local Types = require(script.Parent.Parent.iris_Types)
|
|
3
|
-
|
|
4
|
-
return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
|
|
5
|
-
local function openTab(TabBar: Types.TabBar, Index: number)
|
|
6
|
-
if TabBar.state.index.value > 0 then
|
|
7
|
-
return
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
TabBar.state.index:set(Index)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
local function closeTab(TabBar: Types.TabBar, Index: number)
|
|
14
|
-
if TabBar.state.index.value ~= Index then
|
|
15
|
-
return
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
-- search left for open tabs
|
|
19
|
-
for i = Index - 1, 1, -1 do
|
|
20
|
-
if TabBar.Tabs[i].state.isOpened.value == true then
|
|
21
|
-
TabBar.state.index:set(i)
|
|
22
|
-
return
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
-- search right for open tabs
|
|
27
|
-
for i = Index, #TabBar.Tabs do
|
|
28
|
-
if TabBar.Tabs[i].state.isOpened.value == true then
|
|
29
|
-
TabBar.state.index:set(i)
|
|
30
|
-
return
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
-- no open tabs, so wait for one
|
|
35
|
-
TabBar.state.index:set(0)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
--stylua: ignore
|
|
39
|
-
Iris.WidgetConstructor("TabBar", {
|
|
40
|
-
hasState = true,
|
|
41
|
-
hasChildren = true,
|
|
42
|
-
Args = {},
|
|
43
|
-
Events = {},
|
|
44
|
-
Generate = function(thisWidget: Types.TabBar)
|
|
45
|
-
local TabBar = Instance.new("Frame")
|
|
46
|
-
TabBar.Name = "Iris_TabBar"
|
|
47
|
-
TabBar.AutomaticSize = Enum.AutomaticSize.Y
|
|
48
|
-
TabBar.Size = UDim2.fromScale(1, 0)
|
|
49
|
-
TabBar.BackgroundTransparency = 1
|
|
50
|
-
TabBar.BorderSizePixel = 0
|
|
51
|
-
|
|
52
|
-
widgets.UIListLayout(TabBar, Enum.FillDirection.Vertical, UDim.new()).VerticalAlignment = Enum.VerticalAlignment.Bottom
|
|
53
|
-
|
|
54
|
-
local Bar = Instance.new("Frame")
|
|
55
|
-
Bar.Name = "Bar"
|
|
56
|
-
Bar.AutomaticSize = Enum.AutomaticSize.Y
|
|
57
|
-
Bar.Size = UDim2.fromScale(1, 0)
|
|
58
|
-
Bar.BackgroundTransparency = 1
|
|
59
|
-
Bar.BorderSizePixel = 0
|
|
60
|
-
|
|
61
|
-
widgets.UIListLayout(Bar, Enum.FillDirection.Horizontal, UDim.new(0, Iris._config.ItemInnerSpacing.X))
|
|
62
|
-
|
|
63
|
-
Bar.Parent = TabBar
|
|
64
|
-
|
|
65
|
-
local Underline = Instance.new("Frame")
|
|
66
|
-
Underline.Name = "Underline"
|
|
67
|
-
Underline.Size = UDim2.new(1, 0, 0, 1)
|
|
68
|
-
Underline.BackgroundColor3 = Iris._config.TabActiveColor
|
|
69
|
-
Underline.BackgroundTransparency = Iris._config.TabActiveTransparency
|
|
70
|
-
Underline.BorderSizePixel = 0
|
|
71
|
-
Underline.LayoutOrder = 1
|
|
72
|
-
|
|
73
|
-
Underline.Parent = TabBar
|
|
74
|
-
|
|
75
|
-
local ChildContainer = Instance.new("Frame")
|
|
76
|
-
ChildContainer.Name = "TabContainer"
|
|
77
|
-
ChildContainer.AutomaticSize = Enum.AutomaticSize.Y
|
|
78
|
-
ChildContainer.Size = UDim2.fromScale(1, 0)
|
|
79
|
-
ChildContainer.BackgroundTransparency = 1
|
|
80
|
-
ChildContainer.BorderSizePixel = 0
|
|
81
|
-
ChildContainer.LayoutOrder = 2
|
|
82
|
-
ChildContainer.ClipsDescendants = true
|
|
83
|
-
|
|
84
|
-
ChildContainer.Parent = TabBar
|
|
85
|
-
|
|
86
|
-
thisWidget.ChildContainer = ChildContainer
|
|
87
|
-
thisWidget.Tabs = {}
|
|
88
|
-
|
|
89
|
-
return TabBar
|
|
90
|
-
end,
|
|
91
|
-
Update = function(_thisWidget: Types.TabBar) end,
|
|
92
|
-
ChildAdded = function(thisWidget: Types.TabBar, thisChild: Types.Tab)
|
|
93
|
-
assert(thisChild.type == "Tab", "Only Iris.Tab can be parented to Iris.TabBar.")
|
|
94
|
-
local TabBar = thisWidget.Instance :: Frame
|
|
95
|
-
thisChild.ChildContainer.Parent = thisWidget.ChildContainer
|
|
96
|
-
thisChild.Index = #thisWidget.Tabs + 1
|
|
97
|
-
thisWidget.state.index.ConnectedWidgets[thisChild.ID] = thisChild
|
|
98
|
-
table.insert(thisWidget.Tabs, thisChild)
|
|
99
|
-
|
|
100
|
-
return TabBar.Bar
|
|
101
|
-
end,
|
|
102
|
-
ChildDiscarded = function(thisWidget: Types.TabBar, thisChild: Types.Tab)
|
|
103
|
-
local Index = thisChild.Index
|
|
104
|
-
table.remove(thisWidget.Tabs, Index)
|
|
105
|
-
|
|
106
|
-
for i = Index, #thisWidget.Tabs do
|
|
107
|
-
thisWidget.Tabs[i].Index = i
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
closeTab(thisWidget, Index)
|
|
111
|
-
end,
|
|
112
|
-
GenerateState = function(thisWidget: Types.Tab)
|
|
113
|
-
if thisWidget.state.index == nil then
|
|
114
|
-
thisWidget.state.index = Iris._widgetState(thisWidget, "index", 1)
|
|
115
|
-
end
|
|
116
|
-
end,
|
|
117
|
-
UpdateState = function(_thisWidget: Types.Tab)
|
|
118
|
-
end,
|
|
119
|
-
Discard = function(thisWidget: Types.TabBar)
|
|
120
|
-
thisWidget.Instance:Destroy()
|
|
121
|
-
end,
|
|
122
|
-
} :: Types.WidgetClass)
|
|
123
|
-
|
|
124
|
-
--stylua: ignore
|
|
125
|
-
Iris.WidgetConstructor("Tab", {
|
|
126
|
-
hasState = true,
|
|
127
|
-
hasChildren = true,
|
|
128
|
-
Args = {
|
|
129
|
-
["Text"] = 1,
|
|
130
|
-
["Hideable"] = 2,
|
|
131
|
-
},
|
|
132
|
-
Events = {
|
|
133
|
-
["clicked"] = widgets.EVENTS.click(function(thisWidget: Types.Widget)
|
|
134
|
-
return thisWidget.Instance
|
|
135
|
-
end),
|
|
136
|
-
["hovered"] = widgets.EVENTS.hover(function(thisWidget: Types.Widget)
|
|
137
|
-
return thisWidget.Instance
|
|
138
|
-
end),
|
|
139
|
-
["selected"] = {
|
|
140
|
-
["Init"] = function(_thisWidget: Types.Tab) end,
|
|
141
|
-
["Get"] = function(thisWidget: Types.Tab)
|
|
142
|
-
return thisWidget.lastSelectedTick == Iris._cycleTick
|
|
143
|
-
end,
|
|
144
|
-
},
|
|
145
|
-
["unselected"] = {
|
|
146
|
-
["Init"] = function(_thisWidget: Types.Tab) end,
|
|
147
|
-
["Get"] = function(thisWidget: Types.Tab)
|
|
148
|
-
return thisWidget.lastUnselectedTick == Iris._cycleTick
|
|
149
|
-
end,
|
|
150
|
-
},
|
|
151
|
-
["active"] = {
|
|
152
|
-
["Init"] = function(_thisWidget: Types.Tab) end,
|
|
153
|
-
["Get"] = function(thisWidget: Types.Tab)
|
|
154
|
-
return thisWidget.state.index.value == thisWidget.Index
|
|
155
|
-
end,
|
|
156
|
-
},
|
|
157
|
-
["opened"] = {
|
|
158
|
-
["Init"] = function(_thisWidget: Types.Tab) end,
|
|
159
|
-
["Get"] = function(thisWidget: Types.Tab)
|
|
160
|
-
return thisWidget.lastOpenedTick == Iris._cycleTick
|
|
161
|
-
end,
|
|
162
|
-
},
|
|
163
|
-
["closed"] = {
|
|
164
|
-
["Init"] = function(_thisWidget: Types.Tab) end,
|
|
165
|
-
["Get"] = function(thisWidget: Types.Tab)
|
|
166
|
-
return thisWidget.lastClosedTick == Iris._cycleTick
|
|
167
|
-
end,
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
Generate = function(thisWidget: Types.Tab)
|
|
171
|
-
local Tab = Instance.new("TextButton")
|
|
172
|
-
Tab.Name = "Iris_Tab"
|
|
173
|
-
Tab.AutomaticSize = Enum.AutomaticSize.XY
|
|
174
|
-
Tab.BackgroundColor3 = Iris._config.TabColor
|
|
175
|
-
Tab.BackgroundTransparency = Iris._config.TabTransparency
|
|
176
|
-
Tab.BorderSizePixel = 0
|
|
177
|
-
Tab.Text = ""
|
|
178
|
-
Tab.AutoButtonColor = false
|
|
179
|
-
|
|
180
|
-
thisWidget.ButtonColors = {
|
|
181
|
-
Color = Iris._config.TabColor,
|
|
182
|
-
Transparency = Iris._config.TabTransparency,
|
|
183
|
-
HoveredColor = Iris._config.TabHoveredColor,
|
|
184
|
-
HoveredTransparency = Iris._config.TabHoveredTransparency,
|
|
185
|
-
ActiveColor = Iris._config.TabActiveColor,
|
|
186
|
-
ActiveTransparency = Iris._config.TabActiveTransparency,
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
widgets.UIPadding(Tab, Vector2.new(Iris._config.FramePadding.X, 0))
|
|
190
|
-
widgets.applyFrameStyle(Tab, true, true)
|
|
191
|
-
widgets.UIListLayout(Tab, Enum.FillDirection.Horizontal, UDim.new(0, Iris._config.ItemInnerSpacing.X)).VerticalAlignment = Enum.VerticalAlignment.Center
|
|
192
|
-
widgets.applyInteractionHighlights("Background", Tab, Tab, thisWidget.ButtonColors)
|
|
193
|
-
widgets.applyButtonClick(Tab, function()
|
|
194
|
-
thisWidget.state.index:set(thisWidget.Index)
|
|
195
|
-
end)
|
|
196
|
-
|
|
197
|
-
local TextLabel = Instance.new("TextLabel")
|
|
198
|
-
TextLabel.Name = "TextLabel"
|
|
199
|
-
TextLabel.AutomaticSize = Enum.AutomaticSize.XY
|
|
200
|
-
TextLabel.BackgroundTransparency = 1
|
|
201
|
-
TextLabel.BorderSizePixel = 0
|
|
202
|
-
|
|
203
|
-
widgets.applyTextStyle(TextLabel)
|
|
204
|
-
widgets.UIPadding(TextLabel, Vector2.new(0, Iris._config.FramePadding.Y))
|
|
205
|
-
|
|
206
|
-
TextLabel.Parent = Tab
|
|
207
|
-
|
|
208
|
-
local ButtonSize = Iris._config.TextSize + ((Iris._config.FramePadding.Y - 1) * 2)
|
|
209
|
-
|
|
210
|
-
local CloseButton = Instance.new("TextButton")
|
|
211
|
-
CloseButton.Name = "CloseButton"
|
|
212
|
-
CloseButton.Size = UDim2.fromOffset(ButtonSize, ButtonSize)
|
|
213
|
-
CloseButton.BackgroundTransparency = 1
|
|
214
|
-
CloseButton.BorderSizePixel = 0
|
|
215
|
-
CloseButton.Text = ""
|
|
216
|
-
CloseButton.AutoButtonColor = false
|
|
217
|
-
CloseButton.LayoutOrder = 1
|
|
218
|
-
|
|
219
|
-
widgets.UICorner(CloseButton)
|
|
220
|
-
widgets.applyButtonClick(CloseButton, function()
|
|
221
|
-
thisWidget.state.isOpened:set(false)
|
|
222
|
-
closeTab(thisWidget.parentWidget, thisWidget.Index)
|
|
223
|
-
end)
|
|
224
|
-
|
|
225
|
-
widgets.applyInteractionHighlights("Background", CloseButton, CloseButton, {
|
|
226
|
-
Color = Iris._config.TabColor,
|
|
227
|
-
Transparency = 1,
|
|
228
|
-
HoveredColor = Iris._config.ButtonHoveredColor,
|
|
229
|
-
HoveredTransparency = Iris._config.ButtonHoveredTransparency,
|
|
230
|
-
ActiveColor = Iris._config.ButtonActiveColor,
|
|
231
|
-
ActiveTransparency = Iris._config.ButtonActiveTransparency,
|
|
232
|
-
})
|
|
233
|
-
|
|
234
|
-
CloseButton.Parent = Tab
|
|
235
|
-
|
|
236
|
-
local Icon = Instance.new("ImageLabel")
|
|
237
|
-
Icon.Name = "Icon"
|
|
238
|
-
Icon.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
239
|
-
Icon.Position = UDim2.fromScale(0.5, 0.5)
|
|
240
|
-
Icon.Size = UDim2.fromOffset(math.floor(0.7 * ButtonSize), math.floor(0.7 * ButtonSize))
|
|
241
|
-
Icon.BackgroundTransparency = 1
|
|
242
|
-
Icon.BorderSizePixel = 0
|
|
243
|
-
Icon.Image = widgets.ICONS.MULTIPLICATION_SIGN
|
|
244
|
-
Icon.ImageTransparency = 1
|
|
245
|
-
|
|
246
|
-
widgets.applyInteractionHighlights("Image", Tab, Icon, {
|
|
247
|
-
Color = Iris._config.TextColor,
|
|
248
|
-
Transparency = 1,
|
|
249
|
-
HoveredColor = Iris._config.TextColor,
|
|
250
|
-
HoveredTransparency = Iris._config.TextTransparency,
|
|
251
|
-
ActiveColor = Iris._config.TextColor,
|
|
252
|
-
ActiveTransparency = Iris._config.TextTransparency,
|
|
253
|
-
})
|
|
254
|
-
Icon.Parent = CloseButton
|
|
255
|
-
|
|
256
|
-
local ChildContainer = Instance.new("Frame")
|
|
257
|
-
ChildContainer.Name = "TabContainer"
|
|
258
|
-
ChildContainer.AutomaticSize = Enum.AutomaticSize.Y
|
|
259
|
-
ChildContainer.Size = UDim2.fromScale(1, 0)
|
|
260
|
-
ChildContainer.BackgroundTransparency = 1
|
|
261
|
-
ChildContainer.BorderSizePixel = 0
|
|
262
|
-
|
|
263
|
-
ChildContainer.ClipsDescendants = true
|
|
264
|
-
widgets.UIListLayout(ChildContainer, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.ItemSpacing.Y))
|
|
265
|
-
widgets.UIPadding(ChildContainer, Vector2.new(0, Iris._config.ItemSpacing.Y)).PaddingBottom = UDim.new()
|
|
266
|
-
|
|
267
|
-
thisWidget.ChildContainer = ChildContainer
|
|
268
|
-
|
|
269
|
-
return Tab
|
|
270
|
-
end,
|
|
271
|
-
Update = function(thisWidget: Types.Tab)
|
|
272
|
-
local Tab = thisWidget.Instance :: TextButton
|
|
273
|
-
local TextLabel: TextLabel = Tab.TextLabel
|
|
274
|
-
local CloseButton: TextButton = Tab.CloseButton
|
|
275
|
-
|
|
276
|
-
TextLabel.Text = thisWidget.arguments.Text
|
|
277
|
-
CloseButton.Visible = if thisWidget.arguments.Hideable == true then true else false
|
|
278
|
-
end,
|
|
279
|
-
ChildAdded = function(thisWidget: Types.Tab, _thisChild: Types.Widget)
|
|
280
|
-
return thisWidget.ChildContainer
|
|
281
|
-
end,
|
|
282
|
-
GenerateState = function(thisWidget: Types.Tab)
|
|
283
|
-
thisWidget.state.index = thisWidget.parentWidget.state.index
|
|
284
|
-
thisWidget.state.index.ConnectedWidgets[thisWidget.ID] = thisWidget
|
|
285
|
-
|
|
286
|
-
if thisWidget.state.isOpened == nil then
|
|
287
|
-
thisWidget.state.isOpened = Iris._widgetState(thisWidget, "isOpened", true)
|
|
288
|
-
end
|
|
289
|
-
end,
|
|
290
|
-
UpdateState = function(thisWidget: Types.Tab)
|
|
291
|
-
local Tab = thisWidget.Instance :: TextButton
|
|
292
|
-
local Container = thisWidget.ChildContainer :: Frame
|
|
293
|
-
|
|
294
|
-
if thisWidget.state.isOpened.lastChangeTick == Iris._cycleTick then
|
|
295
|
-
if thisWidget.state.isOpened.value == true then
|
|
296
|
-
thisWidget.lastOpenedTick = Iris._cycleTick + 1
|
|
297
|
-
openTab(thisWidget.parentWidget, thisWidget.Index)
|
|
298
|
-
Tab.Visible = true
|
|
299
|
-
else
|
|
300
|
-
thisWidget.lastClosedTick = Iris._cycleTick + 1
|
|
301
|
-
closeTab(thisWidget.parentWidget, thisWidget.Index)
|
|
302
|
-
Tab.Visible = false
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
|
|
306
|
-
if thisWidget.state.index.lastChangeTick == Iris._cycleTick then
|
|
307
|
-
if thisWidget.state.index.value == thisWidget.Index then
|
|
308
|
-
thisWidget.ButtonColors.Color = Iris._config.TabActiveColor
|
|
309
|
-
thisWidget.ButtonColors.Transparency = Iris._config.TabActiveTransparency
|
|
310
|
-
Tab.BackgroundColor3 = Iris._config.TabActiveColor
|
|
311
|
-
Tab.BackgroundTransparency = Iris._config.TabActiveTransparency
|
|
312
|
-
Container.Visible = true
|
|
313
|
-
thisWidget.lastSelectedTick = Iris._cycleTick + 1
|
|
314
|
-
else
|
|
315
|
-
thisWidget.ButtonColors.Color = Iris._config.TabColor
|
|
316
|
-
thisWidget.ButtonColors.Transparency = Iris._config.TabTransparency
|
|
317
|
-
Tab.BackgroundColor3 = Iris._config.TabColor
|
|
318
|
-
Tab.BackgroundTransparency = Iris._config.TabTransparency
|
|
319
|
-
Container.Visible = false
|
|
320
|
-
thisWidget.lastUnselectedTick = Iris._cycleTick + 1
|
|
321
|
-
end
|
|
322
|
-
end
|
|
323
|
-
end,
|
|
324
|
-
Discard = function(thisWidget: Types.Tab)
|
|
325
|
-
if thisWidget.state.isOpened.value == true then
|
|
326
|
-
closeTab(thisWidget.parentWidget, thisWidget.Index)
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
thisWidget.Instance:Destroy()
|
|
330
|
-
thisWidget.ChildContainer:Destroy()
|
|
331
|
-
widgets.discardState(thisWidget)
|
|
332
|
-
end
|
|
333
|
-
} :: Types.WidgetClass)
|
|
334
|
-
end
|