Skip to content

Commit

Permalink
[Window]
Browse files Browse the repository at this point in the history
Fix for adjusting the window position to match mouse location when tearing from dock.

close #60
  • Loading branch information
coding-jackalope committed Nov 22, 2020
1 parent c4f8ef9 commit 59cdb79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Internal/UI/Dock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ function Dock.UpdateTear(WinId, X, Y)
end
end

function Dock.GetCachedOptions(WinId)
for Id, Instance in pairs(Instances) do
if Instance.Window == WinId then
return Instance.CachedOptions
end
end

return nil
end

function Dock.Toggle(List, Enabled)
List = List == nil and {} or List
Enabled = Enabled == nil and true or Enabled
Expand Down
10 changes: 10 additions & 0 deletions Internal/UI/Window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,14 @@ local function UpdateTitleBar(Instance, IsObstructed, AllowMove)
elseif IsTethered then
Dock.UpdateTear(Instance.Id, MouseX, MouseY)

local Options = Dock.GetCachedOptions(Instance.Id)
if not Dock.IsTethered(Instance.Id) then
Instance.IsMoving = true

if Options ~= nil then
Instance.TitleDeltaX = MouseX - Options.X - (MouseX - Instance.X)
Instance.TitleDeltaY = MouseY - Options.Y - (MouseY - Instance.Y + H)
end
end
end
end
Expand Down Expand Up @@ -219,6 +225,10 @@ local function UpdateSize(Instance, IsObstructed)
return
end

if MovingInstance ~= nil then
return
end

local X = Instance.X
local Y = Instance.Y
local W = Instance.W
Expand Down

0 comments on commit 59cdb79

Please # to comment.