@quenty/uiobjectutils 6.9.1-canary.513.484c203.0 → 6.10.1
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 +8 -3
- package/package.json +7 -7
- package/src/Client/RxClippedRectUtils.lua +0 -142
package/CHANGELOG.md
CHANGED
|
@@ -3,12 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [6.
|
|
6
|
+
## [6.10.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/uiobjectutils@6.10.0...@quenty/uiobjectutils@6.10.1) (2024-11-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @quenty/uiobjectutils
|
|
9
|
+
|
|
7
10
|
|
|
8
11
|
|
|
9
|
-
### Features
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
# [6.10.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/uiobjectutils@6.9.0...@quenty/uiobjectutils@6.10.0) (2024-11-03)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @quenty/uiobjectutils
|
|
12
17
|
|
|
13
18
|
|
|
14
19
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/uiobjectutils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.1",
|
|
4
4
|
"description": "UI object utils library for Roblox",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@quenty/brio": "14.
|
|
32
|
-
"@quenty/enumutils": "3.3.0",
|
|
33
|
-
"@quenty/instanceutils": "13.
|
|
34
|
-
"@quenty/loader": "10.7.
|
|
35
|
-
"@quenty/rx": "13.
|
|
31
|
+
"@quenty/brio": "^14.11.1",
|
|
32
|
+
"@quenty/enumutils": "^3.3.0",
|
|
33
|
+
"@quenty/instanceutils": "^13.11.1",
|
|
34
|
+
"@quenty/loader": "^10.7.1",
|
|
35
|
+
"@quenty/rx": "^13.11.1"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "01c43a0ddd3c5e0cb2d9027313dbfa9852eedef1"
|
|
38
38
|
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
--[=[
|
|
2
|
-
Helper functions to observe parts of a Gui that are clipped or not
|
|
3
|
-
|
|
4
|
-
@class RxClippedRectUtils
|
|
5
|
-
]=]
|
|
6
|
-
|
|
7
|
-
local require = require(script.Parent.loader).load(script)
|
|
8
|
-
|
|
9
|
-
local Rx = require("Rx")
|
|
10
|
-
local RxInstanceUtils = require("RxInstanceUtils")
|
|
11
|
-
|
|
12
|
-
local RxClippedRectUtils = {}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
--[=[
|
|
16
|
-
Observes the clipped rect for the given Gui
|
|
17
|
-
|
|
18
|
-
@param gui Gui
|
|
19
|
-
@return Observable<Rect>
|
|
20
|
-
]=]
|
|
21
|
-
function RxClippedRectUtils.observeClippedRect(gui)
|
|
22
|
-
assert(typeof(gui) == "Instance" and gui:IsA("GuiObject"), "Bad GuiBase2d")
|
|
23
|
-
|
|
24
|
-
-- At least use our object's size here...
|
|
25
|
-
return Rx.combineLatest({
|
|
26
|
-
absolutePosition = RxInstanceUtils.observeProperty(gui, "AbsolutePosition");
|
|
27
|
-
absoluteSize = RxInstanceUtils.observeProperty(gui, "AbsoluteSize");
|
|
28
|
-
parentRect = RxClippedRectUtils._observeParentClippedRect(gui);
|
|
29
|
-
}):Pipe({
|
|
30
|
-
Rx.map(function(state)
|
|
31
|
-
return RxClippedRectUtils._computeClippedRect(state)
|
|
32
|
-
end);
|
|
33
|
-
Rx.distinct();
|
|
34
|
-
})
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
local function clampVector2(value)
|
|
38
|
-
return Vector2.new(math.clamp(value.x, 0, 1), math.clamp(value.y, 0, 1))
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
function RxClippedRectUtils.observeClippedRectInScale(gui)
|
|
42
|
-
assert(typeof(gui) == "Instance" and gui:IsA("GuiObject"), "Bad GuiBase2d")
|
|
43
|
-
|
|
44
|
-
return Rx.combineLatest({
|
|
45
|
-
absolutePosition = RxInstanceUtils.observeProperty(gui, "AbsolutePosition");
|
|
46
|
-
absoluteSize = RxInstanceUtils.observeProperty(gui, "AbsoluteSize");
|
|
47
|
-
visibleRect = RxClippedRectUtils.observeClippedRect(gui);
|
|
48
|
-
}):Pipe({
|
|
49
|
-
Rx.map(function(state)
|
|
50
|
-
if state.absoluteSize.x == 0 or state.absoluteSize.y == 0 then
|
|
51
|
-
return Rect.new(Vector2.zero, Vector2.zero)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
local ourMin = state.absolutePosition
|
|
55
|
-
local ourSize = state.absoluteSize
|
|
56
|
-
|
|
57
|
-
local visibleMin = state.visibleRect.Min
|
|
58
|
-
local visibleSize = state.visibleRect.Max - visibleMin
|
|
59
|
-
|
|
60
|
-
local topLeft = clampVector2((visibleMin - ourMin)/ourSize)
|
|
61
|
-
local size = clampVector2(visibleSize/ourSize)
|
|
62
|
-
local bottomRight = topLeft + size
|
|
63
|
-
return Rect.new(topLeft, bottomRight)
|
|
64
|
-
end);
|
|
65
|
-
Rx.distinct();
|
|
66
|
-
})
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
function RxClippedRectUtils._observeClippedRectImpl(gui)
|
|
70
|
-
if gui:IsA("GuiObject") then
|
|
71
|
-
return RxInstanceUtils.observeProperty(gui, "ClipsDescendants"):Pipe({
|
|
72
|
-
Rx.switchMap(function(clipDescendants)
|
|
73
|
-
if not clipDescendants then
|
|
74
|
-
return RxClippedRectUtils._observeParentClippedRect(gui)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
return Rx.combineLatest({
|
|
78
|
-
absolutePosition = RxInstanceUtils.observeProperty(gui, "AbsolutePosition");
|
|
79
|
-
absoluteSize = RxInstanceUtils.observeProperty(gui, "AbsoluteSize");
|
|
80
|
-
parentRect = RxClippedRectUtils._observeParentClippedRect(gui);
|
|
81
|
-
}):Pipe({
|
|
82
|
-
Rx.map(function(state)
|
|
83
|
-
return RxClippedRectUtils._computeClippedRect(state)
|
|
84
|
-
end);
|
|
85
|
-
})
|
|
86
|
-
end)
|
|
87
|
-
})
|
|
88
|
-
else
|
|
89
|
-
if not gui:IsA("LayerCollector") then
|
|
90
|
-
warn(string.format("[RxClippedRectUtils._observeClippedRectImpl] - Unknown gui instance type behind GuiBase2d of class %s - treating as layer collector. Please patch this method.", tostring(gui.ClassName)))
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
return Rx.combineLatest({
|
|
94
|
-
absolutePosition = RxInstanceUtils.observeProperty(gui, "AbsolutePosition");
|
|
95
|
-
absoluteSize = RxInstanceUtils.observeProperty(gui, "AbsoluteSize");
|
|
96
|
-
parentRect = RxClippedRectUtils._observeParentClippedRect(gui);
|
|
97
|
-
}):Pipe({
|
|
98
|
-
Rx.map(function(state)
|
|
99
|
-
return RxClippedRectUtils._computeClippedRect(state)
|
|
100
|
-
end);
|
|
101
|
-
})
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
function RxClippedRectUtils._computeClippedRect(state)
|
|
106
|
-
if not state.parentRect then
|
|
107
|
-
return Rect.new(state.absolutePosition, state.absolutePosition + state.absoluteSize)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
local topLeft = state.absolutePosition
|
|
111
|
-
local bottomRight = state.absolutePosition + state.absoluteSize
|
|
112
|
-
|
|
113
|
-
local parentMin = state.parentRect.Min
|
|
114
|
-
local parentMax = state.parentRect.Max
|
|
115
|
-
local topLeftX = math.max(topLeft.x, parentMin.x)
|
|
116
|
-
local topLeftY = math.max(topLeft.y, parentMin.y)
|
|
117
|
-
|
|
118
|
-
local bottomRightX = math.min(bottomRight.x, parentMax.x)
|
|
119
|
-
local bottomRightY = math.min(bottomRight.y, parentMax.y)
|
|
120
|
-
|
|
121
|
-
-- negative sizes not allowed...
|
|
122
|
-
local sizeX = math.max(0, bottomRightX - topLeftX)
|
|
123
|
-
local sizeY = math.max(0, bottomRightY - topLeftY)
|
|
124
|
-
|
|
125
|
-
return Rect.new(topLeftX, topLeftY, topLeftX + sizeX, topLeftY + sizeY)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
function RxClippedRectUtils._observeParentClippedRect(gui)
|
|
129
|
-
assert(typeof(gui) == "Instance" and gui:IsA("GuiBase2d"), "Bad GuiBase2d")
|
|
130
|
-
|
|
131
|
-
return RxInstanceUtils.observeFirstAncestor(gui, "GuiObject"):Pipe({
|
|
132
|
-
Rx.switchMap(function(parent)
|
|
133
|
-
if parent then
|
|
134
|
-
return RxClippedRectUtils._observeClippedRectImpl(parent)
|
|
135
|
-
else
|
|
136
|
-
return Rx.of(nil);
|
|
137
|
-
end
|
|
138
|
-
end);
|
|
139
|
-
});
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
return RxClippedRectUtils
|