Xiiph@0: --[[----------------------------------------------------------------------------- Xiiph@0: InlineGroup Container Xiiph@0: Simple container widget that creates a visible "box" with an optional title. Xiiph@0: -------------------------------------------------------------------------------]] Xiiph@0: local Type, Version = "InlineGroup", 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:SetWidth(300) Xiiph@0: self:SetHeight(100) Xiiph@0: end, Xiiph@0: Xiiph@0: -- ["OnRelease"] = nil, Xiiph@0: Xiiph@0: ["SetTitle"] = function(self,title) Xiiph@0: self.titletext:SetText(title) Xiiph@0: end, Xiiph@0: Xiiph@0: Xiiph@0: ["LayoutFinished"] = function(self, width, height) Xiiph@0: if self.noAutoHeight then return end Xiiph@0: self:SetHeight((height or 0) + 40) Xiiph@0: end, Xiiph@0: Xiiph@0: ["OnWidthSet"] = function(self, width) Xiiph@0: local content = self.content Xiiph@0: local contentwidth = width - 20 Xiiph@0: if contentwidth < 0 then Xiiph@0: contentwidth = 0 Xiiph@0: end Xiiph@0: content:SetWidth(contentwidth) Xiiph@0: content.width = contentwidth Xiiph@0: end, Xiiph@0: Xiiph@0: ["OnHeightSet"] = function(self, height) Xiiph@0: local content = self.content Xiiph@0: local contentheight = height - 20 Xiiph@0: if contentheight < 0 then Xiiph@0: contentheight = 0 Xiiph@0: end Xiiph@0: content:SetHeight(contentheight) Xiiph@0: content.height = contentheight Xiiph@0: end Xiiph@0: } Xiiph@0: Xiiph@0: --[[----------------------------------------------------------------------------- Xiiph@0: Constructor Xiiph@0: -------------------------------------------------------------------------------]] Xiiph@0: local PaneBackdrop = { Xiiph@0: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", Xiiph@0: edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", Xiiph@0: tile = true, tileSize = 16, edgeSize = 16, Xiiph@0: insets = { left = 3, right = 3, top = 5, bottom = 3 } Xiiph@0: } Xiiph@0: Xiiph@0: local function Constructor() Xiiph@0: local frame = CreateFrame("Frame", nil, UIParent) Xiiph@0: frame:SetFrameStrata("FULLSCREEN_DIALOG") Xiiph@0: Xiiph@0: local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal") Xiiph@0: titletext:SetPoint("TOPLEFT", 14, 0) Xiiph@0: titletext:SetPoint("TOPRIGHT", -14, 0) Xiiph@0: titletext:SetJustifyH("LEFT") Xiiph@0: titletext:SetHeight(18) Xiiph@0: Xiiph@0: local border = CreateFrame("Frame", nil, frame) Xiiph@0: border:SetPoint("TOPLEFT", 0, -17) Xiiph@0: border:SetPoint("BOTTOMRIGHT", -1, 3) Xiiph@0: border:SetBackdrop(PaneBackdrop) Xiiph@0: border:SetBackdropColor(0.1, 0.1, 0.1, 0.5) Xiiph@0: border:SetBackdropBorderColor(0.4, 0.4, 0.4) Xiiph@0: Xiiph@0: --Container Support Xiiph@0: local content = CreateFrame("Frame", nil, border) Xiiph@0: content:SetPoint("TOPLEFT", 10, -10) Xiiph@0: content:SetPoint("BOTTOMRIGHT", -10, 10) Xiiph@0: Xiiph@0: local widget = { Xiiph@0: frame = frame, Xiiph@0: content = content, Xiiph@0: titletext = titletext, 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:RegisterAsContainer(widget) Xiiph@0: end Xiiph@0: Xiiph@0: AceGUI:RegisterWidgetType(Type, Constructor, Version)