Skip to content

Commit

Permalink
[Bugfix] Fix positioning issues when using scaled Cell
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Sep 10, 2024
1 parent e0bcaa2 commit a7e11b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Core/OnLoad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ local function OnCellInitialUpdateLayout(_layout)
end
end

-- Main Frame
---@class CUFMainFrame: Frame
local CUFMainFrame = CreateFrame("Frame", "CUFMainFrame", UIParent, "SecureFrameTemplate")
CUF.mainFrame = CUFMainFrame
CUFMainFrame:SetIgnoreParentScale(true)
CUF.Util.SetPixelScale(CUFMainFrame)

-- Init Unit Buttons
CUF.uFuncs:InitUnitButtons()
CUF:Fire("UpdateUnitButtons")
Expand Down
2 changes: 1 addition & 1 deletion UnitFrames/UnitButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ local function CreateUnitButton(unit)
local name = CUF.constants.TITLE_CASED_UNITS[unit]

---@class CUFUnitFrame: Frame
local frame = CreateFrame("Frame", "CUF_" .. name .. "_Frame", Cell.frames.mainFrame, "SecureFrameTemplate")
local frame = CreateFrame("Frame", "CUF_" .. name .. "_Frame", CUF.mainFrame, "SecureFrameTemplate")

local button = CreateFrame("Button",
"CUF_" .. name,
Expand Down
15 changes: 15 additions & 0 deletions Util/Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,21 @@ end
-- MARK: Pixel Perfect
-------------------------------------------------

---@return number
function Util.GetPixelScale()
local width, height = GetPhysicalScreenSize()
if height then
return 768 / height
else
return 1
end
end

---@param frame Frame
function Util.SetPixelScale(frame)
frame:SetScale(Util.GetPixelScale())
end

--- Calculates the nearest pixel size of a number
---@param number number
---@return number
Expand Down

0 comments on commit a7e11b3

Please sign in to comment.