WoWInterface SVN NeedyGreedy

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 132 to Rev 133
    Reverse comparison

Rev 132 → Rev 133

libs/LibQTip-1.0/LibQTip-1.0.lua
1,5 → 1,5
local MAJOR = "LibQTip-1.0"
local MINOR = 36 -- Should be manually increased
local MINOR = 38 -- Should be manually increased
assert(LibStub, MAJOR.." requires LibStub")
 
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
8,6 → 8,8
------------------------------------------------------------------------------
-- Upvalued globals
------------------------------------------------------------------------------
local _G = getfenv(0)
 
local type = type
local select = select
local error = error
247,9 → 249,11
 
function labelPrototype:SetupCell(tooltip, value, justification, font, l_pad, r_pad, max_width, min_width, ...)
local fs = self.fontString
local line = tooltip.lines[self._line]
 
-- detatch fs from cell for size calculations
fs:ClearAllPoints()
fs:SetFontObject(font or tooltip:GetFont())
fs:SetFontObject(font or (line.is_header and tooltip:GetHeaderFont() or tooltip:GetFont()))
fs:SetJustifyH(justification)
fs:SetText(tostring(value))
 
348,6 → 352,7
 
tooltip.releasing = nil
tooltip.key = nil
tooltip.step = nil
 
ClearTooltipScripts(tooltip)
 
396,8 → 401,13
cell:SetParent(nil)
cell:SetBackdrop(nil)
ClearFrameScripts(cell)
cell._font, cell._justification, cell._colSpan, cell._line, cell._column = nil
 
cell._font = nil
cell._justification = nil
cell._colSpan = nil
cell._line = nil
cell._column = nil
 
cell._provider:ReleaseCell(cell)
cell._provider = nil
end
600,14 → 610,20
local slider = self.slider
local currentValue = slider:GetValue()
local minValue, maxValue = slider:GetMinMaxValues()
local stepValue = self.step or 10
 
if delta < 0 and currentValue < maxValue then
slider:SetValue(min(maxValue, currentValue + 10))
slider:SetValue(min(maxValue, currentValue + stepValue))
elseif delta > 0 and currentValue > minValue then
slider:SetValue(max(minValue, currentValue - 10))
slider:SetValue(max(minValue, currentValue - stepValue))
end
end
 
-- Set the step size for the scroll bar
function tipPrototype:SetScrollStep(step)
self.step = step
end
 
-- will resize the tooltip to fit the screen and show a scrollbar if needed
function tipPrototype:UpdateScrolling(maxheight)
self:SetClampedToScreen(false)
620,7 → 636,7
local topside = self:GetTop()
local bottomside = self:GetBottom()
local screensize = UIParent:GetHeight() / scale
local tipsize = (topside - bottomside) / scale
local tipsize = (topside - bottomside)
 
-- if the tooltip would be too high, limit its height and show the slider
if bottomside < 0 or topside > screensize or (maxheight and tipsize > maxheight) then
680,6 → 696,7
end
ReleaseTable(line.cells)
line.cells = nil
line.is_header = nil
ReleaseFrame(line)
self.lines[i] = nil
end
716,30 → 733,6
self.cell_margin_v = size
end
 
local function checkFont(font, level, silent)
if not font or type(font) ~= 'table' or type(font.IsObjectType) ~= 'function' or not font:IsObjectType("Font") then
if silent then
return false
end
error("font must be Font instance, not: "..tostring(font), level + 1)
end
return true
end
 
function tipPrototype:SetFont(font)
checkFont(font, 2)
self.regularFont = font
end
 
function tipPrototype:GetFont() return self.regularFont end
 
function tipPrototype:SetHeaderFont(font)
checkFont(font, 2)
self.headerFont = font
end
 
function tipPrototype:GetHeaderFont() return self.headerFont end
 
function SetTooltipSize(tooltip, width, height)
tooltip:SetHeight(2 * TOOLTIP_PADDING + height)
tooltip.scrollChild:SetHeight(height)
843,6 → 836,7
end
return lineNum, colNum
end
font = font or (line.is_header and tooltip.headerFont or tooltip.regularFont)
 
-- Check previous cell
local cell
850,7 → 844,6
 
if prevCell then
-- There is a cell here
font = font or prevCell._font
justification = justification or prevCell._justification
colSpan = colSpan or prevCell._colSpan
 
870,7 → 863,6
elseif prevCell == nil then
-- Creating a new cell, using meaningful defaults.
provider = provider or tooltip.labelProvider
font = font or tooltip.regularFont
justification = justification or tooltip.columns[colNum].justification or "LEFT"
colSpan = colSpan or 1
else
950,51 → 942,56
end
end
 
local function CreateLine(tooltip, font, ...)
if #tooltip.columns == 0 then
error("column layout should be defined before adding line", 3)
end
local lineNum = #tooltip.lines + 1
local line = tooltip.lines[lineNum] or AcquireFrame(tooltip.scrollChild)
do
local function CreateLine(tooltip, font, ...)
if #tooltip.columns == 0 then
error("column layout should be defined before adding line", 3)
end
local lineNum = #tooltip.lines + 1
local line = tooltip.lines[lineNum] or AcquireFrame(tooltip.scrollChild)
 
line:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 2)
line:SetPoint('LEFT', tooltip.scrollChild)
line:SetPoint('RIGHT', tooltip.scrollChild)
line:SetFrameLevel(tooltip.scrollChild:GetFrameLevel() + 2)
line:SetPoint('LEFT', tooltip.scrollChild)
line:SetPoint('RIGHT', tooltip.scrollChild)
 
if lineNum > 1 then
local v_margin = tooltip.cell_margin_v or CELL_MARGIN_V
if lineNum > 1 then
local v_margin = tooltip.cell_margin_v or CELL_MARGIN_V
 
line:SetPoint('TOP', tooltip.lines[lineNum-1], 'BOTTOM', 0, -v_margin)
SetTooltipSize(tooltip, tooltip.width, tooltip.height + v_margin)
else
line:SetPoint('TOP', tooltip.scrollChild)
end
tooltip.lines[lineNum] = line
line.cells = line.cells or AcquireTable()
line.height = 0
line:SetHeight(1)
line:Show()
line:SetPoint('TOP', tooltip.lines[lineNum-1], 'BOTTOM', 0, -v_margin)
SetTooltipSize(tooltip, tooltip.width, tooltip.height + v_margin)
else
line:SetPoint('TOP', tooltip.scrollChild)
end
tooltip.lines[lineNum] = line
line.cells = line.cells or AcquireTable()
line.height = 0
line:SetHeight(1)
line:Show()
 
local colNum = 1
local colNum = 1
 
for i = 1, #tooltip.columns do
local value = select(i, ...)
for i = 1, #tooltip.columns do
local value = select(i, ...)
 
if value ~= nil then
lineNum, colNum = _SetCell(tooltip, lineNum, i, value, font, nil, 1, tooltip.labelProvider)
if value ~= nil then
lineNum, colNum = _SetCell(tooltip, lineNum, i, value, font, nil, 1, tooltip.labelProvider)
end
end
return lineNum, colNum
end
return lineNum, colNum
end
 
function tipPrototype:AddLine(...)
return CreateLine(self, self.regularFont, ...)
end
function tipPrototype:AddLine(...)
return CreateLine(self, self.regularFont, ...)
end
 
function tipPrototype:AddHeader(...)
return CreateLine(self, self.headerFont, ...)
end
function tipPrototype:AddHeader(...)
local line, col = CreateLine(self, self.headerFont, ...)
 
self.lines[line].is_header = true
return line, col
end
end -- do-block
 
local GenericBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
}
1043,42 → 1040,90
end
end
 
-- TODO: fixed argument positions / remove checks for performance?
function tipPrototype:SetCell(lineNum, colNum, value, ...)
-- Mandatory argument checking
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)
elseif 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)
end
do
local function checkFont(font, level, silent)
local bad = false
 
-- Variable argument checking
local font, justification, colSpan, provider
local i, arg = 1, ...
if not font then
bad = true
elseif type(font) == "string" then
local ref = _G[font]
 
if arg == nil or checkFont(arg, 2, true) then
i, font, arg = 2, ...
if not ref or type(ref) ~= 'table' or type(ref.IsObjectType) ~= 'function' or not ref:IsObjectType("Font") then
bad = true
end
elseif type(font) ~= 'table' or type(font.IsObjectType) ~= 'function' or not font:IsObjectType("Font") then
bad = true
end
 
if bad then
if silent then
return false
end
error("font must be a Font instance or a string matching the name of a global Font instance, not: "..tostring(font), level + 1)
end
return true
end
 
if arg == nil or checkJustification(arg, 2, true) then
i, justification, arg = i + 1, select(i, ...)
function tipPrototype:SetFont(font)
local is_string = type(font) == "string"
 
checkFont(font, 2)
self.regularFont = is_string and _G[font] or font
end
 
if arg == nil or type(arg) == 'number' then
i, colSpan, arg = i + 1, select(i, ...)
function tipPrototype:SetHeaderFont(font)
local is_string = type(font) == "string"
 
checkFont(font, 2)
self.headerFont = is_string and _G[font] or font
end
 
if arg == nil or type(arg) == 'table' and type(arg.AcquireCell) == 'function' then
i, provider = i + 1, arg
-- TODO: fixed argument positions / remove checks for performance?
function tipPrototype:SetCell(lineNum, colNum, value, ...)
-- Mandatory argument checking
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)
elseif 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)
end
 
-- Variable argument checking
local font, justification, colSpan, provider
local i, arg = 1, ...
 
if arg == nil or checkFont(arg, 2, true) then
i, font, arg = 2, ...
end
 
if arg == nil or checkJustification(arg, 2, true) then
i, justification, arg = i + 1, select(i, ...)
end
 
if arg == nil or type(arg) == 'number' then
i, colSpan, arg = i + 1, select(i, ...)
end
 
if arg == nil or type(arg) == 'table' and type(arg.AcquireCell) == 'function' then
i, provider = i + 1, arg
end
 
return _SetCell(self, lineNum, colNum, value, font, justification, colSpan, provider, select(i, ...))
end
end -- do-block
 
return _SetCell(self, lineNum, colNum, value, font, justification, colSpan, provider, select(i, ...))
function tipPrototype:GetFont()
return self.regularFont
end
 
function tipPrototype:GetHeaderFont()
return self.headerFont
end
 
function tipPrototype:GetLineCount() return #self.lines end
 
function tipPrototype:GetColumnCount() return #self.columns end
1119,6 → 1164,9
OnMouseUp = function(frame, ...)
frame:_OnMouseUp_func(frame._OnMouseUp_arg, ...)
end,
OnReceiveDrag = function(frame, ...)
frame:_OnReceiveDrag_func(frame._OnReceiveDrag_arg, ...)
end,
}
 
function SetFrameScript(frame, script, func, arg)
1128,7 → 1176,7
frame["_"..script.."_func"] = func
frame["_"..script.."_arg"] = arg
 
if script == "OnMouseDown" or script == "OnMouseUp" then
if script == "OnMouseDown" or script == "OnMouseUp" or script == "OnReceiveDrag" then
if func then
frame:SetScript(script, scripts[script])
else
1137,7 → 1185,7
end
 
-- if at least one script is set, set the OnEnter/OnLeave scripts for the highlight
if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func then
if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then
frame:EnableMouse(true)
frame:SetScript("OnEnter", scripts.OnEnter)
frame:SetScript("OnLeave", scripts.OnLeave)
1149,7 → 1197,7
end
 
function ClearFrameScripts(frame)
if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func then
if frame._OnEnter_func or frame._OnLeave_func or frame._OnMouseDown_func or frame._OnMouseUp_func or frame._OnReceiveDrag_func then
frame:EnableMouse(false)
frame:SetScript("OnEnter", nil)
frame._OnEnter_func = nil
1157,6 → 1205,9
frame:SetScript("OnLeave", nil)
frame._OnLeave_func = nil
frame._OnLeave_arg = nil
frame:SetScript("OnReceiveDrag", nil)
frame._OnReceiveDrag_func = nil
frame._OnReceiveDrag_arg = nil
frame:SetScript("OnMouseDown", nil)
frame._OnMouseDown_func = nil
frame._OnMouseDown_arg = nil
libs/LibQTip-1.0/LibQTip-1.0.toc
1,14 → 1,14
## Interface: 30300
## Interface: 40000
## Title: Lib: QTip-1.0
## Notes: Library providing multi-column tooltips.
## Author: Torhal, Adirelle, Elkano, Tristanian
## Version: r139-release
## Version: r150-release
## LoadOnDemand: 1
## X-Date: 2010-08-03T20:56:32Z
## X-Date: 2010-11-28T09:11:14Z
## X-Credits: Kaelten (input on initial design)
## X-Category: Library, Tooltip
## X-License: Ace3 BSD-like license
## X-Curse-Packaged-Version: r139-release
## X-Curse-Packaged-Version: r150-release
## X-Curse-Project-Name: LibQTip-1.0
## X-Curse-Project-ID: libqtip-1-0
## X-Curse-Repository-ID: wow/libqtip-1-0/mainline