Cooldowns: size the numbers from OnSizeChanged, not timer starts

Buff buttons start their timers before they are sized, so their numbers took
the height-0 font and kept it until a timer restarted.
This commit is contained in:
Brues
2026-11-02 01:18:59 -06:00
parent 23d25c4791
commit 48a2ed36f4
+12 -11
View File
@@ -58,14 +58,17 @@ function pfUI.api.GetCooldownFontSize(height)
return size return size
end end
-- sizes the numbers to the cooldown's parent; the size follows its height, -- sizes the numbers to the height of the frame the cooldown covers
-- so a timer start calls this again whenever that height changed local function UpdateFont(cooldown, height)
local function UpdateFont(cooldown)
local height = (cooldown:GetParent() or cooldown):GetHeight()
cooldown.pfCountdownHeight = height
cooldown:GetCountdownFontString():SetFont(pfUI.media[C.cooldown.font], pfUI.api.GetCooldownFontSize(height), "OUTLINE") cooldown:GetCountdownFontString():SetFont(pfUI.media[C.cooldown.font], pfUI.api.GetCooldownFontSize(height), "OUTLINE")
end end
-- a pfUI cooldown covers its parent, so it resizes with it; a hidden one is
-- laid out, and this runs, as it shows
local function OnSizeChanged(cooldown, width, height)
UpdateFont(cooldown, height)
end
-- applies the settings of its kind to one of pfUI's cooldowns -- applies the settings of its kind to one of pfUI's cooldowns
local function SetupCooldown(cooldown) local function SetupCooldown(cooldown)
local kind = cooldown.pfCooldownKind local kind = cooldown.pfCooldownKind
@@ -78,7 +81,7 @@ local function SetupCooldown(cooldown)
cooldown:SetReverse(config.reverse == "1") cooldown:SetReverse(config.reverse == "1")
cooldown:SetMinimumCountdownDuration(spell[kind] and tonumber(C.cooldown.threshold) * 1000 or 0) cooldown:SetMinimumCountdownDuration(spell[kind] and tonumber(C.cooldown.threshold) * 1000 or 0)
cooldown:SetCountdownFormatter(GetFormatter()) cooldown:SetCountdownFormatter(GetFormatter())
UpdateFont(cooldown) UpdateFont(cooldown, cooldown:GetParent():GetHeight())
end end
-- applies the "foreign" settings to another addon's cooldown. They only take -- applies the "foreign" settings to another addon's cooldown. They only take
@@ -100,18 +103,15 @@ local function SetupForeign(cooldown)
cooldown:SetMinimumCountdownDuration(tonumber(C.cooldown.threshold) * 1000) cooldown:SetMinimumCountdownDuration(tonumber(C.cooldown.threshold) * 1000)
cooldown:SetCountdownFormatter(GetFormatter()) cooldown:SetCountdownFormatter(GetFormatter())
UpdateFont(cooldown) UpdateFont(cooldown, (cooldown:GetParent() or cooldown):GetHeight())
end end
-- runs as a pfUI cooldown's timer starts: a timer with a total brings back -- runs as a pfUI cooldown's timer starts: a timer with a total brings back
-- the sweep a time-left-only one took away, and the font follows a changed -- the sweep a time-left-only one took away
-- height
local function StartTimer(cooldown, timeleftOnly) local function StartTimer(cooldown, timeleftOnly)
if cooldown.pfTimeLeftOnly ~= timeleftOnly then if cooldown.pfTimeLeftOnly ~= timeleftOnly then
cooldown.pfTimeLeftOnly = timeleftOnly cooldown.pfTimeLeftOnly = timeleftOnly
SetupCooldown(cooldown) SetupCooldown(cooldown)
elseif cooldown:GetParent():GetHeight() ~= cooldown.pfCountdownHeight then
UpdateFont(cooldown)
end end
end end
@@ -140,6 +140,7 @@ end)
function pfUI.api.CreateCooldown(parent, kind, name) function pfUI.api.CreateCooldown(parent, kind, name)
local cooldown = CreateFrame("Cooldown", name, parent, "CooldownFrameTemplate") local cooldown = CreateFrame("Cooldown", name, parent, "CooldownFrameTemplate")
cooldown.pfCooldownKind = kind cooldown.pfCooldownKind = kind
cooldown:SetScript("OnSizeChanged", OnSizeChanged)
table.insert(cooldowns, cooldown) table.insert(cooldowns, cooldown)
SetupCooldown(cooldown) SetupCooldown(cooldown)
return cooldown return cooldown