Skip to content

Commit

Permalink
[Window]
Browse files Browse the repository at this point in the history
Refactored obstruction check to handle docked windows.
  • Loading branch information
coding-jackalope committed Nov 1, 2020
1 parent aa64e92 commit da4d057
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Internal/UI/MenuState.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ local MenuState =
{
IsOpened = false,
WasOpened = false,
RequireClose = false,
RequestClose = false,
MainMenuBarH = 0
}

Expand Down
60 changes: 36 additions & 24 deletions Internal/UI/Window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,12 @@ function Window.IsObstructed(X, Y, SkipScrollCheck)
return true
end

if ActiveInstance ~= nil then
local FoundStackLock = false
-- If there are no windows, then nothing can obstruct.
if #Stack == 0 then
return false
end

if ActiveInstance ~= nil then
if not ActiveInstance.IsOpen then
return true
end
Expand All @@ -368,38 +371,47 @@ function Window.IsObstructed(X, Y, SkipScrollCheck)
return false
end

-- Check if docked windows are obstructing floating windows.
for I, V in ipairs(Stack) do
if Dock.IsTethered(V.Id) then
if ActiveInstance == V then
return false
end

if Contains(V, X, Y) and V.CanObstruct and V.IsOpen then
return true
end
end
if ActiveInstance.IsAppearing then
return true
end

-- Proceed to check stack order of floating windows. Dialogs are pushed to the top of
-- the stack.
-- Gather all potential windows that can obstruct the given position.
local List = {}
for I, V in ipairs(Stack) do
-- Stack locks prevents other windows to be considered.
if V.Id == StackLockId then
FoundStackLock = true
elseif FoundStackLock then
return true
insert(List, V)
break
end

if Contains(V, X, Y) and V.CanObstruct then
if ActiveInstance == V then
if not SkipScrollCheck and Region.IsHoverScrollBar(ActiveInstance.Id) then
return true
end
insert(List, V)
end
end

-- Certain layers are rendered on top of 'Normal' windows. Consider these windows first.
local Top = nil
for I, V in ipairs(List) do
if V.Layer ~= 'Normal' then
Top = V
break
end
end

-- If all windows are considered the normal layer, then just grab the window at the top of the stack.
if Top == nil then
Top = List[1]
end

return false
elseif V.IsOpen then
if Top ~= nil then
if ActiveInstance == Top then
if not SkipScrollCheck and Region.IsHoverScrollBar(ActiveInstance.Id) then
return true
end

return false
elseif Top.IsOpen then
return true
end
end
end
Expand Down
1 change: 0 additions & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
v0.7.1
==========
[Platform]: Test running on Android. Applies to issue #35.
[Dock]: Unable to interact with menu when window is docked.

v0.8.0
==========
Expand Down

0 comments on commit da4d057

Please sign in to comment.