@quenty/basicpane 5.2.0 → 6.0.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 +11 -0
- package/package.json +4 -3
- package/src/Client/BasicPaneUtils.lua +83 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +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.0.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/basicpane@5.2.0...@quenty/basicpane@6.0.0) (2022-08-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* Add BasicPaneUtils.whenVisibleBrio(createBasicPane) which allows for guis only while visible. ([05dd547](https://github.com/Quenty/NevermoreEngine/commit/05dd54729f9dd53348d24150e60a4bd5fc9fcea1))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [5.2.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/basicpane@5.1.0...@quenty/basicpane@5.2.0) (2022-07-31)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @quenty/basicpane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quenty/basicpane",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Base UI object with visibility and a maid",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Roblox",
|
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
"Quenty"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@quenty/brio": "^7.0.0",
|
|
28
29
|
"@quenty/loader": "^5.0.0",
|
|
29
30
|
"@quenty/maid": "^2.4.0",
|
|
30
|
-
"@quenty/rx": "^
|
|
31
|
+
"@quenty/rx": "^6.0.0",
|
|
31
32
|
"@quenty/signal": "^2.2.0"
|
|
32
33
|
},
|
|
33
34
|
"publishConfig": {
|
|
34
35
|
"access": "public"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "dbb62609f980983cc32da90acfef13e30ed41113"
|
|
37
38
|
}
|
|
@@ -8,6 +8,7 @@ local Observable = require("Observable")
|
|
|
8
8
|
local Maid = require("Maid")
|
|
9
9
|
local Rx = require("Rx")
|
|
10
10
|
local BasicPane = require("BasicPane")
|
|
11
|
+
local Brio = require("Brio")
|
|
11
12
|
|
|
12
13
|
local BasicPaneUtils = {}
|
|
13
14
|
|
|
@@ -31,6 +32,88 @@ function BasicPaneUtils.observeVisible(basicPane)
|
|
|
31
32
|
end)
|
|
32
33
|
end
|
|
33
34
|
|
|
35
|
+
--[=[
|
|
36
|
+
Shows the basic pane only when the emitting observable is visible. This
|
|
37
|
+
allows the basic pane 1 second to hide. If the pane gets reshown in that
|
|
38
|
+
time it will reshow it.
|
|
39
|
+
|
|
40
|
+
This can help lead to performance gains when you have a generally hidden pane
|
|
41
|
+
underneath another one and it needs to be shown.
|
|
42
|
+
|
|
43
|
+
See [GuiVisibleManager] for the OOP version.
|
|
44
|
+
|
|
45
|
+
```lua
|
|
46
|
+
Rx.of(true):Pipe({
|
|
47
|
+
BasicPaneUtils.whenVisibleBrio(function(maid)
|
|
48
|
+
-- generally you'd have your subclass here
|
|
49
|
+
local pane = BasicPane.new()
|
|
50
|
+
pane.Gui.Parent = screenGui
|
|
51
|
+
|
|
52
|
+
return pane
|
|
53
|
+
end)
|
|
54
|
+
})
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
@param createBasicPane (maid: Maid) -> BasicPane
|
|
58
|
+
@return (source: Observable<boolean>) -> Observable<Brio<GuiBase>>
|
|
59
|
+
]=]
|
|
60
|
+
function BasicPaneUtils.whenVisibleBrio(createBasicPane)
|
|
61
|
+
return function(source)
|
|
62
|
+
return Observable.new(function(sub)
|
|
63
|
+
local maid = Maid.new()
|
|
64
|
+
|
|
65
|
+
local currentPane = nil
|
|
66
|
+
|
|
67
|
+
local function ensurePane()
|
|
68
|
+
if currentPane then
|
|
69
|
+
return currentPane
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
local paneMaid = Maid.new()
|
|
73
|
+
|
|
74
|
+
local basicPane = createBasicPane(paneMaid)
|
|
75
|
+
assert(BasicPane.isBasicPane(basicPane), "Bad BasicPane")
|
|
76
|
+
paneMaid:GiveTask(basicPane)
|
|
77
|
+
|
|
78
|
+
local brio = Brio.new(basicPane.Gui)
|
|
79
|
+
paneMaid:GiveTask(brio)
|
|
80
|
+
|
|
81
|
+
do
|
|
82
|
+
currentPane = basicPane
|
|
83
|
+
maid:GiveTask(function()
|
|
84
|
+
if currentPane == basicPane then
|
|
85
|
+
currentPane = nil
|
|
86
|
+
end
|
|
87
|
+
end)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
-- Fire off
|
|
91
|
+
maid._currentPaneMaid = paneMaid
|
|
92
|
+
sub:Fire(brio)
|
|
93
|
+
|
|
94
|
+
return currentPane
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
maid:GiveTask(source:Subscribe(function(isVisible)
|
|
98
|
+
if isVisible then
|
|
99
|
+
maid._hideTask = nil
|
|
100
|
+
ensurePane():Show()
|
|
101
|
+
else
|
|
102
|
+
if currentPane and currentPane:IsVisible() then
|
|
103
|
+
currentPane:Hide()
|
|
104
|
+
maid._hideTask = task.delay(1, function()
|
|
105
|
+
currentPane = nil
|
|
106
|
+
maid._currentPaneMaid = nil
|
|
107
|
+
end)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end))
|
|
111
|
+
|
|
112
|
+
return maid
|
|
113
|
+
end)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
34
117
|
--[=[
|
|
35
118
|
Observes percent visibility
|
|
36
119
|
@param basicPane BasicPane
|