mirror of
https://github.com/Bluewhale1337/ElvUIModernized.git
synced 2026-07-27 08:24:44 +00:00
Ace3 backport
This commit is contained in:
@@ -8,6 +8,8 @@ if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
||||
|
||||
-- Lua APIs
|
||||
local pairs, ipairs, assert, type, wipe = pairs, ipairs, assert, type, wipe
|
||||
local format = string.format
|
||||
local getn = table.getn
|
||||
|
||||
-- WoW APIs
|
||||
local PlaySound = PlaySound
|
||||
@@ -52,34 +54,34 @@ local function Tab_SetDisabled(frame, disabled)
|
||||
UpdateTabLook(frame)
|
||||
end
|
||||
|
||||
local function BuildTabsOnUpdate(frame)
|
||||
local self = frame.obj
|
||||
local function BuildTabsOnUpdate()
|
||||
local self = this.obj
|
||||
self:BuildTabs()
|
||||
frame:SetScript("OnUpdate", nil)
|
||||
this:SetScript("OnUpdate", nil)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
Scripts
|
||||
-------------------------------------------------------------------------------]]
|
||||
local function Tab_OnClick(frame)
|
||||
if not (frame.selected or frame.disabled) then
|
||||
local function Tab_OnClick()
|
||||
if not (this.selected or this.disabled) then
|
||||
PlaySound("igCharacterInfoTab")
|
||||
frame.obj:SelectTab(frame.value)
|
||||
this.obj:SelectTab(this.value)
|
||||
end
|
||||
end
|
||||
|
||||
local function Tab_OnEnter(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnTabEnter", self.tabs[frame.id].value, frame)
|
||||
local function Tab_OnEnter()
|
||||
local self = this.obj
|
||||
self:Fire("OnTabEnter", self.tabs[this.id].value, this)
|
||||
end
|
||||
|
||||
local function Tab_OnLeave(frame)
|
||||
local self = frame.obj
|
||||
self:Fire("OnTabLeave", self.tabs[frame.id].value, frame)
|
||||
local function Tab_OnLeave()
|
||||
local self = this.obj
|
||||
self:Fire("OnTabLeave", self.tabs[this.id].value, this)
|
||||
end
|
||||
|
||||
local function Tab_OnShow(frame)
|
||||
_G[frame:GetName().."HighlightTexture"]:SetWidth(frame:GetTextWidth() + 30)
|
||||
local function Tab_OnShow()
|
||||
_G[this:GetName().."HighlightTexture"]:SetWidth(this:GetTextWidth() + 30)
|
||||
end
|
||||
|
||||
--[[-----------------------------------------------------------------------------
|
||||
@@ -102,10 +104,32 @@ local methods = {
|
||||
end,
|
||||
|
||||
["CreateTab"] = function(self, id)
|
||||
local tabname = ("AceGUITabGroup%dTab%d"):format(self.num, id)
|
||||
local tab = CreateFrame("Button", tabname, self.border, "OptionsFrameTabButtonTemplate")
|
||||
local tabname = format("AceGUITabGroup%dTab%d", self.num, id)
|
||||
local tab = CreateFrame("Button", tabname, self.border, "TabButtonTemplate")
|
||||
tab.obj = self
|
||||
tab.id = id
|
||||
tab:SetHeight(24)
|
||||
|
||||
-- Normal texture
|
||||
local texture = _G[tabname.."Left"]
|
||||
texture:ClearAllPoints()
|
||||
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
|
||||
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
|
||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
||||
texture = _G[tabname.."Middle"]
|
||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
||||
texture = _G[tabname.."Right"]
|
||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
||||
-- Disabled texture
|
||||
texture = _G[tabname.."LeftDisabled"]
|
||||
texture:ClearAllPoints()
|
||||
texture:SetPoint("BOTTOMLEFT", tab,"BOTTOMLEFT")
|
||||
texture:SetPoint("TOPLEFT", tab,"TOPLEFT")
|
||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
||||
texture = _G[tabname.."MiddleDisabled"]
|
||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
||||
texture = _G[tabname.."RightDisabled"]
|
||||
texture:SetTexture("Interface\\ChatFrame\\ChatFrameTab")
|
||||
|
||||
tab.text = _G[tabname .. "Text"]
|
||||
tab.text:ClearAllPoints()
|
||||
@@ -186,23 +210,28 @@ local methods = {
|
||||
end
|
||||
|
||||
tab:Show()
|
||||
tab:SetText(v.text)
|
||||
tab:SetDisabled(v.disabled)
|
||||
tab.value = v.value
|
||||
if type(v) == "table" then
|
||||
tab:SetText(v.text)
|
||||
tab:SetDisabled(v.disabled)
|
||||
tab.value = v.value
|
||||
elseif type(v) == "string" then
|
||||
tab:SetText(v)
|
||||
tab.value = v
|
||||
end
|
||||
|
||||
widths[i] = tab:GetWidth() - 6 --tabs are anchored 10 pixels from the right side of the previous one to reduce spacing, but add a fixed 4px padding for the text
|
||||
end
|
||||
|
||||
for i = (#tablist)+1, #tabs, 1 do
|
||||
for i = getn(tablist)+1, getn(tabs), 1 do
|
||||
tabs[i]:Hide()
|
||||
end
|
||||
|
||||
--First pass, find the minimum number of rows needed to hold all tabs and the initial tab layout
|
||||
local numtabs = #tablist
|
||||
local numtabs = getn(tablist)
|
||||
local numrows = 1
|
||||
local usedwidth = 0
|
||||
|
||||
for i = 1, #tablist do
|
||||
for i = 1, numtabs do
|
||||
--If this is not the first tab of a row and there isn't room for it
|
||||
if usedwidth ~= 0 and (width - usedwidth - widths[i]) < 0 then
|
||||
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
|
||||
@@ -213,7 +242,7 @@ local methods = {
|
||||
usedwidth = usedwidth + widths[i]
|
||||
end
|
||||
rowwidths[numrows] = usedwidth + 10 --first tab in each row takes up an extra 10px
|
||||
rowends[numrows] = #tablist
|
||||
rowends[numrows] = numtabs
|
||||
|
||||
--Fix for single tabs being left on the last row, move a tab from the row above if applicable
|
||||
if numrows > 1 then
|
||||
|
||||
Reference in New Issue
Block a user