diff --git a/UnitFrames/Components/UnitFrame.lua b/UnitFrames/Components/UnitFrame.lua index e3145da..8ee70b6 100644 --- a/UnitFrames/Components/UnitFrame.lua +++ b/UnitFrames/Components/UnitFrame.lua @@ -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() @@ -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") diff --git a/tests/spec/units/hover_spec.lua b/tests/spec/units/hover_spec.lua index ad49db4..51bc754 100644 --- a/tests/spec/units/hover_spec.lua +++ b/tests/spec/units/hover_spec.lua @@ -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