forked from LetsTimeIt/DungeonTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AceGUIWidget-DungeonToolsSpellLabel.lua
84 lines (73 loc) · 2.54 KB
/
AceGUIWidget-DungeonToolsSpellLabel.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
local LabelType, LabelVersion = "MDTSpellLabel", 1
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
local width,height = 248,18
local tinsert,SetPortraitToTexture,SetPortraitTextureFromCreatureDisplayID,GetItemQualityColor,MouseIsOver = table.insert,SetPortraitToTexture,SetPortraitTextureFromCreatureDisplayID,GetItemQualityColor,MouseIsOver
local labelMethods = {
["OnAcquire"] = function(self)
self:SetWidth(width);
self:SetHeight(height);
end,
["Initialize"] = function(self)
self.callbacks = {
["OnClickNormal"] = function() end,
["OnKeyDown"] = function()
if (key == "ESCAPE") then
--
end
end,
["OnEnter"] = function() end,
["OnLeave"] = function() end
};
self.frame:EnableKeyboard(false);
self.frame:SetScript("OnClick", self.callbacks.OnClickNormal);
-- self.frame:SetScript("OnKeyDown", self.callbacks.OnKeyDown);
self.frame:SetScript("OnEnter", self.callbacks.OnEnter);
self.frame:SetScript("OnLeave", self.callbacks.OnLeave);
self:Enable();
end,
["Disable"] = function(self)
self.frame:Disable();
end,
["Enable"] = function(self)
self.frame:Enable();
end,
["SetIndex"] = function(self, index)
self.index = index
end,
["SetTitle"] = function(self, title)
self.titletext = title;
self.title:SetText(title);
end
}
--Constructor
local function LabelConstructor()
local name = "MDTSpellLabel"..AceGUI:GetNextWidgetNum(LabelType);
local button = CreateFrame("BUTTON", name, UIParent, "OptionsListButtonTemplate");
button:SetHeight(height);
button:SetWidth(width);
button.dgroup = nil;
button.data = {};
local title = button:CreateFontString(nil, "OVERLAY", "GameFontNormal");
button.title = title;
title:SetHeight(14);
title:SetJustifyH("LEFT");
title:SetPoint("TOP", button, "TOP", 0, -2);
-- title:SetPoint("LEFT", button, "RIGHT", 2, 0);
title:SetPoint("LEFT", button, "LEFT");
button.description = {};
button:SetScript("OnEnter", function()
end);
button:SetScript("OnLeave", function()
end);
local widget = {
frame = button,
title = title,
type = LabelType,
parent = UIParent
}
for method, func in pairs(labelMethods) do
widget[method] = func
end
return AceGUI:RegisterAsWidget(widget);
end
AceGUI:RegisterWidgetType(LabelType, LabelConstructor, LabelVersion)