@quenty/iris 1.1.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE.md +22 -0
  3. package/README.md +33 -0
  4. package/default.project.json +14 -0
  5. package/package.json +42 -0
  6. package/src/Shared/Iris.lua +702 -0
  7. package/src/Shared/iris_API.lua +231 -0
  8. package/src/Shared/iris_Internal.lua +923 -0
  9. package/src/Shared/iris_PubTypes.lua +44 -0
  10. package/src/Shared/iris_Types.lua +674 -0
  11. package/src/Shared/iris_WidgetTypes.lua +522 -0
  12. package/src/Shared/iris_config.lua +306 -0
  13. package/src/Shared/iris_demoWindow.lua +2148 -0
  14. package/src/Shared/widgets/iris_Button.lua +91 -0
  15. package/src/Shared/widgets/iris_Checkbox.lua +116 -0
  16. package/src/Shared/widgets/iris_Combo.lua +498 -0
  17. package/src/Shared/widgets/iris_Format.lua +141 -0
  18. package/src/Shared/widgets/iris_Image.lua +156 -0
  19. package/src/Shared/widgets/iris_Input.lua +1430 -0
  20. package/src/Shared/widgets/iris_Menu.lua +603 -0
  21. package/src/Shared/widgets/iris_Plot.lua +642 -0
  22. package/src/Shared/widgets/iris_RadioButton.lua +127 -0
  23. package/src/Shared/widgets/iris_Root.lua +148 -0
  24. package/src/Shared/widgets/iris_Tab.lua +334 -0
  25. package/src/Shared/widgets/iris_Table.lua +641 -0
  26. package/src/Shared/widgets/iris_Text.lua +133 -0
  27. package/src/Shared/widgets/iris_Tree.lua +291 -0
  28. package/src/Shared/widgets/iris_Window.lua +1158 -0
  29. package/src/Shared/widgets/iris_widgets.lua +487 -0
  30. package/src/jest.config.lua +3 -0
  31. package/src/node_modules.project.json +7 -0
  32. package/test/default.project.json +25 -0
  33. package/test/scripts/Server/ServerMain.server.lua +13 -0
@@ -0,0 +1,2148 @@
1
+ --!nocheck
2
+ local Types = require(script.Parent.iris_Types)
3
+
4
+ return function(Iris: Types.Iris)
5
+ local showMainWindow = Iris.State(true)
6
+ local showRecursiveWindow = Iris.State(false)
7
+ local showRuntimeInfo = Iris.State(false)
8
+ local showStyleEditor = Iris.State(false)
9
+ local showWindowlessDemo = Iris.State(false)
10
+ local showMainMenuBarWindow = Iris.State(false)
11
+ local showDebugWindow = Iris.State(false)
12
+
13
+ local showBackground = Iris.State(false)
14
+ local backgroundColour = Iris.State(Color3.fromRGB(115, 140, 152))
15
+ local backgroundTransparency = Iris.State(0)
16
+ table.insert(Iris.Internal._initFunctions, function()
17
+ local background = Instance.new("Frame")
18
+ background.Name = "Background"
19
+ background.Size = UDim2.fromScale(1, 1)
20
+ background.BackgroundColor3 = backgroundColour.value
21
+ background.BackgroundTransparency = backgroundTransparency.value
22
+
23
+ local widget
24
+ if Iris._config.UseScreenGUIs then
25
+ widget = Instance.new("ScreenGui")
26
+ widget.Name = "Iris_Background"
27
+ widget.IgnoreGuiInset = true
28
+ widget.DisplayOrder = Iris._config.DisplayOrderOffset - 1
29
+ widget.ScreenInsets = Enum.ScreenInsets.None
30
+ widget.Enabled = true
31
+
32
+ background.Parent = widget
33
+ else
34
+ background.ZIndex = Iris._config.DisplayOrderOffset - 1
35
+ widget = background
36
+ end
37
+
38
+ backgroundColour:onChange(function(value: Color3)
39
+ background.BackgroundColor3 = value
40
+ end)
41
+ backgroundTransparency:onChange(function(value: number)
42
+ background.BackgroundTransparency = value
43
+ end)
44
+
45
+ showBackground:onChange(function(show: boolean)
46
+ if show then
47
+ widget.Parent = Iris.Internal.parentInstance
48
+ else
49
+ widget.Parent = nil
50
+ end
51
+ end)
52
+ end)
53
+
54
+ local function helpMarker(helpText: string)
55
+ Iris.PushConfig({ TextColor = Iris._config.TextDisabledColor })
56
+ local text = Iris.Text({ "(?)" })
57
+ Iris.PopConfig()
58
+
59
+ Iris.PushConfig({ ContentWidth = UDim.new(0, 350) })
60
+ if text.hovered() then
61
+ Iris.Tooltip({ helpText })
62
+ end
63
+ Iris.PopConfig()
64
+ end
65
+
66
+ local function textAndHelpMarker(text: string, helpText: string)
67
+ Iris.SameLine()
68
+ do
69
+ Iris.Text({ text })
70
+ helpMarker(helpText)
71
+ end
72
+ Iris.End()
73
+ end
74
+
75
+ -- shows each widgets functionality
76
+ local widgetDemos = {
77
+ Basic = function()
78
+ Iris.Tree({ "Basic" })
79
+ do
80
+ Iris.SeparatorText({ "Basic" })
81
+
82
+ local radioButtonState = Iris.State(1)
83
+ Iris.Button({ "Button" })
84
+ Iris.SmallButton({ "SmallButton" })
85
+ Iris.Text({ "Text" })
86
+ Iris.TextWrapped({ string.rep("Text Wrapped ", 5) })
87
+ Iris.TextColored({ "Colored Text", Color3.fromRGB(255, 128, 0) })
88
+ Iris.Text({
89
+ `Rich Text: <b>bold text</b> <i>italic text</i> <u>underline text</u> <s>strikethrough text</s> <font color= "rgb(240, 40, 10)">red text</font> <font size="32">bigger text</font>`,
90
+ true,
91
+ nil,
92
+ true,
93
+ })
94
+
95
+ Iris.SameLine()
96
+ do
97
+ Iris.RadioButton({ "Index '1'", 1 }, { index = radioButtonState })
98
+ Iris.RadioButton({ "Index 'two'", "two" }, { index = radioButtonState })
99
+ if Iris.RadioButton({ "Index 'false'", false }, { index = radioButtonState }).active() == false then
100
+ if Iris.SmallButton({ "Select last" }).clicked() then
101
+ radioButtonState:set(false)
102
+ end
103
+ end
104
+ end
105
+ Iris.End()
106
+
107
+ Iris.Text({ "The Index is: " .. tostring(radioButtonState.value) })
108
+
109
+ Iris.SeparatorText({ "Inputs" })
110
+
111
+ Iris.InputNum({})
112
+ Iris.DragNum({})
113
+ Iris.SliderNum({})
114
+ end
115
+ Iris.End()
116
+ end,
117
+
118
+ Image = function()
119
+ Iris.Tree({ "Image" })
120
+ do
121
+ Iris.SeparatorText({ "Image Controls" })
122
+
123
+ local AssetState = Iris.State("rbxasset://textures/ui/common/robux.png")
124
+ local SizeState = Iris.State(UDim2.fromOffset(100, 100))
125
+ local RectState = Iris.State(Rect.new(0, 0, 0, 0))
126
+ local ScaleTypeState = Iris.State(Enum.ScaleType.Stretch)
127
+ local PixelatedCheckState = Iris.State(false)
128
+ local PixelatedState = Iris.ComputedState(PixelatedCheckState, function(check)
129
+ return check and Enum.ResamplerMode.Pixelated or Enum.ResamplerMode.Default
130
+ end)
131
+
132
+ local ImageColorState = Iris.State(Iris._config.ImageColor)
133
+ local ImageTransparencyState = Iris.State(Iris._config.ImageTransparency)
134
+ Iris.InputColor4({ "Image Tint" }, { color = ImageColorState, transparency = ImageTransparencyState })
135
+
136
+ Iris.Combo({ "Asset" }, { index = AssetState })
137
+ do
138
+ Iris.Selectable(
139
+ { "Robux Small", "rbxasset://textures/ui/common/robux.png" },
140
+ { index = AssetState }
141
+ )
142
+ Iris.Selectable(
143
+ { "Robux Large", "rbxasset://textures//ui/common/robux@3x.png" },
144
+ { index = AssetState }
145
+ )
146
+ Iris.Selectable(
147
+ { "Loading Texture", "rbxasset://textures//loading/darkLoadingTexture.png" },
148
+ { index = AssetState }
149
+ )
150
+ Iris.Selectable(
151
+ { "Hue-Saturation Gradient", "rbxasset://textures//TagEditor/huesatgradient.png" },
152
+ { index = AssetState }
153
+ )
154
+ Iris.Selectable(
155
+ { "famfamfam.png (WHY?)", "rbxasset://textures//TagEditor/famfamfam.png" },
156
+ { index = AssetState }
157
+ )
158
+ end
159
+ Iris.End()
160
+
161
+ Iris.SliderUDim2({ "Image Size", nil, nil, UDim2.new(1, 240, 1, 240) }, { number = SizeState })
162
+ Iris.SliderRect({ "Image Rect", nil, nil, Rect.new(256, 256, 256, 256) }, { number = RectState })
163
+
164
+ Iris.Combo({ "Scale Type" }, { index = ScaleTypeState })
165
+ do
166
+ Iris.Selectable({ "Stretch", Enum.ScaleType.Stretch }, { index = ScaleTypeState })
167
+ Iris.Selectable({ "Fit", Enum.ScaleType.Fit }, { index = ScaleTypeState })
168
+ Iris.Selectable({ "Crop", Enum.ScaleType.Crop }, { index = ScaleTypeState })
169
+ end
170
+
171
+ Iris.End()
172
+ Iris.Checkbox({ "Pixelated" }, { isChecked = PixelatedCheckState })
173
+
174
+ Iris.PushConfig({
175
+ ImageColor = ImageColorState:get(),
176
+ ImageTransparency = ImageTransparencyState:get(),
177
+ })
178
+ Iris.Image({
179
+ AssetState:get(),
180
+ SizeState:get(),
181
+ RectState:get(),
182
+ ScaleTypeState:get(),
183
+ PixelatedState:get(),
184
+ })
185
+ Iris.PopConfig()
186
+
187
+ Iris.SeparatorText({ "Tile" })
188
+ local TileState = Iris.State(UDim2.fromScale(0.5, 0.5))
189
+ Iris.SliderUDim2({ "Tile Size", nil, nil, UDim2.new(1, 240, 1, 240) }, { number = TileState })
190
+
191
+ Iris.PushConfig({
192
+ ImageColor = ImageColorState:get(),
193
+ ImageTransparency = ImageTransparencyState:get(),
194
+ })
195
+ Iris.Image({
196
+ "rbxasset://textures/grid2.png",
197
+ SizeState:get(),
198
+ nil,
199
+ Enum.ScaleType.Tile,
200
+ PixelatedState:get(),
201
+ TileState:get(),
202
+ })
203
+ Iris.PopConfig()
204
+
205
+ Iris.SeparatorText({ "Slice" })
206
+ local SliceScaleState = Iris.State(1)
207
+ Iris.SliderNum({ "Image Slice Scale", 0.1, 0.1, 5 }, { number = SliceScaleState })
208
+
209
+ Iris.PushConfig({
210
+ ImageColor = ImageColorState:get(),
211
+ ImageTransparency = ImageTransparencyState:get(),
212
+ })
213
+ Iris.Image({
214
+ "rbxasset://textures/ui/chatBubble_blue_notify_bkg.png",
215
+ SizeState:get(),
216
+ nil,
217
+ Enum.ScaleType.Slice,
218
+ PixelatedState:get(),
219
+ nil,
220
+ Rect.new(12, 12, 56, 56),
221
+ 1,
222
+ }, SliceScaleState:get())
223
+ Iris.PopConfig()
224
+
225
+ Iris.SeparatorText({ "Image Button" })
226
+ local count = Iris.State(0)
227
+
228
+ Iris.SameLine()
229
+ do
230
+ Iris.PushConfig({
231
+ ImageColor = ImageColorState:get(),
232
+ ImageTransparency = ImageTransparencyState:get(),
233
+ })
234
+ if
235
+ Iris.ImageButton({
236
+ "rbxasset://textures/AvatarCompatibilityPreviewer/add.png",
237
+ UDim2.fromOffset(20, 20),
238
+ }).clicked()
239
+ then
240
+ count:set(count.value + 1)
241
+ end
242
+ Iris.PopConfig()
243
+
244
+ Iris.Text({ `Click count: {count.value}` })
245
+ end
246
+ Iris.End()
247
+ end
248
+ Iris.End()
249
+ end,
250
+
251
+ Selectable = function()
252
+ Iris.Tree({ "Selectable" })
253
+ do
254
+ local sharedIndex = Iris.State(2)
255
+ Iris.Selectable({ "Selectable #1", 1 }, { index = sharedIndex })
256
+ Iris.Selectable({ "Selectable #2", 2 }, { index = sharedIndex })
257
+ if Iris.Selectable({ "Double click Selectable", 3, true }, { index = sharedIndex }).doubleClicked() then
258
+ sharedIndex:set(3)
259
+ end
260
+
261
+ Iris.Selectable({ "Impossible to select", 4, true }, { index = sharedIndex })
262
+ if Iris.Button({ "Select last" }).clicked() then
263
+ sharedIndex:set(4)
264
+ end
265
+
266
+ Iris.Selectable({ "Independent Selectable" })
267
+ end
268
+ Iris.End()
269
+ end,
270
+
271
+ Combo = function()
272
+ Iris.Tree({ "Combo" })
273
+ do
274
+ Iris.PushConfig({ ContentWidth = UDim.new(1, -200) })
275
+ local sharedComboIndex = Iris.State("No Selection")
276
+
277
+ local NoPreview, NoButton
278
+ Iris.SameLine()
279
+ do
280
+ NoPreview = Iris.Checkbox({ "No Preview" })
281
+ NoButton = Iris.Checkbox({ "No Button" })
282
+ if NoPreview.checked() and NoButton.isChecked.value == true then
283
+ NoButton.isChecked:set(false)
284
+ end
285
+ if NoButton.checked() and NoPreview.isChecked.value == true then
286
+ NoPreview.isChecked:set(false)
287
+ end
288
+ end
289
+ Iris.End()
290
+
291
+ Iris.Combo(
292
+ { "Basic Usage", NoButton.isChecked:get(), NoPreview.isChecked:get() },
293
+ { index = sharedComboIndex }
294
+ )
295
+ do
296
+ Iris.Selectable({ "Select 1", "One" }, { index = sharedComboIndex })
297
+ Iris.Selectable({ "Select 2", "Two" }, { index = sharedComboIndex })
298
+ Iris.Selectable({ "Select 3", "Three" }, { index = sharedComboIndex })
299
+ end
300
+ Iris.End()
301
+
302
+ Iris.ComboArray({ "Using ComboArray" }, { index = "No Selection" }, { "Red", "Green", "Blue" })
303
+
304
+ local heightTestArray = {}
305
+ for i = 1, 50 do
306
+ table.insert(heightTestArray, tostring(i))
307
+ end
308
+ Iris.ComboArray({ "Height Test" }, { index = "1" }, heightTestArray)
309
+
310
+ local sharedComboIndex2 = Iris.State("7 AM")
311
+
312
+ Iris.Combo({ "Combo with Inner widgets" }, { index = sharedComboIndex2 })
313
+ do
314
+ Iris.Tree({ "Morning Shifts" })
315
+ do
316
+ Iris.Selectable({ "Shift at 7 AM", "7 AM" }, { index = sharedComboIndex2 })
317
+ Iris.Selectable({ "Shift at 11 AM", "11 AM" }, { index = sharedComboIndex2 })
318
+ Iris.Selectable({ "Shift at 3 PM", "3 PM" }, { index = sharedComboIndex2 })
319
+ end
320
+ Iris.End()
321
+ Iris.Tree({ "Night Shifts" })
322
+ do
323
+ Iris.Selectable({ "Shift at 6 PM", "6 PM" }, { index = sharedComboIndex2 })
324
+ Iris.Selectable({ "Shift at 9 PM", "9 PM" }, { index = sharedComboIndex2 })
325
+ end
326
+ Iris.End()
327
+ end
328
+ Iris.End()
329
+
330
+ local ComboEnum = Iris.ComboEnum(
331
+ { "Using ComboEnum" },
332
+ { index = Enum.UserInputState.Begin },
333
+ Enum.UserInputState
334
+ )
335
+ Iris.Text({ "Selected: " .. ComboEnum.index:get().Name })
336
+ Iris.PopConfig()
337
+ end
338
+ Iris.End()
339
+ end,
340
+
341
+ Tree = function()
342
+ Iris.Tree({ "Trees" })
343
+ do
344
+ Iris.Tree({ "Tree using SpanAvailWidth", true })
345
+ do
346
+ helpMarker(
347
+ "SpanAvailWidth determines if the Tree is selectable from its entire with, or only the text area"
348
+ )
349
+ end
350
+ Iris.End()
351
+
352
+ local tree1 = Iris.Tree({ "Tree with Children" })
353
+ do
354
+ Iris.Text({ "Im inside the first tree!" })
355
+ Iris.Button({ "Im a button inside the first tree!" })
356
+ Iris.Tree({ "Im a tree inside the first tree!" })
357
+ do
358
+ Iris.Text({ "I am the innermost text!" })
359
+ end
360
+ Iris.End()
361
+ end
362
+ Iris.End()
363
+
364
+ Iris.Checkbox({ "Toggle above tree" }, { isChecked = tree1.state.isUncollapsed })
365
+ end
366
+ Iris.End()
367
+ end,
368
+
369
+ CollapsingHeader = function()
370
+ Iris.Tree({ "Collapsing Headers" })
371
+ do
372
+ Iris.CollapsingHeader({ "A header" })
373
+ do
374
+ Iris.Text({ "This is under the first header!" })
375
+ end
376
+ Iris.End()
377
+
378
+ local secondHeader = Iris.State(false)
379
+ Iris.CollapsingHeader({ "Another header" }, { isUncollapsed = secondHeader })
380
+ do
381
+ if Iris.Button({ "Shhh... secret button!" }).clicked() then
382
+ secondHeader:set(true)
383
+ end
384
+ end
385
+ Iris.End()
386
+ end
387
+ Iris.End()
388
+ end,
389
+
390
+ Group = function()
391
+ Iris.Tree({ "Groups" })
392
+ do
393
+ Iris.SameLine()
394
+ do
395
+ Iris.Group()
396
+ do
397
+ Iris.Text({ "I am in group A" })
398
+ Iris.Button({ "Im also in A" })
399
+ end
400
+ Iris.End()
401
+
402
+ Iris.Separator()
403
+
404
+ Iris.Group()
405
+ do
406
+ Iris.Text({ "I am in group B" })
407
+ Iris.Button({ "Im also in B" })
408
+ Iris.Button({ "Also group B" })
409
+ end
410
+ Iris.End()
411
+ end
412
+ Iris.End()
413
+ end
414
+ Iris.End()
415
+ end,
416
+
417
+ Tab = function()
418
+ Iris.Tree({ "Tabs" })
419
+ do
420
+ Iris.Tree({ "Simple" })
421
+ do
422
+ Iris.TabBar()
423
+ do
424
+ Iris.Tab({ "Apples" })
425
+ do
426
+ Iris.Text({ "Who loves apples?" })
427
+ end
428
+ Iris.End()
429
+ Iris.Tab({ "Broccoli" })
430
+ do
431
+ Iris.Text({ "And what about broccoli?" })
432
+ end
433
+ Iris.End()
434
+ Iris.Tab({ "Carrots" })
435
+ do
436
+ Iris.Text({ "But carrots are the best." })
437
+ end
438
+ Iris.End()
439
+ end
440
+ Iris.End()
441
+ Iris.Separator()
442
+ Iris.Text({ "Very important questions." })
443
+ end
444
+ Iris.End()
445
+
446
+ Iris.Tree({ "Closable" })
447
+ do
448
+ local a = Iris.State(true)
449
+ local b = Iris.State(true)
450
+ local c = Iris.State(true)
451
+
452
+ Iris.TabBar()
453
+ do
454
+ Iris.Tab({ "🍎", true }, { isOpened = a })
455
+ do
456
+ Iris.Text({ "Who loves apples?" })
457
+ if Iris.Button({ "I don't like apples." }).clicked() then
458
+ a:set(false)
459
+ end
460
+ end
461
+ Iris.End()
462
+ Iris.Tab({ "🥦", true }, { isOpened = b })
463
+ do
464
+ Iris.Text({ "And what about broccoli?" })
465
+ if Iris.Button({ "Not for me." }).clicked() then
466
+ b:set(false)
467
+ end
468
+ end
469
+ Iris.End()
470
+ Iris.Tab({ "🥕", true }, { isOpened = c })
471
+ do
472
+ Iris.Text({ "But carrots are the best." })
473
+ if Iris.Button({ "I disagree with you." }).clicked() then
474
+ c:set(false)
475
+ end
476
+ end
477
+ Iris.End()
478
+ end
479
+ Iris.End()
480
+ Iris.Separator()
481
+ if Iris.Button({ "Actually, let me reconsider it." }).clicked() then
482
+ a:set(true)
483
+ b:set(true)
484
+ c:set(true)
485
+ end
486
+ end
487
+ Iris.End()
488
+ end
489
+ Iris.End()
490
+ end,
491
+
492
+ Indent = function()
493
+ Iris.Tree({ "Indents" })
494
+ Iris.Text({ "Not Indented" })
495
+ Iris.Indent()
496
+ do
497
+ Iris.Text({ "Indented" })
498
+ Iris.Indent({ 7 })
499
+ do
500
+ Iris.Text({ "Indented by 7 more pixels" })
501
+ Iris.End()
502
+
503
+ Iris.Indent({ -7 })
504
+ do
505
+ Iris.Text({ "Indented by 7 less pixels" })
506
+ end
507
+ Iris.End()
508
+ end
509
+ Iris.End()
510
+ end
511
+ Iris.End()
512
+ end,
513
+
514
+ Input = function()
515
+ Iris.Tree({ "Input" })
516
+ do
517
+ local NoField, NoButtons, Min, Max, Increment, Format =
518
+ Iris.State(false),
519
+ Iris.State(false),
520
+ Iris.State(0),
521
+ Iris.State(100),
522
+ Iris.State(1),
523
+ Iris.State("%d")
524
+
525
+ Iris.PushConfig({ ContentWidth = UDim.new(1, -120) })
526
+ local InputNum = Iris.InputNum({
527
+ [Iris.Args.InputNum.Text] = "Input Number",
528
+ -- [Iris.Args.InputNum.NoField] = NoField.value,
529
+ [Iris.Args.InputNum.NoButtons] = NoButtons.value,
530
+ [Iris.Args.InputNum.Min] = Min.value,
531
+ [Iris.Args.InputNum.Max] = Max.value,
532
+ [Iris.Args.InputNum.Increment] = Increment.value,
533
+ [Iris.Args.InputNum.Format] = { Format.value },
534
+ })
535
+ Iris.PopConfig()
536
+ Iris.Text({ "The Value is: " .. InputNum.number.value })
537
+ if Iris.Button({ "Randomize Number" }).clicked() then
538
+ InputNum.number:set(math.random(1, 99))
539
+ end
540
+ local NoFieldCheckbox = Iris.Checkbox({ "NoField" }, { isChecked = NoField })
541
+ local NoButtonsCheckbox = Iris.Checkbox({ "NoButtons" }, { isChecked = NoButtons })
542
+ if NoFieldCheckbox.checked() and NoButtonsCheckbox.isChecked.value == true then
543
+ NoButtonsCheckbox.isChecked:set(false)
544
+ end
545
+ if NoButtonsCheckbox.checked() and NoFieldCheckbox.isChecked.value == true then
546
+ NoFieldCheckbox.isChecked:set(false)
547
+ end
548
+
549
+ Iris.PushConfig({ ContentWidth = UDim.new(1, -120) })
550
+ Iris.InputVector2({ "InputVector2" })
551
+ Iris.InputVector3({ "InputVector3" })
552
+ Iris.InputUDim({ "InputUDim" })
553
+ Iris.InputUDim2({ "InputUDim2" })
554
+ local UseFloats = Iris.State(false)
555
+ local UseHSV = Iris.State(false)
556
+ local sharedColor = Iris.State(Color3.new())
557
+ local transparency = Iris.State(0)
558
+ Iris.SliderNum({ "Transparency", 0.01, 0, 1 }, { number = transparency })
559
+ Iris.InputColor3({ "InputColor3", UseFloats:get(), UseHSV:get() }, { color = sharedColor })
560
+ Iris.InputColor4(
561
+ { "InputColor4", UseFloats:get(), UseHSV:get() },
562
+ { color = sharedColor, transparency = transparency }
563
+ )
564
+ Iris.SameLine()
565
+ Iris.Text({ `#{sharedColor:get():ToHex()}` })
566
+ Iris.Checkbox({ "Use Floats" }, { isChecked = UseFloats })
567
+ Iris.Checkbox({ "Use HSV" }, { isChecked = UseHSV })
568
+ Iris.End()
569
+
570
+ Iris.PopConfig()
571
+
572
+ Iris.Separator()
573
+
574
+ Iris.SameLine()
575
+ do
576
+ Iris.Text({ "Slider Numbers" })
577
+ helpMarker("ctrl + click slider number widgets to input a number")
578
+ end
579
+ Iris.End()
580
+ Iris.PushConfig({ ContentWidth = UDim.new(1, -120) })
581
+ Iris.SliderNum({ "Slide Int", 1, 1, 8 })
582
+ Iris.SliderNum({ "Slide Float", 0.01, 0, 100 })
583
+ Iris.SliderNum({ "Small Numbers", 0.001, -2, 1, "%f radians" })
584
+ Iris.SliderNum({ "Odd Ranges", 0.001, -math.pi, math.pi, "%f radians" })
585
+ Iris.SliderNum({ "Big Numbers", 1e4, 1e5, 1e7 })
586
+ Iris.SliderNum({ "Few Numbers", 1, 0, 3 })
587
+ Iris.PopConfig()
588
+
589
+ Iris.Separator()
590
+
591
+ Iris.SameLine()
592
+ do
593
+ Iris.Text({ "Drag Numbers" })
594
+ helpMarker(
595
+ "ctrl + click or double click drag number widgets to input a number, hold shift/alt while dragging to increase/decrease speed"
596
+ )
597
+ end
598
+ Iris.End()
599
+ Iris.PushConfig({ ContentWidth = UDim.new(1, -120) })
600
+ Iris.DragNum({ "Drag Int" })
601
+ Iris.DragNum({ "Slide Float", 0.001, -10, 10 })
602
+ Iris.DragNum({ "Percentage", 1, 0, 100, "%d %%" })
603
+ Iris.PopConfig()
604
+ end
605
+ Iris.End()
606
+ end,
607
+
608
+ InputText = function()
609
+ Iris.Tree({ "Input Text" })
610
+ do
611
+ local InputText = Iris.InputText({ "Input Text Test", "Input Text here" })
612
+ Iris.Text({ "The text is: " .. InputText.text.value })
613
+ end
614
+ Iris.End()
615
+ end,
616
+
617
+ MultiInput = function()
618
+ Iris.Tree({ "Multi-Component Input" })
619
+ do
620
+ local sharedVector2 = Iris.State(Vector2.new())
621
+ local sharedVector3 = Iris.State(Vector3.new())
622
+ local sharedUDim = Iris.State(UDim.new())
623
+ local sharedUDim2 = Iris.State(UDim2.new())
624
+ local sharedColor3 = Iris.State(Color3.new())
625
+ local SharedRect = Iris.State(Rect.new(0, 0, 0, 0))
626
+
627
+ Iris.SeparatorText({ "Input" })
628
+
629
+ Iris.InputVector2({}, { number = sharedVector2 })
630
+ Iris.InputVector3({}, { number = sharedVector3 })
631
+ Iris.InputUDim({}, { number = sharedUDim })
632
+ Iris.InputUDim2({}, { number = sharedUDim2 })
633
+ Iris.InputRect({}, { number = SharedRect })
634
+
635
+ Iris.SeparatorText({ "Drag" })
636
+
637
+ Iris.DragVector2({}, { number = sharedVector2 })
638
+ Iris.DragVector3({}, { number = sharedVector3 })
639
+ Iris.DragUDim({}, { number = sharedUDim })
640
+ Iris.DragUDim2({}, { number = sharedUDim2 })
641
+ Iris.DragRect({}, { number = SharedRect })
642
+
643
+ Iris.SeparatorText({ "Slider" })
644
+
645
+ Iris.SliderVector2({}, { number = sharedVector2 })
646
+ Iris.SliderVector3({}, { number = sharedVector3 })
647
+ Iris.SliderUDim({}, { number = sharedUDim })
648
+ Iris.SliderUDim2({}, { number = sharedUDim2 })
649
+ Iris.SliderRect({}, { number = SharedRect })
650
+
651
+ Iris.SeparatorText({ "Color" })
652
+
653
+ Iris.InputColor3({}, { color = sharedColor3 })
654
+ Iris.InputColor4({}, { color = sharedColor3 })
655
+ end
656
+ Iris.End()
657
+ end,
658
+
659
+ Tooltip = function()
660
+ Iris.PushConfig({ ContentWidth = UDim.new(0, 250) })
661
+ Iris.Tree({ "Tooltip" })
662
+ do
663
+ if Iris.Text({ "Hover over me to reveal a tooltip" }).hovered() then
664
+ Iris.Tooltip({ "I am some helpful tooltip text" })
665
+ end
666
+ local dynamicText = Iris.State("Hello ")
667
+ local numRepeat = Iris.State(1)
668
+ if Iris.InputNum({ "# of repeat", 1, 1, 50 }, { number = numRepeat }).numberChanged() then
669
+ dynamicText:set(string.rep("Hello ", numRepeat:get()))
670
+ end
671
+ if Iris.Checkbox({ "Show dynamic text tooltip" }).state.isChecked.value then
672
+ Iris.Tooltip({ dynamicText:get() })
673
+ end
674
+ end
675
+ Iris.End()
676
+ Iris.PopConfig()
677
+ end,
678
+
679
+ Plotting = function()
680
+ Iris.Tree({ "Plotting" })
681
+ do
682
+ Iris.SeparatorText({ "Progress" })
683
+ local curTime = os.clock() * 15
684
+
685
+ local Progress = Iris.State(0)
686
+ -- formula to cycle between 0 and 100 linearly
687
+ local newValue = math.clamp((math.abs(curTime % 100 - 50)) - 7.5, 0, 35) / 35
688
+ Progress:set(newValue)
689
+
690
+ Iris.ProgressBar({ "Progress Bar" }, { progress = Progress })
691
+ Iris.ProgressBar(
692
+ { "Progress Bar", `{math.floor(Progress:get() * 1753)}/1753` },
693
+ { progress = Progress }
694
+ )
695
+
696
+ Iris.SeparatorText({ "Graphs" })
697
+
698
+ do
699
+ local ValueState = Iris.State({ 0.5, 0.8, 0.2, 0.9, 0.1, 0.6, 0.4, 0.7, 0.3, 0.0 })
700
+
701
+ Iris.PlotHistogram({ "Histogram", 100, 0, 1, "random" }, { values = ValueState })
702
+ Iris.PlotLines({ "Lines", 100, 0, 1, "random" }, { values = ValueState })
703
+ end
704
+
705
+ do
706
+ local FunctionState = Iris.State("Cos")
707
+ local SampleState = Iris.State(37)
708
+ local BaseLineState = Iris.State(0)
709
+ local ValueState = Iris.State({})
710
+ local TimeState = Iris.State(0)
711
+
712
+ local Animated = Iris.Checkbox({ "Animate" })
713
+ local plotFunc = Iris.ComboArray(
714
+ { "Plotting Function" },
715
+ { index = FunctionState },
716
+ { "Sin", "Cos", "Tan", "Saw" }
717
+ )
718
+ local samples = Iris.SliderNum({ "Samples", 1, 1, 145, "%d samples" }, { number = SampleState })
719
+ if Iris.SliderNum({ "Baseline", 0.1, -1, 1 }, { number = BaseLineState }).numberChanged() then
720
+ ValueState:set(ValueState.value, true)
721
+ end
722
+
723
+ if
724
+ Animated.state.isChecked.value
725
+ or plotFunc.closed()
726
+ or samples.numberChanged()
727
+ or #ValueState.value == 0
728
+ then
729
+ if Animated.state.isChecked.value then
730
+ TimeState:set(TimeState.value + Iris.Internal._deltaTime)
731
+ end
732
+ local offset = math.floor(TimeState.value * 30) - 1
733
+ local func = FunctionState.value
734
+ table.clear(ValueState.value)
735
+ for i = 1, SampleState.value do
736
+ if func == "Sin" then
737
+ ValueState.value[i] = math.sin(math.rad(5 * (i + offset)))
738
+ elseif func == "Cos" then
739
+ ValueState.value[i] = math.cos(math.rad(5 * (i + offset)))
740
+ elseif func == "Tan" then
741
+ ValueState.value[i] = math.tan(math.rad(5 * (i + offset)))
742
+ elseif func == "Saw" then
743
+ ValueState.value[i] = if (i % 2) == (offset % 2) then 1 else -1
744
+ end
745
+ end
746
+
747
+ ValueState:set(ValueState.value, true)
748
+ end
749
+
750
+ Iris.PlotHistogram({ "Histogram", 100, -1, 1, "", BaseLineState:get() }, { values = ValueState })
751
+ Iris.PlotLines({ "Lines", 100, -1, 1 }, { values = ValueState })
752
+ end
753
+ end
754
+ Iris.End()
755
+ end,
756
+ }
757
+ local widgetDemosOrder = {
758
+ "Basic",
759
+ "Image",
760
+ "Selectable",
761
+ "Combo",
762
+ "Tree",
763
+ "CollapsingHeader",
764
+ "Group",
765
+ "Tab",
766
+ "Indent",
767
+ "Input",
768
+ "MultiInput",
769
+ "InputText",
770
+ "Tooltip",
771
+ "Plotting",
772
+ }
773
+
774
+ local function recursiveTree()
775
+ local theTree = Iris.Tree({ "Recursive Tree" })
776
+ do
777
+ if theTree.state.isUncollapsed.value then
778
+ recursiveTree()
779
+ end
780
+ end
781
+ Iris.End()
782
+ end
783
+
784
+ local function recursiveWindow(parentCheckboxState)
785
+ local theCheckbox
786
+ Iris.Window(
787
+ { "Recursive Window" },
788
+ { size = Iris.State(Vector2.new(175, 100)), isOpened = parentCheckboxState }
789
+ )
790
+ do
791
+ theCheckbox = Iris.Checkbox({ "Recurse Again" })
792
+ end
793
+ Iris.End()
794
+
795
+ if theCheckbox.isChecked.value then
796
+ recursiveWindow(theCheckbox.isChecked)
797
+ end
798
+ end
799
+
800
+ -- shows list of runtime widgets and states, including IDs. shows other info about runtime and can show widgets/state info in depth.
801
+ local function runtimeInfo()
802
+ local runtimeInfoWindow = Iris.Window({ "Runtime Info" }, { isOpened = showRuntimeInfo })
803
+ do
804
+ local lastVDOM = Iris.Internal._lastVDOM
805
+ local states = Iris.Internal._states
806
+
807
+ local numSecondsDisabled = Iris.State(3)
808
+ local rollingDT = Iris.State(0)
809
+ local lastT = Iris.State(os.clock())
810
+
811
+ Iris.SameLine()
812
+ do
813
+ Iris.InputNum({
814
+ [Iris.Args.InputNum.Text] = "",
815
+ [Iris.Args.InputNum.Format] = "%d Seconds",
816
+ [Iris.Args.InputNum.Max] = 10,
817
+ }, { number = numSecondsDisabled })
818
+ if Iris.Button({ "Disable" }).clicked() then
819
+ Iris.Disabled = true
820
+ task.delay(numSecondsDisabled:get(), function()
821
+ Iris.Disabled = false
822
+ end)
823
+ end
824
+ end
825
+ Iris.End()
826
+
827
+ local t = os.clock()
828
+ local dt = t - lastT.value
829
+ rollingDT.value += (dt - rollingDT.value) * 0.2
830
+ lastT.value = t
831
+ Iris.Text({ string.format("Average %.3f ms/frame (%.1f FPS)", rollingDT.value * 1000, 1 / rollingDT.value) })
832
+
833
+ Iris.Text({
834
+ string.format(
835
+ "Window Position: (%d, %d), Window Size: (%d, %d)",
836
+ runtimeInfoWindow.position.value.X,
837
+ runtimeInfoWindow.position.value.Y,
838
+ runtimeInfoWindow.size.value.X,
839
+ runtimeInfoWindow.size.value.Y
840
+ ),
841
+ })
842
+
843
+ Iris.SameLine()
844
+ do
845
+ Iris.Text({ "Enter an ID to learn more about it." })
846
+ helpMarker(
847
+ "every widget and state has an ID which Iris tracks to remember which widget is which. below lists all widgets and states, with their respective IDs"
848
+ )
849
+ end
850
+ Iris.End()
851
+
852
+ Iris.PushConfig({ ItemWidth = UDim.new(1, -150) })
853
+ local enteredText =
854
+ Iris.InputText({ "ID field" }, { text = Iris.State(runtimeInfoWindow.ID) }).state.text.value
855
+ Iris.PopConfig()
856
+
857
+ Iris.Indent()
858
+ do
859
+ local enteredWidget = lastVDOM[enteredText]
860
+ local enteredState = states[enteredText]
861
+ if enteredWidget then
862
+ Iris.Table({ 1 })
863
+ Iris.Text({ string.format('The ID, "%s", is a widget', enteredText) })
864
+ Iris.NextRow()
865
+
866
+ Iris.Text({ string.format("Widget is type: %s", enteredWidget.type) })
867
+ Iris.NextRow()
868
+
869
+ Iris.Tree({ "Widget has Args:" }, { isUncollapsed = Iris.State(true) })
870
+ for i, v in enteredWidget.arguments do
871
+ Iris.Text({ i .. " - " .. tostring(v) })
872
+ end
873
+ Iris.End()
874
+ Iris.NextRow()
875
+
876
+ if enteredWidget.state then
877
+ Iris.Tree({ "Widget has State:" }, { isUncollapsed = Iris.State(true) })
878
+ for i, v in enteredWidget.state do
879
+ Iris.Text({ i .. " - " .. tostring(v.value) })
880
+ end
881
+ Iris.End()
882
+ end
883
+ Iris.End()
884
+ elseif enteredState then
885
+ Iris.Table({ 1 })
886
+ Iris.Text({ string.format('The ID, "%s", is a state', enteredText) })
887
+ Iris.NextRow()
888
+
889
+ Iris.Text({
890
+ string.format(
891
+ "Value is type: %s, Value = %s",
892
+ typeof(enteredState.value),
893
+ tostring(enteredState.value)
894
+ ),
895
+ })
896
+ Iris.NextRow()
897
+
898
+ Iris.Tree({ "state has connected widgets:" }, { isUncollapsed = Iris.State(true) })
899
+ for i, v in enteredState.ConnectedWidgets do
900
+ Iris.Text({ i .. " - " .. v.type })
901
+ end
902
+ Iris.End()
903
+ Iris.NextRow()
904
+
905
+ Iris.Text({ string.format("state has: %d connected functions", #enteredState.ConnectedFunctions) })
906
+ Iris.End()
907
+ else
908
+ Iris.Text({ string.format('The ID, "%s", is not a state or widget', enteredText) })
909
+ end
910
+ end
911
+ Iris.End()
912
+
913
+ if Iris.Tree({ "Widgets" }).state.isUncollapsed.value then
914
+ local widgetCount = 0
915
+ local widgetStr = ""
916
+ for _, v in lastVDOM do
917
+ widgetCount += 1
918
+ widgetStr ..= "\n" .. v.ID .. " - " .. v.type
919
+ end
920
+
921
+ Iris.Text({ "Number of Widgets: " .. widgetCount })
922
+
923
+ Iris.Text({ widgetStr })
924
+ end
925
+ Iris.End()
926
+
927
+ if Iris.Tree({ "States" }).state.isUncollapsed.value then
928
+ local stateCount = 0
929
+ local stateStr = ""
930
+ for i, v in states do
931
+ stateCount += 1
932
+ stateStr ..= "\n" .. i .. " - " .. tostring(v.value)
933
+ end
934
+
935
+ Iris.Text({ "Number of States: " .. stateCount })
936
+
937
+ Iris.Text({ stateStr })
938
+ end
939
+ Iris.End()
940
+ end
941
+ Iris.End()
942
+ end
943
+
944
+ local function debugPanel()
945
+ Iris.Window({ "Debug Panel" }, { isOpened = showDebugWindow })
946
+ do
947
+ Iris.CollapsingHeader({ "Widgets" })
948
+ do
949
+ Iris.SeparatorText({ "GuiService" })
950
+ Iris.Text({ `GuiOffset: {Iris.Internal._utility.GuiOffset}` })
951
+ Iris.Text({ `MouseOffset: {Iris.Internal._utility.MouseOffset}` })
952
+
953
+ Iris.SeparatorText({ "UserInputService" })
954
+ Iris.Text({ `MousePosition: {Iris.Internal._utility.UserInputService:GetMouseLocation()}` })
955
+ Iris.Text({ `MouseLocation: {Iris.Internal._utility.getMouseLocation()}` })
956
+
957
+ Iris.Text({
958
+ `Left Control: {Iris.Internal._utility.UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)}`,
959
+ })
960
+ Iris.Text({
961
+ `Right Control: {Iris.Internal._utility.UserInputService:IsKeyDown(Enum.KeyCode.RightControl)}`,
962
+ })
963
+ end
964
+ Iris.End()
965
+ end
966
+ Iris.End()
967
+ end
968
+
969
+ local function recursiveMenu()
970
+ if Iris.Menu({ "Recursive" }).state.isOpened.value then
971
+ Iris.MenuItem({ "New", Enum.KeyCode.N, Enum.ModifierKey.Ctrl })
972
+ Iris.MenuItem({ "Open", Enum.KeyCode.O, Enum.ModifierKey.Ctrl })
973
+ Iris.MenuItem({ "Save", Enum.KeyCode.S, Enum.ModifierKey.Ctrl })
974
+ Iris.Separator()
975
+ Iris.MenuToggle({ "Autosave" })
976
+ Iris.MenuToggle({ "Checked" })
977
+ Iris.Separator()
978
+ Iris.Menu({ "Options" })
979
+ Iris.MenuItem({ "Red" })
980
+ Iris.MenuItem({ "Yellow" })
981
+ Iris.MenuItem({ "Green" })
982
+ Iris.MenuItem({ "Blue" })
983
+ Iris.Separator()
984
+ recursiveMenu()
985
+ Iris.End()
986
+ end
987
+ Iris.End()
988
+ end
989
+
990
+ local function mainMenuBar()
991
+ Iris.MenuBar()
992
+ do
993
+ Iris.Menu({ "File" })
994
+ do
995
+ Iris.MenuItem({ "New", Enum.KeyCode.N, Enum.ModifierKey.Ctrl })
996
+ Iris.MenuItem({ "Open", Enum.KeyCode.O, Enum.ModifierKey.Ctrl })
997
+ Iris.MenuItem({ "Save", Enum.KeyCode.S, Enum.ModifierKey.Ctrl })
998
+ recursiveMenu()
999
+ if Iris.MenuItem({ "Quit", Enum.KeyCode.Q, Enum.ModifierKey.Alt }).clicked() then
1000
+ showMainWindow:set(false)
1001
+ end
1002
+ end
1003
+ Iris.End()
1004
+
1005
+ Iris.Menu({ "Examples" })
1006
+ do
1007
+ Iris.MenuToggle({ "Recursive Window" }, { isChecked = showRecursiveWindow })
1008
+ Iris.MenuToggle({ "Windowless" }, { isChecked = showWindowlessDemo })
1009
+ Iris.MenuToggle({ "Main Menu Bar" }, { isChecked = showMainMenuBarWindow })
1010
+ end
1011
+ Iris.End()
1012
+
1013
+ Iris.Menu({ "Tools" })
1014
+ do
1015
+ Iris.MenuToggle({ "Runtime Info" }, { isChecked = showRuntimeInfo })
1016
+ Iris.MenuToggle({ "Style Editor" }, { isChecked = showStyleEditor })
1017
+ Iris.MenuToggle({ "Debug Panel" }, { isChecked = showDebugWindow })
1018
+ end
1019
+ Iris.End()
1020
+ end
1021
+ Iris.End()
1022
+ end
1023
+
1024
+ local function mainMenuBarExample()
1025
+ -- local screenSize = Iris.Internal._rootWidget.Instance.PseudoWindowScreenGui.AbsoluteSize
1026
+ -- Iris.Window(
1027
+ -- {[Iris.Args.Window.NoBackground] = true, [Iris.Args.Window.NoTitleBar] = true, [Iris.Args.Window.NoMove] = true, [Iris.Args.Window.NoResize] = true},
1028
+ -- {size = Iris.State(screenSize), position = Iris.State(Vector2.new(0, 0))}
1029
+ -- )
1030
+
1031
+ mainMenuBar()
1032
+
1033
+ --Iris.End()
1034
+ end
1035
+
1036
+ -- allows users to edit state
1037
+ local styleEditor
1038
+ do
1039
+ styleEditor = function()
1040
+ local styleList = {
1041
+ {
1042
+ "Sizing",
1043
+ function()
1044
+ local UpdatedConfig = Iris.State({})
1045
+
1046
+ Iris.SameLine()
1047
+ do
1048
+ if Iris.Button({ "Update" }).clicked() then
1049
+ Iris.UpdateGlobalConfig(UpdatedConfig.value)
1050
+ UpdatedConfig:set({})
1051
+ end
1052
+
1053
+ helpMarker("Update the global config with these changes.")
1054
+ end
1055
+ Iris.End()
1056
+
1057
+ local function SliderInput(input: string, arguments: { any })
1058
+ local Input =
1059
+ Iris[input](arguments, { number = Iris.WeakState(Iris._config[arguments[1]]) })
1060
+ if Input.numberChanged() then
1061
+ UpdatedConfig.value[arguments[1]] = Input.number:get()
1062
+ end
1063
+ end
1064
+
1065
+ local function BooleanInput(arguments: { any })
1066
+ local Input =
1067
+ Iris.Checkbox(arguments, { isChecked = Iris.WeakState(Iris._config[arguments[1]]) })
1068
+ if Input.checked() or Input.unchecked() then
1069
+ UpdatedConfig.value[arguments[1]] = Input.isChecked:get()
1070
+ end
1071
+ end
1072
+
1073
+ Iris.SeparatorText({ "Main" })
1074
+ SliderInput("SliderVector2", { "WindowPadding", nil, Vector2.zero, Vector2.new(20, 20) })
1075
+ SliderInput("SliderVector2", { "WindowResizePadding", nil, Vector2.zero, Vector2.new(20, 20) })
1076
+ SliderInput("SliderVector2", { "FramePadding", nil, Vector2.zero, Vector2.new(20, 20) })
1077
+ SliderInput("SliderVector2", { "ItemSpacing", nil, Vector2.zero, Vector2.new(20, 20) })
1078
+ SliderInput("SliderVector2", { "ItemInnerSpacing", nil, Vector2.zero, Vector2.new(20, 20) })
1079
+ SliderInput("SliderVector2", { "CellPadding", nil, Vector2.zero, Vector2.new(20, 20) })
1080
+ SliderInput("SliderNum", { "IndentSpacing", 1, 0, 36 })
1081
+ SliderInput("SliderNum", { "ScrollbarSize", 1, 0, 20 })
1082
+ SliderInput("SliderNum", { "GrabMinSize", 1, 0, 20 })
1083
+
1084
+ Iris.SeparatorText({ "Borders & Rounding" })
1085
+ SliderInput("SliderNum", { "FrameBorderSize", 0.1, 0, 1 })
1086
+ SliderInput("SliderNum", { "WindowBorderSize", 0.1, 0, 1 })
1087
+ SliderInput("SliderNum", { "PopupBorderSize", 0.1, 0, 1 })
1088
+ SliderInput("SliderNum", { "SeparatorTextBorderSize", 1, 0, 20 })
1089
+ SliderInput("SliderNum", { "FrameRounding", 1, 0, 12 })
1090
+ SliderInput("SliderNum", { "GrabRounding", 1, 0, 12 })
1091
+ SliderInput("SliderNum", { "PopupRounding", 1, 0, 12 })
1092
+
1093
+ Iris.SeparatorText({ "Widgets" })
1094
+ SliderInput(
1095
+ "SliderVector2",
1096
+ { "DisplaySafeAreaPadding", nil, Vector2.zero, Vector2.new(20, 20) }
1097
+ )
1098
+ SliderInput("SliderVector2", { "SeparatorTextPadding", nil, Vector2.zero, Vector2.new(36, 36) })
1099
+ SliderInput("SliderUDim", { "ItemWidth", nil, UDim.new(), UDim.new(1, 200) })
1100
+ SliderInput("SliderUDim", { "ContentWidth", nil, UDim.new(), UDim.new(1, 200) })
1101
+ SliderInput("SliderNum", { "ImageBorderSize", 1, 0, 12 })
1102
+ local TitleInput = Iris.ComboEnum(
1103
+ { "WindowTitleAlign" },
1104
+ { index = Iris.WeakState(Iris._config.WindowTitleAlign) },
1105
+ Enum.LeftRight
1106
+ )
1107
+ if TitleInput.closed() then
1108
+ UpdatedConfig.value["WindowTitleAlign"] = TitleInput.index:get()
1109
+ end
1110
+ BooleanInput({ "RichText" })
1111
+ BooleanInput({ "TextWrapped" })
1112
+
1113
+ Iris.SeparatorText({ "Config" })
1114
+ BooleanInput({ "UseScreenGUIs" })
1115
+ SliderInput("DragNum", { "DisplayOrderOffset", 1, 0 })
1116
+ SliderInput("DragNum", { "ZIndexOffset", 1, 0 })
1117
+ SliderInput("SliderNum", { "MouseDoubleClickTime", 0.1, 0, 5 })
1118
+ SliderInput("SliderNum", { "MouseDoubleClickMaxDist", 0.1, 0, 20 })
1119
+ end,
1120
+ },
1121
+ {
1122
+ "Colors",
1123
+ function()
1124
+ local UpdatedConfig = Iris.State({})
1125
+
1126
+ Iris.SameLine()
1127
+ do
1128
+ if Iris.Button({ "Update" }).clicked() then
1129
+ Iris.UpdateGlobalConfig(UpdatedConfig.value)
1130
+ UpdatedConfig:set({})
1131
+ end
1132
+ helpMarker("Update the global config with these changes.")
1133
+ end
1134
+ Iris.End()
1135
+
1136
+ local color4s = {
1137
+ "Text",
1138
+ "TextDisabled",
1139
+ "WindowBg",
1140
+ "PopupBg",
1141
+ "Border",
1142
+ "BorderActive",
1143
+ "ScrollbarGrab",
1144
+ "TitleBg",
1145
+ "TitleBgActive",
1146
+ "TitleBgCollapsed",
1147
+ "MenubarBg",
1148
+ "FrameBg",
1149
+ "FrameBgHovered",
1150
+ "FrameBgActive",
1151
+ "Button",
1152
+ "ButtonHovered",
1153
+ "ButtonActive",
1154
+ "Image",
1155
+ "SliderGrab",
1156
+ "SliderGrabActive",
1157
+ "Header",
1158
+ "HeaderHovered",
1159
+ "HeaderActive",
1160
+ "SelectionImageObject",
1161
+ "SelectionImageObjectBorder",
1162
+ "TableBorderStrong",
1163
+ "TableBorderLight",
1164
+ "TableRowBg",
1165
+ "TableRowBgAlt",
1166
+ "NavWindowingHighlight",
1167
+ "NavWindowingDimBg",
1168
+ "Separator",
1169
+ "CheckMark",
1170
+ }
1171
+
1172
+ for _, vColor in color4s do
1173
+ local Input = Iris.InputColor4({ vColor }, {
1174
+ color = Iris.WeakState(Iris._config[vColor .. "Color"]),
1175
+ transparency = Iris.WeakState(Iris._config[vColor .. "Transparency"]),
1176
+ })
1177
+ if Input.numberChanged() then
1178
+ UpdatedConfig.value[vColor .. "Color"] = Input.color:get()
1179
+ UpdatedConfig.value[vColor .. "Transparency"] = Input.transparency:get()
1180
+ end
1181
+ end
1182
+ end,
1183
+ },
1184
+ {
1185
+ "Fonts",
1186
+ function()
1187
+ local UpdatedConfig = Iris.State({})
1188
+
1189
+ Iris.SameLine()
1190
+ do
1191
+ if Iris.Button({ "Update" }).clicked() then
1192
+ Iris.UpdateGlobalConfig(UpdatedConfig.value)
1193
+ UpdatedConfig:set({})
1194
+ end
1195
+
1196
+ helpMarker("Update the global config with these changes.")
1197
+ end
1198
+ Iris.End()
1199
+
1200
+ local fonts: { [string]: Font } = {
1201
+ ["Code (default)"] = Font.fromEnum(Enum.Font.Code),
1202
+ ["Ubuntu (template)"] = Font.fromEnum(Enum.Font.Ubuntu),
1203
+ ["Arial"] = Font.fromEnum(Enum.Font.Arial),
1204
+ ["Highway"] = Font.fromEnum(Enum.Font.Highway),
1205
+ ["Roboto"] = Font.fromEnum(Enum.Font.Roboto),
1206
+ ["Roboto Mono"] = Font.fromEnum(Enum.Font.RobotoMono),
1207
+ ["Noto Sans"] = Font.new("rbxassetid://12187370747"),
1208
+ ["Builder Sans"] = Font.fromEnum(Enum.Font.BuilderSans),
1209
+ ["Builder Mono"] = Font.new("rbxassetid://16658246179"),
1210
+ ["Sono"] = Font.new("rbxassetid://12187374537"),
1211
+ }
1212
+
1213
+ Iris.Text({
1214
+ `Current Font: {Iris._config.TextFont.Family} Weight: {Iris._config.TextFont.Weight} Style: {Iris._config.TextFont.Style}`,
1215
+ })
1216
+ Iris.SeparatorText({ "Size" })
1217
+
1218
+ local TextSize = Iris.SliderNum(
1219
+ { "Font Size", 1, 4, 20 },
1220
+ { number = Iris.WeakState(Iris._config.TextSize) }
1221
+ )
1222
+ if TextSize.numberChanged() then
1223
+ UpdatedConfig.value["TextSize"] = TextSize.state.number:get()
1224
+ end
1225
+
1226
+ Iris.SeparatorText({ "Properties" })
1227
+
1228
+ local TextFont = Iris.WeakState(Iris._config.TextFont.Family)
1229
+ local FontWeight = Iris.ComboEnum(
1230
+ { "Font Weight" },
1231
+ { index = Iris.WeakState(Iris._config.TextFont.Weight) },
1232
+ Enum.FontWeight
1233
+ )
1234
+ local FontStyle = Iris.ComboEnum(
1235
+ { "Font Style" },
1236
+ { index = Iris.WeakState(Iris._config.TextFont.Style) },
1237
+ Enum.FontStyle
1238
+ )
1239
+
1240
+ Iris.SeparatorText({ "Fonts" })
1241
+ for name, font in fonts do
1242
+ font = Font.new(font.Family, FontWeight.state.index.value, FontStyle.state.index.value)
1243
+ Iris.SameLine()
1244
+ do
1245
+ Iris.PushConfig({
1246
+ TextFont = font,
1247
+ })
1248
+
1249
+ if
1250
+ Iris.Selectable(
1251
+ { `{name} | "The quick brown fox jumps over the lazy dog."`, font.Family },
1252
+ { index = TextFont }
1253
+ ).selected()
1254
+ then
1255
+ UpdatedConfig.value["TextFont"] = font
1256
+ end
1257
+ Iris.PopConfig()
1258
+ end
1259
+ Iris.End()
1260
+ end
1261
+ end,
1262
+ },
1263
+ }
1264
+
1265
+ Iris.Window({ "Style Editor" }, { isOpened = showStyleEditor })
1266
+ do
1267
+ Iris.Text({ "Customize the look of Iris in realtime." })
1268
+
1269
+ local ThemeState = Iris.State("Dark Theme")
1270
+ if Iris.ComboArray({ "Theme" }, { index = ThemeState }, { "Dark Theme", "Light Theme" }).closed() then
1271
+ if ThemeState.value == "Dark Theme" then
1272
+ Iris.UpdateGlobalConfig(Iris.TemplateConfig.colorDark)
1273
+ elseif ThemeState.value == "Light Theme" then
1274
+ Iris.UpdateGlobalConfig(Iris.TemplateConfig.colorLight)
1275
+ end
1276
+ end
1277
+
1278
+ local SizeState = Iris.State("Classic Size")
1279
+ if Iris.ComboArray({ "Size" }, { index = SizeState }, { "Classic Size", "Larger Size" }).closed() then
1280
+ if SizeState.value == "Classic Size" then
1281
+ Iris.UpdateGlobalConfig(Iris.TemplateConfig.sizeDefault)
1282
+ elseif SizeState.value == "Larger Size" then
1283
+ Iris.UpdateGlobalConfig(Iris.TemplateConfig.sizeClear)
1284
+ end
1285
+ end
1286
+
1287
+ Iris.SameLine()
1288
+ do
1289
+ if Iris.Button({ "Revert" }).clicked() then
1290
+ Iris.UpdateGlobalConfig(Iris.TemplateConfig.colorDark)
1291
+ Iris.UpdateGlobalConfig(Iris.TemplateConfig.sizeDefault)
1292
+ ThemeState:set("Dark Theme")
1293
+ SizeState:set("Classic Size")
1294
+ end
1295
+
1296
+ helpMarker("Reset Iris to the default theme and size.")
1297
+ end
1298
+ Iris.End()
1299
+
1300
+ Iris.TabBar()
1301
+ do
1302
+ for i, v in ipairs(styleList) do
1303
+ Iris.Tab({ v[1] })
1304
+ do
1305
+ styleList[i][2]()
1306
+ end
1307
+ Iris.End()
1308
+ end
1309
+ end
1310
+ Iris.End()
1311
+
1312
+ Iris.Separator()
1313
+ end
1314
+ Iris.End()
1315
+ end
1316
+ end
1317
+
1318
+ local function widgetEventInteractivity()
1319
+ Iris.CollapsingHeader({ "Widget Event Interactivity" })
1320
+ do
1321
+ local clickCount = Iris.State(0)
1322
+ if Iris.Button({ "Click to increase Number" }).clicked() then
1323
+ clickCount:set(clickCount:get() + 1)
1324
+ end
1325
+ Iris.Text({ "The Number is: " .. clickCount:get() })
1326
+
1327
+ Iris.Separator()
1328
+
1329
+ local showEventText = Iris.State(false)
1330
+ local selectedEvent = Iris.State("clicked")
1331
+
1332
+ Iris.SameLine()
1333
+ do
1334
+ Iris.RadioButton({ "clicked", "clicked" }, { index = selectedEvent })
1335
+ Iris.RadioButton({ "rightClicked", "rightClicked" }, { index = selectedEvent })
1336
+ Iris.RadioButton({ "doubleClicked", "doubleClicked" }, { index = selectedEvent })
1337
+ Iris.RadioButton({ "ctrlClicked", "ctrlClicked" }, { index = selectedEvent })
1338
+ end
1339
+ Iris.End()
1340
+
1341
+ Iris.SameLine()
1342
+ do
1343
+ local button = Iris.Button({ selectedEvent:get() .. " to reveal text" })
1344
+ if button[selectedEvent:get()]() then
1345
+ showEventText:set(not showEventText:get())
1346
+ end
1347
+ if showEventText:get() then
1348
+ Iris.Text({ "Here i am!" })
1349
+ end
1350
+ end
1351
+ Iris.End()
1352
+
1353
+ Iris.Separator()
1354
+
1355
+ local showTextTimer = Iris.State(0)
1356
+ Iris.SameLine()
1357
+ do
1358
+ if Iris.Button({ "Click to show text for 20 frames" }).clicked() then
1359
+ showTextTimer:set(20)
1360
+ end
1361
+ if showTextTimer:get() > 0 then
1362
+ Iris.Text({ "Here i am!" })
1363
+ end
1364
+ end
1365
+ Iris.End()
1366
+
1367
+ showTextTimer:set(math.max(0, showTextTimer:get() - 1))
1368
+ Iris.Text({ "Text Timer: " .. showTextTimer:get() })
1369
+
1370
+ local checkbox0 = Iris.Checkbox({ "Event-tracked checkbox" })
1371
+ Iris.Indent()
1372
+ do
1373
+ Iris.Text({ "unchecked: " .. tostring(checkbox0.unchecked()) })
1374
+ Iris.Text({ "checked: " .. tostring(checkbox0.checked()) })
1375
+ end
1376
+ Iris.End()
1377
+
1378
+ Iris.SameLine()
1379
+ do
1380
+ if Iris.Button({ "Hover over me" }).hovered() then
1381
+ Iris.Text({ "The button is hovered" })
1382
+ end
1383
+ end
1384
+ Iris.End()
1385
+ end
1386
+ Iris.End()
1387
+ end
1388
+
1389
+ local function widgetStateInteractivity()
1390
+ Iris.CollapsingHeader({ "Widget State Interactivity" })
1391
+ do
1392
+ local checkbox0 = Iris.Checkbox({ "Widget-Generated State" })
1393
+ Iris.Text({ `isChecked: {checkbox0.state.isChecked.value}\n` })
1394
+
1395
+ local checkboxState0 = Iris.State(false)
1396
+ local checkbox1 = Iris.Checkbox({ "User-Generated State" }, { isChecked = checkboxState0 })
1397
+ Iris.Text({ `isChecked: {checkbox1.state.isChecked.value}\n` })
1398
+
1399
+ local checkbox2 = Iris.Checkbox({ "Widget Coupled State" })
1400
+ local checkbox3 = Iris.Checkbox({ "Coupled to above Checkbox" }, { isChecked = checkbox2.state.isChecked })
1401
+ Iris.Text({ `isChecked: {checkbox3.state.isChecked.value}\n` })
1402
+
1403
+ local checkboxState1 = Iris.State(false)
1404
+ local _checkbox4 = Iris.Checkbox({ "Widget and Code Coupled State" }, { isChecked = checkboxState1 })
1405
+ local Button0 = Iris.Button({ "Click to toggle above checkbox" })
1406
+ if Button0.clicked() then
1407
+ checkboxState1:set(not checkboxState1:get())
1408
+ end
1409
+ Iris.Text({ `isChecked: {checkboxState1.value}\n` })
1410
+
1411
+ local checkboxState2 = Iris.State(true)
1412
+ local checkboxState3 = Iris.ComputedState(checkboxState2, function(newValue)
1413
+ return not newValue
1414
+ end)
1415
+ local _checkbox5 = Iris.Checkbox({ "ComputedState (dynamic coupling)" }, { isChecked = checkboxState2 })
1416
+ local _checkbox5 = Iris.Checkbox({ "Inverted of above checkbox" }, { isChecked = checkboxState3 })
1417
+ Iris.Text({ `isChecked: {checkboxState3.value}\n` })
1418
+ end
1419
+ Iris.End()
1420
+ end
1421
+
1422
+ local function dynamicStyle()
1423
+ Iris.CollapsingHeader({ "Dynamic Styles" })
1424
+ do
1425
+ local colorH = Iris.State(0)
1426
+ Iris.SameLine()
1427
+ do
1428
+ if Iris.Button({ "Change Color" }).clicked() then
1429
+ colorH:set(math.random())
1430
+ end
1431
+ Iris.Text({ "Hue: " .. math.floor(colorH:get() * 255) })
1432
+ helpMarker("Using PushConfig with a changing value, this can be done with any config field")
1433
+ end
1434
+ Iris.End()
1435
+
1436
+ Iris.PushConfig({ TextColor = Color3.fromHSV(colorH:get(), 1, 1) })
1437
+ Iris.Text({ "Text with a unique and changable color" })
1438
+ Iris.PopConfig()
1439
+ end
1440
+ Iris.End()
1441
+ end
1442
+
1443
+ local function tablesDemo()
1444
+ local showTablesTree = Iris.State(false)
1445
+
1446
+ Iris.CollapsingHeader({ "Tables & Columns" }, { isUncollapsed = showTablesTree })
1447
+ if showTablesTree.value == false then
1448
+ -- optimization to skip code which draws GUI which wont be seen.
1449
+ -- its a trade off because when the tree becomes opened widgets will all have to be generated again.
1450
+ -- Dear ImGui utilizes the same trick, but its less useful here because the Retained mode Backend
1451
+ Iris.End()
1452
+ else
1453
+ Iris.Tree({ "Basic" })
1454
+ do
1455
+ Iris.SameLine()
1456
+ do
1457
+ Iris.Text({ "Table using NextColumn syntax:" })
1458
+ helpMarker(
1459
+ "calling Iris.NextColumn() in the inner loop,\nwhich automatically goes to the next row at the end."
1460
+ )
1461
+ end
1462
+ Iris.End()
1463
+
1464
+ Iris.Table({ 3 })
1465
+ do
1466
+ for i = 1, 4 do
1467
+ for i2 = 1, 3 do
1468
+ Iris.Text({ `Row: {i}, Column: {i2}` })
1469
+ Iris.NextColumn()
1470
+ end
1471
+ end
1472
+ end
1473
+ Iris.End()
1474
+
1475
+ Iris.Text({ "" })
1476
+
1477
+ Iris.SameLine()
1478
+ do
1479
+ Iris.Text({ "Table using NextColumn and NextRow syntax:" })
1480
+ helpMarker(
1481
+ "Calling Iris.NextColumn() in the inner loop and Iris.NextRow() in the outer loop,\nto acehieve a visually identical result. Technically they are not the same."
1482
+ )
1483
+ end
1484
+ Iris.End()
1485
+
1486
+ Iris.Table({ 3 })
1487
+ do
1488
+ for j = 1, 4 do
1489
+ for i = 1, 3 do
1490
+ Iris.Text({ `Row: {j}, Column: {i}` })
1491
+ Iris.NextColumn()
1492
+ end
1493
+ Iris.NextRow()
1494
+ end
1495
+ end
1496
+ Iris.End()
1497
+ end
1498
+ Iris.End()
1499
+
1500
+ Iris.Tree({ "Headers, borders and backgrounds" })
1501
+ do
1502
+ local Type = Iris.State(0)
1503
+ local Header = Iris.State(false)
1504
+ local RowBackgrounds = Iris.State(false)
1505
+ local OuterBorders = Iris.State(true)
1506
+ local InnerBorders = Iris.State(true)
1507
+
1508
+ Iris.Checkbox({ "Table header row" }, { isChecked = Header })
1509
+ Iris.Checkbox({ "Table row backgrounds" }, { isChecked = RowBackgrounds })
1510
+ Iris.Checkbox({ "Table outer border" }, { isChecked = OuterBorders })
1511
+ Iris.Checkbox({ "Table inner borders" }, { isChecked = InnerBorders })
1512
+ Iris.SameLine()
1513
+ do
1514
+ Iris.Text({ "Cell contents" })
1515
+ Iris.RadioButton({ "Text", 0 }, { index = Type })
1516
+ Iris.RadioButton({ "Fill button", 1 }, { index = Type })
1517
+ end
1518
+ Iris.End()
1519
+
1520
+ Iris.Table({ 3, Header.value, RowBackgrounds.value, OuterBorders.value, InnerBorders.value })
1521
+ do
1522
+ Iris.SetHeaderColumnIndex(1)
1523
+ for j = 0, 4 do
1524
+ for i = 1, 3 do
1525
+ if Type.value == 0 then
1526
+ Iris.Text({ `Cell ({i}, {j})` })
1527
+ else
1528
+ Iris.Button({ `Cell ({i}, {j})`, UDim2.fromScale(1, 0) })
1529
+ end
1530
+ Iris.NextColumn()
1531
+ end
1532
+ end
1533
+ end
1534
+ Iris.End()
1535
+ end
1536
+ Iris.End()
1537
+
1538
+ Iris.Tree({ "Sizing" })
1539
+ do
1540
+ local Resizable = Iris.State(false)
1541
+ local LimitWidth = Iris.State(false)
1542
+ Iris.Checkbox({ "Resizable" }, { isChecked = Resizable })
1543
+ Iris.Checkbox({ "Limit Table Width" }, { isChecked = LimitWidth })
1544
+
1545
+ do
1546
+ Iris.SeparatorText({ "stretch, equal" })
1547
+ Iris.Table({ 3, false, true, true, true, Resizable.value })
1548
+ do
1549
+ for _ = 1, 3 do
1550
+ for _ = 1, 3 do
1551
+ Iris.Text({ "stretch" })
1552
+ Iris.NextColumn()
1553
+ end
1554
+ end
1555
+ end
1556
+ Iris.End()
1557
+ Iris.Table({ 3, false, true, true, true, Resizable.value })
1558
+ do
1559
+ for _ = 1, 3 do
1560
+ for i = 1, 3 do
1561
+ Iris.Text({ string.rep(string.char(64 + i), 4 * i) })
1562
+ Iris.NextColumn()
1563
+ end
1564
+ end
1565
+ end
1566
+ Iris.End()
1567
+ end
1568
+
1569
+ do
1570
+ Iris.SeparatorText({ "stretch, proportional" })
1571
+ Iris.Table({ 3, false, true, true, true, Resizable.value, false, true })
1572
+ do
1573
+ for _ = 1, 3 do
1574
+ for _ = 1, 3 do
1575
+ Iris.Text({ "stretch" })
1576
+ Iris.NextColumn()
1577
+ end
1578
+ end
1579
+ end
1580
+ Iris.End()
1581
+ Iris.Table({ 3, false, true, true, true, Resizable.value, false, true })
1582
+ do
1583
+ for _ = 1, 3 do
1584
+ for i = 1, 3 do
1585
+ Iris.Text({ string.rep(string.char(64 + i), 4 * i) })
1586
+ Iris.NextColumn()
1587
+ end
1588
+ end
1589
+ end
1590
+ Iris.End()
1591
+ end
1592
+
1593
+ do
1594
+ Iris.SeparatorText({ "fixed, equal" })
1595
+ Iris.Table({ 3, false, true, true, true, Resizable.value, true, false, LimitWidth.value })
1596
+ do
1597
+ for _ = 1, 3 do
1598
+ for _ = 1, 3 do
1599
+ Iris.Text({ "fixed" })
1600
+ Iris.NextColumn()
1601
+ end
1602
+ end
1603
+ end
1604
+ Iris.End()
1605
+ Iris.Table({ 3, false, true, true, true, Resizable.value, true, false, LimitWidth.value })
1606
+ do
1607
+ for _ = 1, 3 do
1608
+ for i = 1, 3 do
1609
+ Iris.Text({ string.rep(string.char(64 + i), 4 * i) })
1610
+ Iris.NextColumn()
1611
+ end
1612
+ end
1613
+ end
1614
+ Iris.End()
1615
+ end
1616
+
1617
+ do
1618
+ Iris.SeparatorText({ "fixed, proportional" })
1619
+ Iris.Table({ 3, false, true, true, true, Resizable.value, true, true, LimitWidth.value })
1620
+ do
1621
+ for _ = 1, 3 do
1622
+ for _ = 1, 3 do
1623
+ Iris.Text({ "fixed" })
1624
+ Iris.NextColumn()
1625
+ end
1626
+ end
1627
+ end
1628
+ Iris.End()
1629
+ Iris.Table({ 3, false, true, true, true, Resizable.value, true, true, LimitWidth.value })
1630
+ do
1631
+ for _ = 1, 3 do
1632
+ for i = 1, 3 do
1633
+ Iris.Text({ string.rep(string.char(64 + i), 4 * i) })
1634
+ Iris.NextColumn()
1635
+ end
1636
+ end
1637
+ end
1638
+ Iris.End()
1639
+ end
1640
+ end
1641
+ Iris.End()
1642
+
1643
+ Iris.Tree({ "Resizable" })
1644
+ do
1645
+ local NumColumns = Iris.State(4)
1646
+ local NumRows = Iris.State(3)
1647
+ local TableUseButtons = Iris.State(false)
1648
+
1649
+ local HeaderState = Iris.State(true)
1650
+ local BackgroundState = Iris.State(true)
1651
+ local OuterBorderState = Iris.State(true)
1652
+ local InnerBorderState = Iris.State(true)
1653
+ local ResizableState = Iris.State(false)
1654
+ local FixedWidthState = Iris.State(false)
1655
+ local ProportionalWidthState = Iris.State(false)
1656
+ local LimitTableWidthState = Iris.State(false)
1657
+
1658
+ local AddExtra = Iris.State(false)
1659
+
1660
+ local WidthState = Iris.State(table.create(10, 100))
1661
+
1662
+ Iris.SliderNum({ "Num Columns", 1, 1, 10 }, { number = NumColumns })
1663
+ Iris.SliderNum({ "Number of rows", 1, 0, 100 }, { number = NumRows })
1664
+
1665
+ Iris.SameLine()
1666
+ do
1667
+ Iris.RadioButton({ "Buttons", true }, { index = TableUseButtons })
1668
+ Iris.RadioButton({ "Text", false }, { index = TableUseButtons })
1669
+ end
1670
+ Iris.End()
1671
+
1672
+ Iris.Table({ 3 })
1673
+ do
1674
+ Iris.Checkbox({ "Show Header Row" }, { isChecked = HeaderState })
1675
+ Iris.NextColumn()
1676
+ Iris.Checkbox({ "Show Row Backgrounds" }, { isChecked = BackgroundState })
1677
+ Iris.NextColumn()
1678
+ Iris.Checkbox({ "Show Outer Border" }, { isChecked = OuterBorderState })
1679
+ Iris.NextColumn()
1680
+ Iris.Checkbox({ "Show Inner Border" }, { isChecked = InnerBorderState })
1681
+ Iris.NextColumn()
1682
+ Iris.Checkbox({ "Resizable" }, { isChecked = ResizableState })
1683
+ Iris.NextColumn()
1684
+ Iris.Checkbox({ "Fixed Width" }, { isChecked = FixedWidthState })
1685
+ Iris.NextColumn()
1686
+ Iris.Checkbox({ "Proportional Width" }, { isChecked = ProportionalWidthState })
1687
+ Iris.NextColumn()
1688
+ Iris.Checkbox({ "Limit Table Width" }, { isChecked = LimitTableWidthState })
1689
+ Iris.NextColumn()
1690
+ Iris.Checkbox({ "Add extra" }, { isChecked = AddExtra })
1691
+ Iris.NextColumn()
1692
+ end
1693
+ Iris.End()
1694
+
1695
+ for i = 1, NumColumns.value do
1696
+ local increment = if FixedWidthState.value == true then 1 else 0.05
1697
+ local min = if FixedWidthState.value == true then 2 else 0.05
1698
+ local max = if FixedWidthState.value == true then 480 else 1
1699
+ Iris.SliderNum({ `Column {i} Width`, increment, min, max }, {
1700
+ number = Iris.TableState(WidthState.value, i, function(value)
1701
+ -- we have to force the state to change, because comparing two tables is equal
1702
+ WidthState.value[i] = value
1703
+ WidthState:set(WidthState.value, true)
1704
+ return false
1705
+ end),
1706
+ })
1707
+ end
1708
+
1709
+ Iris.PushConfig({
1710
+ NumColumns = NumColumns.value,
1711
+ })
1712
+ Iris.Table({
1713
+ NumColumns.value,
1714
+ HeaderState.value,
1715
+ BackgroundState.value,
1716
+ OuterBorderState.value,
1717
+ InnerBorderState.value,
1718
+ ResizableState.value,
1719
+ FixedWidthState.value,
1720
+ ProportionalWidthState.value,
1721
+ LimitTableWidthState.value,
1722
+ }, { widths = WidthState })
1723
+ do
1724
+ Iris.SetHeaderColumnIndex(1)
1725
+ for i = 0, NumRows:get() do
1726
+ for j = 1, NumColumns.value do
1727
+ if i == 0 then
1728
+ if TableUseButtons.value then
1729
+ Iris.Button({ `H: {j}` })
1730
+ else
1731
+ Iris.Text({ `H: {j}` })
1732
+ end
1733
+ else
1734
+ if TableUseButtons.value then
1735
+ Iris.Button({ `R: {i}, C: {j}` })
1736
+ Iris.Button({ string.rep("...", j) })
1737
+ else
1738
+ Iris.Text({ `R: {i}, C: {j}` })
1739
+ Iris.Text({ string.rep("...", j) })
1740
+ end
1741
+ end
1742
+ Iris.NextColumn()
1743
+ end
1744
+ end
1745
+
1746
+ if AddExtra.value then
1747
+ Iris.Text({ "A really long piece of text!" })
1748
+ end
1749
+ end
1750
+ Iris.End()
1751
+ Iris.PopConfig()
1752
+ end
1753
+ Iris.End()
1754
+
1755
+ Iris.End()
1756
+ end
1757
+ end
1758
+
1759
+ local function layoutDemo()
1760
+ Iris.CollapsingHeader({ "Widget Layout" })
1761
+ do
1762
+ Iris.Tree({ "Widget Alignment" })
1763
+ do
1764
+ Iris.Text({ "Iris.SameLine has optional argument supporting horizontal and vertical alignments." })
1765
+ Iris.Text({ "This allows widgets to be place anywhere on the line." })
1766
+ Iris.Separator()
1767
+
1768
+ Iris.SameLine()
1769
+ do
1770
+ Iris.Text({ "By default child widgets will be aligned to the left." })
1771
+ helpMarker(
1772
+ 'Iris.SameLine()\n\tIris.Button({ "Button A" })\n\tIris.Button({ "Button B" })\nIris.End()'
1773
+ )
1774
+ end
1775
+ Iris.End()
1776
+
1777
+ Iris.SameLine()
1778
+ do
1779
+ Iris.Button({ "Button A" })
1780
+ Iris.Button({ "Button B" })
1781
+ end
1782
+ Iris.End()
1783
+
1784
+ Iris.SameLine()
1785
+ do
1786
+ Iris.Text({ "But can be aligned to the center." })
1787
+ helpMarker(
1788
+ 'Iris.SameLine({ nil, nil, Enum.HorizontalAlignment.Center })\n\tIris.Button({ "Button A" })\n\tIris.Button({ "Button B" })\nIris.End()'
1789
+ )
1790
+ end
1791
+ Iris.End()
1792
+
1793
+ Iris.SameLine({ nil, nil, Enum.HorizontalAlignment.Center })
1794
+ do
1795
+ Iris.Button({ "Button A" })
1796
+ Iris.Button({ "Button B" })
1797
+ end
1798
+ Iris.End()
1799
+
1800
+ Iris.SameLine()
1801
+ do
1802
+ Iris.Text({ "Or right." })
1803
+ helpMarker(
1804
+ 'Iris.SameLine({ nil, nil, Enum.HorizontalAlignment.Right })\n\tIris.Button({ "Button A" })\n\tIris.Button({ "Button B" })\nIris.End()'
1805
+ )
1806
+ end
1807
+ Iris.End()
1808
+
1809
+ Iris.SameLine({ nil, nil, Enum.HorizontalAlignment.Right })
1810
+ do
1811
+ Iris.Button({ "Button A" })
1812
+ Iris.Button({ "Button B" })
1813
+ end
1814
+ Iris.End()
1815
+
1816
+ Iris.Separator()
1817
+
1818
+ Iris.SameLine()
1819
+ do
1820
+ Iris.Text({ "You can also specify the padding." })
1821
+ helpMarker(
1822
+ 'Iris.SameLine({ 0, nil, Enum.HorizontalAlignment.Center })\n\tIris.Button({ "Button A" })\n\tIris.Button({ "Button B" })\nIris.End()'
1823
+ )
1824
+ end
1825
+ Iris.End()
1826
+
1827
+ Iris.SameLine({ 0, nil, Enum.HorizontalAlignment.Center })
1828
+ do
1829
+ Iris.Button({ "Button A" })
1830
+ Iris.Button({ "Button B" })
1831
+ end
1832
+ Iris.End()
1833
+ end
1834
+ Iris.End()
1835
+
1836
+ Iris.Tree({ "Widget Sizing" })
1837
+ do
1838
+ Iris.Text({ "Nearly all widgets are the minimum size of the content." })
1839
+ Iris.Text({ "For example, text and button widgets will be the size of the text labels." })
1840
+ Iris.Text({
1841
+ "Some widgets, such as the Image and Button have Size arguments will will set the size of them.",
1842
+ })
1843
+ Iris.Separator()
1844
+
1845
+ textAndHelpMarker(
1846
+ "The button takes up the full screen-width.",
1847
+ 'Iris.Button({ "Button", UDim2.fromScale(1, 0) })'
1848
+ )
1849
+ Iris.Button({ "Button", UDim2.fromScale(1, 0) })
1850
+ textAndHelpMarker(
1851
+ "The button takes up half the screen-width.",
1852
+ 'Iris.Button({ "Button", UDim2.fromScale(0.5, 0) })'
1853
+ )
1854
+ Iris.Button({ "Button", UDim2.fromScale(0.5, 0) })
1855
+
1856
+ textAndHelpMarker(
1857
+ "Combining with SameLine, the buttons can fill the screen width.",
1858
+ "The button will still be larger that the text size."
1859
+ )
1860
+ local num = Iris.State(2)
1861
+ Iris.SliderNum({ "Number of Buttons", 1, 1, 8 }, { number = num })
1862
+ Iris.SameLine({ 0, nil, Enum.HorizontalAlignment.Center })
1863
+ do
1864
+ for i = 1, num.value do
1865
+ Iris.Button({ `Button {i}`, UDim2.fromScale(1 / num.value, 0) })
1866
+ end
1867
+ end
1868
+ Iris.End()
1869
+ end
1870
+ Iris.End()
1871
+
1872
+ Iris.Tree({ "Content Width" })
1873
+ do
1874
+ local value = Iris.State(50)
1875
+ local index = Iris.State(Enum.Axis.X)
1876
+
1877
+ Iris.Text({ "The Content Width is a size property which determines the width of input fields." })
1878
+ Iris.SameLine()
1879
+ do
1880
+ Iris.Text({ "By default the value is UDim.new(0.65, 0)" })
1881
+ helpMarker("This is the default value from Dear ImGui.\nIt is 65% of the window width.")
1882
+ end
1883
+ Iris.End()
1884
+
1885
+ Iris.Text({
1886
+ "This works well, but sometimes we know how wide elements are going to be and want to maximise the space.",
1887
+ })
1888
+ Iris.Text({ "Therefore, we can use Iris.PushConfig() to change the width" })
1889
+
1890
+ Iris.Separator()
1891
+
1892
+ Iris.SameLine()
1893
+ do
1894
+ Iris.Text({ "Content Width = 150 pixels" })
1895
+ helpMarker("UDim.new(0, 150)")
1896
+ end
1897
+ Iris.End()
1898
+
1899
+ Iris.PushConfig({ ContentWidth = UDim.new(0, 150) })
1900
+ Iris.DragNum({ "number", 1, 0, 100 }, { number = value })
1901
+ Iris.InputEnum({ "axis" }, { index = index }, Enum.Axis)
1902
+ Iris.PopConfig()
1903
+
1904
+ Iris.SameLine()
1905
+ do
1906
+ Iris.Text({ "Content Width = 50% window width" })
1907
+ helpMarker("UDim.new(0.5, 0)")
1908
+ end
1909
+ Iris.End()
1910
+
1911
+ Iris.PushConfig({ ContentWidth = UDim.new(0.5, 0) })
1912
+ Iris.DragNum({ "number", 1, 0, 100 }, { number = value })
1913
+ Iris.InputEnum({ "axis" }, { index = index }, Enum.Axis)
1914
+ Iris.PopConfig()
1915
+
1916
+ Iris.SameLine()
1917
+ do
1918
+ Iris.Text({ "Content Width = -150 pixels from the right side" })
1919
+ helpMarker("UDim.new(1, -150)")
1920
+ end
1921
+ Iris.End()
1922
+
1923
+ Iris.PushConfig({ ContentWidth = UDim.new(1, -150) })
1924
+ Iris.DragNum({ "number", 1, 0, 100 }, { number = value })
1925
+ Iris.InputEnum({ "axis" }, { index = index }, Enum.Axis)
1926
+ Iris.PopConfig()
1927
+ end
1928
+ Iris.End()
1929
+
1930
+ Iris.Tree({ "Content Height" })
1931
+ do
1932
+ local text = Iris.State("a single line")
1933
+ local value = Iris.State(50)
1934
+ local index = Iris.State(Enum.Axis.X)
1935
+ local progress = Iris.State(0)
1936
+
1937
+ -- formula to cycle between 0 and 100 linearly
1938
+ local newValue = math.clamp((math.abs((os.clock() * 15) % 100 - 50)) - 7.5, 0, 35) / 35
1939
+ progress:set(newValue)
1940
+
1941
+ Iris.Text({
1942
+ "The Content Height is a size property that determines the minimum size of certain widgets.",
1943
+ })
1944
+ Iris.Text({ "By default the value is UDim.new(0, 0), so there is no minimum height." })
1945
+ Iris.Text({ "We use Iris.PushConfig() to change this value." })
1946
+
1947
+ Iris.Separator()
1948
+ Iris.SameLine()
1949
+ do
1950
+ Iris.Text({ "Content Height = 0 pixels" })
1951
+ helpMarker("UDim.new(0, 0)")
1952
+ end
1953
+ Iris.End()
1954
+
1955
+ Iris.InputText({ "text" }, { text = text })
1956
+ Iris.ProgressBar({ "progress" }, { progress = progress })
1957
+ Iris.DragNum({ "number", 1, 0, 100 }, { number = value })
1958
+ Iris.ComboEnum({ "axis" }, { index = index }, Enum.Axis)
1959
+
1960
+ Iris.SameLine()
1961
+ do
1962
+ Iris.Text({ "Content Height = 60 pixels" })
1963
+ helpMarker("UDim.new(0, 60)")
1964
+ end
1965
+ Iris.End()
1966
+
1967
+ Iris.PushConfig({ ContentHeight = UDim.new(0, 60) })
1968
+ Iris.InputText({ "text", nil, nil, true }, { text = text })
1969
+ Iris.ProgressBar({ "progress" }, { progress = progress })
1970
+ Iris.DragNum({ "number", 1, 0, 100 }, { number = value })
1971
+ Iris.ComboEnum({ "axis" }, { index = index }, Enum.Axis)
1972
+ Iris.PopConfig()
1973
+
1974
+ Iris.Text({ "This property can be used to force the height of a text box." })
1975
+ Iris.Text({ "Just make sure you enable the MultiLine argument." })
1976
+ end
1977
+ Iris.End()
1978
+ end
1979
+ Iris.End()
1980
+ end
1981
+
1982
+ -- showcases how widgets placed outside of a window are placed inside root
1983
+ local function windowlessDemo()
1984
+ Iris.PushConfig({ ItemWidth = UDim.new(0, 150) })
1985
+ Iris.SameLine()
1986
+ do
1987
+ Iris.TextWrapped({ "Windowless widgets" })
1988
+ helpMarker("Widgets which are placed outside of a window will appear on the top left side of the screen.")
1989
+ end
1990
+ Iris.End()
1991
+
1992
+ Iris.Button({})
1993
+ Iris.Tree({})
1994
+ do
1995
+ Iris.InputText({})
1996
+ end
1997
+ Iris.End()
1998
+
1999
+ Iris.PopConfig()
2000
+ end
2001
+
2002
+ -- main demo window
2003
+ return function()
2004
+ local NoTitleBar = Iris.State(false)
2005
+ local NoBackground = Iris.State(false)
2006
+ local NoCollapse = Iris.State(false)
2007
+ local NoClose = Iris.State(true)
2008
+ local NoMove = Iris.State(false)
2009
+ local NoScrollbar = Iris.State(false)
2010
+ local NoResize = Iris.State(false)
2011
+ local NoNav = Iris.State(false)
2012
+ local NoMenu = Iris.State(false)
2013
+
2014
+ if showMainWindow.value == false then
2015
+ Iris.Checkbox({ "Open main window" }, { isChecked = showMainWindow })
2016
+ return
2017
+ end
2018
+
2019
+ debug.profilebegin("Iris/Demo/Window")
2020
+ local window = Iris.Window({
2021
+ [Iris.Args.Window.Title] = "Iris Demo Window",
2022
+ [Iris.Args.Window.NoTitleBar] = NoTitleBar.value,
2023
+ [Iris.Args.Window.NoBackground] = NoBackground.value,
2024
+ [Iris.Args.Window.NoCollapse] = NoCollapse.value,
2025
+ [Iris.Args.Window.NoClose] = NoClose.value,
2026
+ [Iris.Args.Window.NoMove] = NoMove.value,
2027
+ [Iris.Args.Window.NoScrollbar] = NoScrollbar.value,
2028
+ [Iris.Args.Window.NoResize] = NoResize.value,
2029
+ [Iris.Args.Window.NoNav] = NoNav.value,
2030
+ [Iris.Args.Window.NoMenu] = NoMenu.value,
2031
+ }, {
2032
+ size = Iris.State(Vector2.new(600, 550)),
2033
+ position = Iris.State(Vector2.new(100, 25)),
2034
+ isOpened = showMainWindow,
2035
+ })
2036
+
2037
+ if window.state.isUncollapsed.value and window.state.isOpened.value then
2038
+ debug.profilebegin("Iris/Demo/MenuBar")
2039
+ mainMenuBar()
2040
+ debug.profileend()
2041
+
2042
+ Iris.Text({ "Iris says hello. (" .. Iris.Internal._version .. ")" })
2043
+
2044
+ debug.profilebegin("Iris/Demo/Options")
2045
+ Iris.CollapsingHeader({ "Window Options" })
2046
+ do
2047
+ Iris.Table({ 3, false, false, false })
2048
+ do
2049
+ Iris.Checkbox({ "NoTitleBar" }, { isChecked = NoTitleBar })
2050
+ Iris.NextColumn()
2051
+ Iris.Checkbox({ "NoBackground" }, { isChecked = NoBackground })
2052
+ Iris.NextColumn()
2053
+ Iris.Checkbox({ "NoCollapse" }, { isChecked = NoCollapse })
2054
+ Iris.NextColumn()
2055
+ Iris.Checkbox({ "NoClose" }, { isChecked = NoClose })
2056
+ Iris.NextColumn()
2057
+ Iris.Checkbox({ "NoMove" }, { isChecked = NoMove })
2058
+ Iris.NextColumn()
2059
+ Iris.Checkbox({ "NoScrollbar" }, { isChecked = NoScrollbar })
2060
+ Iris.NextColumn()
2061
+ Iris.Checkbox({ "NoResize" }, { isChecked = NoResize })
2062
+ Iris.NextColumn()
2063
+ Iris.Checkbox({ "NoNav" }, { isChecked = NoNav })
2064
+ Iris.NextColumn()
2065
+ Iris.Checkbox({ "NoMenu" }, { isChecked = NoMenu })
2066
+ Iris.NextColumn()
2067
+ end
2068
+ Iris.End()
2069
+ end
2070
+ Iris.End()
2071
+ debug.profileend()
2072
+
2073
+ debug.profilebegin("Iris/Demo/Events")
2074
+ widgetEventInteractivity()
2075
+ debug.profileend()
2076
+
2077
+ debug.profilebegin("Iris/Demo/States")
2078
+ widgetStateInteractivity()
2079
+ debug.profileend()
2080
+
2081
+ debug.profilebegin("Iris/Demo/Recursive")
2082
+ Iris.CollapsingHeader({ "Recursive Tree" })
2083
+ recursiveTree()
2084
+ Iris.End()
2085
+ debug.profileend()
2086
+
2087
+ debug.profilebegin("Iris/Demo/Style")
2088
+ dynamicStyle()
2089
+ debug.profileend()
2090
+
2091
+ Iris.Separator()
2092
+
2093
+ debug.profilebegin("Iris/Demo/Widgets")
2094
+ Iris.CollapsingHeader({ "Widgets" })
2095
+ do
2096
+ for _, name in widgetDemosOrder do
2097
+ debug.profilebegin(`Iris/Demo/Widgets/{name}`)
2098
+ widgetDemos[name]()
2099
+ debug.profileend()
2100
+ end
2101
+ end
2102
+ Iris.End()
2103
+ debug.profileend()
2104
+
2105
+ debug.profilebegin("Iris/Demo/Tables")
2106
+ tablesDemo()
2107
+ debug.profileend()
2108
+
2109
+ debug.profilebegin("Iris/Demo/Layout")
2110
+ layoutDemo()
2111
+ debug.profileend()
2112
+
2113
+ Iris.CollapsingHeader({ "Background" })
2114
+ do
2115
+ Iris.Checkbox({ "Show background colour" }, { isChecked = showBackground })
2116
+ Iris.InputColor4(
2117
+ { "Background colour" },
2118
+ { color = backgroundColour, transparency = backgroundTransparency }
2119
+ )
2120
+ end
2121
+ Iris.End()
2122
+ end
2123
+ Iris.End()
2124
+ debug.profileend()
2125
+
2126
+ if showRecursiveWindow.value then
2127
+ recursiveWindow(showRecursiveWindow)
2128
+ end
2129
+ if showRuntimeInfo.value then
2130
+ runtimeInfo()
2131
+ end
2132
+ if showDebugWindow.value then
2133
+ debugPanel()
2134
+ end
2135
+ if showStyleEditor.value then
2136
+ styleEditor()
2137
+ end
2138
+ if showWindowlessDemo.value then
2139
+ windowlessDemo()
2140
+ end
2141
+
2142
+ if showMainMenuBarWindow.value then
2143
+ mainMenuBarExample()
2144
+ end
2145
+
2146
+ return window
2147
+ end
2148
+ end