Text is offset from frame.
Timour-Khan opened this issue ยท 0 comments
Not exactly sure why but some lua texts seems to randomly get slightly tilted left or right.
Not super proficient in lua but I would imagine we need to reparse the width of the frame or something ?
--- Return an estimated half-width of elements in a given location on a frame.
-- @param frame a unit frame
-- @param indicators_and_texts a list of element ids to estimate the width of.
-- @return the estimated number of pixels that make up half the width.
-- @Usage local width = get_half_width(frame, { "CombatText", "HappinessIcon" })
local function get_half_width(frame, indicators_and_texts)
local num = 0local layout = frame.layout
local layout_db = frame.layout_dbfor _, id in ipairs(indicators_and_texts) do
local element = frame[id]
local element_db = get_element_db(id, layout)
local scale = scale_cache[element]
if element.SetJustifyH then
-- a text
num = num + scale * ASSUMED_TEXT_WIDTH * (element_db and element_db.size or 1)
else
-- an indicator
num = num + scale * (element_db and element_db.size or 1) * layout_db.indicator_size * element:GetWidth() / element:GetHeight() * (element.height or 1)
end
endnum = num + (#indicators_and_texts - 1) * layout_db.indicator_spacing
return num / 2
end
Let me know if you have any more question about this :)
Cheers for the addon, it's great!