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