annotate Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua @ 32:8368036a4abf

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