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