Skip to content

Commit

Permalink
Text RegionType: Fix size calculation on scaled regions
Browse files Browse the repository at this point in the history
Somehow in the linked bug report, the aura is attached to an nameplate
with an very small scale factor. This makes the text aura set the region
width to an excessive number, which with the left aligned text looks
like a offset to the left.

Fixes: #5230
  • Loading branch information
InfusOnWoW committed Jul 23, 2024
1 parent 8de72dd commit 001969d
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions WeakAuras/RegionTypes/Text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,22 @@ local function modify(parent, region, data)
if text:GetFont() then
text:SetText(WeakAuras.ReplaceRaidMarkerSymbols(textStr));
end
end
local width = text:GetWidth();
local height = text:GetStringHeight();
if(width ~= region.width or height ~= region.height ) then
region.width = width;
region.height = height;
region:SetWidth(region.width);
region:SetHeight(region.height);
if(data.parent and Private.regions[data.parent].region.PositionChildren) then
Private.regions[data.parent].region:PositionChildren();
-- If the text changes we need to figure out the text size
-- To unset scaling we need to temporarily detach the text from
-- the region
text:SetParent(UIParent)
local width = text:GetWidth();
local height = text:GetStringHeight();
if(width ~= region.width or height ~= region.height ) then
region.width = width
region.height = height
region:SetWidth(region.width);
region:SetHeight(region.height);
if(data.parent and Private.regions[data.parent].region.PositionChildren) then
Private.regions[data.parent].region:PositionChildren();
end
end
text:SetParent(region)
end
end
end
Expand Down

0 comments on commit 001969d

Please sign in to comment.