@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.
- package/CHANGELOG.md +14 -0
- package/LICENSE.md +22 -0
- package/README.md +33 -0
- package/default.project.json +14 -0
- package/package.json +42 -0
- package/src/Shared/Iris.lua +702 -0
- package/src/Shared/iris_API.lua +231 -0
- package/src/Shared/iris_Internal.lua +923 -0
- package/src/Shared/iris_PubTypes.lua +44 -0
- package/src/Shared/iris_Types.lua +674 -0
- package/src/Shared/iris_WidgetTypes.lua +522 -0
- package/src/Shared/iris_config.lua +306 -0
- package/src/Shared/iris_demoWindow.lua +2148 -0
- package/src/Shared/widgets/iris_Button.lua +91 -0
- package/src/Shared/widgets/iris_Checkbox.lua +116 -0
- package/src/Shared/widgets/iris_Combo.lua +498 -0
- package/src/Shared/widgets/iris_Format.lua +141 -0
- package/src/Shared/widgets/iris_Image.lua +156 -0
- package/src/Shared/widgets/iris_Input.lua +1430 -0
- package/src/Shared/widgets/iris_Menu.lua +603 -0
- package/src/Shared/widgets/iris_Plot.lua +642 -0
- package/src/Shared/widgets/iris_RadioButton.lua +127 -0
- package/src/Shared/widgets/iris_Root.lua +148 -0
- package/src/Shared/widgets/iris_Tab.lua +334 -0
- package/src/Shared/widgets/iris_Table.lua +641 -0
- package/src/Shared/widgets/iris_Text.lua +133 -0
- package/src/Shared/widgets/iris_Tree.lua +291 -0
- package/src/Shared/widgets/iris_Window.lua +1158 -0
- package/src/Shared/widgets/iris_widgets.lua +487 -0
- package/src/jest.config.lua +3 -0
- package/src/node_modules.project.json +7 -0
- package/test/default.project.json +25 -0
- package/test/scripts/Server/ServerMain.server.lua +13 -0
|
@@ -0,0 +1,1158 @@
|
|
|
1
|
+
--!nocheck
|
|
2
|
+
local Types = require(script.Parent.Parent.iris_Types)
|
|
3
|
+
|
|
4
|
+
return function(Iris: Types.Internal, widgets: Types.WidgetUtility)
|
|
5
|
+
local function relocateTooltips()
|
|
6
|
+
if Iris._rootInstance == nil then
|
|
7
|
+
return
|
|
8
|
+
end
|
|
9
|
+
-- Root can be destroyed mid-ForceRefresh (or orphaned while Iris.Disabled skips _cycle heal).
|
|
10
|
+
-- InputChanged still fires in those gaps, so guard before indexing.
|
|
11
|
+
local PopupScreenGui = Iris._rootInstance:FindFirstChild("PopupScreenGui")
|
|
12
|
+
if PopupScreenGui == nil then
|
|
13
|
+
return
|
|
14
|
+
end
|
|
15
|
+
local TooltipContainer: Frame? = PopupScreenGui:FindFirstChild("TooltipContainer")
|
|
16
|
+
if TooltipContainer == nil then
|
|
17
|
+
return
|
|
18
|
+
end
|
|
19
|
+
local mouseLocation = widgets.getMouseLocation()
|
|
20
|
+
local newPosition = widgets.findBestWindowPosForPopup(
|
|
21
|
+
mouseLocation,
|
|
22
|
+
TooltipContainer.AbsoluteSize,
|
|
23
|
+
Iris._config.DisplaySafeAreaPadding,
|
|
24
|
+
PopupScreenGui.AbsoluteSize
|
|
25
|
+
)
|
|
26
|
+
TooltipContainer.Position = UDim2.fromOffset(newPosition.X, newPosition.Y)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
widgets.registerEvent("InputChanged", function()
|
|
30
|
+
-- Must respect Disabled: Init registers this forever, and egg-hunt keeps Iris
|
|
31
|
+
-- started with Disabled=true while the debug panel is closed.
|
|
32
|
+
if not Iris._started or Iris.Disabled then
|
|
33
|
+
return
|
|
34
|
+
end
|
|
35
|
+
relocateTooltips()
|
|
36
|
+
end)
|
|
37
|
+
|
|
38
|
+
--stylua: ignore
|
|
39
|
+
Iris.WidgetConstructor("Tooltip", {
|
|
40
|
+
hasState = false,
|
|
41
|
+
hasChildren = false,
|
|
42
|
+
Args = {
|
|
43
|
+
["Text"] = 1,
|
|
44
|
+
},
|
|
45
|
+
Events = {},
|
|
46
|
+
Generate = function(thisWidget: Types.Tooltip)
|
|
47
|
+
thisWidget.parentWidget = Iris._rootWidget -- only allow root as parent
|
|
48
|
+
|
|
49
|
+
local Tooltip = Instance.new("Frame")
|
|
50
|
+
Tooltip.Name = "Iris_Tooltip"
|
|
51
|
+
Tooltip.AutomaticSize = Enum.AutomaticSize.Y
|
|
52
|
+
Tooltip.Size = UDim2.new(Iris._config.ContentWidth, UDim.new(0, 0))
|
|
53
|
+
Tooltip.BorderSizePixel = 0
|
|
54
|
+
Tooltip.BackgroundTransparency = 1
|
|
55
|
+
|
|
56
|
+
local TooltipText = Instance.new("TextLabel")
|
|
57
|
+
TooltipText.Name = "TooltipText"
|
|
58
|
+
TooltipText.AutomaticSize = Enum.AutomaticSize.XY
|
|
59
|
+
TooltipText.Size = UDim2.fromOffset(0, 0)
|
|
60
|
+
TooltipText.BackgroundColor3 = Iris._config.PopupBgColor
|
|
61
|
+
TooltipText.BackgroundTransparency = Iris._config.PopupBgTransparency
|
|
62
|
+
|
|
63
|
+
widgets.applyTextStyle(TooltipText)
|
|
64
|
+
widgets.UIStroke(TooltipText, Iris._config.PopupBorderSize, Iris._config.BorderActiveColor, Iris._config.BorderActiveTransparency)
|
|
65
|
+
widgets.UIPadding(TooltipText, Iris._config.WindowPadding)
|
|
66
|
+
if Iris._config.PopupRounding > 0 then
|
|
67
|
+
widgets.UICorner(TooltipText, Iris._config.PopupRounding)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
TooltipText.Parent = Tooltip
|
|
71
|
+
|
|
72
|
+
return Tooltip
|
|
73
|
+
end,
|
|
74
|
+
Update = function(thisWidget: Types.Tooltip)
|
|
75
|
+
local Tooltip = thisWidget.Instance :: Frame
|
|
76
|
+
local TooltipText: TextLabel = Tooltip.TooltipText
|
|
77
|
+
if thisWidget.arguments.Text == nil then
|
|
78
|
+
error("Text argument is required for Iris.Tooltip().", 5)
|
|
79
|
+
end
|
|
80
|
+
TooltipText.Text = thisWidget.arguments.Text
|
|
81
|
+
relocateTooltips()
|
|
82
|
+
end,
|
|
83
|
+
Discard = function(thisWidget: Types.Tooltip)
|
|
84
|
+
thisWidget.Instance:Destroy()
|
|
85
|
+
end,
|
|
86
|
+
} :: Types.WidgetClass)
|
|
87
|
+
|
|
88
|
+
local windowDisplayOrder = 0 -- incremental count which is used for determining focused windows ZIndex
|
|
89
|
+
local dragWindow: Types.Window? -- window being dragged, may be nil
|
|
90
|
+
local isDragging = false
|
|
91
|
+
local moveDeltaCursorPosition: Vector2 -- cursor offset from drag origin (top left of window)
|
|
92
|
+
|
|
93
|
+
local resizeWindow: Types.Window? -- window being resized, may be nil
|
|
94
|
+
local isResizing = false
|
|
95
|
+
local isInsideResize = false -- is cursor inside of the focused window resize outer padding
|
|
96
|
+
local isInsideWindow = false -- is cursor inside of the focused window
|
|
97
|
+
local resizeFromTopBottom = Enum.TopBottom.Top
|
|
98
|
+
local resizeFromLeftRight = Enum.LeftRight.Left
|
|
99
|
+
|
|
100
|
+
local lastCursorPosition: Vector2
|
|
101
|
+
|
|
102
|
+
local focusedWindow: Types.Window? -- window with focus, may be nil
|
|
103
|
+
local anyFocusedWindow = false -- is there any focused window?
|
|
104
|
+
|
|
105
|
+
local windowWidgets: { [Types.ID]: Types.Window } = {} -- array of widget objects of type window
|
|
106
|
+
|
|
107
|
+
local function quickSwapWindows()
|
|
108
|
+
-- ctrl + tab swapping functionality
|
|
109
|
+
if Iris._config.UseScreenGUIs == false then
|
|
110
|
+
return
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
local lowest = 0xFFFF
|
|
114
|
+
local lowestWidget: Types.Window
|
|
115
|
+
|
|
116
|
+
for _, widget in windowWidgets do
|
|
117
|
+
if widget.state.isOpened.value and not widget.arguments.NoNav then
|
|
118
|
+
if widget.Instance:IsA("ScreenGui") then
|
|
119
|
+
local value = widget.Instance.DisplayOrder
|
|
120
|
+
if value < lowest then
|
|
121
|
+
lowest = value
|
|
122
|
+
lowestWidget = widget
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
if not lowestWidget then
|
|
129
|
+
return
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if lowestWidget.state.isUncollapsed.value == false then
|
|
133
|
+
lowestWidget.state.isUncollapsed:set(true)
|
|
134
|
+
end
|
|
135
|
+
Iris.SetFocusedWindow(lowestWidget)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
local function fitSizeToWindowBounds(thisWidget: Types.Window, intentedSize: Vector2)
|
|
139
|
+
local windowSize = Vector2.new(thisWidget.state.position.value.X, thisWidget.state.position.value.Y)
|
|
140
|
+
local minWindowSize = (Iris._config.TextSize + 2 * Iris._config.FramePadding.Y) * 2
|
|
141
|
+
local usableSize = widgets.getScreenSizeForWindow(thisWidget)
|
|
142
|
+
local safeAreaPadding = Vector2.new(
|
|
143
|
+
Iris._config.WindowBorderSize + Iris._config.DisplaySafeAreaPadding.X,
|
|
144
|
+
Iris._config.WindowBorderSize + Iris._config.DisplaySafeAreaPadding.Y
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
local maxWindowSize = (usableSize - windowSize - safeAreaPadding)
|
|
148
|
+
return Vector2.new(
|
|
149
|
+
math.clamp(intentedSize.X, minWindowSize, math.max(maxWindowSize.X, minWindowSize)),
|
|
150
|
+
math.clamp(intentedSize.Y, minWindowSize, math.max(maxWindowSize.Y, minWindowSize))
|
|
151
|
+
)
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
local function fitPositionToWindowBounds(thisWidget: Types.Window, intendedPosition: Vector2)
|
|
155
|
+
local thisWidgetInstance = thisWidget.Instance
|
|
156
|
+
local usableSize = widgets.getScreenSizeForWindow(thisWidget)
|
|
157
|
+
local safeAreaPadding = Vector2.new(
|
|
158
|
+
Iris._config.WindowBorderSize + Iris._config.DisplaySafeAreaPadding.X,
|
|
159
|
+
Iris._config.WindowBorderSize + Iris._config.DisplaySafeAreaPadding.Y
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return Vector2.new(
|
|
163
|
+
math.clamp(
|
|
164
|
+
intendedPosition.X,
|
|
165
|
+
safeAreaPadding.X,
|
|
166
|
+
math.max(
|
|
167
|
+
safeAreaPadding.X,
|
|
168
|
+
usableSize.X - thisWidgetInstance.WindowButton.AbsoluteSize.X - safeAreaPadding.X
|
|
169
|
+
)
|
|
170
|
+
),
|
|
171
|
+
math.clamp(
|
|
172
|
+
intendedPosition.Y,
|
|
173
|
+
safeAreaPadding.Y,
|
|
174
|
+
math.max(
|
|
175
|
+
safeAreaPadding.Y,
|
|
176
|
+
usableSize.Y - thisWidgetInstance.WindowButton.AbsoluteSize.Y - safeAreaPadding.Y
|
|
177
|
+
)
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
Iris.SetFocusedWindow = function(thisWidget: Types.Window?)
|
|
183
|
+
if focusedWindow == thisWidget then
|
|
184
|
+
return
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
if anyFocusedWindow and focusedWindow ~= nil then
|
|
188
|
+
if windowWidgets[focusedWindow.ID] then
|
|
189
|
+
local Window = focusedWindow.Instance :: Frame
|
|
190
|
+
local WindowButton = Window.WindowButton :: TextButton
|
|
191
|
+
local Content = WindowButton.Content :: Frame
|
|
192
|
+
local TitleBar: Frame = Content.TitleBar
|
|
193
|
+
-- update appearance to unfocus
|
|
194
|
+
if focusedWindow.state.isUncollapsed.value then
|
|
195
|
+
TitleBar.BackgroundColor3 = Iris._config.TitleBgColor
|
|
196
|
+
TitleBar.BackgroundTransparency = Iris._config.TitleBgTransparency
|
|
197
|
+
else
|
|
198
|
+
TitleBar.BackgroundColor3 = Iris._config.TitleBgCollapsedColor
|
|
199
|
+
TitleBar.BackgroundTransparency = Iris._config.TitleBgCollapsedTransparency
|
|
200
|
+
end
|
|
201
|
+
WindowButton.UIStroke.Color = Iris._config.BorderColor
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
anyFocusedWindow = false
|
|
205
|
+
focusedWindow = nil
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
if thisWidget ~= nil then
|
|
209
|
+
-- update appearance to focus
|
|
210
|
+
anyFocusedWindow = true
|
|
211
|
+
focusedWindow = thisWidget
|
|
212
|
+
local Window = thisWidget.Instance :: Frame
|
|
213
|
+
local WindowButton = Window.WindowButton :: TextButton
|
|
214
|
+
local Content = WindowButton.Content :: Frame
|
|
215
|
+
local TitleBar: Frame = Content.TitleBar
|
|
216
|
+
|
|
217
|
+
TitleBar.BackgroundColor3 = Iris._config.TitleBgActiveColor
|
|
218
|
+
TitleBar.BackgroundTransparency = Iris._config.TitleBgActiveTransparency
|
|
219
|
+
WindowButton.UIStroke.Color = Iris._config.BorderActiveColor
|
|
220
|
+
|
|
221
|
+
windowDisplayOrder += 1
|
|
222
|
+
if thisWidget.usesScreenGuis then
|
|
223
|
+
Window.DisplayOrder = windowDisplayOrder + Iris._config.DisplayOrderOffset
|
|
224
|
+
else
|
|
225
|
+
Window.ZIndex = windowDisplayOrder + Iris._config.DisplayOrderOffset
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
if thisWidget.state.isUncollapsed.value == false then
|
|
229
|
+
thisWidget.state.isUncollapsed:set(true)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
local firstSelectedObject: GuiObject? = widgets.GuiService.SelectedObject
|
|
233
|
+
if firstSelectedObject then
|
|
234
|
+
if TitleBar.Visible then
|
|
235
|
+
widgets.GuiService:Select(TitleBar)
|
|
236
|
+
else
|
|
237
|
+
widgets.GuiService:Select(thisWidget.ChildContainer)
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
widgets.registerEvent("InputBegan", function(input: InputObject)
|
|
244
|
+
if not Iris._started then
|
|
245
|
+
return
|
|
246
|
+
end
|
|
247
|
+
if input.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
248
|
+
local inWindow = false
|
|
249
|
+
local position = widgets.getMouseLocation()
|
|
250
|
+
for _, window in windowWidgets do
|
|
251
|
+
local Window = window.Instance
|
|
252
|
+
if not Window then
|
|
253
|
+
continue
|
|
254
|
+
end
|
|
255
|
+
local WindowButton = Window.WindowButton :: TextButton
|
|
256
|
+
local ResizeBorder: TextButton = WindowButton.ResizeBorder
|
|
257
|
+
if
|
|
258
|
+
ResizeBorder
|
|
259
|
+
and widgets.isPosInsideRect(
|
|
260
|
+
position,
|
|
261
|
+
ResizeBorder.AbsolutePosition - widgets.GuiOffset,
|
|
262
|
+
ResizeBorder.AbsolutePosition - widgets.GuiOffset + ResizeBorder.AbsoluteSize
|
|
263
|
+
)
|
|
264
|
+
then
|
|
265
|
+
inWindow = true
|
|
266
|
+
break
|
|
267
|
+
end
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
if not inWindow then
|
|
271
|
+
Iris.SetFocusedWindow(nil)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
if
|
|
276
|
+
input.KeyCode == Enum.KeyCode.Tab
|
|
277
|
+
and (
|
|
278
|
+
widgets.UserInputService:IsKeyDown(Enum.KeyCode.LeftControl)
|
|
279
|
+
or widgets.UserInputService:IsKeyDown(Enum.KeyCode.RightControl)
|
|
280
|
+
)
|
|
281
|
+
then
|
|
282
|
+
quickSwapWindows()
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
if
|
|
286
|
+
input.UserInputType == Enum.UserInputType.MouseButton1
|
|
287
|
+
and isInsideResize
|
|
288
|
+
and not isInsideWindow
|
|
289
|
+
and anyFocusedWindow
|
|
290
|
+
and focusedWindow
|
|
291
|
+
then
|
|
292
|
+
local midWindow = focusedWindow.state.position.value + (focusedWindow.state.size.value / 2)
|
|
293
|
+
local cursorPosition = widgets.getMouseLocation() - midWindow
|
|
294
|
+
|
|
295
|
+
-- check which axis its closest to, then check which side is closest with math.sign
|
|
296
|
+
if
|
|
297
|
+
math.abs(cursorPosition.X) * focusedWindow.state.size.value.Y
|
|
298
|
+
>= math.abs(cursorPosition.Y) * focusedWindow.state.size.value.X
|
|
299
|
+
then
|
|
300
|
+
resizeFromTopBottom = Enum.TopBottom.Center
|
|
301
|
+
resizeFromLeftRight = if math.sign(cursorPosition.X) == -1
|
|
302
|
+
then Enum.LeftRight.Left
|
|
303
|
+
else Enum.LeftRight.Right
|
|
304
|
+
else
|
|
305
|
+
resizeFromLeftRight = Enum.LeftRight.Center
|
|
306
|
+
resizeFromTopBottom = if math.sign(cursorPosition.Y) == -1
|
|
307
|
+
then Enum.TopBottom.Top
|
|
308
|
+
else Enum.TopBottom.Bottom
|
|
309
|
+
end
|
|
310
|
+
isResizing = true
|
|
311
|
+
resizeWindow = focusedWindow
|
|
312
|
+
end
|
|
313
|
+
end)
|
|
314
|
+
|
|
315
|
+
widgets.registerEvent("TouchTapInWorld", function(_, gameProcessedEvent: boolean)
|
|
316
|
+
if not Iris._started then
|
|
317
|
+
return
|
|
318
|
+
end
|
|
319
|
+
if not gameProcessedEvent then
|
|
320
|
+
Iris.SetFocusedWindow(nil)
|
|
321
|
+
end
|
|
322
|
+
end)
|
|
323
|
+
|
|
324
|
+
widgets.registerEvent("InputChanged", function(input: InputObject)
|
|
325
|
+
if not Iris._started then
|
|
326
|
+
return
|
|
327
|
+
end
|
|
328
|
+
if isDragging and dragWindow then
|
|
329
|
+
local mouseLocation
|
|
330
|
+
if input.UserInputType == Enum.UserInputType.Touch then
|
|
331
|
+
local location = input.Position
|
|
332
|
+
mouseLocation = Vector2.new(location.X, location.Y)
|
|
333
|
+
else
|
|
334
|
+
mouseLocation = widgets.getMouseLocation()
|
|
335
|
+
end
|
|
336
|
+
local Window = dragWindow.Instance :: Frame
|
|
337
|
+
local dragInstance: TextButton = Window.WindowButton
|
|
338
|
+
local intendedPosition = mouseLocation - moveDeltaCursorPosition
|
|
339
|
+
local newPos = fitPositionToWindowBounds(dragWindow, intendedPosition)
|
|
340
|
+
|
|
341
|
+
-- state shouldnt be used like this, but calling :set would run the entire UpdateState function for the window, which is slow.
|
|
342
|
+
dragInstance.Position = UDim2.fromOffset(newPos.X, newPos.Y)
|
|
343
|
+
dragWindow.state.position.value = newPos
|
|
344
|
+
end
|
|
345
|
+
if isResizing and resizeWindow and resizeWindow.arguments.NoResize ~= true then
|
|
346
|
+
local Window = resizeWindow.Instance :: Frame
|
|
347
|
+
local resizeInstance: TextButton = Window.WindowButton
|
|
348
|
+
local windowPosition = Vector2.new(resizeInstance.Position.X.Offset, resizeInstance.Position.Y.Offset)
|
|
349
|
+
local windowSize = Vector2.new(resizeInstance.Size.X.Offset, resizeInstance.Size.Y.Offset)
|
|
350
|
+
|
|
351
|
+
local mouseDelta
|
|
352
|
+
if input.UserInputType == Enum.UserInputType.Touch then
|
|
353
|
+
mouseDelta = input.Delta
|
|
354
|
+
else
|
|
355
|
+
mouseDelta = widgets.getMouseLocation() - lastCursorPosition
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
local intendedPosition = windowPosition
|
|
359
|
+
+ Vector2.new(
|
|
360
|
+
if resizeFromLeftRight == Enum.LeftRight.Left then mouseDelta.X else 0,
|
|
361
|
+
if resizeFromTopBottom == Enum.TopBottom.Top then mouseDelta.Y else 0
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
local intendedSize = windowSize
|
|
365
|
+
+ Vector2.new(
|
|
366
|
+
if resizeFromLeftRight == Enum.LeftRight.Left
|
|
367
|
+
then -mouseDelta.X
|
|
368
|
+
elseif resizeFromLeftRight == Enum.LeftRight.Right then mouseDelta.X
|
|
369
|
+
else 0,
|
|
370
|
+
if resizeFromTopBottom == Enum.TopBottom.Top
|
|
371
|
+
then -mouseDelta.Y
|
|
372
|
+
elseif resizeFromTopBottom == Enum.TopBottom.Bottom then mouseDelta.Y
|
|
373
|
+
else 0
|
|
374
|
+
)
|
|
375
|
+
|
|
376
|
+
local newSize = fitSizeToWindowBounds(resizeWindow, intendedSize)
|
|
377
|
+
local newPosition = fitPositionToWindowBounds(resizeWindow, intendedPosition)
|
|
378
|
+
|
|
379
|
+
resizeInstance.Size = UDim2.fromOffset(newSize.X, newSize.Y)
|
|
380
|
+
resizeWindow.state.size.value = newSize
|
|
381
|
+
resizeInstance.Position = UDim2.fromOffset(newPosition.X, newPosition.Y)
|
|
382
|
+
resizeWindow.state.position.value = newPosition
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
lastCursorPosition = widgets.getMouseLocation()
|
|
386
|
+
end)
|
|
387
|
+
|
|
388
|
+
widgets.registerEvent("InputEnded", function(input, _)
|
|
389
|
+
if not Iris._started then
|
|
390
|
+
return
|
|
391
|
+
end
|
|
392
|
+
if
|
|
393
|
+
(input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch)
|
|
394
|
+
and isDragging
|
|
395
|
+
and dragWindow
|
|
396
|
+
then
|
|
397
|
+
local Window = dragWindow.Instance :: Frame
|
|
398
|
+
local dragInstance: TextButton = Window.WindowButton
|
|
399
|
+
isDragging = false
|
|
400
|
+
dragWindow.state.position:set(Vector2.new(dragInstance.Position.X.Offset, dragInstance.Position.Y.Offset))
|
|
401
|
+
end
|
|
402
|
+
if
|
|
403
|
+
(input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch)
|
|
404
|
+
and isResizing
|
|
405
|
+
and resizeWindow
|
|
406
|
+
then
|
|
407
|
+
local Window = resizeWindow.Instance :: Instance
|
|
408
|
+
isResizing = false
|
|
409
|
+
resizeWindow.state.size:set(Window.WindowButton.AbsoluteSize)
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
if input.KeyCode == Enum.KeyCode.ButtonX then
|
|
413
|
+
quickSwapWindows()
|
|
414
|
+
end
|
|
415
|
+
end)
|
|
416
|
+
|
|
417
|
+
--stylua: ignore
|
|
418
|
+
Iris.WidgetConstructor("Window", {
|
|
419
|
+
hasState = true,
|
|
420
|
+
hasChildren = true,
|
|
421
|
+
Args = {
|
|
422
|
+
["Title"] = 1,
|
|
423
|
+
["NoTitleBar"] = 2,
|
|
424
|
+
["NoBackground"] = 3,
|
|
425
|
+
["NoCollapse"] = 4,
|
|
426
|
+
["NoClose"] = 5,
|
|
427
|
+
["NoMove"] = 6,
|
|
428
|
+
["NoScrollbar"] = 7,
|
|
429
|
+
["NoResize"] = 8,
|
|
430
|
+
["NoNav"] = 9,
|
|
431
|
+
["NoMenu"] = 10,
|
|
432
|
+
},
|
|
433
|
+
Events = {
|
|
434
|
+
["closed"] = {
|
|
435
|
+
["Init"] = function(_thisWidget: Types.Window) end,
|
|
436
|
+
["Get"] = function(thisWidget: Types.Window)
|
|
437
|
+
return thisWidget.lastClosedTick == Iris._cycleTick
|
|
438
|
+
end,
|
|
439
|
+
},
|
|
440
|
+
["opened"] = {
|
|
441
|
+
["Init"] = function(_thisWidget: Types.Window) end,
|
|
442
|
+
["Get"] = function(thisWidget: Types.Window)
|
|
443
|
+
return thisWidget.lastOpenedTick == Iris._cycleTick
|
|
444
|
+
end,
|
|
445
|
+
},
|
|
446
|
+
["collapsed"] = {
|
|
447
|
+
["Init"] = function(_thisWidget: Types.Window) end,
|
|
448
|
+
["Get"] = function(thisWidget: Types.Window)
|
|
449
|
+
return thisWidget.lastCollapsedTick == Iris._cycleTick
|
|
450
|
+
end,
|
|
451
|
+
},
|
|
452
|
+
["uncollapsed"] = {
|
|
453
|
+
["Init"] = function(_thisWidget: Types.Window) end,
|
|
454
|
+
["Get"] = function(thisWidget: Types.Window)
|
|
455
|
+
return thisWidget.lastUncollapsedTick == Iris._cycleTick
|
|
456
|
+
end,
|
|
457
|
+
},
|
|
458
|
+
["hovered"] = widgets.EVENTS.hover(function(thisWidget: Types.Widget)
|
|
459
|
+
local Window = thisWidget.Instance :: Frame
|
|
460
|
+
return Window.WindowButton
|
|
461
|
+
end),
|
|
462
|
+
},
|
|
463
|
+
Generate = function(thisWidget: Types.Window)
|
|
464
|
+
thisWidget.parentWidget = Iris._rootWidget -- only allow root as parent
|
|
465
|
+
|
|
466
|
+
thisWidget.usesScreenGuis = Iris._config.UseScreenGUIs
|
|
467
|
+
windowWidgets[thisWidget.ID] = thisWidget
|
|
468
|
+
|
|
469
|
+
local Window
|
|
470
|
+
if thisWidget.usesScreenGuis then
|
|
471
|
+
Window = Instance.new("ScreenGui")
|
|
472
|
+
Window.ResetOnSpawn = false
|
|
473
|
+
Window.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
|
|
474
|
+
Window.DisplayOrder = Iris._config.DisplayOrderOffset
|
|
475
|
+
Window.ScreenInsets = Iris._config.ScreenInsets
|
|
476
|
+
Window.IgnoreGuiInset = Iris._config.IgnoreGuiInset
|
|
477
|
+
else
|
|
478
|
+
Window = Instance.new("Frame")
|
|
479
|
+
Window.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
480
|
+
Window.Position = UDim2.fromScale(0.5, 0.5)
|
|
481
|
+
Window.Size = UDim2.fromScale(1, 1)
|
|
482
|
+
Window.BackgroundTransparency = 1
|
|
483
|
+
Window.ZIndex = Iris._config.DisplayOrderOffset
|
|
484
|
+
end
|
|
485
|
+
Window.Name = "Iris_Window"
|
|
486
|
+
|
|
487
|
+
local WindowButton = Instance.new("TextButton")
|
|
488
|
+
WindowButton.Name = "WindowButton"
|
|
489
|
+
WindowButton.Size = UDim2.fromOffset(0, 0)
|
|
490
|
+
WindowButton.BackgroundTransparency = 1
|
|
491
|
+
WindowButton.BorderSizePixel = 0
|
|
492
|
+
WindowButton.Text = ""
|
|
493
|
+
WindowButton.AutoButtonColor = false
|
|
494
|
+
WindowButton.ClipsDescendants = false
|
|
495
|
+
WindowButton.Selectable = false
|
|
496
|
+
|
|
497
|
+
WindowButton.SelectionImageObject = Iris.SelectionImageObject
|
|
498
|
+
WindowButton.SelectionGroup = true
|
|
499
|
+
WindowButton.SelectionBehaviorUp = Enum.SelectionBehavior.Stop
|
|
500
|
+
WindowButton.SelectionBehaviorDown = Enum.SelectionBehavior.Stop
|
|
501
|
+
WindowButton.SelectionBehaviorLeft = Enum.SelectionBehavior.Stop
|
|
502
|
+
WindowButton.SelectionBehaviorRight = Enum.SelectionBehavior.Stop
|
|
503
|
+
|
|
504
|
+
widgets.UIStroke(WindowButton, Iris._config.WindowBorderSize, Iris._config.BorderColor, Iris._config.BorderTransparency)
|
|
505
|
+
|
|
506
|
+
WindowButton.Parent = Window
|
|
507
|
+
|
|
508
|
+
widgets.applyInputBegan(WindowButton, function(input)
|
|
509
|
+
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Keyboard then
|
|
510
|
+
return
|
|
511
|
+
end
|
|
512
|
+
if thisWidget.state.isUncollapsed.value then
|
|
513
|
+
Iris.SetFocusedWindow(thisWidget)
|
|
514
|
+
end
|
|
515
|
+
if not thisWidget.arguments.NoMove and input.UserInputType == Enum.UserInputType.MouseButton1 then
|
|
516
|
+
dragWindow = thisWidget
|
|
517
|
+
isDragging = true
|
|
518
|
+
moveDeltaCursorPosition = widgets.getMouseLocation() - thisWidget.state.position.value
|
|
519
|
+
end
|
|
520
|
+
end)
|
|
521
|
+
|
|
522
|
+
local Content = Instance.new("Frame")
|
|
523
|
+
Content.Name = "Content"
|
|
524
|
+
Content.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
525
|
+
Content.Position = UDim2.fromScale(0.5, 0.5)
|
|
526
|
+
Content.Size = UDim2.fromScale(1, 1)
|
|
527
|
+
Content.BackgroundTransparency = 1
|
|
528
|
+
Content.ClipsDescendants = true
|
|
529
|
+
Content.Parent = WindowButton
|
|
530
|
+
|
|
531
|
+
local UIListLayout = widgets.UIListLayout(Content, Enum.FillDirection.Vertical, UDim.new(0, 0))
|
|
532
|
+
UIListLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
|
|
533
|
+
UIListLayout.VerticalAlignment = Enum.VerticalAlignment.Top
|
|
534
|
+
|
|
535
|
+
local ChildContainer = Instance.new("ScrollingFrame")
|
|
536
|
+
ChildContainer.Name = "WindowContainer"
|
|
537
|
+
ChildContainer.Size = UDim2.fromScale(1, 1)
|
|
538
|
+
ChildContainer.BackgroundColor3 = Iris._config.WindowBgColor
|
|
539
|
+
ChildContainer.BackgroundTransparency = Iris._config.WindowBgTransparency
|
|
540
|
+
ChildContainer.BorderSizePixel = 0
|
|
541
|
+
|
|
542
|
+
ChildContainer.AutomaticCanvasSize = Enum.AutomaticSize.Y
|
|
543
|
+
ChildContainer.ScrollBarImageTransparency = Iris._config.ScrollbarGrabTransparency
|
|
544
|
+
ChildContainer.ScrollBarImageColor3 = Iris._config.ScrollbarGrabColor
|
|
545
|
+
ChildContainer.CanvasSize = UDim2.fromScale(0, 0)
|
|
546
|
+
ChildContainer.VerticalScrollBarInset = Enum.ScrollBarInset.ScrollBar
|
|
547
|
+
ChildContainer.TopImage = widgets.ICONS.BLANK_SQUARE
|
|
548
|
+
ChildContainer.MidImage = widgets.ICONS.BLANK_SQUARE
|
|
549
|
+
ChildContainer.BottomImage = widgets.ICONS.BLANK_SQUARE
|
|
550
|
+
|
|
551
|
+
ChildContainer.LayoutOrder = thisWidget.ZIndex + 0xFFFF
|
|
552
|
+
ChildContainer.ClipsDescendants = true
|
|
553
|
+
|
|
554
|
+
widgets.UIPadding(ChildContainer, Iris._config.WindowPadding)
|
|
555
|
+
|
|
556
|
+
ChildContainer.Parent = Content
|
|
557
|
+
|
|
558
|
+
local UIFlexItem = Instance.new("UIFlexItem")
|
|
559
|
+
UIFlexItem.FlexMode = Enum.UIFlexMode.Fill
|
|
560
|
+
UIFlexItem.ItemLineAlignment = Enum.ItemLineAlignment.End
|
|
561
|
+
UIFlexItem.Parent = ChildContainer
|
|
562
|
+
|
|
563
|
+
ChildContainer:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
|
|
564
|
+
-- "wrong" use of state here, for optimization
|
|
565
|
+
thisWidget.state.scrollDistance.value = ChildContainer.CanvasPosition.Y
|
|
566
|
+
end)
|
|
567
|
+
|
|
568
|
+
widgets.applyInputBegan(ChildContainer, function(input)
|
|
569
|
+
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Keyboard then
|
|
570
|
+
return
|
|
571
|
+
end
|
|
572
|
+
if thisWidget.state.isUncollapsed.value then
|
|
573
|
+
Iris.SetFocusedWindow(thisWidget)
|
|
574
|
+
end
|
|
575
|
+
end)
|
|
576
|
+
|
|
577
|
+
local TerminatingFrame = Instance.new("Frame")
|
|
578
|
+
TerminatingFrame.Name = "TerminatingFrame"
|
|
579
|
+
TerminatingFrame.Size = UDim2.fromOffset(0, Iris._config.WindowPadding.Y + Iris._config.FramePadding.Y)
|
|
580
|
+
TerminatingFrame.BackgroundTransparency = 1
|
|
581
|
+
TerminatingFrame.BorderSizePixel = 0
|
|
582
|
+
TerminatingFrame.LayoutOrder = 0x7FFFFFF0
|
|
583
|
+
|
|
584
|
+
widgets.UIListLayout(ChildContainer, Enum.FillDirection.Vertical, UDim.new(0, Iris._config.ItemSpacing.Y)).VerticalAlignment = Enum.VerticalAlignment.Top
|
|
585
|
+
|
|
586
|
+
TerminatingFrame.Parent = ChildContainer
|
|
587
|
+
|
|
588
|
+
local TitleBar = Instance.new("Frame")
|
|
589
|
+
TitleBar.Name = "TitleBar"
|
|
590
|
+
TitleBar.AutomaticSize = Enum.AutomaticSize.Y
|
|
591
|
+
TitleBar.Size = UDim2.fromScale(1, 0)
|
|
592
|
+
TitleBar.BorderSizePixel = 0
|
|
593
|
+
TitleBar.ClipsDescendants = true
|
|
594
|
+
|
|
595
|
+
TitleBar.Parent = Content
|
|
596
|
+
|
|
597
|
+
widgets.UIPadding(TitleBar, Vector2.new(Iris._config.FramePadding.X))
|
|
598
|
+
widgets.UIListLayout(TitleBar, Enum.FillDirection.Horizontal, UDim.new(0, Iris._config.ItemInnerSpacing.X)).VerticalAlignment = Enum.VerticalAlignment.Center
|
|
599
|
+
widgets.applyInputBegan(TitleBar, function(input)
|
|
600
|
+
if input.UserInputType == Enum.UserInputType.Touch then
|
|
601
|
+
if not thisWidget.arguments.NoMove then
|
|
602
|
+
dragWindow = thisWidget
|
|
603
|
+
isDragging = true
|
|
604
|
+
local location = input.Position
|
|
605
|
+
moveDeltaCursorPosition = Vector2.new(location.X, location.Y) - thisWidget.state.position.value
|
|
606
|
+
end
|
|
607
|
+
end
|
|
608
|
+
end)
|
|
609
|
+
|
|
610
|
+
local TitleButtonSize = Iris._config.TextSize + ((Iris._config.FramePadding.Y - 1) * 2)
|
|
611
|
+
|
|
612
|
+
local CollapseButton = Instance.new("TextButton")
|
|
613
|
+
CollapseButton.Name = "CollapseButton"
|
|
614
|
+
CollapseButton.AutomaticSize = Enum.AutomaticSize.None
|
|
615
|
+
CollapseButton.AnchorPoint = Vector2.new(0, 0.5)
|
|
616
|
+
CollapseButton.Size = UDim2.fromOffset(TitleButtonSize, TitleButtonSize)
|
|
617
|
+
CollapseButton.Position = UDim2.fromScale(0, 0.5)
|
|
618
|
+
CollapseButton.BackgroundTransparency = 1
|
|
619
|
+
CollapseButton.BorderSizePixel = 0
|
|
620
|
+
CollapseButton.AutoButtonColor = false
|
|
621
|
+
CollapseButton.Text = ""
|
|
622
|
+
|
|
623
|
+
widgets.UICorner(CollapseButton)
|
|
624
|
+
|
|
625
|
+
CollapseButton.Parent = TitleBar
|
|
626
|
+
|
|
627
|
+
widgets.applyButtonClick(CollapseButton, function()
|
|
628
|
+
thisWidget.state.isUncollapsed:set(not thisWidget.state.isUncollapsed.value)
|
|
629
|
+
end)
|
|
630
|
+
|
|
631
|
+
widgets.applyInteractionHighlights("Background", CollapseButton, CollapseButton, {
|
|
632
|
+
Color = Iris._config.ButtonColor,
|
|
633
|
+
Transparency = 1,
|
|
634
|
+
HoveredColor = Iris._config.ButtonHoveredColor,
|
|
635
|
+
HoveredTransparency = Iris._config.ButtonHoveredTransparency,
|
|
636
|
+
ActiveColor = Iris._config.ButtonActiveColor,
|
|
637
|
+
ActiveTransparency = Iris._config.ButtonActiveTransparency,
|
|
638
|
+
})
|
|
639
|
+
|
|
640
|
+
local CollapseArrow = Instance.new("ImageLabel")
|
|
641
|
+
CollapseArrow.Name = "Arrow"
|
|
642
|
+
CollapseArrow.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
643
|
+
CollapseArrow.Size = UDim2.fromOffset(math.floor(0.7 * TitleButtonSize), math.floor(0.7 * TitleButtonSize))
|
|
644
|
+
CollapseArrow.Position = UDim2.fromScale(0.5, 0.5)
|
|
645
|
+
CollapseArrow.BackgroundTransparency = 1
|
|
646
|
+
CollapseArrow.BorderSizePixel = 0
|
|
647
|
+
CollapseArrow.Image = widgets.ICONS.MULTIPLICATION_SIGN
|
|
648
|
+
CollapseArrow.ImageColor3 = Iris._config.TextColor
|
|
649
|
+
CollapseArrow.ImageTransparency = Iris._config.TextTransparency
|
|
650
|
+
CollapseArrow.Parent = CollapseButton
|
|
651
|
+
|
|
652
|
+
local CloseButton = Instance.new("TextButton")
|
|
653
|
+
CloseButton.Name = "CloseButton"
|
|
654
|
+
CloseButton.AutomaticSize = Enum.AutomaticSize.None
|
|
655
|
+
CloseButton.AnchorPoint = Vector2.new(1, 0.5)
|
|
656
|
+
CloseButton.Size = UDim2.fromOffset(TitleButtonSize, TitleButtonSize)
|
|
657
|
+
CloseButton.Position = UDim2.fromScale(1, 0.5)
|
|
658
|
+
CloseButton.BackgroundTransparency = 1
|
|
659
|
+
CloseButton.BorderSizePixel = 0
|
|
660
|
+
CloseButton.Text = ""
|
|
661
|
+
CloseButton.AutoButtonColor = false
|
|
662
|
+
CloseButton.LayoutOrder = 2
|
|
663
|
+
|
|
664
|
+
widgets.UICorner(CloseButton)
|
|
665
|
+
|
|
666
|
+
widgets.applyButtonClick(CloseButton, function()
|
|
667
|
+
thisWidget.state.isOpened:set(false)
|
|
668
|
+
end)
|
|
669
|
+
|
|
670
|
+
widgets.applyInteractionHighlights("Background", CloseButton, CloseButton, {
|
|
671
|
+
Color = Iris._config.ButtonColor,
|
|
672
|
+
Transparency = 1,
|
|
673
|
+
HoveredColor = Iris._config.ButtonHoveredColor,
|
|
674
|
+
HoveredTransparency = Iris._config.ButtonHoveredTransparency,
|
|
675
|
+
ActiveColor = Iris._config.ButtonActiveColor,
|
|
676
|
+
ActiveTransparency = Iris._config.ButtonActiveTransparency,
|
|
677
|
+
})
|
|
678
|
+
|
|
679
|
+
CloseButton.Parent = TitleBar
|
|
680
|
+
|
|
681
|
+
local CloseIcon = Instance.new("ImageLabel")
|
|
682
|
+
CloseIcon.Name = "Icon"
|
|
683
|
+
CloseIcon.AnchorPoint = Vector2.new(0.5, 0.5)
|
|
684
|
+
CloseIcon.Size = UDim2.fromOffset(math.floor(0.7 * TitleButtonSize), math.floor(0.7 * TitleButtonSize))
|
|
685
|
+
CloseIcon.Position = UDim2.fromScale(0.5, 0.5)
|
|
686
|
+
CloseIcon.BackgroundTransparency = 1
|
|
687
|
+
CloseIcon.BorderSizePixel = 0
|
|
688
|
+
CloseIcon.Image = widgets.ICONS.MULTIPLICATION_SIGN
|
|
689
|
+
CloseIcon.ImageColor3 = Iris._config.TextColor
|
|
690
|
+
CloseIcon.ImageTransparency = Iris._config.TextTransparency
|
|
691
|
+
CloseIcon.Parent = CloseButton
|
|
692
|
+
|
|
693
|
+
-- allowing fractional titlebar title location dosent seem useful, as opposed to Enum.LeftRight.
|
|
694
|
+
|
|
695
|
+
local Title = Instance.new("TextLabel")
|
|
696
|
+
Title.Name = "Title"
|
|
697
|
+
Title.AutomaticSize = Enum.AutomaticSize.XY
|
|
698
|
+
Title.BorderSizePixel = 0
|
|
699
|
+
Title.BackgroundTransparency = 1
|
|
700
|
+
Title.LayoutOrder = 1
|
|
701
|
+
Title.ClipsDescendants = true
|
|
702
|
+
|
|
703
|
+
widgets.UIPadding(Title, Vector2.new(0, Iris._config.FramePadding.Y))
|
|
704
|
+
widgets.applyTextStyle(Title)
|
|
705
|
+
Title.TextXAlignment = Enum.TextXAlignment[Iris._config.WindowTitleAlign.Name] :: Enum.TextXAlignment
|
|
706
|
+
|
|
707
|
+
local TitleFlexItem = Instance.new("UIFlexItem")
|
|
708
|
+
TitleFlexItem.FlexMode = Enum.UIFlexMode.Fill
|
|
709
|
+
TitleFlexItem.ItemLineAlignment = Enum.ItemLineAlignment.Center
|
|
710
|
+
|
|
711
|
+
TitleFlexItem.Parent = Title
|
|
712
|
+
|
|
713
|
+
Title.Parent = TitleBar
|
|
714
|
+
|
|
715
|
+
local ResizeButtonSize = Iris._config.TextSize + Iris._config.FramePadding.X
|
|
716
|
+
|
|
717
|
+
local LeftResizeGrip = Instance.new("ImageButton")
|
|
718
|
+
LeftResizeGrip.Name = "LeftResizeGrip"
|
|
719
|
+
LeftResizeGrip.AnchorPoint = Vector2.yAxis
|
|
720
|
+
LeftResizeGrip.Rotation = 180
|
|
721
|
+
LeftResizeGrip.Position = UDim2.fromScale(0, 1)
|
|
722
|
+
LeftResizeGrip.Size = UDim2.fromOffset(ResizeButtonSize, ResizeButtonSize)
|
|
723
|
+
LeftResizeGrip.BackgroundTransparency = 1
|
|
724
|
+
LeftResizeGrip.BorderSizePixel = 0
|
|
725
|
+
LeftResizeGrip.Image = widgets.ICONS.BOTTOM_RIGHT_CORNER
|
|
726
|
+
LeftResizeGrip.ImageColor3 = Iris._config.ResizeGripColor
|
|
727
|
+
LeftResizeGrip.ImageTransparency = 1
|
|
728
|
+
LeftResizeGrip.AutoButtonColor = false
|
|
729
|
+
LeftResizeGrip.ZIndex = 3
|
|
730
|
+
LeftResizeGrip.Parent = WindowButton
|
|
731
|
+
|
|
732
|
+
widgets.applyInteractionHighlights("Image", LeftResizeGrip, LeftResizeGrip, {
|
|
733
|
+
Color = Iris._config.ResizeGripColor,
|
|
734
|
+
Transparency = 1,
|
|
735
|
+
HoveredColor = Iris._config.ResizeGripHoveredColor,
|
|
736
|
+
HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
|
|
737
|
+
ActiveColor = Iris._config.ResizeGripActiveColor,
|
|
738
|
+
ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
|
|
739
|
+
})
|
|
740
|
+
|
|
741
|
+
widgets.applyButtonDown(LeftResizeGrip, function()
|
|
742
|
+
if not anyFocusedWindow or not (focusedWindow == thisWidget) then
|
|
743
|
+
Iris.SetFocusedWindow(thisWidget)
|
|
744
|
+
-- mitigating wrong focus when clicking on buttons inside of a window without clicking the window itself
|
|
745
|
+
end
|
|
746
|
+
isResizing = true
|
|
747
|
+
resizeFromTopBottom = Enum.TopBottom.Bottom
|
|
748
|
+
resizeFromLeftRight = Enum.LeftRight.Left
|
|
749
|
+
resizeWindow = thisWidget
|
|
750
|
+
end)
|
|
751
|
+
|
|
752
|
+
-- each border uses an image, allowing it to have a visible borde which is larger than the UI
|
|
753
|
+
local RightResizeGrip = Instance.new("ImageButton")
|
|
754
|
+
RightResizeGrip.Name = "RightResizeGrip"
|
|
755
|
+
RightResizeGrip.AnchorPoint = Vector2.one
|
|
756
|
+
RightResizeGrip.Rotation = 90
|
|
757
|
+
RightResizeGrip.Position = UDim2.fromScale(1, 1)
|
|
758
|
+
RightResizeGrip.Size = UDim2.fromOffset(ResizeButtonSize, ResizeButtonSize)
|
|
759
|
+
RightResizeGrip.BackgroundTransparency = 1
|
|
760
|
+
RightResizeGrip.BorderSizePixel = 0
|
|
761
|
+
RightResizeGrip.Image = widgets.ICONS.BOTTOM_RIGHT_CORNER
|
|
762
|
+
RightResizeGrip.ImageColor3 = Iris._config.ResizeGripColor
|
|
763
|
+
RightResizeGrip.ImageTransparency = Iris._config.ResizeGripTransparency
|
|
764
|
+
RightResizeGrip.AutoButtonColor = false
|
|
765
|
+
RightResizeGrip.ZIndex = 3
|
|
766
|
+
RightResizeGrip.Parent = WindowButton
|
|
767
|
+
|
|
768
|
+
widgets.applyInteractionHighlights("Image", RightResizeGrip, RightResizeGrip, {
|
|
769
|
+
Color = Iris._config.ResizeGripColor,
|
|
770
|
+
Transparency = Iris._config.ResizeGripTransparency,
|
|
771
|
+
HoveredColor = Iris._config.ResizeGripHoveredColor,
|
|
772
|
+
HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
|
|
773
|
+
ActiveColor = Iris._config.ResizeGripActiveColor,
|
|
774
|
+
ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
|
|
775
|
+
})
|
|
776
|
+
|
|
777
|
+
widgets.applyButtonDown(RightResizeGrip, function()
|
|
778
|
+
if not anyFocusedWindow or not (focusedWindow == thisWidget) then
|
|
779
|
+
Iris.SetFocusedWindow(thisWidget)
|
|
780
|
+
-- mitigating wrong focus when clicking on buttons inside of a window without clicking the window itself
|
|
781
|
+
end
|
|
782
|
+
isResizing = true
|
|
783
|
+
resizeFromTopBottom = Enum.TopBottom.Bottom
|
|
784
|
+
resizeFromLeftRight = Enum.LeftRight.Right
|
|
785
|
+
resizeWindow = thisWidget
|
|
786
|
+
end)
|
|
787
|
+
|
|
788
|
+
local LeftResizeBorder = Instance.new("ImageButton")
|
|
789
|
+
LeftResizeBorder.Name = "LeftResizeBorder"
|
|
790
|
+
LeftResizeBorder.AnchorPoint = Vector2.new(1, .5)
|
|
791
|
+
LeftResizeBorder.Position = UDim2.fromScale(0, .5)
|
|
792
|
+
LeftResizeBorder.Size = UDim2.new(0, Iris._config.WindowResizePadding.X, 1, 2 * Iris._config.WindowBorderSize)
|
|
793
|
+
LeftResizeBorder.Transparency = 1
|
|
794
|
+
LeftResizeBorder.Image = widgets.ICONS.BORDER
|
|
795
|
+
LeftResizeBorder.ResampleMode = Enum.ResamplerMode.Pixelated
|
|
796
|
+
LeftResizeBorder.ScaleType = Enum.ScaleType.Slice
|
|
797
|
+
LeftResizeBorder.SliceCenter = Rect.new(0, 0, 1, 1)
|
|
798
|
+
LeftResizeBorder.ImageRectOffset = Vector2.new(2, 2)
|
|
799
|
+
LeftResizeBorder.ImageRectSize = Vector2.new(2, 1)
|
|
800
|
+
LeftResizeBorder.ImageTransparency = 1
|
|
801
|
+
LeftResizeBorder.AutoButtonColor = false
|
|
802
|
+
LeftResizeBorder.ZIndex = 4
|
|
803
|
+
|
|
804
|
+
LeftResizeBorder.Parent = WindowButton
|
|
805
|
+
|
|
806
|
+
local RightResizeBorder = Instance.new("ImageButton")
|
|
807
|
+
RightResizeBorder.Name = "RightResizeBorder"
|
|
808
|
+
RightResizeBorder.AnchorPoint = Vector2.new(0, .5)
|
|
809
|
+
RightResizeBorder.Position = UDim2.fromScale(1, .5)
|
|
810
|
+
RightResizeBorder.Size = UDim2.new(0, Iris._config.WindowResizePadding.X, 1, 2 * Iris._config.WindowBorderSize)
|
|
811
|
+
RightResizeBorder.Transparency = 1
|
|
812
|
+
RightResizeBorder.Image = widgets.ICONS.BORDER
|
|
813
|
+
RightResizeBorder.ResampleMode = Enum.ResamplerMode.Pixelated
|
|
814
|
+
RightResizeBorder.ScaleType = Enum.ScaleType.Slice
|
|
815
|
+
RightResizeBorder.SliceCenter = Rect.new(1, 0, 2, 1)
|
|
816
|
+
RightResizeBorder.ImageRectOffset = Vector2.new(1, 2)
|
|
817
|
+
RightResizeBorder.ImageRectSize = Vector2.new(2, 1)
|
|
818
|
+
RightResizeBorder.ImageTransparency = 1
|
|
819
|
+
RightResizeBorder.AutoButtonColor = false
|
|
820
|
+
RightResizeBorder.ZIndex = 4
|
|
821
|
+
|
|
822
|
+
RightResizeBorder.Parent = WindowButton
|
|
823
|
+
|
|
824
|
+
local TopResizeBorder = Instance.new("ImageButton")
|
|
825
|
+
TopResizeBorder.Name = "TopResizeBorder"
|
|
826
|
+
TopResizeBorder.AnchorPoint = Vector2.new(.5, 1)
|
|
827
|
+
TopResizeBorder.Position = UDim2.fromScale(.5, 0)
|
|
828
|
+
TopResizeBorder.Size = UDim2.new(1, 2 * Iris._config.WindowBorderSize, 0, Iris._config.WindowResizePadding.Y)
|
|
829
|
+
TopResizeBorder.Transparency = 1
|
|
830
|
+
TopResizeBorder.Image = widgets.ICONS.BORDER
|
|
831
|
+
TopResizeBorder.ResampleMode = Enum.ResamplerMode.Pixelated
|
|
832
|
+
TopResizeBorder.ScaleType = Enum.ScaleType.Slice
|
|
833
|
+
TopResizeBorder.SliceCenter = Rect.new(0, 0, 1, 1)
|
|
834
|
+
TopResizeBorder.ImageRectOffset = Vector2.new(2, 2)
|
|
835
|
+
TopResizeBorder.ImageRectSize = Vector2.new(1, 2)
|
|
836
|
+
TopResizeBorder.ImageTransparency = 1
|
|
837
|
+
TopResizeBorder.AutoButtonColor = false
|
|
838
|
+
TopResizeBorder.ZIndex = 4
|
|
839
|
+
|
|
840
|
+
TopResizeBorder.Parent = WindowButton
|
|
841
|
+
|
|
842
|
+
local BottomResizeBorder = Instance.new("ImageButton")
|
|
843
|
+
BottomResizeBorder.Name = "BottomResizeBorder"
|
|
844
|
+
BottomResizeBorder.AnchorPoint = Vector2.new(.5, 0)
|
|
845
|
+
BottomResizeBorder.Position = UDim2.fromScale(.5, 1)
|
|
846
|
+
BottomResizeBorder.Size = UDim2.new(1, 2 * Iris._config.WindowBorderSize, 0, Iris._config.WindowResizePadding.Y)
|
|
847
|
+
BottomResizeBorder.Transparency = 1
|
|
848
|
+
BottomResizeBorder.Image = widgets.ICONS.BORDER
|
|
849
|
+
BottomResizeBorder.ResampleMode = Enum.ResamplerMode.Pixelated
|
|
850
|
+
BottomResizeBorder.ScaleType = Enum.ScaleType.Slice
|
|
851
|
+
BottomResizeBorder.SliceCenter = Rect.new(0, 1, 1, 2)
|
|
852
|
+
BottomResizeBorder.ImageRectOffset = Vector2.new(2, 1)
|
|
853
|
+
BottomResizeBorder.ImageRectSize = Vector2.new(1, 2)
|
|
854
|
+
BottomResizeBorder.ImageTransparency = 1
|
|
855
|
+
BottomResizeBorder.AutoButtonColor = false
|
|
856
|
+
BottomResizeBorder.ZIndex = 4
|
|
857
|
+
|
|
858
|
+
BottomResizeBorder.Parent = WindowButton
|
|
859
|
+
|
|
860
|
+
widgets.applyInteractionHighlights("Image", LeftResizeBorder, LeftResizeBorder, {
|
|
861
|
+
Color = Iris._config.ResizeGripColor,
|
|
862
|
+
Transparency = 1,
|
|
863
|
+
HoveredColor = Iris._config.ResizeGripHoveredColor,
|
|
864
|
+
HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
|
|
865
|
+
ActiveColor = Iris._config.ResizeGripActiveColor,
|
|
866
|
+
ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
|
|
867
|
+
})
|
|
868
|
+
|
|
869
|
+
widgets.applyInteractionHighlights("Image", RightResizeBorder, RightResizeBorder, {
|
|
870
|
+
Color = Iris._config.ResizeGripColor,
|
|
871
|
+
Transparency = 1,
|
|
872
|
+
HoveredColor = Iris._config.ResizeGripHoveredColor,
|
|
873
|
+
HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
|
|
874
|
+
ActiveColor = Iris._config.ResizeGripActiveColor,
|
|
875
|
+
ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
|
|
876
|
+
})
|
|
877
|
+
|
|
878
|
+
widgets.applyInteractionHighlights("Image", TopResizeBorder, TopResizeBorder, {
|
|
879
|
+
Color = Iris._config.ResizeGripColor,
|
|
880
|
+
Transparency = 1,
|
|
881
|
+
HoveredColor = Iris._config.ResizeGripHoveredColor,
|
|
882
|
+
HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
|
|
883
|
+
ActiveColor = Iris._config.ResizeGripActiveColor,
|
|
884
|
+
ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
|
|
885
|
+
})
|
|
886
|
+
|
|
887
|
+
widgets.applyInteractionHighlights("Image", BottomResizeBorder, BottomResizeBorder, {
|
|
888
|
+
Color = Iris._config.ResizeGripColor,
|
|
889
|
+
Transparency = 1,
|
|
890
|
+
HoveredColor = Iris._config.ResizeGripHoveredColor,
|
|
891
|
+
HoveredTransparency = Iris._config.ResizeGripHoveredTransparency,
|
|
892
|
+
ActiveColor = Iris._config.ResizeGripActiveColor,
|
|
893
|
+
ActiveTransparency = Iris._config.ResizeGripActiveTransparency,
|
|
894
|
+
})
|
|
895
|
+
|
|
896
|
+
local ResizeBorder = Instance.new("Frame")
|
|
897
|
+
ResizeBorder.Name = "ResizeBorder"
|
|
898
|
+
ResizeBorder.Position = UDim2.fromOffset(-Iris._config.WindowResizePadding.X, -Iris._config.WindowResizePadding.Y)
|
|
899
|
+
ResizeBorder.Size = UDim2.new(1, Iris._config.WindowResizePadding.X * 2, 1, Iris._config.WindowResizePadding.Y * 2)
|
|
900
|
+
ResizeBorder.BackgroundTransparency = 1
|
|
901
|
+
ResizeBorder.BorderSizePixel = 0
|
|
902
|
+
ResizeBorder.Active = false
|
|
903
|
+
ResizeBorder.Selectable = false
|
|
904
|
+
ResizeBorder.ClipsDescendants = false
|
|
905
|
+
ResizeBorder.Parent = WindowButton
|
|
906
|
+
|
|
907
|
+
widgets.applyMouseEnter(ResizeBorder, function()
|
|
908
|
+
if focusedWindow == thisWidget then
|
|
909
|
+
isInsideResize = true
|
|
910
|
+
end
|
|
911
|
+
end)
|
|
912
|
+
widgets.applyMouseLeave(ResizeBorder, function()
|
|
913
|
+
if focusedWindow == thisWidget then
|
|
914
|
+
isInsideResize = false
|
|
915
|
+
end
|
|
916
|
+
end)
|
|
917
|
+
widgets.applyInputBegan(ResizeBorder, function(input)
|
|
918
|
+
if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Keyboard then
|
|
919
|
+
return
|
|
920
|
+
end
|
|
921
|
+
if thisWidget.state.isUncollapsed.value then
|
|
922
|
+
Iris.SetFocusedWindow(thisWidget)
|
|
923
|
+
end
|
|
924
|
+
end)
|
|
925
|
+
|
|
926
|
+
widgets.applyMouseEnter(WindowButton, function()
|
|
927
|
+
if focusedWindow == thisWidget then
|
|
928
|
+
isInsideWindow = true
|
|
929
|
+
end
|
|
930
|
+
end)
|
|
931
|
+
widgets.applyMouseLeave(WindowButton, function()
|
|
932
|
+
if focusedWindow == thisWidget then
|
|
933
|
+
isInsideWindow = false
|
|
934
|
+
end
|
|
935
|
+
end)
|
|
936
|
+
|
|
937
|
+
thisWidget.ChildContainer = ChildContainer
|
|
938
|
+
return Window
|
|
939
|
+
end,
|
|
940
|
+
GenerateState = function(thisWidget: Types.Window)
|
|
941
|
+
if thisWidget.state.size == nil then
|
|
942
|
+
thisWidget.state.size = Iris._widgetState(thisWidget, "size", Vector2.new(400, 300))
|
|
943
|
+
end
|
|
944
|
+
if thisWidget.state.position == nil then
|
|
945
|
+
thisWidget.state.position = Iris._widgetState(thisWidget, "position", if anyFocusedWindow and focusedWindow then focusedWindow.state.position.value + Vector2.new(15, 45) else Vector2.new(150, 250))
|
|
946
|
+
end
|
|
947
|
+
thisWidget.state.position.value = fitPositionToWindowBounds(thisWidget, thisWidget.state.position.value)
|
|
948
|
+
thisWidget.state.size.value = fitSizeToWindowBounds(thisWidget, thisWidget.state.size.value)
|
|
949
|
+
|
|
950
|
+
if thisWidget.state.isUncollapsed == nil then
|
|
951
|
+
thisWidget.state.isUncollapsed = Iris._widgetState(thisWidget, "isUncollapsed", true)
|
|
952
|
+
end
|
|
953
|
+
if thisWidget.state.isOpened == nil then
|
|
954
|
+
thisWidget.state.isOpened = Iris._widgetState(thisWidget, "isOpened", true)
|
|
955
|
+
end
|
|
956
|
+
if thisWidget.state.scrollDistance == nil then
|
|
957
|
+
thisWidget.state.scrollDistance = Iris._widgetState(thisWidget, "scrollDistance", 0)
|
|
958
|
+
end
|
|
959
|
+
end,
|
|
960
|
+
Update = function(thisWidget: Types.Window)
|
|
961
|
+
local Window = thisWidget.Instance :: GuiObject
|
|
962
|
+
local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame
|
|
963
|
+
local WindowButton = Window.WindowButton :: TextButton
|
|
964
|
+
local Content = WindowButton.Content :: Frame
|
|
965
|
+
local TitleBar = Content.TitleBar :: Frame
|
|
966
|
+
local Title: TextLabel = TitleBar.Title
|
|
967
|
+
local MenuBar: Frame? = Content:FindFirstChild("Iris_MenuBar")
|
|
968
|
+
local LeftResizeGrip: TextButton = WindowButton.LeftResizeGrip
|
|
969
|
+
local RightResizeGrip: TextButton = WindowButton.RightResizeGrip
|
|
970
|
+
local LeftResizeBorder: Frame = WindowButton.LeftResizeBorder
|
|
971
|
+
local RightResizeBorder: Frame = WindowButton.RightResizeBorder
|
|
972
|
+
local TopResizeBorder: Frame = WindowButton.TopResizeBorder
|
|
973
|
+
local BottomResizeBorder: Frame = WindowButton.BottomResizeBorder
|
|
974
|
+
|
|
975
|
+
if thisWidget.arguments.NoResize ~= true then
|
|
976
|
+
LeftResizeGrip.Visible = true
|
|
977
|
+
RightResizeGrip.Visible = true
|
|
978
|
+
LeftResizeBorder.Visible = true
|
|
979
|
+
RightResizeBorder.Visible = true
|
|
980
|
+
TopResizeBorder.Visible = true
|
|
981
|
+
BottomResizeBorder.Visible = true
|
|
982
|
+
else
|
|
983
|
+
LeftResizeGrip.Visible = false
|
|
984
|
+
RightResizeGrip.Visible = false
|
|
985
|
+
LeftResizeBorder.Visible = false
|
|
986
|
+
RightResizeBorder.Visible = false
|
|
987
|
+
TopResizeBorder.Visible = false
|
|
988
|
+
BottomResizeBorder.Visible = false
|
|
989
|
+
end
|
|
990
|
+
if thisWidget.arguments.NoScrollbar then
|
|
991
|
+
ChildContainer.ScrollBarThickness = 0
|
|
992
|
+
else
|
|
993
|
+
ChildContainer.ScrollBarThickness = Iris._config.ScrollbarSize
|
|
994
|
+
end
|
|
995
|
+
if thisWidget.arguments.NoTitleBar then
|
|
996
|
+
TitleBar.Visible = false
|
|
997
|
+
else
|
|
998
|
+
TitleBar.Visible = true
|
|
999
|
+
end
|
|
1000
|
+
if MenuBar then
|
|
1001
|
+
if thisWidget.arguments.NoMenu then
|
|
1002
|
+
MenuBar.Visible = false
|
|
1003
|
+
else
|
|
1004
|
+
MenuBar.Visible = true
|
|
1005
|
+
end
|
|
1006
|
+
end
|
|
1007
|
+
if thisWidget.arguments.NoBackground then
|
|
1008
|
+
ChildContainer.BackgroundTransparency = 1
|
|
1009
|
+
else
|
|
1010
|
+
ChildContainer.BackgroundTransparency = Iris._config.WindowBgTransparency
|
|
1011
|
+
end
|
|
1012
|
+
|
|
1013
|
+
-- TitleBar buttons
|
|
1014
|
+
if thisWidget.arguments.NoCollapse then
|
|
1015
|
+
TitleBar.CollapseButton.Visible = false
|
|
1016
|
+
else
|
|
1017
|
+
TitleBar.CollapseButton.Visible = true
|
|
1018
|
+
end
|
|
1019
|
+
if thisWidget.arguments.NoClose then
|
|
1020
|
+
TitleBar.CloseButton.Visible = false
|
|
1021
|
+
else
|
|
1022
|
+
TitleBar.CloseButton.Visible = true
|
|
1023
|
+
end
|
|
1024
|
+
|
|
1025
|
+
Title.Text = thisWidget.arguments.Title or ""
|
|
1026
|
+
end,
|
|
1027
|
+
UpdateState = function(thisWidget: Types.Window)
|
|
1028
|
+
local stateSize = thisWidget.state.size.value
|
|
1029
|
+
local statePosition = thisWidget.state.position.value
|
|
1030
|
+
local stateIsUncollapsed = thisWidget.state.isUncollapsed.value
|
|
1031
|
+
local stateIsOpened = thisWidget.state.isOpened.value
|
|
1032
|
+
local stateScrollDistance = thisWidget.state.scrollDistance.value
|
|
1033
|
+
|
|
1034
|
+
local Window = thisWidget.Instance :: Frame
|
|
1035
|
+
local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame
|
|
1036
|
+
local WindowButton = Window.WindowButton :: TextButton
|
|
1037
|
+
local Content = WindowButton.Content :: Frame
|
|
1038
|
+
local TitleBar = Content.TitleBar :: Frame
|
|
1039
|
+
local MenuBar: Frame? = Content:FindFirstChild("Iris_MenuBar")
|
|
1040
|
+
local LeftResizeGrip: TextButton = WindowButton.LeftResizeGrip
|
|
1041
|
+
local RightResizeGrip: TextButton = WindowButton.RightResizeGrip
|
|
1042
|
+
local LeftResizeBorder: Frame = WindowButton.LeftResizeBorder
|
|
1043
|
+
local RightResizeBorder: Frame = WindowButton.RightResizeBorder
|
|
1044
|
+
local TopResizeBorder: Frame = WindowButton.TopResizeBorder
|
|
1045
|
+
local BottomResizeBorder: Frame = WindowButton.BottomResizeBorder
|
|
1046
|
+
|
|
1047
|
+
WindowButton.Size = UDim2.fromOffset(stateSize.X, stateSize.Y)
|
|
1048
|
+
WindowButton.Position = UDim2.fromOffset(statePosition.X, statePosition.Y)
|
|
1049
|
+
|
|
1050
|
+
if stateIsOpened then
|
|
1051
|
+
if thisWidget.usesScreenGuis then
|
|
1052
|
+
Window.Enabled = true
|
|
1053
|
+
WindowButton.Visible = true
|
|
1054
|
+
else
|
|
1055
|
+
Window.Visible = true
|
|
1056
|
+
WindowButton.Visible = true
|
|
1057
|
+
end
|
|
1058
|
+
thisWidget.lastOpenedTick = Iris._cycleTick + 1
|
|
1059
|
+
else
|
|
1060
|
+
if thisWidget.usesScreenGuis then
|
|
1061
|
+
Window.Enabled = false
|
|
1062
|
+
WindowButton.Visible = false
|
|
1063
|
+
else
|
|
1064
|
+
Window.Visible = false
|
|
1065
|
+
WindowButton.Visible = false
|
|
1066
|
+
end
|
|
1067
|
+
thisWidget.lastClosedTick = Iris._cycleTick + 1
|
|
1068
|
+
end
|
|
1069
|
+
|
|
1070
|
+
if stateIsUncollapsed then
|
|
1071
|
+
TitleBar.CollapseButton.Arrow.Image = widgets.ICONS.DOWN_POINTING_TRIANGLE
|
|
1072
|
+
if MenuBar then
|
|
1073
|
+
MenuBar.Visible = not thisWidget.arguments.NoMenu
|
|
1074
|
+
end
|
|
1075
|
+
ChildContainer.Visible = true
|
|
1076
|
+
if thisWidget.arguments.NoResize ~= true then
|
|
1077
|
+
LeftResizeGrip.Visible = true
|
|
1078
|
+
RightResizeGrip.Visible = true
|
|
1079
|
+
LeftResizeBorder.Visible = true
|
|
1080
|
+
RightResizeBorder.Visible = true
|
|
1081
|
+
TopResizeBorder.Visible = true
|
|
1082
|
+
BottomResizeBorder.Visible = true
|
|
1083
|
+
end
|
|
1084
|
+
WindowButton.AutomaticSize = Enum.AutomaticSize.None
|
|
1085
|
+
thisWidget.lastUncollapsedTick = Iris._cycleTick + 1
|
|
1086
|
+
else
|
|
1087
|
+
local collapsedHeight: number = TitleBar.AbsoluteSize.Y -- Iris._config.TextSize + Iris._config.FramePadding.Y * 2
|
|
1088
|
+
TitleBar.CollapseButton.Arrow.Image = widgets.ICONS.RIGHT_POINTING_TRIANGLE
|
|
1089
|
+
|
|
1090
|
+
if MenuBar then
|
|
1091
|
+
MenuBar.Visible = false
|
|
1092
|
+
end
|
|
1093
|
+
ChildContainer.Visible = false
|
|
1094
|
+
LeftResizeGrip.Visible = false
|
|
1095
|
+
RightResizeGrip.Visible = false
|
|
1096
|
+
LeftResizeBorder.Visible = false
|
|
1097
|
+
RightResizeBorder.Visible = false
|
|
1098
|
+
TopResizeBorder.Visible = false
|
|
1099
|
+
BottomResizeBorder.Visible = false
|
|
1100
|
+
WindowButton.Size = UDim2.fromOffset(stateSize.X, collapsedHeight)
|
|
1101
|
+
thisWidget.lastCollapsedTick = Iris._cycleTick + 1
|
|
1102
|
+
end
|
|
1103
|
+
|
|
1104
|
+
if stateIsOpened and stateIsUncollapsed then
|
|
1105
|
+
Iris.SetFocusedWindow(thisWidget)
|
|
1106
|
+
else
|
|
1107
|
+
TitleBar.BackgroundColor3 = Iris._config.TitleBgCollapsedColor
|
|
1108
|
+
TitleBar.BackgroundTransparency = Iris._config.TitleBgCollapsedTransparency
|
|
1109
|
+
WindowButton.UIStroke.Color = Iris._config.BorderColor
|
|
1110
|
+
|
|
1111
|
+
Iris.SetFocusedWindow(nil)
|
|
1112
|
+
end
|
|
1113
|
+
|
|
1114
|
+
-- cant update canvasPosition in this cycle because scrollingframe isint ready to be changed
|
|
1115
|
+
if stateScrollDistance and stateScrollDistance ~= 0 then
|
|
1116
|
+
local callbackIndex = #Iris._postCycleCallbacks + 1
|
|
1117
|
+
local desiredCycleTick = Iris._cycleTick + 1
|
|
1118
|
+
Iris._postCycleCallbacks[callbackIndex] = function()
|
|
1119
|
+
if Iris._cycleTick >= desiredCycleTick then
|
|
1120
|
+
if thisWidget.lastCycleTick ~= -1 then
|
|
1121
|
+
ChildContainer.CanvasPosition = Vector2.new(0, stateScrollDistance)
|
|
1122
|
+
end
|
|
1123
|
+
Iris._postCycleCallbacks[callbackIndex] = nil
|
|
1124
|
+
end
|
|
1125
|
+
end
|
|
1126
|
+
end
|
|
1127
|
+
end,
|
|
1128
|
+
ChildAdded = function(thisWidget: Types.Window, thisChid: Types.Widget)
|
|
1129
|
+
local Window = thisWidget.Instance :: Frame
|
|
1130
|
+
local WindowButton = Window.WindowButton :: TextButton
|
|
1131
|
+
local Content = WindowButton.Content :: Frame
|
|
1132
|
+
if thisChid.type == "MenuBar" then
|
|
1133
|
+
local ChildContainer = thisWidget.ChildContainer :: ScrollingFrame
|
|
1134
|
+
thisChid.Instance.ZIndex = ChildContainer.ZIndex + 1
|
|
1135
|
+
thisChid.Instance.LayoutOrder = ChildContainer.LayoutOrder - 1
|
|
1136
|
+
return Content
|
|
1137
|
+
end
|
|
1138
|
+
return thisWidget.ChildContainer
|
|
1139
|
+
end,
|
|
1140
|
+
Discard = function(thisWidget: Types.Window)
|
|
1141
|
+
if focusedWindow == thisWidget then
|
|
1142
|
+
focusedWindow = nil
|
|
1143
|
+
anyFocusedWindow = false
|
|
1144
|
+
end
|
|
1145
|
+
if dragWindow == thisWidget then
|
|
1146
|
+
dragWindow = nil
|
|
1147
|
+
isDragging = false
|
|
1148
|
+
end
|
|
1149
|
+
if resizeWindow == thisWidget then
|
|
1150
|
+
resizeWindow = nil
|
|
1151
|
+
isResizing = false
|
|
1152
|
+
end
|
|
1153
|
+
windowWidgets[thisWidget.ID] = nil
|
|
1154
|
+
thisWidget.Instance:Destroy()
|
|
1155
|
+
widgets.discardState(thisWidget)
|
|
1156
|
+
end,
|
|
1157
|
+
} :: Types.WidgetClass)
|
|
1158
|
+
end
|