Verified Commit b3c93407 authored by Repooc's avatar Repooc
Browse files

update libqtip

parent 3430f6f9
......@@ -37,7 +37,7 @@ local geterrorhandler = _G.geterrorhandler
------------------------------------------------------------------------------
-- Tables and locals
------------------------------------------------------------------------------
lib.frameMetatable = lib.frameMetatable or {__index = CreateFrame("Frame")}
lib.frameMetatable = lib.frameMetatable or {__index = CreateFrame("Frame", nil, nil, BackdropTemplateMixin and "BackdropTemplate")}
lib.tipPrototype = lib.tipPrototype or setmetatable({}, lib.frameMetatable)
lib.tipMetatable = lib.tipMetatable or {__index = lib.tipPrototype}
......@@ -52,6 +52,7 @@ lib.activeTooltips = lib.activeTooltips or {}
lib.tooltipHeap = lib.tooltipHeap or {}
lib.frameHeap = lib.frameHeap or {}
lib.timerHeap = lib.timerHeap or {}
lib.tableHeap = lib.tableHeap or {}
lib.onReleaseHandlers = lib.onReleaseHandlers or {}
......@@ -163,16 +164,16 @@ function lib:IterateTooltips()
end
------------------------------------------------------------------------------
-- Frame cache
-- Frame cache (for lines and columns)
------------------------------------------------------------------------------
local frameHeap = lib.frameHeap
local function AcquireFrame(parent)
local frame = tremove(frameHeap) or CreateFrame("Frame", nil, nil, "BackdropTemplate")
local frame = tremove(frameHeap) or CreateFrame("Frame", nil, nil, BackdropTemplateMixin and "BackdropTemplate")
frame:SetParent(parent)
--[===[@debug@
--@debug@
usedFrames = usedFrames + 1
--@end-debug@]===]
--@end-debug@
return frame
end
......@@ -185,9 +186,29 @@ local function ReleaseFrame(frame)
ClearFrameScripts(frame)
tinsert(frameHeap, frame)
--[===[@debug@
--@debug@
usedFrames = usedFrames - 1
--@end-debug@]===]
--@end-debug@
end
------------------------------------------------------------------------------
-- Timer cache
------------------------------------------------------------------------------
local timerHeap = lib.timerHeap
local function AcquireTimer(parent)
local frame = tremove(timerHeap) or CreateFrame("Frame")
frame:SetParent(parent)
return frame
end
local function ReleaseTimer(frame)
frame:Hide()
frame:SetParent(nil)
ClearFrameScripts(frame)
tinsert(timerHeap, frame)
end
------------------------------------------------------------------------------
......@@ -222,7 +243,7 @@ function providerPrototype:AcquireCell()
local cell = tremove(self.heap)
if not cell then
cell = setmetatable(CreateFrame("Frame", nil, UIParent, "BackdropTemplate"), self.cellMetatable)
cell = setmetatable(CreateFrame("Frame", nil, UIParent), self.cellMetatable)
if type(cell.InitializeCell) == "function" then
cell:InitializeCell()
......@@ -361,7 +382,7 @@ function AcquireTooltip()
local tooltip = tremove(tooltipHeap)
if not tooltip then
tooltip = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
tooltip = CreateFrame("Frame", nil, UIParent)
local scrollFrame = CreateFrame("ScrollFrame", nil, tooltip)
scrollFrame:SetPoint("TOP", tooltip, "TOP", 0, -TOOLTIP_PADDING)
......@@ -377,9 +398,9 @@ function AcquireTooltip()
setmetatable(tooltip, tipMetatable)
end
--[===[@debug@
--@debug@
usedTooltips = usedTooltips + 1
--@end-debug@]===]
--@end-debug@
return tooltip
end
......@@ -442,9 +463,9 @@ function ReleaseTooltip(tooltip)
highlightTexture:SetTexture(DEFAULT_HIGHLIGHT_TEXTURE_PATH)
highlightTexture:SetTexCoord(0, 1, 0, 1)
--[===[@debug@
--@debug@
usedTooltips = usedTooltips - 1
--@end-debug@]===]
--@end-debug@
end
------------------------------------------------------------------------------
......@@ -492,9 +513,9 @@ local tableHeap = lib.tableHeap
-- Returns a table
function AcquireTable()
local tbl = tremove(tableHeap) or {}
--[===[@debug@
--@debug@
usedTables = usedTables + 1
--@end-debug@]===]
--@end-debug@
return tbl
end
......@@ -502,9 +523,9 @@ end
function ReleaseTable(tableInstance)
wipe(tableInstance)
tinsert(tableHeap, tableInstance)
--[===[@debug@
--@debug@
usedTables = usedTables - 1
--@end-debug@]===]
--@end-debug@
end
------------------------------------------------------------------------------
......@@ -669,19 +690,15 @@ end
------------------------------------------------------------------------------
-- Scrollbar data and functions
------------------------------------------------------------------------------
local sliderBackdrop = {
bgFile = [[Interface\Buttons\UI-SliderBar-Background]],
edgeFile = [[Interface\Buttons\UI-SliderBar-Border]],
local BACKDROP_SLIDER_8_8 = {
bgFile = "Interface\\Buttons\\UI-SliderBar-Background",
edgeFile = "Interface\\Buttons\\UI-SliderBar-Border",
tile = true,
edgeSize = 8,
tileEdge = true,
tileSize = 8,
insets = {
left = 3,
right = 3,
top = 3,
bottom = 3
}
}
edgeSize = 8,
insets = { left = 3, right = 3, top = 6, bottom = 6 },
};
local function slider_OnValueChanged(self)
self.scrollFrame:SetVerticalScroll(self:GetValue())
......@@ -732,13 +749,13 @@ function tipPrototype:UpdateScrolling(maxheight)
self.scrollFrame:SetPoint("RIGHT", self, "RIGHT", -(TOOLTIP_PADDING + 20), 0)
if not self.slider then
local slider = CreateFrame("Slider", nil, self)
local slider = CreateFrame("Slider", nil, self, BackdropTemplateMixin and "BackdropTemplate")
slider.scrollFrame = self.scrollFrame
slider:SetOrientation("VERTICAL")
slider:SetPoint("TOPRIGHT", self, "TOPRIGHT", -TOOLTIP_PADDING, -TOOLTIP_PADDING)
slider:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -TOOLTIP_PADDING, TOOLTIP_PADDING)
slider:SetBackdrop(sliderBackdrop)
slider:SetBackdrop(BACKDROP_SLIDER_8_8)
slider:SetThumbTexture([[Interface\Buttons\UI-SliderBar-Button-Vertical]])
slider:SetMinMaxValues(0, 1)
slider:SetValueStep(1)
......@@ -1452,7 +1469,7 @@ function tipPrototype:SetAutoHideDelay(delay, alternateFrame, releaseHandler)
if delay > 0 then
if not timerFrame then
timerFrame = AcquireFrame(self)
timerFrame = AcquireTimer(self)
timerFrame:SetScript("OnUpdate", AutoHideTimerFrame_OnUpdate)
self.autoHideTimerFrame = timerFrame
......@@ -1470,7 +1487,7 @@ function tipPrototype:SetAutoHideDelay(delay, alternateFrame, releaseHandler)
timerFrame.alternateFrame = nil
timerFrame:SetScript("OnUpdate", nil)
ReleaseFrame(timerFrame)
ReleaseTimer(timerFrame)
end
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment