annotate Libs/AceGUI-3.0/widgets/AceGUIWidget-Heading.lua @ 201:3447634f0388 tip

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