-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindow-manager.lua
More file actions
64 lines (54 loc) · 1.71 KB
/
Copy pathwindow-manager.lua
File metadata and controls
64 lines (54 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
local currentPath = (...):match('(.-)[^%./]+$')
--- @class IUILib
local iui = require(currentPath .. "iui")
--- @class IUIWindowManager
--- @field draw IUIDrawRootContext
--- @field layer IUILayerRootContext
--- @field state IUIStateRootContext
--- @field disabledCount number
--- @field hoverID? number The ID of the widget a pointer is hovering over.
--- @field activeID? number The ID of the widget that's being actively used.
--- @field cursor? IUICursorName The desired mouse cursor to display.
--- @field hadActiveID boolean Internal flag for detecting widget deactivation.
local IUIWindowManager = {}
IUIWindowManager.__index = IUIWindowManager
--- @return IUIWindowManager
function iui.newWindowManager()
--- @type IUIWindowManager
local manager = {
draw = iui.draw.newRootContext(),
layer = iui.layer.newRootContext(),
state = iui.state.newRootContext(),
disabledCount = 0,
hadActiveID = false,
}
setmetatable(manager, IUIWindowManager)
return manager
end
function IUIWindowManager:beginFrame()
iui.disabledCount = 0
iui.hoverID = nil
iui.cursor = nil
iui.resetIDCheck()
iui.state.beginFrame()
iui.draw.beginFrame()
iui.layout.beginFrame()
iui.style.beginFrame()
iui.layer.beginFrame()
end
function IUIWindowManager:endFrame()
if iui.disabledCount ~= 0 then
error("Unbalanced control disable count")
end
if self.activeID == nil and self.hadActiveID == true then
self.hadActiveID = false
if iui.widgetDeactivated then
iui.widgetDeactivated()
end
end
iui.layout.endFrame()
iui.draw.endFrame()
iui.layer.endFrame()
iui.style.endFrame()
iui.state.endFrame()
end