@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.
@@ -1,641 +0,0 @@
1
- --!nocheck
2
- local Types = require(script.Parent.Parent.iris_Types)
3
-
4
- -- Tables need an overhaul.
5
-
6
- --[[
7
- Iris.Table(
8
- {
9
- NumColumns,
10
- Header,
11
- RowBackground,
12
- OuterBorders,
13
- InnerBorders
14
- }
15
- )
16
-
17
- Config = {
18
- CellPadding: Vector2,
19
- CellSize: UDim2,
20
- }
21
-
22
- Iris.NextColumn()
23
- Iris.NextRow()
24
- Iris.SetColumnIndex(index: number)
25
- Iris.SetRowIndex(index: number)
26
-
27
- Iris.NextHeaderColumn()
28
- Iris.SetHeaderColumnIndex(index: number)
29
-
30
- Iris.SetColumnWidth(index: number, width: number | UDim)
31
- ]]
32
-
33
- return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
34
- local Tables: { [Types.ID]: Types.Table } = {}
35
- local TableMinWidths: { [Types.Table]: { boolean } } = {}
36
- local AnyActiveTable = false
37
- local ActiveTable: Types.Table? = nil
38
- local ActiveColumn = 0
39
- local ActiveLeftWidth = -1
40
- local ActiveRightWidth = -1
41
- local MousePositionX = 0
42
-
43
- local function CalculateMinColumnWidth(thisWidget: Types.Table, index: number)
44
- local width = 0
45
- for _, row in thisWidget._cellInstances do
46
- local cell = row[index]
47
- for _, child in cell:GetChildren() do
48
- if child:IsA("GuiObject") then
49
- width = math.max(width, child.AbsoluteSize.X)
50
- end
51
- end
52
- end
53
-
54
- thisWidget._minWidths[index] = width + 2 * Iris._config.CellPadding.X
55
- end
56
-
57
- table.insert(Iris._postCycleCallbacks, function()
58
- for _, thisWidget in Tables do
59
- for rowIndex, cycleTick in thisWidget._rowCycles do
60
- if cycleTick < Iris._cycleTick - 1 then
61
- local Row = thisWidget._rowInstances[rowIndex]
62
- local RowBorder = thisWidget._rowBorders[rowIndex - 1]
63
- if Row ~= nil then
64
- Row:Destroy()
65
- end
66
- if RowBorder ~= nil then
67
- RowBorder:Destroy()
68
- end
69
- thisWidget._rowInstances[rowIndex] = nil
70
- thisWidget._rowBorders[rowIndex - 1] = nil
71
- thisWidget._cellInstances[rowIndex] = nil
72
- thisWidget._rowCycles[rowIndex] = nil
73
- end
74
- end
75
-
76
- thisWidget._rowIndex = 1
77
- thisWidget._columnIndex = 1
78
-
79
- -- update the border container size to be the same, albeit *every* frame!
80
- local Table = thisWidget.Instance :: Frame
81
- local BorderContainer: Frame = Table.BorderContainer
82
- BorderContainer.Size = UDim2.new(1, 0, 0, thisWidget._rowContainer.AbsoluteSize.Y)
83
- thisWidget._columnBorders[0].Size = UDim2.fromOffset(5, thisWidget._rowContainer.AbsoluteSize.Y)
84
- end
85
-
86
- for thisWidget, columns in TableMinWidths do
87
- local refresh = false
88
- for column, _ in columns do
89
- CalculateMinColumnWidth(thisWidget, column)
90
- refresh = true
91
- end
92
- if refresh then
93
- table.clear(columns)
94
- Iris._widgets["Table"].UpdateState(thisWidget)
95
- end
96
- end
97
- end)
98
-
99
- local function UpdateActiveColumn()
100
- if AnyActiveTable == false or ActiveTable == nil then
101
- return
102
- end
103
-
104
- local widths = ActiveTable.state.widths
105
- local NumColumns = ActiveTable.arguments.NumColumns
106
- local Table = ActiveTable.Instance :: Frame
107
- local BorderContainer = Table.BorderContainer :: Frame
108
- local Fixed = ActiveTable.arguments.FixedWidth
109
- local Padding = 2 * Iris._config.CellPadding.X
110
-
111
- if ActiveLeftWidth == -1 then
112
- ActiveLeftWidth = widths.value[ActiveColumn]
113
- if ActiveLeftWidth == 0 then
114
- ActiveLeftWidth = Padding / Table.AbsoluteSize.X
115
- end
116
- ActiveRightWidth = widths.value[ActiveColumn + 1] or -1
117
- if ActiveRightWidth == 0 then
118
- ActiveRightWidth = Padding / Table.AbsoluteSize.X
119
- end
120
- end
121
-
122
- local BorderX = Table.AbsolutePosition.X
123
- local LeftX: number -- the start of the current column
124
- -- local CurrentX: number = BorderContainer:FindFirstChild(`Border_{ActiveColumn}`).AbsolutePosition.X + 3 - BorderX -- the current column position
125
- local RightX: number -- the end of the next column
126
- if ActiveColumn == 1 then
127
- LeftX = 0
128
- else
129
- LeftX =
130
- math.floor(BorderContainer:FindFirstChild(`Border_{ActiveColumn - 1}`).AbsolutePosition.X + 3 - BorderX)
131
- end
132
- if ActiveColumn >= NumColumns - 1 then
133
- RightX = Table.AbsoluteSize.X
134
- else
135
- RightX =
136
- math.floor(BorderContainer:FindFirstChild(`Border_{ActiveColumn + 1}`).AbsolutePosition.X + 3 - BorderX)
137
- end
138
-
139
- local TableX: number = BorderX - widgets.GuiOffset.X
140
- local DeltaX: number = math.clamp(
141
- widgets.getMouseLocation().X,
142
- LeftX + TableX + Padding,
143
- RightX + TableX - Padding
144
- ) - MousePositionX
145
- local LeftOffset = (MousePositionX - TableX) - LeftX
146
- local LeftRatio = ActiveLeftWidth / LeftOffset
147
-
148
- if Fixed then
149
- widths.value[ActiveColumn] =
150
- math.clamp(math.round(ActiveLeftWidth + DeltaX), Padding, Table.AbsoluteSize.X - LeftX)
151
- else
152
- local Change = LeftRatio * DeltaX
153
- widths.value[ActiveColumn] =
154
- math.clamp(ActiveLeftWidth + Change, 0, (RightX - LeftX - Padding) / Table.AbsoluteSize.X)
155
- if ActiveColumn < NumColumns then
156
- widths.value[ActiveColumn + 1] = math.clamp(ActiveRightWidth - Change, 0, 1)
157
- end
158
- end
159
-
160
- widths:set(widths.value, true)
161
- end
162
-
163
- local function ColumnMouseDown(thisWidget: Types.Table, index: number)
164
- AnyActiveTable = true
165
- ActiveTable = thisWidget
166
- ActiveColumn = index
167
- ActiveLeftWidth = -1
168
- ActiveRightWidth = -1
169
- MousePositionX = widgets.getMouseLocation().X
170
- end
171
-
172
- widgets.registerEvent("InputChanged", function()
173
- if not Iris._started then
174
- return
175
- end
176
- UpdateActiveColumn()
177
- end)
178
-
179
- widgets.registerEvent("InputEnded", function(inputObject: InputObject)
180
- if not Iris._started then
181
- return
182
- end
183
- if inputObject.UserInputType == Enum.UserInputType.MouseButton1 and AnyActiveTable then
184
- AnyActiveTable = false
185
- ActiveTable = nil
186
- ActiveColumn = 0
187
- ActiveLeftWidth = -1
188
- ActiveRightWidth = -1
189
- MousePositionX = 0
190
- end
191
- end)
192
-
193
- local function GenerateCell(_thisWidget: Types.Table, index: number, width: UDim, header: boolean)
194
- local Cell: TextButton
195
- if header then
196
- Cell = Instance.new("TextButton")
197
- Cell.Text = ""
198
- Cell.AutoButtonColor = false
199
- else
200
- Cell = (Instance.new("Frame") :: GuiObject) :: TextButton
201
- end
202
- Cell.Name = `Cell_{index}`
203
- Cell.AutomaticSize = Enum.AutomaticSize.Y
204
- Cell.Size = UDim2.new(width, UDim.new())
205
- Cell.BackgroundTransparency = 1
206
- Cell.ZIndex = index
207
- Cell.LayoutOrder = index
208
- Cell.ClipsDescendants = true
209
-
210
- if header then
211
- widgets.applyInteractionHighlights("Background", Cell, Cell, {
212
- Color = Iris._config.HeaderColor,
213
- Transparency = 1,
214
- HoveredColor = Iris._config.HeaderHoveredColor,
215
- HoveredTransparency = Iris._config.HeaderHoveredTransparency,
216
- ActiveColor = Iris._config.HeaderActiveColor,
217
- ActiveTransparency = Iris._config.HeaderActiveTransparency,
218
- })
219
- end
220
-
221
- widgets.UIPadding(Cell, Iris._config.CellPadding)
222
- widgets.UIListLayout(Cell, Enum.FillDirection.Vertical, UDim.new())
223
- widgets.UISizeConstraint(Cell, Vector2.new(2 * Iris._config.CellPadding.X, 0))
224
-
225
- return Cell
226
- end
227
-
228
- local function GenerateColumnBorder(thisWidget: Types.Table, index: number, style: "Light" | "Strong")
229
- local Border = Instance.new("ImageButton")
230
- Border.Name = `Border_{index}`
231
- Border.Size = UDim2.new(0, 5, 1, 0)
232
- Border.BackgroundTransparency = 1
233
- Border.Image = ""
234
- Border.ImageTransparency = 1
235
- Border.AutoButtonColor = false
236
- Border.ZIndex = index
237
- Border.LayoutOrder = 2 * index
238
-
239
- local offset = if index == thisWidget.arguments.NumColumns then 3 else 2
240
-
241
- local Line = Instance.new("Frame")
242
- Line.Name = "Line"
243
- Line.Size = UDim2.new(0, 1, 1, 0)
244
- Line.Position = UDim2.fromOffset(offset, 0)
245
- Line.BackgroundColor3 = Iris._config[`TableBorder{style}Color`]
246
- Line.BackgroundTransparency = Iris._config[`TableBorder{style}Transparency`]
247
- Line.BorderSizePixel = 0
248
-
249
- Line.Parent = Border
250
-
251
- local Hover = Instance.new("Frame")
252
- Hover.Name = "Hover"
253
- Hover.Position = UDim2.fromOffset(offset, 0)
254
- Hover.Size = UDim2.new(0, 1, 1, 0)
255
- Hover.BackgroundColor3 = Iris._config[`TableBorder{style}Color`]
256
- Hover.BackgroundTransparency = Iris._config[`TableBorder{style}Transparency`]
257
- Hover.BorderSizePixel = 0
258
-
259
- Hover.Visible = thisWidget.arguments.Resizable
260
-
261
- Hover.Parent = Border
262
-
263
- widgets.applyInteractionHighlights("Background", Border, Hover, {
264
- Color = Iris._config.ResizeGripColor,
265
- Transparency = 1,
266
- HoveredColor = Iris._config.ResizeGripHoveredColor,
267
- HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
268
- ActiveColor = Iris._config.ResizeGripActiveColor,
269
- ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
270
- })
271
-
272
- widgets.applyButtonDown(Border, function()
273
- if thisWidget.arguments.Resizable then
274
- ColumnMouseDown(thisWidget, index)
275
- end
276
- end)
277
-
278
- return Border
279
- end
280
-
281
- -- creates a new row and all columns, and adds all to the table's row and cell instance tables, but does not parent
282
- local function GenerateRow(thisWidget: Types.Table, index: number)
283
- local Row: Frame = Instance.new("Frame")
284
- Row.Name = `Row_{index}`
285
- Row.AutomaticSize = Enum.AutomaticSize.Y
286
- Row.Size = UDim2.fromScale(1, 0)
287
- if index == 0 then
288
- Row.BackgroundColor3 = Iris._config.TableHeaderColor
289
- Row.BackgroundTransparency = Iris._config.TableHeaderTransparency
290
- elseif thisWidget.arguments.RowBackground == true then
291
- if (index % 2) == 0 then
292
- Row.BackgroundColor3 = Iris._config.TableRowBgAltColor
293
- Row.BackgroundTransparency = Iris._config.TableRowBgAltTransparency
294
- else
295
- Row.BackgroundColor3 = Iris._config.TableRowBgColor
296
- Row.BackgroundTransparency = Iris._config.TableRowBgTransparency
297
- end
298
- else
299
- Row.BackgroundTransparency = 1
300
- end
301
- Row.BorderSizePixel = 0
302
- Row.ZIndex = 2 * index - 1
303
- Row.LayoutOrder = 2 * index - 1
304
- Row.ClipsDescendants = true
305
-
306
- widgets.UIListLayout(Row, Enum.FillDirection.Horizontal, UDim.new())
307
-
308
- thisWidget._cellInstances[index] = table.create(thisWidget.arguments.NumColumns)
309
- for columnIndex = 1, thisWidget.arguments.NumColumns do
310
- local Cell = GenerateCell(thisWidget, columnIndex, thisWidget._widths[columnIndex], index == 0)
311
- Cell.Parent = Row
312
- thisWidget._cellInstances[index][columnIndex] = Cell
313
- end
314
-
315
- thisWidget._rowInstances[index] = Row
316
-
317
- return Row
318
- end
319
-
320
- local function GenerateRowBorder(_thisWidget: Types.Table, index: number, style: "Light" | "Strong")
321
- local Border = Instance.new("Frame")
322
- Border.Name = `Border_{index}`
323
- Border.Size = UDim2.fromScale(1, 0)
324
- Border.BackgroundTransparency = 1
325
- Border.ZIndex = 2 * index
326
- Border.LayoutOrder = 2 * index
327
-
328
- local Line = Instance.new("Frame")
329
- Line.Name = "Line"
330
- Line.AnchorPoint = Vector2.new(0, 0.5)
331
- Line.Size = UDim2.new(1, 0, 0, 1)
332
- Line.BackgroundColor3 = Iris._config[`TableBorder{style}Color`]
333
- Line.BackgroundTransparency = Iris._config[`TableBorder{style}Transparency`]
334
- Line.BorderSizePixel = 0
335
-
336
- Line.Parent = Border
337
-
338
- return Border
339
- end
340
-
341
- --stylua: ignore
342
- Iris.WidgetConstructor("Table", {
343
- hasState = true,
344
- hasChildren = true,
345
- Args = {
346
- NumColumns = 1,
347
- Header = 2,
348
- RowBackground = 3,
349
- OuterBorders = 4,
350
- InnerBorders = 5,
351
- Resizable = 6,
352
- FixedWidth = 7,
353
- ProportionalWidth = 8,
354
- LimitTableWidth = 9,
355
- },
356
- Events = {},
357
- Generate = function(thisWidget: Types.Table)
358
- Tables[thisWidget.ID] = thisWidget
359
- TableMinWidths[thisWidget] = {}
360
-
361
- local Table = Instance.new("Frame")
362
- Table.Name = "Iris_Table"
363
- Table.AutomaticSize = Enum.AutomaticSize.Y
364
- Table.Size = UDim2.fromScale(1, 0)
365
- Table.BackgroundTransparency = 1
366
-
367
- local RowContainer = Instance.new("Frame")
368
- RowContainer.Name = "RowContainer"
369
- RowContainer.AutomaticSize = Enum.AutomaticSize.Y
370
- RowContainer.Size = UDim2.fromScale(1, 0)
371
- RowContainer.BackgroundTransparency = 1
372
- RowContainer.ZIndex = 1
373
-
374
- widgets.UISizeConstraint(RowContainer)
375
- widgets.UIListLayout(RowContainer, Enum.FillDirection.Vertical, UDim.new())
376
-
377
- RowContainer.Parent = Table
378
- thisWidget._rowContainer = RowContainer
379
-
380
- local BorderContainer = Instance.new("Frame")
381
- BorderContainer.Name = "BorderContainer"
382
- BorderContainer.Size = UDim2.fromScale(1, 1)
383
- BorderContainer.BackgroundTransparency = 1
384
- BorderContainer.ZIndex = 2
385
- BorderContainer.ClipsDescendants = true
386
-
387
- widgets.UISizeConstraint(BorderContainer)
388
- widgets.UIListLayout(BorderContainer, Enum.FillDirection.Horizontal, UDim.new())
389
- widgets.UIStroke(BorderContainer, 1, Iris._config.TableBorderStrongColor, Iris._config.TableBorderStrongTransparency)
390
-
391
- BorderContainer.Parent = Table
392
-
393
- thisWidget._columnIndex = 1
394
- thisWidget._rowIndex = 1
395
- thisWidget._rowInstances = {}
396
- thisWidget._cellInstances = {}
397
- thisWidget._rowBorders = {}
398
- thisWidget._columnBorders = {}
399
- thisWidget._rowCycles = {}
400
-
401
- local callbackIndex = #Iris._postCycleCallbacks + 1
402
- local desiredCycleTick = Iris._cycleTick + 1
403
- Iris._postCycleCallbacks[callbackIndex] = function()
404
- if Iris._cycleTick >= desiredCycleTick then
405
- if thisWidget.lastCycleTick ~= -1 then
406
- thisWidget.state.widths.lastChangeTick = Iris._cycleTick
407
- Iris._widgets["Table"].UpdateState(thisWidget)
408
- end
409
- Iris._postCycleCallbacks[callbackIndex] = nil
410
- end
411
- end
412
-
413
- return Table
414
- end,
415
- GenerateState = function(thisWidget: Types.Table)
416
- local NumColumns = thisWidget.arguments.NumColumns
417
- if thisWidget.state.widths == nil then
418
- local Widths: { number } = table.create(NumColumns, 1 / NumColumns)
419
- thisWidget.state.widths = Iris._widgetState(thisWidget, "widths", Widths)
420
- end
421
- thisWidget._widths = table.create(NumColumns, UDim.new())
422
- thisWidget._minWidths = table.create(NumColumns, 0)
423
-
424
- local Table = thisWidget.Instance :: Frame
425
- local BorderContainer: Frame = Table.BorderContainer
426
-
427
- thisWidget._cellInstances[-1] = table.create(NumColumns)
428
- for index = 1, NumColumns do
429
- local Border = GenerateColumnBorder(thisWidget, index, "Light")
430
- Border.Visible = thisWidget.arguments.InnerBorders
431
- thisWidget._columnBorders[index] = Border
432
- Border.Parent = BorderContainer
433
-
434
- local Cell = GenerateCell(thisWidget, index, thisWidget._widths[index], false)
435
- local UISizeConstraint = Cell:FindFirstChild("UISizeConstraint") :: UISizeConstraint
436
- UISizeConstraint.MinSize = Vector2.new(
437
- 2 * Iris._config.CellPadding.X + (if index > 1 then -2 else 0) + (if index < NumColumns then -3 else 0),
438
- 0
439
- )
440
- Cell.LayoutOrder = 2 * index - 1
441
- thisWidget._cellInstances[-1][index] = Cell
442
- Cell.Parent = BorderContainer
443
- end
444
-
445
- local TableColumnBorder = GenerateColumnBorder(thisWidget, NumColumns, "Strong")
446
- thisWidget._columnBorders[0] = TableColumnBorder
447
- TableColumnBorder.Parent = Table
448
- end,
449
- Update = function(thisWidget: Types.Table)
450
- local NumColumns = thisWidget.arguments.NumColumns
451
- assert(NumColumns >= 1, "Iris.Table must have at least one column.")
452
-
453
- if thisWidget._widths ~= nil and #thisWidget._widths ~= NumColumns then
454
- -- disallow changing the number of columns. It's too much effort
455
- thisWidget.arguments.NumColumns = #thisWidget._widths
456
- warn("NumColumns cannot change once set. See documentation.")
457
- end
458
-
459
- for rowIndex, row in thisWidget._rowInstances do
460
- if rowIndex == 0 then
461
- row.BackgroundColor3 = Iris._config.TableHeaderColor
462
- row.BackgroundTransparency = Iris._config.TableHeaderTransparency
463
- elseif thisWidget.arguments.RowBackground == true then
464
- if (rowIndex % 2) == 0 then
465
- row.BackgroundColor3 = Iris._config.TableRowBgAltColor
466
- row.BackgroundTransparency = Iris._config.TableRowBgAltTransparency
467
- else
468
- row.BackgroundColor3 = Iris._config.TableRowBgColor
469
- row.BackgroundTransparency = Iris._config.TableRowBgTransparency
470
- end
471
- else
472
- row.BackgroundTransparency = 1
473
- end
474
- end
475
-
476
- for _, Border: Frame in thisWidget._rowBorders do
477
- Border.Visible = thisWidget.arguments.InnerBorders
478
- end
479
-
480
- for _, Border: GuiButton in thisWidget._columnBorders do
481
- Border.Visible = thisWidget.arguments.InnerBorders or thisWidget.arguments.Resizable
482
- end
483
-
484
- for _, border in thisWidget._columnBorders do
485
- local hover = border:FindFirstChild("Hover") :: Frame?
486
- if hover then
487
- hover.Visible = thisWidget.arguments.Resizable
488
- end
489
- end
490
-
491
- if thisWidget._columnBorders[NumColumns] ~= nil then
492
- thisWidget._columnBorders[NumColumns].Visible =
493
- not thisWidget.arguments.LimitTableWidth and (thisWidget.arguments.Resizable or thisWidget.arguments.InnerBorders)
494
- thisWidget._columnBorders[0].Visible =
495
- thisWidget.arguments.LimitTableWidth and (thisWidget.arguments.Resizable or thisWidget.arguments.OuterBorders)
496
- end
497
-
498
- -- the header border visibility must be updated after settings all borders
499
- -- visiblity or not
500
- local HeaderRow: Frame? = thisWidget._rowInstances[0]
501
- local HeaderBorder: Frame? = thisWidget._rowBorders[0]
502
- if HeaderRow ~= nil then
503
- HeaderRow.Visible = thisWidget.arguments.Header
504
- end
505
- if HeaderBorder ~= nil then
506
- HeaderBorder.Visible = thisWidget.arguments.Header and thisWidget.arguments.InnerBorders
507
- end
508
-
509
- local Table = thisWidget.Instance :: Frame
510
- local BorderContainer = Table.BorderContainer :: Frame
511
- BorderContainer.UIStroke.Enabled = thisWidget.arguments.OuterBorders
512
-
513
- for index = 1, thisWidget.arguments.NumColumns do
514
- TableMinWidths[thisWidget][index] = true
515
- end
516
-
517
- if thisWidget._widths ~= nil then
518
- Iris._widgets["Table"].UpdateState(thisWidget)
519
- end
520
- end,
521
- UpdateState = function(thisWidget: Types.Table)
522
- local Table = thisWidget.Instance :: Frame
523
- local BorderContainer = Table.BorderContainer :: Frame
524
- local RowContainer = Table.RowContainer :: Frame
525
- local NumColumns = thisWidget.arguments.NumColumns
526
- local ColumnWidths = thisWidget.state.widths.value
527
- local MinWidths = thisWidget._minWidths
528
-
529
- local Fixed = thisWidget.arguments.FixedWidth
530
- local Proportional = thisWidget.arguments.ProportionalWidth
531
-
532
- if not thisWidget.arguments.Resizable then
533
- if Fixed then
534
- if Proportional then
535
- for index = 1, NumColumns do
536
- ColumnWidths[index] = MinWidths[index]
537
- end
538
- else
539
- local maxWidth = 0
540
- for _, width in MinWidths do
541
- maxWidth = math.max(maxWidth, width)
542
- end
543
- for index = 1, NumColumns do
544
- ColumnWidths[index] = maxWidth
545
- end
546
- end
547
- else
548
- if Proportional then
549
- local TotalWidth = 0
550
- for _, width in MinWidths do
551
- TotalWidth += width
552
- end
553
- local Ratio = 1 / TotalWidth
554
- for index = 1, NumColumns do
555
- ColumnWidths[index] = Ratio * MinWidths[index]
556
- end
557
- else
558
- local width = 1 / NumColumns
559
- for index = 1, NumColumns do
560
- ColumnWidths[index] = width
561
- end
562
- end
563
- end
564
- end
565
-
566
- local Position = UDim.new()
567
- for index = 1, NumColumns do
568
- local ColumnWidth = ColumnWidths[index]
569
-
570
- local Width = UDim.new(
571
- if Fixed then 0 else math.clamp(ColumnWidth, 0, 1),
572
- if Fixed then math.max(ColumnWidth, 0) else 0
573
- )
574
- thisWidget._widths[index] = Width
575
- Position += Width
576
-
577
- for _, row in thisWidget._cellInstances do
578
- row[index].Size = UDim2.new(Width, UDim.new())
579
- end
580
-
581
- thisWidget._cellInstances[-1][index].Size = UDim2.new(Width + UDim.new(0,
582
- (if index > 1 then -2 else 0) - 3
583
- ), UDim.new())
584
- end
585
-
586
- -- if the table has a fixed width and we want to cap it, we calculate the table width necessary
587
- local Width = Position.Offset
588
- if not thisWidget.arguments.FixedWidth or not thisWidget.arguments.LimitTableWidth then
589
- Width = math.huge
590
- end
591
-
592
- BorderContainer.UISizeConstraint.MaxSize = Vector2.new(Width, math.huge)
593
- RowContainer.UISizeConstraint.MaxSize = Vector2.new(Width, math.huge)
594
- thisWidget._columnBorders[0].Position = UDim2.fromOffset(Width - 3, 0)
595
- end,
596
- ChildAdded = function(thisWidget: Types.Table, _: Types.Widget)
597
- local rowIndex = thisWidget._rowIndex
598
- local columnIndex = thisWidget._columnIndex
599
- -- determine if the row exists yet
600
- local Row = thisWidget._rowInstances[rowIndex]
601
- thisWidget._rowCycles[rowIndex] = Iris._cycleTick
602
- TableMinWidths[thisWidget][columnIndex] = true
603
-
604
- if Row ~= nil then
605
- return thisWidget._cellInstances[rowIndex][columnIndex]
606
- end
607
-
608
- Row = GenerateRow(thisWidget, rowIndex)
609
- if rowIndex == 0 then
610
- Row.Visible = thisWidget.arguments.Header
611
- end
612
- Row.Parent = thisWidget._rowContainer
613
-
614
- if rowIndex > 0 then
615
- local Border = GenerateRowBorder(thisWidget, rowIndex - 1, if rowIndex == 1 then "Strong" else "Light")
616
- Border.Visible = thisWidget.arguments.InnerBorders and (if rowIndex == 1 then (thisWidget.arguments.Header and thisWidget.arguments.InnerBorders) and (thisWidget._rowInstances[0] ~= nil) else true)
617
- thisWidget._rowBorders[rowIndex - 1] = Border
618
- Border.Parent = thisWidget._rowContainer
619
- end
620
-
621
- return thisWidget._cellInstances[rowIndex][columnIndex]
622
- end,
623
- ChildDiscarded = function(thisWidget: Types.Table, thisChild: Types.Widget)
624
- local Cell = thisChild.Instance.Parent
625
-
626
- if Cell ~= nil then
627
- local columnIndex = tonumber(Cell.Name:sub(6))
628
-
629
- if columnIndex then
630
- TableMinWidths[thisWidget][columnIndex] = true
631
- end
632
- end
633
- end,
634
- Discard = function(thisWidget: Types.Table)
635
- Tables[thisWidget.ID] = nil
636
- TableMinWidths[thisWidget] = nil
637
- thisWidget.Instance:Destroy()
638
- widgets.discardState(thisWidget)
639
- end
640
- } :: Types.WidgetClass)
641
- end