Skip to content

Commit

Permalink
Refined off screen protection for the bag to disallow just the item b…
Browse files Browse the repository at this point in the history
…utton from being offscreen.
  • Loading branch information
Cidan committed Dec 1, 2023
1 parent f7a8448 commit 02a2f17
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions frames/bag.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,16 @@ function bagProto:Draw(dirtyItems)
end
local text = self.frame.SearchBox:GetText()
self:Search(text)
self:KeepBagInBounds()
end

function bagProto:KeepBagInBounds()
-- Size protection for the bag frame, to prevent it from going off screen.
local left, top = self.frame:GetLeft(), self.frame:GetTop()
local uitop = UIParent:GetTop()
if left < 0 or top > uitop then
self.frame:SetClampedToScreen(false)
else
self.frame:SetClampedToScreen(true)
end
local w, h = self.frame:GetSize()
self.frame:SetClampRectInsets(0, -w+50, 0, h-50)
-- Toggle the clamp setting to force the frame to rebind to the screen
-- on the correct clamp insets.
self.frame:SetClampedToScreen(false)
self.frame:SetClampedToScreen(true)
end

function bagProto:OnResize()
Expand Down Expand Up @@ -410,6 +409,7 @@ function bagFrame:Create(kind)
b.frame:RegisterForDrag("LeftButton")
b.frame:SetClampedToScreen(true)
b.frame:SetScript("OnDragStart", function(drag)
b:KeepBagInBounds()
drag:StartMoving()
end)
b.frame:SetScript("OnDragStop", function(drag)
Expand Down

0 comments on commit 02a2f17

Please sign in to comment.