@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,498 +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("Selectable", {
|
|
7
|
-
hasState = true,
|
|
8
|
-
hasChildren = false,
|
|
9
|
-
Args = {
|
|
10
|
-
["Text"] = 1,
|
|
11
|
-
["Index"] = 2,
|
|
12
|
-
["NoClick"] = 3,
|
|
13
|
-
},
|
|
14
|
-
Events = {
|
|
15
|
-
["selected"] = {
|
|
16
|
-
["Init"] = function(_thisWidget: Types.Selectable) end,
|
|
17
|
-
["Get"] = function(thisWidget: Types.Selectable)
|
|
18
|
-
return thisWidget.lastSelectedTick == Iris._cycleTick
|
|
19
|
-
end,
|
|
20
|
-
},
|
|
21
|
-
["unselected"] = {
|
|
22
|
-
["Init"] = function(_thisWidget: Types.Selectable) end,
|
|
23
|
-
["Get"] = function(thisWidget: Types.Selectable)
|
|
24
|
-
return thisWidget.lastUnselectedTick == Iris._cycleTick
|
|
25
|
-
end,
|
|
26
|
-
},
|
|
27
|
-
["active"] = {
|
|
28
|
-
["Init"] = function(_thisWidget: Types.Selectable) end,
|
|
29
|
-
["Get"] = function(thisWidget: Types.Selectable)
|
|
30
|
-
return thisWidget.state.index.value == thisWidget.arguments.Index
|
|
31
|
-
end,
|
|
32
|
-
},
|
|
33
|
-
["clicked"] = widgets.EVENTS.click(function(thisWidget: Types.Widget)
|
|
34
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
35
|
-
return Selectable.SelectableButton
|
|
36
|
-
end),
|
|
37
|
-
["rightClicked"] = widgets.EVENTS.rightClick(function(thisWidget: Types.Widget)
|
|
38
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
39
|
-
return Selectable.SelectableButton
|
|
40
|
-
end),
|
|
41
|
-
["doubleClicked"] = widgets.EVENTS.doubleClick(function(thisWidget: Types.Widget)
|
|
42
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
43
|
-
return Selectable.SelectableButton
|
|
44
|
-
end),
|
|
45
|
-
["ctrlClicked"] = widgets.EVENTS.ctrlClick(function(thisWidget: Types.Widget)
|
|
46
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
47
|
-
return Selectable.SelectableButton
|
|
48
|
-
end),
|
|
49
|
-
["hovered"] = widgets.EVENTS.hover(function(thisWidget: Types.Widget)
|
|
50
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
51
|
-
return Selectable.SelectableButton
|
|
52
|
-
end),
|
|
53
|
-
},
|
|
54
|
-
Generate = function(thisWidget: Types.Selectable)
|
|
55
|
-
local Selectable = Instance.new("Frame")
|
|
56
|
-
Selectable.Name = "Iris_Selectable"
|
|
57
|
-
Selectable.Size = UDim2.new(Iris._config.ItemWidth, UDim.new(0, Iris._config.TextSize + 2 * Iris._config.FramePadding.Y - Iris._config.ItemSpacing.Y))
|
|
58
|
-
Selectable.BackgroundTransparency = 1
|
|
59
|
-
Selectable.BorderSizePixel = 0
|
|
60
|
-
|
|
61
|
-
local SelectableButton = Instance.new("TextButton")
|
|
62
|
-
SelectableButton.Name = "SelectableButton"
|
|
63
|
-
SelectableButton.Size = UDim2.new(1, 0, 0, Iris._config.TextSize + 2 * Iris._config.FramePadding.Y)
|
|
64
|
-
SelectableButton.Position = UDim2.fromOffset(0, -bit32.rshift(Iris._config.ItemSpacing.Y, 1)) -- divide by 2
|
|
65
|
-
SelectableButton.BackgroundColor3 = Iris._config.HeaderColor
|
|
66
|
-
SelectableButton.ClipsDescendants = true
|
|
67
|
-
|
|
68
|
-
widgets.applyFrameStyle(SelectableButton)
|
|
69
|
-
widgets.applyTextStyle(SelectableButton)
|
|
70
|
-
widgets.UISizeConstraint(SelectableButton, Vector2.xAxis)
|
|
71
|
-
|
|
72
|
-
thisWidget.ButtonColors = {
|
|
73
|
-
Color = Iris._config.HeaderColor,
|
|
74
|
-
Transparency = 1,
|
|
75
|
-
HoveredColor = Iris._config.HeaderHoveredColor,
|
|
76
|
-
HoveredTransparency = Iris._config.HeaderHoveredTransparency,
|
|
77
|
-
ActiveColor = Iris._config.HeaderActiveColor,
|
|
78
|
-
ActiveTransparency = Iris._config.HeaderActiveTransparency,
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
widgets.applyInteractionHighlights("Background", SelectableButton, SelectableButton, thisWidget.ButtonColors)
|
|
82
|
-
|
|
83
|
-
widgets.applyButtonClick(SelectableButton, function()
|
|
84
|
-
if thisWidget.arguments.NoClick ~= true then
|
|
85
|
-
if type(thisWidget.state.index.value) == "boolean" then
|
|
86
|
-
thisWidget.state.index:set(not thisWidget.state.index.value)
|
|
87
|
-
else
|
|
88
|
-
thisWidget.state.index:set(thisWidget.arguments.Index)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end)
|
|
92
|
-
|
|
93
|
-
SelectableButton.Parent = Selectable
|
|
94
|
-
|
|
95
|
-
return Selectable
|
|
96
|
-
end,
|
|
97
|
-
GenerateState = function(thisWidget: Types.Selectable)
|
|
98
|
-
if thisWidget.state.index == nil then
|
|
99
|
-
if thisWidget.arguments.Index ~= nil then
|
|
100
|
-
error("A shared state index is required for Iris.Selectables() with an Index argument.", 5)
|
|
101
|
-
end
|
|
102
|
-
thisWidget.state.index = Iris._widgetState(thisWidget, "index", false)
|
|
103
|
-
end
|
|
104
|
-
end,
|
|
105
|
-
Update = function(thisWidget: Types.Selectable)
|
|
106
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
107
|
-
local SelectableButton: TextButton = Selectable.SelectableButton
|
|
108
|
-
SelectableButton.Text = thisWidget.arguments.Text or "Selectable"
|
|
109
|
-
end,
|
|
110
|
-
UpdateState = function(thisWidget: Types.Selectable)
|
|
111
|
-
local Selectable = thisWidget.Instance :: Frame
|
|
112
|
-
local SelectableButton: TextButton = Selectable.SelectableButton
|
|
113
|
-
|
|
114
|
-
if thisWidget.state.index.value == thisWidget.arguments.Index or thisWidget.state.index.value == true then
|
|
115
|
-
thisWidget.ButtonColors.Transparency = Iris._config.HeaderTransparency
|
|
116
|
-
SelectableButton.BackgroundTransparency = Iris._config.HeaderTransparency
|
|
117
|
-
thisWidget.lastSelectedTick = Iris._cycleTick + 1
|
|
118
|
-
else
|
|
119
|
-
thisWidget.ButtonColors.Transparency = 1
|
|
120
|
-
SelectableButton.BackgroundTransparency = 1
|
|
121
|
-
thisWidget.lastUnselectedTick = Iris._cycleTick + 1
|
|
122
|
-
end
|
|
123
|
-
end,
|
|
124
|
-
Discard = function(thisWidget: Types.Selectable)
|
|
125
|
-
thisWidget.Instance:Destroy()
|
|
126
|
-
widgets.discardState(thisWidget)
|
|
127
|
-
end,
|
|
128
|
-
} :: Types.WidgetClass)
|
|
129
|
-
|
|
130
|
-
local AnyOpenedCombo = false
|
|
131
|
-
local ComboOpenedTick = -1
|
|
132
|
-
local OpenedCombo: Types.Combo? = nil
|
|
133
|
-
local CachedContentSize = 0
|
|
134
|
-
|
|
135
|
-
local function UpdateChildContainerTransform(thisWidget: Types.Combo)
|
|
136
|
-
local Combo = thisWidget.Instance :: Frame
|
|
137
|
-
local PreviewContainer = Combo.PreviewContainer :: TextButton
|
|
138
|
-
local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame
|
|
139
|
-
|
|
140
|
-
local previewPosition = PreviewContainer.AbsolutePosition - widgets.GuiOffset
|
|
141
|
-
local previewSize = PreviewContainer.AbsoluteSize
|
|
142
|
-
local borderSize = Iris._config.PopupBorderSize
|
|
143
|
-
local screenSize: Vector2 = ChildContainer.Parent.AbsoluteSize
|
|
144
|
-
|
|
145
|
-
local absoluteContentSize = thisWidget.UIListLayout.AbsoluteContentSize.Y
|
|
146
|
-
CachedContentSize = absoluteContentSize
|
|
147
|
-
|
|
148
|
-
local contentsSize = absoluteContentSize + 2 * Iris._config.WindowPadding.Y
|
|
149
|
-
|
|
150
|
-
local x = previewPosition.X
|
|
151
|
-
local y = previewPosition.Y + previewSize.Y + borderSize
|
|
152
|
-
local anchor = Vector2.zero
|
|
153
|
-
local distanceToScreen = screenSize.Y - y
|
|
154
|
-
|
|
155
|
-
-- Only extend upwards if we cannot fully extend downwards, and we are on the bottom half of the screen.
|
|
156
|
-
-- i.e. there is more space upwards than there is downwards.
|
|
157
|
-
if contentsSize > distanceToScreen and y > (screenSize.Y / 2) then
|
|
158
|
-
y = previewPosition.Y - borderSize
|
|
159
|
-
anchor = Vector2.yAxis
|
|
160
|
-
distanceToScreen = y -- from 0 to the current position
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
ChildContainer.AnchorPoint = anchor
|
|
164
|
-
ChildContainer.Position = UDim2.fromOffset(x, y)
|
|
165
|
-
|
|
166
|
-
local height = math.min(contentsSize, distanceToScreen)
|
|
167
|
-
ChildContainer.Size = UDim2.fromOffset(PreviewContainer.AbsoluteSize.X, height)
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
table.insert(Iris._postCycleCallbacks, function()
|
|
171
|
-
if AnyOpenedCombo and OpenedCombo then
|
|
172
|
-
local contentSize = OpenedCombo.UIListLayout.AbsoluteContentSize.Y
|
|
173
|
-
if contentSize ~= CachedContentSize then
|
|
174
|
-
UpdateChildContainerTransform(OpenedCombo)
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
end)
|
|
178
|
-
|
|
179
|
-
local function UpdateComboState(input: InputObject)
|
|
180
|
-
if not Iris._started then
|
|
181
|
-
return
|
|
182
|
-
end
|
|
183
|
-
if
|
|
184
|
-
input.UserInputType ~= Enum.UserInputType.MouseButton1
|
|
185
|
-
and input.UserInputType ~= Enum.UserInputType.MouseButton2
|
|
186
|
-
and input.UserInputType ~= Enum.UserInputType.Touch
|
|
187
|
-
and input.UserInputType ~= Enum.UserInputType.MouseWheel
|
|
188
|
-
then
|
|
189
|
-
return
|
|
190
|
-
end
|
|
191
|
-
if AnyOpenedCombo == false or not OpenedCombo then
|
|
192
|
-
return
|
|
193
|
-
end
|
|
194
|
-
if ComboOpenedTick == Iris._cycleTick then
|
|
195
|
-
return
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
local MouseLocation = widgets.getMouseLocation()
|
|
199
|
-
local Combo = OpenedCombo.Instance :: Frame
|
|
200
|
-
local PreviewContainer: TextButton = Combo.PreviewContainer
|
|
201
|
-
local ChildContainer = OpenedCombo.ChildContainer
|
|
202
|
-
local rectMin = PreviewContainer.AbsolutePosition - widgets.GuiOffset
|
|
203
|
-
local rectMax = PreviewContainer.AbsolutePosition - widgets.GuiOffset + PreviewContainer.AbsoluteSize
|
|
204
|
-
if widgets.isPosInsideRect(MouseLocation, rectMin, rectMax) then
|
|
205
|
-
return
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
rectMin = ChildContainer.AbsolutePosition - widgets.GuiOffset
|
|
209
|
-
rectMax = ChildContainer.AbsolutePosition - widgets.GuiOffset + ChildContainer.AbsoluteSize
|
|
210
|
-
if widgets.isPosInsideRect(MouseLocation, rectMin, rectMax) then
|
|
211
|
-
return
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
OpenedCombo.state.isOpened:set(false)
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
widgets.registerEvent("InputBegan", UpdateComboState)
|
|
218
|
-
|
|
219
|
-
widgets.registerEvent("InputChanged", UpdateComboState)
|
|
220
|
-
|
|
221
|
-
--stylua: ignore
|
|
222
|
-
Iris.WidgetConstructor("Combo", {
|
|
223
|
-
hasState = true,
|
|
224
|
-
hasChildren = true,
|
|
225
|
-
Args = {
|
|
226
|
-
["Text"] = 1,
|
|
227
|
-
["NoButton"] = 2,
|
|
228
|
-
["NoPreview"] = 3,
|
|
229
|
-
},
|
|
230
|
-
Events = {
|
|
231
|
-
["opened"] = {
|
|
232
|
-
["Init"] = function(_thisWidget: Types.Combo) end,
|
|
233
|
-
["Get"] = function(thisWidget: Types.Combo)
|
|
234
|
-
return thisWidget.lastOpenedTick == Iris._cycleTick
|
|
235
|
-
end,
|
|
236
|
-
},
|
|
237
|
-
["closed"] = {
|
|
238
|
-
["Init"] = function(_thisWidget: Types.Combo) end,
|
|
239
|
-
["Get"] = function(thisWidget: Types.Combo)
|
|
240
|
-
return thisWidget.lastClosedTick == Iris._cycleTick
|
|
241
|
-
end,
|
|
242
|
-
},
|
|
243
|
-
["changed"] = {
|
|
244
|
-
["Init"] = function(_thisWidget: Types.Combo) end,
|
|
245
|
-
["Get"] = function(thisWidget: Types.Combo)
|
|
246
|
-
return thisWidget.lastChangedTick == Iris._cycleTick
|
|
247
|
-
end,
|
|
248
|
-
},
|
|
249
|
-
["clicked"] = widgets.EVENTS.click(function(thisWidget: Types.Widget)
|
|
250
|
-
local Combo = thisWidget.Instance :: Frame
|
|
251
|
-
return Combo.PreviewContainer
|
|
252
|
-
end),
|
|
253
|
-
["hovered"] = widgets.EVENTS.hover(function(thisWidget: Types.Widget)
|
|
254
|
-
return thisWidget.Instance
|
|
255
|
-
end),
|
|
256
|
-
},
|
|
257
|
-
Generate = function(thisWidget: Types.Combo)
|
|
258
|
-
local frameHeight = Iris._config.TextSize + 2 * Iris._config.FramePadding.Y
|
|
259
|
-
|
|
260
|
-
local Combo = Instance.new("Frame")
|
|
261
|
-
Combo.Name = "Iris_Combo"
|
|
262
|
-
Combo.AutomaticSize = Enum.AutomaticSize.Y
|
|
263
|
-
Combo.Size = UDim2.new(Iris._config.ItemWidth, UDim.new())
|
|
264
|
-
Combo.BackgroundTransparency = 1
|
|
265
|
-
Combo.BorderSizePixel = 0
|
|
266
|
-
|
|
267
|
-
widgets.UIListLayout(Combo, Enum.FillDirection.Horizontal, UDim.new(0, Iris._config.ItemInnerSpacing.X)).VerticalAlignment = Enum.VerticalAlignment.Center
|
|
268
|
-
|
|
269
|
-
local PreviewContainer = Instance.new("TextButton")
|
|
270
|
-
PreviewContainer.Name = "PreviewContainer"
|
|
271
|
-
PreviewContainer.AutomaticSize = Enum.AutomaticSize.Y
|
|
272
|
-
PreviewContainer.Size = UDim2.new(Iris._config.ContentWidth, UDim.new(0, 0))
|
|
273
|
-
PreviewContainer.BackgroundTransparency = 1
|
|
274
|
-
PreviewContainer.Text = ""
|
|
275
|
-
PreviewContainer.AutoButtonColor = false
|
|
276
|
-
PreviewContainer.ZIndex = 2
|
|
277
|
-
|
|
278
|
-
widgets.applyFrameStyle(PreviewContainer, true)
|
|
279
|
-
widgets.UIListLayout(PreviewContainer, Enum.FillDirection.Horizontal, UDim.new(0, 0))
|
|
280
|
-
widgets.UISizeConstraint(PreviewContainer, Vector2.new(frameHeight))
|
|
281
|
-
|
|
282
|
-
PreviewContainer.Parent = Combo
|
|
283
|
-
|
|
284
|
-
local PreviewLabel = Instance.new("TextLabel")
|
|
285
|
-
PreviewLabel.Name = "PreviewLabel"
|
|
286
|
-
PreviewLabel.AutomaticSize = Enum.AutomaticSize.Y
|
|
287
|
-
PreviewLabel.Size = UDim2.new(UDim.new(1, 0), Iris._config.ContentHeight)
|
|
288
|
-
PreviewLabel.BackgroundColor3 = Iris._config.FrameBgColor
|
|
289
|
-
PreviewLabel.BackgroundTransparency = Iris._config.FrameBgTransparency
|
|
290
|
-
PreviewLabel.BorderSizePixel = 0
|
|
291
|
-
PreviewLabel.ClipsDescendants = true
|
|
292
|
-
|
|
293
|
-
widgets.applyTextStyle(PreviewLabel)
|
|
294
|
-
widgets.UIPadding(PreviewLabel, Iris._config.FramePadding)
|
|
295
|
-
|
|
296
|
-
PreviewLabel.Parent = PreviewContainer
|
|
297
|
-
|
|
298
|
-
local DropdownButton = Instance.new("TextLabel")
|
|
299
|
-
DropdownButton.Name = "DropdownButton"
|
|
300
|
-
DropdownButton.Size = UDim2.new(0, frameHeight, Iris._config.ContentHeight.Scale, math.max(Iris._config.ContentHeight.Offset, frameHeight))
|
|
301
|
-
DropdownButton.BackgroundColor3 = Iris._config.ButtonColor
|
|
302
|
-
DropdownButton.BackgroundTransparency = Iris._config.ButtonTransparency
|
|
303
|
-
DropdownButton.BorderSizePixel = 0
|
|
304
|
-
DropdownButton.Text = ""
|
|
305
|
-
|
|
306
|
-
local padding = math.round(frameHeight * 0.2)
|
|
307
|
-
local dropdownSize = frameHeight - 2 * padding
|
|
308
|
-
|
|
309
|
-
local Dropdown = Instance.new("ImageLabel")
|
|
310
|
-
Dropdown.Name = "Dropdown"
|
|
311
|
-
Dropdown.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
312
|
-
Dropdown.Size = UDim2.fromOffset(dropdownSize, dropdownSize)
|
|
313
|
-
Dropdown.Position = UDim2.fromScale(0.5, 0.5)
|
|
314
|
-
Dropdown.BackgroundTransparency = 1
|
|
315
|
-
Dropdown.BorderSizePixel = 0
|
|
316
|
-
Dropdown.ImageColor3 = Iris._config.TextColor
|
|
317
|
-
Dropdown.ImageTransparency = Iris._config.TextTransparency
|
|
318
|
-
|
|
319
|
-
Dropdown.Parent = DropdownButton
|
|
320
|
-
|
|
321
|
-
DropdownButton.Parent = PreviewContainer
|
|
322
|
-
|
|
323
|
-
-- for some reason ImGui Combo has no highlights for Active, only hovered.
|
|
324
|
-
-- so this deviates from ImGui, but its a good UX change
|
|
325
|
-
widgets.applyInteractionHighlightsWithMultiHighlightee("Background", PreviewContainer, {
|
|
326
|
-
{
|
|
327
|
-
PreviewLabel,
|
|
328
|
-
{
|
|
329
|
-
Color = Iris._config.FrameBgColor,
|
|
330
|
-
Transparency = Iris._config.FrameBgTransparency,
|
|
331
|
-
HoveredColor = Iris._config.FrameBgHoveredColor,
|
|
332
|
-
HoveredTransparency = Iris._config.FrameBgHoveredTransparency,
|
|
333
|
-
ActiveColor = Iris._config.FrameBgActiveColor,
|
|
334
|
-
ActiveTransparency = Iris._config.FrameBgActiveTransparency,
|
|
335
|
-
},
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
DropdownButton,
|
|
339
|
-
{
|
|
340
|
-
Color = Iris._config.ButtonColor,
|
|
341
|
-
Transparency = Iris._config.ButtonTransparency,
|
|
342
|
-
HoveredColor = Iris._config.ButtonHoveredColor,
|
|
343
|
-
HoveredTransparency = Iris._config.ButtonHoveredTransparency,
|
|
344
|
-
-- Use hovered for active
|
|
345
|
-
ActiveColor = Iris._config.ButtonHoveredColor,
|
|
346
|
-
ActiveTransparency = Iris._config.ButtonHoveredTransparency,
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
widgets.applyButtonClick(PreviewContainer, function()
|
|
352
|
-
if AnyOpenedCombo and OpenedCombo ~= thisWidget then
|
|
353
|
-
return
|
|
354
|
-
end
|
|
355
|
-
thisWidget.state.isOpened:set(not thisWidget.state.isOpened.value)
|
|
356
|
-
end)
|
|
357
|
-
|
|
358
|
-
local TextLabel = Instance.new("TextLabel")
|
|
359
|
-
TextLabel.Name = "TextLabel"
|
|
360
|
-
TextLabel.AutomaticSize = Enum.AutomaticSize.X
|
|
361
|
-
TextLabel.Size = UDim2.fromOffset(0, frameHeight)
|
|
362
|
-
TextLabel.BackgroundTransparency = 1
|
|
363
|
-
TextLabel.BorderSizePixel = 0
|
|
364
|
-
|
|
365
|
-
widgets.applyTextStyle(TextLabel)
|
|
366
|
-
|
|
367
|
-
TextLabel.Parent = Combo
|
|
368
|
-
|
|
369
|
-
local ChildContainer = Instance.new("ScrollingFrame")
|
|
370
|
-
ChildContainer.Name = "ComboContainer"
|
|
371
|
-
ChildContainer.BackgroundColor3 = Iris._config.PopupBgColor
|
|
372
|
-
ChildContainer.BackgroundTransparency = Iris._config.PopupBgTransparency
|
|
373
|
-
ChildContainer.BorderSizePixel = 0
|
|
374
|
-
|
|
375
|
-
ChildContainer.AutomaticCanvasSize = Enum.AutomaticSize.Y
|
|
376
|
-
ChildContainer.ScrollBarImageTransparency = Iris._config.ScrollbarGrabTransparency
|
|
377
|
-
ChildContainer.ScrollBarImageColor3 = Iris._config.ScrollbarGrabColor
|
|
378
|
-
ChildContainer.ScrollBarThickness = Iris._config.ScrollbarSize
|
|
379
|
-
ChildContainer.CanvasSize = UDim2.fromScale(0, 0)
|
|
380
|
-
ChildContainer.VerticalScrollBarInset = Enum.ScrollBarInset.ScrollBar
|
|
381
|
-
ChildContainer.TopImage = widgets.ICONS.BLANK_SQUARE
|
|
382
|
-
ChildContainer.MidImage = widgets.ICONS.BLANK_SQUARE
|
|
383
|
-
ChildContainer.BottomImage = widgets.ICONS.BLANK_SQUARE
|
|
384
|
-
|
|
385
|
-
-- appear over everything else
|
|
386
|
-
ChildContainer.ClipsDescendants = true
|
|
387
|
-
|
|
388
|
-
-- Unfortunatley, ScrollingFrame does not work with UICorner
|
|
389
|
-
-- if Iris._config.PopupRounding > 0 then
|
|
390
|
-
-- widgets.UICorner(ChildContainer, Iris._config.PopupRounding)
|
|
391
|
-
-- end
|
|
392
|
-
|
|
393
|
-
widgets.UIStroke(ChildContainer, Iris._config.WindowBorderSize, Iris._config.BorderColor, Iris._config.BorderTransparency)
|
|
394
|
-
widgets.UIPadding(ChildContainer, Vector2.new(2, Iris._config.WindowPadding.Y))
|
|
395
|
-
widgets.UISizeConstraint(ChildContainer, Vector2.new(100))
|
|
396
|
-
|
|
397
|
-
local ChildContainerUIListLayout = widgets.UIListLayout(ChildContainer, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.ItemSpacing.Y))
|
|
398
|
-
ChildContainerUIListLayout.VerticalAlignment = Enum.VerticalAlignment.Top
|
|
399
|
-
|
|
400
|
-
local RootPopupScreenGui = Iris._rootInstance and Iris._rootInstance:WaitForChild("PopupScreenGui") :: GuiObject
|
|
401
|
-
ChildContainer.Parent = RootPopupScreenGui
|
|
402
|
-
|
|
403
|
-
thisWidget.ChildContainer = ChildContainer
|
|
404
|
-
thisWidget.UIListLayout = ChildContainerUIListLayout
|
|
405
|
-
return Combo
|
|
406
|
-
end,
|
|
407
|
-
GenerateState = function(thisWidget: Types.Combo)
|
|
408
|
-
if thisWidget.state.index == nil then
|
|
409
|
-
thisWidget.state.index = Iris._widgetState(thisWidget, "index", "No Selection")
|
|
410
|
-
end
|
|
411
|
-
if thisWidget.state.isOpened == nil then
|
|
412
|
-
thisWidget.state.isOpened = Iris._widgetState(thisWidget, "isOpened", false)
|
|
413
|
-
end
|
|
414
|
-
|
|
415
|
-
thisWidget.state.index:onChange(function()
|
|
416
|
-
thisWidget.lastChangedTick = Iris._cycleTick + 1
|
|
417
|
-
if thisWidget.state.isOpened.value then
|
|
418
|
-
thisWidget.state.isOpened:set(false)
|
|
419
|
-
end
|
|
420
|
-
end)
|
|
421
|
-
end,
|
|
422
|
-
Update = function(thisWidget: Types.Combo)
|
|
423
|
-
local Iris_Combo = thisWidget.Instance :: Frame
|
|
424
|
-
local PreviewContainer = Iris_Combo.PreviewContainer :: TextButton
|
|
425
|
-
local PreviewLabel: TextLabel = PreviewContainer.PreviewLabel
|
|
426
|
-
local DropdownButton: TextLabel = PreviewContainer.DropdownButton
|
|
427
|
-
local TextLabel: TextLabel = Iris_Combo.TextLabel
|
|
428
|
-
|
|
429
|
-
TextLabel.Text = thisWidget.arguments.Text or "Combo"
|
|
430
|
-
|
|
431
|
-
if thisWidget.arguments.NoButton then
|
|
432
|
-
DropdownButton.Visible = false
|
|
433
|
-
PreviewLabel.Size = UDim2.new(UDim.new(1, 0), PreviewLabel.Size.Height)
|
|
434
|
-
else
|
|
435
|
-
DropdownButton.Visible = true
|
|
436
|
-
local DropdownButtonSize = Iris._config.TextSize + 2 * Iris._config.FramePadding.Y
|
|
437
|
-
PreviewLabel.Size = UDim2.new(UDim.new(1, -DropdownButtonSize), PreviewLabel.Size.Height)
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
if thisWidget.arguments.NoPreview then
|
|
441
|
-
PreviewLabel.Visible = false
|
|
442
|
-
PreviewContainer.Size = UDim2.new(0, 0, 0, 0)
|
|
443
|
-
PreviewContainer.AutomaticSize = Enum.AutomaticSize.XY
|
|
444
|
-
else
|
|
445
|
-
PreviewLabel.Visible = true
|
|
446
|
-
PreviewContainer.Size = UDim2.new(Iris._config.ContentWidth, Iris._config.ContentHeight)
|
|
447
|
-
PreviewContainer.AutomaticSize = Enum.AutomaticSize.Y
|
|
448
|
-
end
|
|
449
|
-
end,
|
|
450
|
-
UpdateState = function(thisWidget: Types.Combo)
|
|
451
|
-
local Combo = thisWidget.Instance :: Frame
|
|
452
|
-
local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame
|
|
453
|
-
local PreviewContainer = Combo.PreviewContainer :: TextButton
|
|
454
|
-
local PreviewLabel: TextLabel = PreviewContainer.PreviewLabel
|
|
455
|
-
local DropdownButton = PreviewContainer.DropdownButton :: TextLabel
|
|
456
|
-
local Dropdown: ImageLabel = DropdownButton.Dropdown
|
|
457
|
-
|
|
458
|
-
if thisWidget.state.isOpened.value then
|
|
459
|
-
AnyOpenedCombo = true
|
|
460
|
-
OpenedCombo = thisWidget
|
|
461
|
-
ComboOpenedTick = Iris._cycleTick
|
|
462
|
-
thisWidget.lastOpenedTick = Iris._cycleTick + 1
|
|
463
|
-
|
|
464
|
-
-- ImGui also does not do this, and the Arrow is always facing down
|
|
465
|
-
Dropdown.Image = widgets.ICONS.RIGHT_POINTING_TRIANGLE
|
|
466
|
-
ChildContainer.Visible = true
|
|
467
|
-
|
|
468
|
-
UpdateChildContainerTransform(thisWidget)
|
|
469
|
-
else
|
|
470
|
-
if AnyOpenedCombo then
|
|
471
|
-
AnyOpenedCombo = false
|
|
472
|
-
OpenedCombo = nil
|
|
473
|
-
thisWidget.lastClosedTick = Iris._cycleTick + 1
|
|
474
|
-
end
|
|
475
|
-
Dropdown.Image = widgets.ICONS.DOWN_POINTING_TRIANGLE
|
|
476
|
-
ChildContainer.Visible = false
|
|
477
|
-
end
|
|
478
|
-
|
|
479
|
-
local stateIndex = thisWidget.state.index.value
|
|
480
|
-
PreviewLabel.Text = if typeof(stateIndex) == "EnumItem" then stateIndex.Name else tostring(stateIndex)
|
|
481
|
-
end,
|
|
482
|
-
ChildAdded = function(thisWidget: Types.Combo, _thisChild: Types.Widget)
|
|
483
|
-
UpdateChildContainerTransform(thisWidget)
|
|
484
|
-
return thisWidget.ChildContainer
|
|
485
|
-
end,
|
|
486
|
-
Discard = function(thisWidget: Types.Combo)
|
|
487
|
-
-- If we are discarding the current combo active, we need to hide it
|
|
488
|
-
if OpenedCombo and OpenedCombo == thisWidget then
|
|
489
|
-
OpenedCombo = nil
|
|
490
|
-
AnyOpenedCombo = false
|
|
491
|
-
end
|
|
492
|
-
|
|
493
|
-
thisWidget.Instance:Destroy()
|
|
494
|
-
thisWidget.ChildContainer:Destroy()
|
|
495
|
-
widgets.discardState(thisWidget)
|
|
496
|
-
end,
|
|
497
|
-
} :: Types.WidgetClass)
|
|
498
|
-
end
|
|
@@ -1,141 +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("Separator", {
|
|
7
|
-
hasState = false,
|
|
8
|
-
hasChildren = false,
|
|
9
|
-
Args = {},
|
|
10
|
-
Events = {},
|
|
11
|
-
Generate = function(thisWidget: Types.Separator)
|
|
12
|
-
local Separator = Instance.new("Frame")
|
|
13
|
-
Separator.Name = "Iris_Separator"
|
|
14
|
-
if thisWidget.parentWidget.type == "SameLine" then
|
|
15
|
-
Separator.Size = UDim2.new(0, 1, Iris._config.ItemWidth.Scale, Iris._config.ItemWidth.Offset)
|
|
16
|
-
else
|
|
17
|
-
Separator.Size = UDim2.new(Iris._config.ItemWidth.Scale, Iris._config.ItemWidth.Offset, 0, 1)
|
|
18
|
-
end
|
|
19
|
-
Separator.BackgroundColor3 = Iris._config.SeparatorColor
|
|
20
|
-
Separator.BackgroundTransparency = Iris._config.SeparatorTransparency
|
|
21
|
-
Separator.BorderSizePixel = 0
|
|
22
|
-
|
|
23
|
-
widgets.UIListLayout(Separator, Enum.FillDirection.Vertical, UDim.new(0, 0))
|
|
24
|
-
-- this is to prevent a bug of AutomaticLayout edge case when its parent has automaticLayout enabled
|
|
25
|
-
|
|
26
|
-
return Separator
|
|
27
|
-
end,
|
|
28
|
-
Update = function(_thisWidget: Types.Separator) end,
|
|
29
|
-
Discard = function(thisWidget: Types.Separator)
|
|
30
|
-
thisWidget.Instance:Destroy()
|
|
31
|
-
end,
|
|
32
|
-
} :: Types.WidgetClass)
|
|
33
|
-
|
|
34
|
-
--stylua: ignore
|
|
35
|
-
Iris.WidgetConstructor("Indent", {
|
|
36
|
-
hasState = false,
|
|
37
|
-
hasChildren = true,
|
|
38
|
-
Args = {
|
|
39
|
-
["Width"] = 1,
|
|
40
|
-
},
|
|
41
|
-
Events = {},
|
|
42
|
-
Generate = function(_thisWidget: Types.Indent)
|
|
43
|
-
local Indent = Instance.new("Frame")
|
|
44
|
-
Indent.Name = "Iris_Indent"
|
|
45
|
-
Indent.AutomaticSize = Enum.AutomaticSize.Y
|
|
46
|
-
Indent.Size = UDim2.new(Iris._config.ItemWidth, UDim.new())
|
|
47
|
-
Indent.BackgroundTransparency = 1
|
|
48
|
-
Indent.BorderSizePixel = 0
|
|
49
|
-
|
|
50
|
-
widgets.UIListLayout(Indent, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.ItemSpacing.Y))
|
|
51
|
-
widgets.UIPadding(Indent, Vector2.zero)
|
|
52
|
-
|
|
53
|
-
return Indent
|
|
54
|
-
end,
|
|
55
|
-
Update = function(thisWidget: Types.Indent)
|
|
56
|
-
local Indent = thisWidget.Instance :: Frame
|
|
57
|
-
|
|
58
|
-
Indent.UIPadding.PaddingLeft = UDim.new(0, if thisWidget.arguments.Width then thisWidget.arguments.Width else Iris._config.IndentSpacing)
|
|
59
|
-
end,
|
|
60
|
-
ChildAdded = function(thisWidget: Types.Indent, _thisChild: Types.Widget)
|
|
61
|
-
return thisWidget.Instance
|
|
62
|
-
end,
|
|
63
|
-
Discard = function(thisWidget: Types.Indent)
|
|
64
|
-
thisWidget.Instance:Destroy()
|
|
65
|
-
end,
|
|
66
|
-
} :: Types.WidgetClass)
|
|
67
|
-
|
|
68
|
-
--stylua: ignore
|
|
69
|
-
Iris.WidgetConstructor("SameLine", {
|
|
70
|
-
hasState = false,
|
|
71
|
-
hasChildren = true,
|
|
72
|
-
Args = {
|
|
73
|
-
["Width"] = 1,
|
|
74
|
-
["VerticalAlignment"] = 2,
|
|
75
|
-
["HorizontalAlignment"] = 3,
|
|
76
|
-
},
|
|
77
|
-
Events = {},
|
|
78
|
-
Generate = function(_thisWidget: Types.SameLine)
|
|
79
|
-
local SameLine = Instance.new("Frame")
|
|
80
|
-
SameLine.Name = "Iris_SameLine"
|
|
81
|
-
SameLine.AutomaticSize = Enum.AutomaticSize.Y
|
|
82
|
-
SameLine.Size = UDim2.new(Iris._config.ItemWidth, UDim.new())
|
|
83
|
-
SameLine.BackgroundTransparency = 1
|
|
84
|
-
SameLine.BorderSizePixel = 0
|
|
85
|
-
|
|
86
|
-
widgets.UIListLayout(SameLine, Enum.FillDirection.Horizontal, UDim.new(0, 0))
|
|
87
|
-
|
|
88
|
-
return SameLine
|
|
89
|
-
end,
|
|
90
|
-
Update = function(thisWidget: Types.SameLine)
|
|
91
|
-
local Sameline = thisWidget.Instance :: Frame
|
|
92
|
-
local UIListLayout: UIListLayout = Sameline.UIListLayout
|
|
93
|
-
|
|
94
|
-
UIListLayout.Padding = UDim.new(0, if thisWidget.arguments.Width then thisWidget.arguments.Width else Iris._config.ItemSpacing.X)
|
|
95
|
-
if thisWidget.arguments.VerticalAlignment then
|
|
96
|
-
UIListLayout.VerticalAlignment = thisWidget.arguments.VerticalAlignment
|
|
97
|
-
else
|
|
98
|
-
UIListLayout.VerticalAlignment = Enum.VerticalAlignment.Top
|
|
99
|
-
end
|
|
100
|
-
if thisWidget.arguments.HorizontalAlignment then
|
|
101
|
-
UIListLayout.HorizontalAlignment = thisWidget.arguments.HorizontalAlignment
|
|
102
|
-
else
|
|
103
|
-
UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Left
|
|
104
|
-
end
|
|
105
|
-
end,
|
|
106
|
-
ChildAdded = function(thisWidget: Types.SameLine, _thisChild: Types.Widget)
|
|
107
|
-
return thisWidget.Instance
|
|
108
|
-
end,
|
|
109
|
-
Discard = function(thisWidget: Types.SameLine)
|
|
110
|
-
thisWidget.Instance:Destroy()
|
|
111
|
-
end,
|
|
112
|
-
} :: Types.WidgetClass)
|
|
113
|
-
|
|
114
|
-
--stylua: ignore
|
|
115
|
-
Iris.WidgetConstructor("Group", {
|
|
116
|
-
hasState = false,
|
|
117
|
-
hasChildren = true,
|
|
118
|
-
Args = {},
|
|
119
|
-
Events = {},
|
|
120
|
-
Generate = function(_thisWidget: Types.Group)
|
|
121
|
-
local Group = Instance.new("Frame")
|
|
122
|
-
Group.Name = "Iris_Group"
|
|
123
|
-
Group.AutomaticSize = Enum.AutomaticSize.XY
|
|
124
|
-
Group.Size = UDim2.fromOffset(0, 0)
|
|
125
|
-
Group.BackgroundTransparency = 1
|
|
126
|
-
Group.BorderSizePixel = 0
|
|
127
|
-
Group.ClipsDescendants = false
|
|
128
|
-
|
|
129
|
-
widgets.UIListLayout(Group, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.ItemSpacing.Y))
|
|
130
|
-
|
|
131
|
-
return Group
|
|
132
|
-
end,
|
|
133
|
-
Update = function(_thisWidget: Types.Group) end,
|
|
134
|
-
ChildAdded = function(thisWidget: Types.Group, _thisChild: Types.Widget)
|
|
135
|
-
return thisWidget.Instance
|
|
136
|
-
end,
|
|
137
|
-
Discard = function(thisWidget: Types.Group)
|
|
138
|
-
thisWidget.Instance:Destroy()
|
|
139
|
-
end,
|
|
140
|
-
} :: Types.WidgetClass)
|
|
141
|
-
end
|