Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions UnitFrames/Components/UnitFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ function UnitFrame:OnCreate(parent, spec)
end
end
-- Mouseover wash on a raised child: textures on the unit button itself
-- render below its bars.
-- render below its bars. Layout keeps it inside the frame border.
self.hoverHost = CreateFrame("Frame", nil, self.frame)
self.hoverHost:SetAllPoints(self.frame)
self.hover = self.hoverHost:CreateTexture(nil, "ARTWORK")
self.hover:SetAllPoints()
self.hover:Hide()
Expand Down Expand Up @@ -673,6 +672,12 @@ function UnitFrame:Layout()
if part.def.stack then part.component:Layout(self.layoutContext) end
end
self.decorations:Reflow()
-- Inside the border padding: chamfered and soft border edges are partly
-- transparent, so a wash under them would show past the corners.
local left, right, top, bottom = Backdrop.Padding(self.resolved.border)
self.hoverHost:ClearAllPoints()
self.hoverHost:SetPoint("TOPLEFT", self.frame, "TOPLEFT", left, -top)
self.hoverHost:SetPoint("BOTTOMRIGHT", self.frame, "BOTTOMRIGHT", -right, bottom)
self.hoverHost:SetFrameLevel(self.frame:GetFrameLevel() + Backdrop.LEVELS.hover)
Backdrop.SetBorderLevel(self.border, self.frame:GetFrameLevel() + Backdrop.LEVELS.frame)
ns.Perf:End("unit layout")
Expand Down
20 changes: 20 additions & 0 deletions tests/spec/units/hover_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ describe("Mouseover highlight", function()
assert.is_true(level < frame:GetFrameLevel() + ns.Components.Backdrop.LEVELS.frame)
end)

it("stays inside the frame border, where the bars sit", function()
local frame = ns.Units.frames.target
local host = frame.uf.hoverHost
local function Inset()
local topLeft, bottomRight = host:GetAnchor("TOPLEFT"), host:GetAnchor("BOTTOMRIGHT")
return topLeft[4], -topLeft[5], -bottomRight[4], bottomRight[5]
end
ns.Config:SetUnitValue("target", "border.enabled", true)
ns.Config:SetUnitValue("target", "border.padding", 5)
assert.same({ 5, 5, 5, 5 }, { Inset() })
ns.Config:SetUnitValue("target", "border.separatePadding", true)
ns.Config:SetUnitValue("target", "border.paddingLeft", 2)
ns.Config:SetUnitValue("target", "border.paddingBottom", 7)
local left, _, _, bottom = Inset()
assert.equals(2, left)
assert.equals(7, bottom)
ns.Config:SetUnitValue("target", "border.enabled", false)
assert.same({ 0, 0, 0, 0 }, { Inset() })
end)

it("keeps the hovered state through restyles and follows the settings, also in combat", function()
local frame = ns.Units.frames.player
local hover = frame.uf.hover
Expand Down
Loading