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
7 changes: 2 additions & 5 deletions UnitFrames/Components/AuraBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,8 @@ function AuraBar:StyleButton(button)
button.ufIconFrame:ClearAllPoints()
button.ufIconFrame:SetPoint("TOPLEFT", button, "TOPLEFT", 0, (size - height) / 2)
-- Text belongs to the visible strip, while texture/cooldown/border stay square.
button.ufCount:ClearAllPoints()
button.ufCount:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2)
button.ufTime:ClearAllPoints()
local position = self.artConfig.durationPosition
button.ufTime:SetPoint(position, button, position, 0, position == "TOP" and -2 or position == "BOTTOM" and 2 or 0)
ns.AuraIcon.PlaceText(button.ufCount, button, self.artConfig.countPosition)
ns.AuraIcon.PlaceText(button.ufTime, button, self.artConfig.durationPosition)
self:ConfigureAnimation(button)
end

Expand Down
28 changes: 22 additions & 6 deletions UnitFrames/Components/AuraIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,25 @@ local function DurationFormatter()
return durationFormatter
end

AuraIcon.DURATION_POSITIONS = {
{ "below", "Below the icon" }, { "CENTER", "Inside: centre" },
{ "TOP", "Inside: top" }, { "BOTTOM", "Inside: bottom" },
AuraIcon.TEXT_POSITIONS = {
{ "TOPLEFT", "Inside: top left" }, { "TOP", "Inside: top" }, { "TOPRIGHT", "Inside: top right" },
{ "LEFT", "Inside: left" }, { "CENTER", "Inside: centre" }, { "RIGHT", "Inside: right" },
{ "BOTTOMLEFT", "Inside: bottom left" }, { "BOTTOM", "Inside: bottom" }, { "BOTTOMRIGHT", "Inside: bottom right" },
}
AuraIcon.DURATION_POSITIONS = { { "below", "Below the icon" } }
for _, position in ipairs(AuraIcon.TEXT_POSITIONS) do AuraIcon.DURATION_POSITIONS[#AuraIcon.DURATION_POSITIONS + 1] = position end

-- Inside texts keep a 2px inset from the edges they sit on.
function AuraIcon.TextOffset(point)
local x = point:find("LEFT") and 2 or point:find("RIGHT") and -2 or 0
local y = point:find("TOP") and -2 or point:find("BOTTOM") and 2 or 0
return x, y
end

function AuraIcon.PlaceText(text, region, point)
text:ClearAllPoints()
text:SetPoint(point, region, point, AuraIcon.TextOffset(point))
end

AuraIcon.GLOW_STYLES = { { "halo", "Soft halo" }, { "proc", "Proc flash" } }

Expand All @@ -46,6 +61,7 @@ AuraIcon.schema = {
{ key = "durationPosition", type = "select", label = "Time position", values = AuraIcon.DURATION_POSITIONS, default = "below" },
{ key = "durationSize", type = "range", label = "Time text size", min = 6, max = 32, step = 1, default = 10 },
{ key = "showCount", type = "toggle", label = "Show stacks", default = true },
{ key = "countPosition", type = "select", label = "Stack position", values = AuraIcon.TEXT_POSITIONS, default = "BOTTOMRIGHT" },
{ key = "countSize", type = "range", label = "Stack text size", min = 6, max = 32, step = 1, default = 10 },
{ key = "font", type = "font", label = "Font", inherit = "font" },
{ key = "fontOutline", type = "select", label = "Font outline", values = ns.Theme.OUTLINES, default = "OUTLINE" },
Expand Down Expand Up @@ -211,12 +227,12 @@ function AuraIcon.Apply(button, cfg, width, height, dispelColors, swipe, showSwi
for _, entry in ipairs({ { button.ufCount, cfg.countSize }, { button.ufTime, cfg.durationSize } }) do
Media:ApplyFont(entry[1], cfg.font, entry[2], cfg.fontOutline)
end
button.ufTime:ClearAllPoints()
AuraIcon.PlaceText(button.ufCount, button.ufIconFrame, cfg.countPosition)
if cfg.durationPosition == "below" then
button.ufTime:ClearAllPoints()
button.ufTime:SetPoint("TOP", button.ufIconFrame, "BOTTOM", 0, -1)
else
local y = cfg.durationPosition == "TOP" and -2 or cfg.durationPosition == "BOTTOM" and 2 or 0
button.ufTime:SetPoint(cfg.durationPosition, button.ufIconFrame, cfg.durationPosition, 0, y)
AuraIcon.PlaceText(button.ufTime, button.ufIconFrame, cfg.durationPosition)
end
button.ufCountHolder:SetShown(cfg.showCount)
button.ufTime:SetShown(cfg.showDuration)
Expand Down
2 changes: 1 addition & 1 deletion UnitFrames/Components/UnitFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ UnitFrame.BLIZZARD_AURAS_SCHEMA = {
UnitFrame.UNIT_STATES = {
{ key = "dead", label = "Dead & ghost", schema = UnitStateSchema(
"While the unit is dead or a ghost, turn this frame greyscale and tint it with the ghost colour. Bar fills take one uniform colour; the health bar shows it across its whole length instead of an empty or 1 health fill.",
"Ghost colour", { 0.55, 0.85, 0.94, 1 }) },
"Ghost colour", { 0.48, 0.65, 0.70, 1 }) },
{ key = "offline", label = "Offline", schema = UnitStateSchema(
"While the unit is offline, turn this frame greyscale. Bar fills take one uniform grey; the health bar shows it across its whole length.",
"Offline colour", { 0.62, 0.62, 0.62, 1 }) },
Expand Down
209 changes: 151 additions & 58 deletions tests/fixtures/schema_snapshot.txt

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions tests/proof/units.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ local function WideAuras(ns)
end
end

local function AuraTextAnchors(ns)
ns.Config:SetUnitValue("target", "auras.durationPosition", "BOTTOMRIGHT")
ns.Config:SetUnitValue("target", "auras.countPosition", "TOPLEFT")
for _, kind in ipairs({ "buffs", "debuffs" }) do ns.Config:SetUnitValue("target", "auras." .. kind .. ".size", 30) end
end

return {
{ name = "player", build = UnitFrame("player") },
{ name = "player-idle", build = UnitFrame("player", { showCast = false }) },
Expand All @@ -56,6 +62,7 @@ return {
{ name = "target", build = UnitFrame("target") },
{ name = "target-35pct", build = UnitFrame("target", { health = 8400, showCast = false }) },
{ name = "target-aura-border", build = UnitFrame("target", { showCast = false }, ThickAuraBorder) },
{ name = "target-aura-text-anchors", build = UnitFrame("target", { showCast = false }, AuraTextAnchors) },
{ name = "target-aura-wide", build = UnitFrame("target", { showCast = false }, WideAuras) },
{ name = "targettarget", build = UnitFrame("targettarget") },
{ name = "focus", build = UnitFrame("focus") },
Expand Down
4 changes: 4 additions & 0 deletions tests/spec/auras/aura_bar_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ describe("Cropped aura icon row", function()
Mock.FireEvent("PLAYER_REGEN_ENABLED")
assert.equals(16, Native("buffs").frames[1]:GetHeight())
assert.same({ "TOP", Native("buffs").frames[1], "TOP", 0, -2 }, Native("buffs").frames[1].ufTime:GetAnchor("TOP"))
bar:Apply({ enabled = true, height = 16, durationPosition = "TOPRIGHT", countPosition = "BOTTOMLEFT" })
local native = Native("buffs").frames[1]
assert.same({ "TOPRIGHT", native, "TOPRIGHT", -2, -2 }, native.ufTime:GetAnchor("TOPRIGHT"))
assert.same({ "BOTTOMLEFT", native, "BOTTOMLEFT", 2, 2 }, native.ufCount:GetAnchor("BOTTOMLEFT"))
bar:ShowSample({ buffs = ns.Units.SAMPLE.buffs, debuffs = ns.Units.SAMPLE.debuffs, animateAuras = true })
local sample = Samples("buffs")[1]
assert.is_true(sample.ufEntryAnimation:IsPlaying())
Expand Down
2 changes: 1 addition & 1 deletion tests/spec/units/unit_state_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local Mock = Helpers.Mock

describe("Dead & ghost and offline looks", function()
local ns, frame, uf, element, unitIsDeadOrGhost
local GHOST, STRENGTH = { 0.55, 0.85, 0.94 }, 0.85
local GHOST, STRENGTH = { 0.48, 0.65, 0.70 }, 0.85

before_each(function()
ns = Helpers.LoadAddon(true, true)
Expand Down
17 changes: 14 additions & 3 deletions tests/spec/units/units_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,12 @@ describe("Player buffs and debuffs", function()
ns.Config:SetUnitValue("player", "auras.countSize", 8)
ns.Config:SetUnitValue("player", "auras.font", "Arial Narrow")
ns.Config:SetUnitValue("player", "auras.fontOutline", "THICKOUTLINE")
for _, position in ipairs({ "CENTER", "TOP", "BOTTOM" }) do
local offsets = { CENTER = { 0, 0 }, TOP = { 0, -2 }, BOTTOM = { 0, 2 }, TOPLEFT = { 2, -2 }, RIGHT = { -2, 0 },
BOTTOMRIGHT = { -2, 2 } }
for position, offset in pairs(offsets) do
ns.Config:SetUnitValue("player", "auras.durationPosition", position)
local button = Group("buffs").frames[1]
local y = position == "TOP" and -2 or position == "BOTTOM" and 2 or 0
assert.same({ position, button.ufIconFrame, position, 0, y }, button.ufTime:GetAnchor(position))
assert.same({ position, button.ufIconFrame, position, offset[1], offset[2] }, button.ufTime:GetAnchor(position))
assert.equals(20, button:GetHeight())
assert.equals(20, Group("buffs").layout.elementHeight)
assert.same({ ns.Media:Fetch("font", "Arial Narrow"), 16, "THICKOUTLINE" }, button.ufTime.__state.font)
Expand All @@ -528,6 +529,16 @@ describe("Player buffs and debuffs", function()
assert.is_false(Group("buffs").frames[1].ufTime:IsShown())
end)

it("moves stack text to any inside anchor", function()
local button = Group("buffs").frames[1]
assert.same({ "BOTTOMRIGHT", button.ufIconFrame, "BOTTOMRIGHT", -2, 2 }, button.ufCount:GetAnchor("BOTTOMRIGHT"))
ns.Config:SetUnitValue("player", "auras.countPosition", "TOPLEFT")
assert.same({ "TOPLEFT", button.ufIconFrame, "TOPLEFT", 2, -2 }, button.ufCount:GetAnchor("TOPLEFT"))
assert.is_nil(button.ufCount:GetAnchor("BOTTOMRIGHT"))
ns.Config:SetUnitValue("player", "auras.countPosition", "LEFT")
assert.same({ "LEFT", button.ufIconFrame, "LEFT", 2, 0 }, button.ufCount:GetAnchor("LEFT"))
end)

it("keeps stack text hidden when the engine updates its shown state", function()
ns.Config:SetUnitValue("player", "auras.showCount", false)
local button = Group("buffs").frames[1]
Expand Down
Loading