backdrop api: rework every single frame sizing

This commit breaks alot of compatibility and maybe
other things too. The change was necessary, because
the old framework ran up against its limits.
A lot of new configuration options are now possible
and some of them were already added.
This commit is contained in:
shagu
2016-11-22 00:04:14 +01:00
parent 32f3b15990
commit 8891a1df44
28 changed files with 692 additions and 682 deletions
+74 -18
View File
@@ -19,7 +19,6 @@ end
pfUI = CreateFrame("Frame",nil,UIParent)
pfUI:RegisterEvent("ADDON_LOADED")
--pfUI:RegisterEvent("PLAYER_ENTERING_WORLD")
-- initialize default variables
pfUI.cache = {}
@@ -36,15 +35,6 @@ pfLocaleSpellEvents = {}
pfLocaleSpellInterrupts = {}
pfUI:SetScript("OnEvent", function()
pfUI.cache["locale"] = GetLocale()
if pfUI.cache["locale"] ~= "enUS" and
pfUI.cache["locale"] ~= "frFR" and
pfUI.cache["locale"] ~= "deDE" and
pfUI.cache["locale"] ~= "zhCN" and
pfUI.cache["locale"] ~= "ruRU" then
pfUI.cache["locale"] = "enUS"
end
if not pfUI_init then
pfUI_init = {}
end
@@ -55,6 +45,16 @@ pfUI:SetScript("OnEvent", function()
pfUI.environment:UpdateFonts()
pfUI.environment:UpdateColors()
-- fill the cache
pfUI.cache["locale"] = GetLocale()
if pfUI.cache["locale"] ~= "enUS" and
pfUI.cache["locale"] ~= "frFR" and
pfUI.cache["locale"] ~= "deDE" and
pfUI.cache["locale"] ~= "zhCN" and
pfUI.cache["locale"] ~= "ruRU" then
pfUI.cache["locale"] = "enUS"
end
if arg1 == "pfUI" then
for i,m in pairs(this.modules) do
-- do not load disabled modules
@@ -65,6 +65,8 @@ pfUI:SetScript("OnEvent", function()
end
end
end
end)
function pfUI:RegisterModule(n, f)
@@ -73,15 +75,14 @@ function pfUI:RegisterModule(n, f)
end
pfUI.backdrop = {
bgFile = "Interface\\AddOns\\pfUI\\img\\bg", tile = true, tileSize = 8,
bgFile = "Interface\\AddOns\\pfUI\\img\\col", tile = true, tileSize = 8,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border", edgeSize = 8,
insets = {left = 0, right = 0, top = 0, bottom = 0},
insets = {left = -1, right = -1, top = -1, bottom = -1},
}
pfUI.backdrop_col = {
bgFile = "Interface\\AddOns\\pfUI\\img\\bg", tile = true, tileSize = 8,
edgeFile = "Interface\\AddOns\\pfUI\\img\\border_col", edgeSize = 8,
insets = {left = 0, right = 0, top = 0, bottom = 0},
pfUI.backdrop_small = {
bgFile = "Interface\\AddOns\\pfUI\\img\\col", tile = true, tileSize = 8,
insets = {left = -1, right = -1, top = -1, bottom = -1},
}
pfUI.backdrop_underline = {
@@ -111,6 +112,62 @@ function pfUI.utils:UpdateMovable(frame)
end
end
function pfUI.utils:CreateBackdrop(f, inset, legacy, transp)
-- use default inset if nothing is given
local border = inset
if not border then
border = tonumber(pfUI_config.appearance.border.default)
end
-- bg and edge colors
if not pfUI.cache.br then
local br, bg, bb, ba = strsplit(",", pfUI_config.appearance.border.background)
local er, eg, eb, ea = strsplit(",", pfUI_config.appearance.border.color)
pfUI.cache.br, pfUI.cache.bg, pfUI.cache.bb, pfUI.cache.ba = br, bg, bb, ba
pfUI.cache.er, pfUI.cache.eg, pfUI.cache.eb, pfUI.cache.ea = er, eg, eb, ea
end
local br, bg, bb, ba = pfUI.cache.br, pfUI.cache.bg, pfUI.cache.bb, pfUI.cache.ba
local er, eg, eb, ea = pfUI.cache.er, pfUI.cache.eg, pfUI.cache.eb, pfUI.cache.ea
if transp then ba = .8 end
-- use legacy backdrop handling
if legacy then
f:SetBackdrop(pfUI.backdrop)
f:SetBackdropColor(br, bg, bb, ba)
f:SetBackdropBorderColor(er, eg, eb , ea)
return
end
-- use new backdrop behaviour
if not f.backdrop then
f:SetBackdrop(nil)
local border = tonumber(border) - 1
local backdrop = pfUI.backdrop
if border < 1 then backdrop = pfUI.backdrop_small end
local b = CreateFrame("Frame", nil, f)
b:SetPoint("TOPLEFT", f, "TOPLEFT", -border, border)
b:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", border, -border)
local level = f:GetFrameLevel()
if level < 1 then
--f:SetFrameLevel(level + 1)
b:SetFrameLevel(level)
else
b:SetFrameLevel(level - 1)
end
f.backdrop = b
b:SetBackdrop(backdrop)
end
local b = f.backdrop
b:SetBackdropColor(br, bg, bb, ba)
b:SetBackdropBorderColor(er, eg, eb , ea)
end
message = function (msg)
DEFAULT_CHAT_FRAME:AddMessage("|cffcccc33INFO: |cffffff55"..msg)
end
@@ -147,8 +204,7 @@ function pfUI.info:ShowInfoBox(text, time, parent, height)
pfUI.info:SetWidth(pfUI.info.text:GetStringWidth() + 50)
pfUI.info:SetHeight(height)
pfUI.info:SetBackdrop(pfUI.backdrop)
pfUI.info:SetBackdropColor(0,0,0,.75)
pfUI.utils:CreateBackdrop(pfUI.info)
pfUI.info:SetPoint("TOP", 0, -25)
pfUI.info.timeout:ClearAllPoints()