comparison Libs/AceGUI-3.0/widgets/AceGUIWidget-Icon.lua @ 0:169f5211fc7f

First public revision. At this point ItemAuditor watches mail for auctions sold or purchased, watches for buy/sell (money and 1 item type change) and conversions/tradeskills. Milling isn't working yet because there is too much time between the first event and the last event.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 20 May 2010 19:22:19 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:169f5211fc7f
1 local AceGUI = LibStub("AceGUI-3.0")
2
3 -- Lua APIs
4 local select = select
5
6 -- WoW APIs
7 local CreateFrame, UIParent = CreateFrame, UIParent
8
9 --------------------------
10 -- Label --
11 --------------------------
12 do
13 local Type = "Icon"
14 local Version = 11
15
16 local function OnAcquire(self)
17 self:SetHeight(110)
18 self:SetWidth(110)
19 self:SetLabel("")
20 self:SetImage(nil)
21 self:SetImageSize(64, 64)
22 end
23
24 local function OnRelease(self)
25 self.frame:ClearAllPoints()
26 self.frame:Hide()
27 self:SetDisabled(false)
28 end
29
30 local function SetLabel(self, text)
31 if text and text ~= "" then
32 self.label:Show()
33 self.label:SetText(text)
34 self.frame:SetHeight(self.image:GetHeight() + 25)
35 else
36 self.label:Hide()
37 self.frame:SetHeight(self.image:GetHeight() + 10)
38 end
39 end
40
41 local function SetImage(self, path, ...)
42 local image = self.image
43 image:SetTexture(path)
44
45 if image:GetTexture() then
46 self.imageshown = true
47 local n = select('#', ...)
48 if n == 4 or n == 8 then
49 image:SetTexCoord(...)
50 else
51 image:SetTexCoord(0, 1, 0, 1)
52 end
53 else
54 self.imageshown = nil
55 end
56 end
57
58 local function SetImageSize(self, width, height)
59 self.image:SetWidth(width)
60 self.image:SetHeight(height)
61 --self.frame:SetWidth(width + 30)
62 if self.label:IsShown() then
63 self.frame:SetHeight(height + 25)
64 else
65 self.frame:SetHeight(height + 10)
66 end
67 end
68
69 local function SetDisabled(self, disabled)
70 self.disabled = disabled
71 if disabled then
72 self.frame:Disable()
73 self.label:SetTextColor(0.5,0.5,0.5)
74 self.image:SetVertexColor(0.5, 0.5, 0.5, 0.5)
75 else
76 self.frame:Enable()
77 self.label:SetTextColor(1,1,1)
78 self.image:SetVertexColor(1, 1, 1)
79 end
80 end
81
82 local function OnClick(this, button)
83 this.obj:Fire("OnClick", button)
84 AceGUI:ClearFocus()
85 end
86
87 local function OnEnter(this)
88 this.obj.highlight:Show()
89 this.obj:Fire("OnEnter")
90 end
91
92 local function OnLeave(this)
93 this.obj.highlight:Hide()
94 this.obj:Fire("OnLeave")
95 end
96
97 local function Constructor()
98 local frame = CreateFrame("Button",nil,UIParent)
99 local self = {}
100 self.type = Type
101
102 self.OnRelease = OnRelease
103 self.OnAcquire = OnAcquire
104 self.SetLabel = SetLabel
105 self.frame = frame
106 self.SetImage = SetImage
107 self.SetImageSize = SetImageSize
108
109 -- SetText should be deprecated along the way
110 self.SetText = SetLabel
111 self.SetDisabled = SetDisabled
112
113 frame.obj = self
114
115 frame:SetHeight(110)
116 frame:SetWidth(110)
117 frame:EnableMouse(true)
118 frame:SetScript("OnClick", OnClick)
119 frame:SetScript("OnLeave", OnLeave)
120 frame:SetScript("OnEnter", OnEnter)
121 local label = frame:CreateFontString(nil,"BACKGROUND","GameFontHighlight")
122 label:SetPoint("BOTTOMLEFT",frame,"BOTTOMLEFT",0,0)
123 label:SetPoint("BOTTOMRIGHT",frame,"BOTTOMRIGHT",0,0)
124 label:SetJustifyH("CENTER")
125 label:SetJustifyV("TOP")
126 label:SetHeight(18)
127 self.label = label
128
129 local image = frame:CreateTexture(nil,"BACKGROUND")
130 self.image = image
131 image:SetWidth(64)
132 image:SetHeight(64)
133 image:SetPoint("TOP",frame,"TOP",0,-5)
134
135 local highlight = frame:CreateTexture(nil,"OVERLAY")
136 self.highlight = highlight
137 highlight:SetAllPoints(image)
138 highlight:SetTexture("Interface\\PaperDollInfoFrame\\UI-Character-Tab-Highlight")
139 highlight:SetTexCoord(0,1,0.23,0.77)
140 highlight:SetBlendMode("ADD")
141 highlight:Hide()
142
143 AceGUI:RegisterAsWidget(self)
144 return self
145 end
146
147 AceGUI:RegisterWidgetType(Type,Constructor,Version)
148 end
149