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