Skip to content

Commit

Permalink
Fix problem with positioning when "Move windows to panels". Fix inden…
Browse files Browse the repository at this point in the history
…tations. Fix for issue otland#33
  • Loading branch information
EgzoT committed Apr 11, 2021
1 parent c873092 commit 7b6be3b
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions modules/corelib/ui/uiminiwindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,42 +162,39 @@ function UIMiniWindow:onDragEnter(mousePos)
end

function UIMiniWindow:onDragLeave(droppedWidget, mousePos)
if self.movedWidget then
self.setMovedChildMargin(self.movedOldMargin or 0)
self.movedWidget = nil
self.setMovedChildMargin = nil
self.movedOldMargin = nil
self.movedIndex = nil
end

if g_settings.getBoolean('moveWindowsToPanel') then
local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
local dropInPanel = 0

for i=1,#children do
local child = children[i]
if child:getId() == 'gameLeftPanel' or child:getId() == 'gameRightPanel' then
dropInPanel = 1
end
end
if g_settings.getBoolean('moveWindowsToPanel') then
local children = rootWidget:recursiveGetChildrenByMarginPos(mousePos)
local dropInPanel = 0

if dropInPanel == 0 then
tmpp = self
if(modules.game_interface.getLeftPanel():isVisible()) then
if modules.game_interface.getRootPanel():getWidth() / 2 < mousePos.x then
addEvent(function() tmpp:setParent(modules.game_interface.getRightPanel()) end)
else
addEvent(function() tmpp:setParent(modules.game_interface.getLeftPanel()) end)
end
else
addEvent(function() tmpp:setParent(modules.game_interface.getRightPanel()) end)
end
end

else
if self.movedWidget then
self.setMovedChildMargin(self.movedOldMargin or 0)
self.movedWidget = nil
self.setMovedChildMargin = nil
self.movedOldMargin = nil
self.movedIndex = nil
for i=1,#children do
local child = children[i]
if child:getId() == 'gameLeftPanel' or child:getId() == 'gameRightPanel' then
dropInPanel = 1
end
end

if dropInPanel == 0 then
if(modules.game_interface.getLeftPanel():isVisible()) then
if modules.game_interface.getRootPanel():getWidth() / 2 < mousePos.x then
self:setParent(modules.game_interface.getRightPanel())
else
self:setParent(modules.game_interface.getLeftPanel())
end

self:saveParent(self:getParent())
else
self:setParent(modules.game_interface.getRightPanel())
end
end
end

self:saveParent(self:getParent())
end

function UIMiniWindow:onDragMove(mousePos, mouseMoved)
Expand Down

0 comments on commit 7b6be3b

Please sign in to comment.