/trunk
return self:GetWidth(), self:GetHeight() |
end |
function ItemCell_Prototype:getContentHeight() |
return 30 |
end |
-- Create functions locally to reduce garbage collection |
local function Detached_OnMouseDown() |
NeedyGreedy.detachedTooltip:StartMoving() |
-- Unit tests |
--[[ |
function NeedyGreedy:SetItems(itemList) |
items = itemList |
self:UpdateReport() |
local MAJOR = "LibQTip-1.0" |
local MINOR = 34 -- Should be manually increased |
local MINOR = 36 -- Should be manually increased |
assert(LibStub, MAJOR.." requires LibStub") |
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) |
local AcquireCell, ReleaseCell |
local AcquireTable, ReleaseTable |
local InitializeTooltip, SetTooltipSize, ResetTooltipSize, LayoutColspans |
local InitializeTooltip, SetTooltipSize, ResetTooltipSize, FixCellSizes |
local ClearTooltipScripts |
local SetFrameScript, ClearFrameScripts |
function layoutCleaner:CleanupLayouts() |
self:Hide() |
for tooltip in pairs(self.registry) do |
LayoutColspans(tooltip) |
FixCellSizes(tooltip) |
end |
wipe(self.registry) |
end |
function labelPrototype:SetupCell(tooltip, value, justification, font, l_pad, r_pad, max_width, min_width, ...) |
local fs = self.fontString |
-- detatch fs from cell for size calculations |
fs:ClearAllPoints() |
fs:SetFontObject(font or tooltip:GetFont()) |
fs:SetJustifyH(justification) |
fs:SetText(tostring(value)) |
local width = fs:GetStringWidth() + l_pad + r_pad |
fs:SetPoint("TOPLEFT", self, "TOPLEFT", l_pad, 0) |
fs:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -r_pad, 0) |
if max_width and min_width and (max_width < min_width) then |
error("maximum width cannot be lower than minimum width: "..tostring(max_width).." < "..tostring(min_width), 2) |
end |
if max_width and (max_width < (l_pad + r_pad)) then |
error("maximum width cannot be lower than the sum of paddings: "..tostring(max_width).." < "..tostring(l_pad).." + "..tostring(r_pad), 2) |
end |
if min_width and width < min_width then |
width = min_width |
end |
if max_width and max_width < width then |
width = max_width |
end |
fs:SetWidth(width) |
fs:Show() |
fs:SetWidth(width - (l_pad + r_pad)) |
-- Use GetHeight() instead of GetStringHeight() so lines which are longer than width will wrap. |
local height = fs:GetHeight() |
-- Use GetHeight() instead of GetStringHeight() so lines which are longer than width will wrap. |
return width, fs:GetHeight() |
-- reanchor fs to cell |
fs:SetWidth(0) |
fs:SetPoint("TOPLEFT", self, "TOPLEFT", l_pad, 0) |
fs:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", -r_pad, 0) |
--~ fs:SetPoint("TOPRIGHT", self, "TOPRIGHT", -r_pad, 0) |
self._paddingL = l_pad |
self._paddingR = r_pad |
return width, height |
end |
function labelPrototype:getContentHeight() |
local fs = self.fontString |
fs:SetWidth(self:GetWidth() - (self._paddingL + self._paddingR)) |
local height = self.fontString:GetHeight() |
fs:SetWidth(0) |
return height |
end |
function labelPrototype:GetPosition() return self._line, self._column end |
------------------------------------------------------------------------------ |
---------------------------------------------------------------------- |
-- (Re)set frame settings |
---------------------------------------------------------------------- |
tooltip:SetBackdrop(GameTooltip:GetBackdrop()) |
tooltip:SetBackdropColor(GameTooltip:GetBackdropColor()) |
tooltip:SetBackdropBorderColor(GameTooltip:GetBackdropBorderColor()) |
local backdrop = GameTooltip:GetBackdrop() |
tooltip:SetBackdrop(backdrop) |
if backdrop then |
tooltip:SetBackdropColor(GameTooltip:GetBackdropColor()) |
tooltip:SetBackdropBorderColor(GameTooltip:GetBackdropBorderColor()) |
end |
tooltip:SetScale(GameTooltip:GetScale()) |
tooltip:SetAlpha(1) |
tooltip:SetFrameStrata("TOOLTIP") |
self:SetClampedToScreen(false) |
-- all data is in the tooltip; fix colspan width and prevent the layout cleaner from messing up the tooltip later |
LayoutColspans(self) |
FixCellSizes(self) |
layoutCleaner.registry[self] = nil |
local scale = self:GetScale() |
end |
end |
function LayoutColspans(tooltip) |
local function ResizeLine(tooltip, line, height) |
SetTooltipSize(tooltip, tooltip.width, tooltip.height + height - line.height) |
line.height = height |
line:SetHeight(height) |
end |
function FixCellSizes(tooltip) |
local columns = tooltip.columns |
local colspans = tooltip.colspans |
local lines = tooltip.lines |
for colRange, width in pairs(tooltip.colspans) do |
local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H |
local left, right = colRange:match("^(%d+)%-(%d+)$") |
left, right = tonumber(left), tonumber(right) |
for col = left, right-1 do |
width = width - columns[col].width - h_margin |
-- resize columns to make room for the colspans |
local h_margin = tooltip.cell_margin_h or CELL_MARGIN_H |
while next(colspans) do |
local maxNeedCols = nil |
local maxNeedWidthPerCol = 0 |
-- calculate the colspan with the highest additional width need per column |
for colRange, width in pairs(colspans) do |
local left, right = colRange:match("^(%d+)%-(%d+)$") |
left, right = tonumber(left), tonumber(right) |
for col = left, right-1 do |
width = width - columns[col].width - h_margin |
end |
width = width - columns[right].width |
if width <=0 then |
colspans[colRange] = nil |
else |
width = width / (right - left + 1) |
if width > maxNeedWidthPerCol then |
maxNeedCols = colRange |
maxNeedWidthPerCol = width |
end |
end |
end |
EnlargeColumn(tooltip, columns[right], width) |
-- resize all columns for that colspan |
if maxNeedCols then |
local left, right = maxNeedCols:match("^(%d+)%-(%d+)$") |
for col = left, right do |
EnlargeColumn(tooltip, columns[col], columns[col].width + maxNeedWidthPerCol) |
end |
colspans[maxNeedCols] = nil |
end |
end |
wipe(tooltip.colspans) |
--now that the cell width is set, recalculate the rows' height |
for _, line in ipairs(lines) do |
if #(line.cells) > 0 then |
local lineheight = 0 |
for _, cell in pairs(line.cells) do |
if cell then |
lineheight = max(lineheight, cell:getContentHeight()) |
end |
end |
if lineheight > 0 then |
ResizeLine(tooltip, line, lineheight) |
end |
end |
end |
end |
local function _SetCell(tooltip, lineNum, colNum, value, font, justification, colSpan, provider, ...) |
-- Store the cell settings directly into the cell |
-- That's a bit risky but is really cheap compared to other ways to do it |
cell._font, cell._justification, cell._colSpan, cell._line, cell._column = font, justification, colSpan, lineNum, colNum |
cell._font, cell._justification, cell._colSpan, cell._line, cell._column = font, justification, colSpan, lineNum, colNum |
-- Setup the cell content |
local width, height = cell:SetupCell(tooltip, value, justification, font, ...) |
## Title: Lib: QTip-1.0 |
## Notes: Library providing multi-column tooltips. |
## Author: Torhal, Adirelle, Elkano, Tristanian |
## Version: r135-release |
## Version: r139-release |
## LoadOnDemand: 1 |
## X-Date: 2010-04-12T12:23:26Z |
## X-Date: 2010-08-03T20:56:32Z |
## X-Credits: Kaelten (input on initial design) |
## X-Category: Library, Tooltip |
## X-License: Ace3 BSD-like license |
## X-Curse-Packaged-Version: r135-release |
## X-Curse-Packaged-Version: r139-release |
## X-Curse-Project-Name: LibQTip-1.0 |
## X-Curse-Project-ID: libqtip-1-0 |
## X-Curse-Repository-ID: wow/libqtip-1-0/mainline |