comparison Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua @ 57:01b63b8ed811 v21

total rewrite to version 21
author yellowfive
date Fri, 05 Jun 2015 11:05:15 -0700
parents
children
comparison
equal deleted inserted replaced
56:75431c084aa0 57:01b63b8ed811
1 --[[-----------------------------------------------------------------------------
2 Heading Widget
3 -------------------------------------------------------------------------------]]
4 local Type, Version = "Heading", 20
5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
7
8 -- Lua APIs
9 local pairs = pairs
10
11 -- WoW APIs
12 local CreateFrame, UIParent = CreateFrame, UIParent
13
14 --[[-----------------------------------------------------------------------------
15 Methods
16 -------------------------------------------------------------------------------]]
17 local methods = {
18 ["OnAcquire"] = function(self)
19 self:SetText()
20 self:SetFullWidth()
21 self:SetHeight(18)
22 end,
23
24 -- ["OnRelease"] = nil,
25
26 ["SetText"] = function(self, text)
27 self.label:SetText(text or "")
28 if text and text ~= "" then
29 self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0)
30 self.right:Show()
31 else
32 self.left:SetPoint("RIGHT", -3, 0)
33 self.right:Hide()
34 end
35 end
36 }
37
38 --[[-----------------------------------------------------------------------------
39 Constructor
40 -------------------------------------------------------------------------------]]
41 local function Constructor()
42 local frame = CreateFrame("Frame", nil, UIParent)
43 frame:Hide()
44
45 local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal")
46 label:SetPoint("TOP")
47 label:SetPoint("BOTTOM")
48 label:SetJustifyH("CENTER")
49
50 local left = frame:CreateTexture(nil, "BACKGROUND")
51 left:SetHeight(8)
52 left:SetPoint("LEFT", 3, 0)
53 left:SetPoint("RIGHT", label, "LEFT", -5, 0)
54 left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
55 left:SetTexCoord(0.81, 0.94, 0.5, 1)
56
57 local right = frame:CreateTexture(nil, "BACKGROUND")
58 right:SetHeight(8)
59 right:SetPoint("RIGHT", -3, 0)
60 right:SetPoint("LEFT", label, "RIGHT", 5, 0)
61 right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
62 right:SetTexCoord(0.81, 0.94, 0.5, 1)
63
64 local widget = {
65 label = label,
66 left = left,
67 right = right,
68 frame = frame,
69 type = Type
70 }
71 for method, func in pairs(methods) do
72 widget[method] = func
73 end
74
75 return AceGUI:RegisterAsWidget(widget)
76 end
77
78 AceGUI:RegisterWidgetType(Type, Constructor, Version)