Mercurial > wow > squawk
comparison Libs/LibQTipClick-1.1/LibQTipClick-1.1.lua @ 22:8df5d8ef2e27 tip
switch back to LibQTip-1.0 as LQTC is depreciated
Fixed up the line resizing as LQT does this automatically now
author | wobin |
---|---|
date | Wed, 22 Jul 2009 23:16:42 +1000 |
parents | e066473450c2 |
children |
comparison
equal
deleted
inserted
replaced
21:e066473450c2 | 22:8df5d8ef2e27 |
---|---|
1 local MAJOR = "LibQTipClick-1.1" | |
2 local MINOR = 3 | |
3 assert(LibStub, MAJOR.." requires LibStub") | |
4 | |
5 local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR) | |
6 | |
7 if not lib then return end -- No upgrade needed | |
8 | |
9 local QTip = LibStub:GetLibrary("LibQTip-1.0") | |
10 assert(QTip, MAJOR.." requires LibQTip-1.0") | |
11 | |
12 local CBH = LibStub:GetLibrary("CallbackHandler-1.0") | |
13 assert(CBH, MAJOR.." requires CallbackHandler-1.0") | |
14 | |
15 ------------------------------------------------------------------------------- | |
16 -- Local variables | |
17 ------------------------------------------------------------------------------- | |
18 lib.LabelProvider, lib.LabelPrototype, lib.BaseProvider = QTip:CreateCellProvider(QTip.LabelProvider) | |
19 local cell_provider, cell_prototype, cell_base = lib.LabelProvider, lib.LabelPrototype, lib.BaseProvider | |
20 | |
21 ------------------------------------------------------------------------------- | |
22 -- Public library API | |
23 ------------------------------------------------------------------------------- | |
24 local highlighter = CreateFrame("Frame", nil, UIParent) | |
25 highlighter:SetFrameStrata("TOOLTIP") | |
26 highlighter:Hide() | |
27 | |
28 local cell_highlight = highlighter:CreateTexture(nil, "BACKGROUND") | |
29 cell_highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight") | |
30 cell_highlight:SetBlendMode("ADD") | |
31 cell_highlight:SetAllPoints(highlighter) | |
32 | |
33 function lib.OnEnter(event, cell, arg) | |
34 highlighter:SetAllPoints(cell) | |
35 highlighter:SetFrameLevel(cell:GetFrameLevel()) | |
36 highlighter:Show() | |
37 end | |
38 | |
39 function lib.OnLeave(event, cell, arg) | |
40 highlighter:ClearAllPoints() | |
41 highlighter:Hide() | |
42 end | |
43 | |
44 function lib.OnMouseDown(event, cell, arg, button) PlaySound("igMainMenuOpen") end | |
45 function lib.OnMouseUp(event, cell, arg, button) end | |
46 | |
47 local function Cell_OnEnter(cell) cell.callbacks:Fire("OnEnter", cell, cell.arg) end | |
48 local function Cell_OnLeave(cell) cell.callbacks:Fire("OnLeave", cell, cell.arg) end | |
49 local function Cell_OnMouseDown(cell, button) cell.callbacks:Fire("OnMouseDown", cell, cell.arg, button) end | |
50 local function Cell_OnMouseUp(cell, button) cell.callbacks:Fire("OnMouseUp", cell, cell.arg, button) end | |
51 | |
52 function cell_prototype:InitializeCell() cell_base.InitializeCell(self) end | |
53 | |
54 function cell_prototype:SetupCell(tooltip, value, justification, font, arg, ...) | |
55 local width, height = cell_base.SetupCell(self, tooltip, value, justification, font, ...) | |
56 self:EnableMouse(true) | |
57 self.arg = arg | |
58 self.callbacks = tooltip.callbacks | |
59 self:SetScript("OnEnter", Cell_OnEnter) | |
60 self:SetScript("OnLeave", Cell_OnLeave) | |
61 self:SetScript("OnMouseDown", Cell_OnMouseDown) | |
62 self:SetScript("OnMouseUp", Cell_OnMouseUp) | |
63 | |
64 return width, height | |
65 end | |
66 | |
67 function cell_prototype:ReleaseCell() | |
68 self:EnableMouse(false) | |
69 self:SetScript("OnEnter", nil) | |
70 self:SetScript("OnLeave", nil) | |
71 self:SetScript("OnMouseDown", nil) | |
72 self:SetScript("OnMouseUp", nil) | |
73 self.arg = nil | |
74 self.callbacks = nil | |
75 end | |
76 | |
77 ------------------------------------------------------------------------------- | |
78 -- LibQTip wrapper API | |
79 ------------------------------------------------------------------------------- | |
80 local function AddNormalLine(tooltip, ...) | |
81 local oldProvider = tooltip:GetDefaultProvider() | |
82 tooltip:SetDefaultProvider(QTip.LabelProvider) | |
83 local lineNum, colNum = tooltip:AddLine(...) | |
84 tooltip:SetDefaultProvider(oldProvider) | |
85 return lineNum, colNum | |
86 end | |
87 | |
88 local function AddNormalHeader(tooltip, ...) | |
89 local oldProvider = tooltip:GetDefaultProvider() | |
90 tooltip:SetDefaultProvider(QTip.LabelProvider) | |
91 local lineNum, colNum = tooltip:AddHeader(...) | |
92 tooltip:SetDefaultProvider(oldProvider) | |
93 return lineNum, colNum | |
94 end | |
95 | |
96 local function SetNormalCell(tooltip, ...) | |
97 local oldProvider = tooltip:GetDefaultProvider() | |
98 tooltip:SetDefaultProvider(QTip.LabelProvider) | |
99 local lineNum, colNum = tooltip:SetCell(...) | |
100 tooltip:SetDefaultProvider(oldProvider) | |
101 return lineNum, colNum | |
102 end | |
103 | |
104 function lib:Acquire(key, ...) | |
105 local tooltip = QTip:Acquire(key, ...) | |
106 tooltip:EnableMouse(true) | |
107 | |
108 tooltip.callbacks = CBH:New(tooltip, "SetCallback", "UnSetCallback", "UnSetAllCallbacks" or false) | |
109 tooltip:SetCallback("OnEnter", self.OnEnter) | |
110 tooltip:SetCallback("OnLeave", self.OnLeave) | |
111 tooltip:SetCallback("OnMouseDown", self.OnMouseDown) | |
112 tooltip:SetCallback("OnMouseUp", self.OnMouseUp) | |
113 | |
114 tooltip.AddNormalLine = AddNormalLine | |
115 tooltip.AddNormalHeader = AddNormalHeader | |
116 tooltip.SetNormalCell = SetNormalCell | |
117 tooltip:SetDefaultProvider(cell_provider) | |
118 return tooltip | |
119 end | |
120 | |
121 function lib:IsAcquired(key) return QTip:IsAcquired(key) end | |
122 | |
123 function lib:Release(tooltip) | |
124 if not tooltip then return end | |
125 tooltip:EnableMouse(false) | |
126 tooltip:UnSetAllCallbacks(tooltip) | |
127 tooltip.callbacks = nil | |
128 tooltip["SetCallback"] = nil | |
129 tooltip["UnSetCallback"] = nil | |
130 tooltip["UnSetAllCallbacks"] = nil | |
131 QTip:Release(tooltip) | |
132 end | |
133 | |
134 function lib:IterateTooltips() return QTip:IterateTooltips() end | |
135 function lib:CreateCellProvider(baseProvider) return QTip:CreateCellProvider(baseProvider) end |