/trunk/libs
## Title: Lib: QTip-1.0 |
## Notes: Library providing multi-column tooltips. |
## Author: Torhal, Adirelle, Elkano, Tristanian |
## Version: r130-release |
## Version: r135-release |
## LoadOnDemand: 1 |
## X-Date: 2010-02-08T16:37:07Z |
## X-Date: 2010-04-12T12:23:26Z |
## X-Credits: Kaelten (input on initial design) |
## X-Category: Library, Tooltip |
## X-License: Ace3 BSD-like license |
## X-Curse-Packaged-Version: r130-release |
## X-Curse-Packaged-Version: r135-release |
## X-Curse-Project-Name: LibQTip-1.0 |
## X-Curse-Project-ID: libqtip-1-0 |
## X-Curse-Repository-ID: wow/libqtip-1-0/mainline |
local MAJOR = "LibQTip-1.0" |
local MINOR = 31 -- Should be manually increased |
local MINOR = 34 -- Should be manually increased |
assert(LibStub, MAJOR.." requires LibStub") |
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
local AcquireTable, ReleaseTable |
local InitializeTooltip, SetTooltipSize, ResetTooltipSize, LayoutColspans |
local ClearTooltipScripts |
local SetFrameScript, ClearFrameScripts |
------------------------------------------------------------------------------ |
-- Cleans the tooltip and stores it in the cache |
function ReleaseTooltip(tooltip) |
if tooltip.releasing then |
return |
end |
tooltip.releasing = true |
tooltip:Hide() |
if tooltip.OnRelease then |
local success, errorMessage = pcall(tooltip.OnRelease, tooltip) |
if not success then |
geterrorhandler()(errorMessage) |
end |
tooltip.OnRelease = nil |
end |
tooltip.releasing = nil |
tooltip.key = nil |
ClearTooltipScripts(tooltip) |
tooltip:SetAutoHideDelay(nil) |
tooltip:Hide() |
tooltip:ClearAllPoints() |
tooltip:Clear() |
tooltip.slider:Hide() |
tooltip.scrollFrame:SetPoint("RIGHT", tooltip, "RIGHT", -TOOLTIP_PADDING, 0) |
tooltip:EnableMouseWheel(false) |
tooltip:SetScript("OnMouseWheel", nil) |
end |
for i, column in ipairs(tooltip.columns) do |
end |
------------------------------------------------------------------------------ |
-- Convenient methods |
------------------------------------------------------------------------------ |
function tipPrototype:Release() |
lib:Release(self) |
end |
function tipPrototype:IsAcquiredBy(key) |
return key ~= nil and self.key == key |
end |
------------------------------------------------------------------------------ |
-- Script hooks |
------------------------------------------------------------------------------ |
local RawSetScript = lib.frameMetatable.__index.SetScript |
function ClearTooltipScripts(tooltip) |
if tooltip.scripts then |
for scriptType in pairs(tooltip.scripts) do |
RawSetScript(tooltip, scriptType, nil) |
end |
tooltip.scripts = ReleaseTable(tooltip.scripts) |
end |
end |
function tipPrototype:SetScript(scriptType, handler) |
RawSetScript(self, scriptType, handler) |
if handler then |
if not self.scripts then |
self.scripts = AcquireTable() |
end |
self.scripts[scriptType] = true |
elseif self.scripts then |
self.scripts[scriptType] = nil |
end |
end |
-- That might break some addons ; those addons were breaking other |
-- addons' tooltip though. |
function tipPrototype:HookScript() |
geterrorhandler()(":HookScript is not allowed on LibQTip tooltips") |
end |
------------------------------------------------------------------------------ |
-- Scrollbar data and functions |
------------------------------------------------------------------------------ |
local sliderBackdrop = { |