/trunk/libs/LibExtraTip
## Title: LibExtraTip |cff224477(lib) |
## Notes: Assists in the management of additional tooltip information. |
## |
## Interface: 30200 |
## Interface: 30300 |
## LoadOnDemand: 0 |
## |
## Version: 1.1 |
## Revision: $Id: LibExtraTip.toc 223 2009-08-06 15:23:01Z Nechckn $ |
## Revision: $Id: LibExtraTip.toc 229 2009-12-08 21:17:49Z Nechckn $ |
## Author: Norganna's AddOns |
## |
Load.xml |
@version 1.1 |
--]] |
local MAJOR,MINOR,REVISION = "LibExtraTip", 1, "$Revision: 224 $" |
local MAJOR,MINOR,REVISION = "LibExtraTip", 1, "$Revision: 227 $" |
-- A string unique to this version to prevent frame name conflicts. |
local LIBSTRING = MAJOR.."_"..MINOR.."_"..REVISION |
@since 1.0 |
]] |
function lib:RemoveCallback(callback) |
if not (self.callbacks and self.callbacks[callback]) then return end |
if not (callback and self.callbacks) then return end |
if not self.callbacks[callback] then |
-- backward compatibility for old 'function' style AddCallback and RemoveCallback |
for options, priority in pairs(self.callbacks) do |
if options.callback == callback then |
callback = options |
break |
end |
end |
if not self.callbacks[callback] then return end |
end |
self.callbacks[callback] = nil |
for i,c in ipairs(self.sortedCallbacks) do |
if c == callback then |
table.remove(self.sortedCallbacks,i) |
for index,options in ipairs(self.sortedCallbacks) do |
if options == callback then |
table.remove(self.sortedCallbacks, index) |
return true |
end |
end |
o:SetScript(script,self[script]) |
end |
o.left = setmetatable({name = o:GetName().."TextLeft"},line_mt) |
o.right = setmetatable({name = o:GetName().."TextRight"},line_mt) |
o.Left = setmetatable({name = o:GetName().."TextLeft"},line_mt) |
o.Right = setmetatable({name = o:GetName().."TextRight"},line_mt) |
return o |
end |
local changedLines = self.changedLines |
if not changedLines or changedLines < n then |
for i = changedLines or 1,n do |
local left,right = self.left[i],self.right[i] |
local left,right = self.Left[i],self.Right[i] |
local font |
if i == 1 then |
font = GameFontNormal |
-- The right-side text is statically positioned to the right of the left-side text. |
-- As a result, manually changing the width of the tooltip causes the right-side text to not be in the right place. |
local function fixRight(tooltip,lefts,rights) |
local name,rn,ln,left,right |
local getglobal = getglobal |
if not lefts then |
name = tooltip:GetName() |
rn = name .. "TextRight" |
ln = name .. "TextLeft" |
local function fixRight(tooltip, shift) |
local rights, rightname |
rights = tooltip.Right |
if not rights then |
rightname = tooltip:GetName().."TextRight" |
end |
for i=1,tooltip:NumLines() do |
left = nil |
right = nil |
if lefts then left = lefts[i] end |
if rights then right = rights[i] end |
if not left then |
left = getglobal(ln..i) |
for line = 1, tooltip:NumLines() do |
local right |
if rights then |
right = rights[line] |
else |
right = _G[rightname..line] |
end |
if not right then |
right = getglobal(rn..i) |
end |
if right and right:IsVisible() then |
right:ClearAllPoints() |
right:SetPoint("LEFT",left,"RIGHT") |
right:SetPoint("RIGHT",-10,0) |
right:SetJustifyH("RIGHT") |
for index = 1, right:GetNumPoints() do |
local point, relativeTo, relativePoint, xofs, yofs = right:GetPoint(index) |
if xofs then |
right:SetPoint(point, relativeTo, relativePoint, xofs + shift, yofs) |
end |
end |
end |
end |
end |
if d > .005 then |
self.sizing = true |
self:SetWidth(pw) |
fixRight(self,self.left,self.right) |
fixRight(self, d) |
elseif d < -.005 then |
self.sizing = true |
p:SetWidth(w) |
fixRight(p) |
fixRight(p, -d) |
end |
end |