/trunk/Broker_Factions/libs/LibQTip-1.0
local MAJOR = "LibQTip-1.0" |
local MINOR = 28 -- Should be manually increased |
local MINOR = 29 -- Should be manually increased |
assert(LibStub, MAJOR.." requires LibStub") |
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
------------------------------------------------------------------------------ |
-- Cache debugging. |
------------------------------------------------------------------------------ |
--[===[@debug@ |
--@debug@ |
local usedTables, usedFrames, usedTooltips = 0, 0, 0 |
--@end-debug@]===] |
--@end-debug@ |
------------------------------------------------------------------------------ |
-- Internal constants to tweak the layout |
local function AcquireFrame(parent) |
local frame = tremove(frameHeap) or CreateFrame("Frame") |
frame:SetParent(parent) |
--[===[@debug@ |
--@debug@ |
usedFrames = usedFrames + 1 |
--@end-debug@]===] |
--@end-debug@ |
return frame |
end |
frame:SetBackdrop(nil) |
ClearFrameScripts(frame) |
tinsert(frameHeap, frame) |
--[===[@debug@ |
--@debug@ |
usedFrames = usedFrames - 1 |
--@end-debug@]===] |
--@end-debug@ |
end |
------------------------------------------------------------------------------ |
tooltip.scrollChild = scrollChild |
setmetatable(tooltip, tipMetatable) |
end |
--[===[@debug@ |
--@debug@ |
usedTooltips = usedTooltips + 1 |
--@end-debug@]===] |
--@end-debug@ |
return tooltip |
end |
layoutCleaner.registry[tooltip] = nil |
tinsert(tooltipHeap, tooltip) |
--[===[@debug@ |
--@debug@ |
usedTooltips = usedTooltips - 1 |
--@end-debug@]===] |
--@end-debug@ |
end |
------------------------------------------------------------------------------ |
cell:Hide() |
cell:ClearAllPoints() |
cell:SetParent(nil) |
cell:SetBackdrop(nil) |
ClearFrameScripts(cell) |
cell._font, cell._justification, cell._colSpan, cell._line, cell._column = nil |
-- Returns a table |
function AcquireTable() |
local tbl = tremove(tableHeap) or {} |
--[===[@debug@ |
--@debug@ |
usedTables = usedTables + 1 |
--@end-debug@]===] |
--@end-debug@ |
return tbl |
end |
function ReleaseTable(table) |
wipe(table) |
tinsert(tableHeap, table) |
--[===[@debug@ |
--@debug@ |
usedTables = usedTables - 1 |
--@end-debug@]===] |
--@end-debug@ |
end |
------------------------------------------------------------------------------ |
return lineNum, colNum |
end |
function tipPrototype:SetCellColor(lineNum, colNum, r, g, b, a) |
local cell = self.lines[lineNum].cells[colNum] |
if cell then |
local sr, sg, sb, sa = self:GetBackdropColor() |
cell:SetBackdrop(GenericBackdrop) |
cell:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) |
end |
end |
function tipPrototype:SetColumnColor(colNum, r, g, b, a) |
if type(colNum) ~= "number" then |
error("column number must be a number, not: "..tostring(colNum), 2) |
elseif colNum < 1 or colNum > #self.columns then |
error("column number out of range: "..tostring(colNum), 2) |
local column = self.columns[colNum] |
if column then |
local sr, sg, sb, sa = self:GetBackdropColor() |
column:SetBackdrop(GenericBackdrop) |
column:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) |
end |
local column = self.columns[colNum] |
local sr, sg, sb, sa = self:GetBackdropColor() |
column:SetBackdrop(GenericBackdrop) |
column:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) |
end |
function tipPrototype:SetLineColor(lineNum, r, g, b, a) |
if type(lineNum) ~= "number" then |
error("line number must be a number, not: "..tostring(lineNum), 2) |
elseif lineNum < 1 or lineNum > #self.lines then |
error("line number out of range: "..tostring(lineNum), 2) |
local line = self.lines[lineNum] |
if line then |
local sr, sg, sb, sa = self:GetBackdropColor() |
line:SetBackdrop(GenericBackdrop) |
line:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) |
end |
local line = self.lines[lineNum] |
local sr, sg, sb, sa = self:GetBackdropColor() |
line:SetBackdrop(GenericBackdrop) |
line:SetBackdropColor(r or sr, g or sg, b or sb, a or sa) |
end |
-- TODO: fixed argument positions / remove checks for performance? |
------------------------------------------------------------------------------ |
-- Debug slashcmds |
------------------------------------------------------------------------------ |
--[===[@debug@ |
--@debug@ |
local print = print |
local function PrintStats() |
local tipCache = tostring(#tooltipHeap) |
SLASH_LibQTip1 = "/qtip" |
SlashCmdList["LibQTip"] = PrintStats |
--@end-debug@]===] |
--@end-debug@ |