From 7b6be3bc82e5be3b1b09040d9ff2447102f1fbdf Mon Sep 17 00:00:00 2001 From: EgzoT Date: Sun, 11 Apr 2021 03:28:33 +0200 Subject: [PATCH] Fix problem with positioning when "Move windows to panels". Fix indentations. Fix for issue #33 --- modules/corelib/ui/uiminiwindow.lua | 61 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/modules/corelib/ui/uiminiwindow.lua b/modules/corelib/ui/uiminiwindow.lua index 0e9f44ee0..0c8bc42ff 100644 --- a/modules/corelib/ui/uiminiwindow.lua +++ b/modules/corelib/ui/uiminiwindow.lua @@ -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)