Xiiph@0: --[[----------------------------------------------------------------------------- Xiiph@0: Heading Widget Xiiph@0: -------------------------------------------------------------------------------]] Xiiph@0: local Type, Version = "Heading", 20 Xiiph@0: local AceGUI = LibStub and LibStub("AceGUI-3.0", true) Xiiph@0: if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end Xiiph@0: Xiiph@0: -- Lua APIs Xiiph@0: local pairs = pairs Xiiph@0: Xiiph@0: -- WoW APIs Xiiph@0: local CreateFrame, UIParent = CreateFrame, UIParent Xiiph@0: Xiiph@0: --[[----------------------------------------------------------------------------- Xiiph@0: Methods Xiiph@0: -------------------------------------------------------------------------------]] Xiiph@0: local methods = { Xiiph@0: ["OnAcquire"] = function(self) Xiiph@0: self:SetText() Xiiph@0: self:SetFullWidth() Xiiph@0: self:SetHeight(18) Xiiph@0: end, Xiiph@0: Xiiph@0: -- ["OnRelease"] = nil, Xiiph@0: Xiiph@0: ["SetText"] = function(self, text) Xiiph@0: self.label:SetText(text or "") Xiiph@0: if text and text ~= "" then Xiiph@0: self.left:SetPoint("RIGHT", self.label, "LEFT", -5, 0) Xiiph@0: self.right:Show() Xiiph@0: else Xiiph@0: self.left:SetPoint("RIGHT", -3, 0) Xiiph@0: self.right:Hide() Xiiph@0: end Xiiph@0: end Xiiph@0: } Xiiph@0: Xiiph@0: --[[----------------------------------------------------------------------------- Xiiph@0: Constructor Xiiph@0: -------------------------------------------------------------------------------]] Xiiph@0: local function Constructor() Xiiph@0: local frame = CreateFrame("Frame", nil, UIParent) Xiiph@0: frame:Hide() Xiiph@0: Xiiph@0: local label = frame:CreateFontString(nil, "BACKGROUND", "GameFontNormal") Xiiph@0: label:SetPoint("TOP") Xiiph@0: label:SetPoint("BOTTOM") Xiiph@0: label:SetJustifyH("CENTER") Xiiph@0: Xiiph@0: local left = frame:CreateTexture(nil, "BACKGROUND") Xiiph@0: left:SetHeight(8) Xiiph@0: left:SetPoint("LEFT", 3, 0) Xiiph@0: left:SetPoint("RIGHT", label, "LEFT", -5, 0) Xiiph@0: left:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") Xiiph@0: left:SetTexCoord(0.81, 0.94, 0.5, 1) Xiiph@0: Xiiph@0: local right = frame:CreateTexture(nil, "BACKGROUND") Xiiph@0: right:SetHeight(8) Xiiph@0: right:SetPoint("RIGHT", -3, 0) Xiiph@0: right:SetPoint("LEFT", label, "RIGHT", 5, 0) Xiiph@0: right:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") Xiiph@0: right:SetTexCoord(0.81, 0.94, 0.5, 1) Xiiph@0: Xiiph@0: local widget = { Xiiph@0: label = label, Xiiph@0: left = left, Xiiph@0: right = right, Xiiph@0: frame = frame, Xiiph@0: type = Type Xiiph@0: } Xiiph@0: for method, func in pairs(methods) do Xiiph@0: widget[method] = func Xiiph@0: end Xiiph@0: Xiiph@0: return AceGUI:RegisterAsWidget(widget) Xiiph@0: end Xiiph@0: Xiiph@0: AceGUI:RegisterWidgetType(Type, Constructor, Version)