yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Panel Container yellowfive@57: Simple container widget that is just a panel that can have a background color yellowfive@57: and contains other widgets. yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local Type, Version = "AmrUiPanel", 1 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: local Amr = LibStub("AceAddon-3.0"):GetAddon("AskMrRobot") 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: --[[----------------------------------------------------------------------------- yellowfive@57: Methods yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local methods = { yellowfive@57: ["OnAcquire"] = function(self) yellowfive@57: self:SetAutoAdjustHeight(false) yellowfive@57: self:SetWidth(300) yellowfive@57: self:SetHeight(100) yellowfive@57: self:SetBackgroundColor(Amr.Colors.Black) yellowfive@57: self:SetStrata("FULLSCREEN_DIALOG") yellowfive@57: self:SetLevel(0) yellowfive@57: self:SetAlpha(1) yellowfive@57: self:SetVisible(true) yellowfive@57: self:EnableMouse(false) yellowfive@57: self.frame:ClearAllPoints() yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetBackgroundColor"] = function(self, color, a) yellowfive@57: self.bg:SetTexture(color.R, color.G, color.B, a or 1) yellowfive@57: end, yellowfive@57: yellowfive@57: -- set a transparent bg to make this panel invisible yellowfive@57: ["SetTransparent"] = function(self) yellowfive@57: self:SetBackgroundColor(Amr.Colors.Black, 0) yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetStrata"] = function(self, strata) yellowfive@57: self.frame:SetFrameStrata(strata) yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetLevel"] = function(self, level) yellowfive@57: self.frame:SetFrameLevel(level) yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetAlpha"] = function(self, a) yellowfive@57: self.frame:SetAlpha(a) yellowfive@57: end, yellowfive@57: yellowfive@57: ["EnableMouse"] = function(self, enable) yellowfive@57: self.frame:EnableMouse(enable) yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetVisible"] = function(self, visible) yellowfive@57: if visible then yellowfive@57: self.frame:Show() yellowfive@57: else yellowfive@57: self.frame: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:SetFrameStrata("FULLSCREEN_DIALOG") yellowfive@57: yellowfive@57: local bg = frame:CreateTexture(nil, "BACKGROUND") yellowfive@57: bg:SetAllPoints() yellowfive@57: yellowfive@57: local widget = { yellowfive@57: bg = bg, yellowfive@57: frame = frame, yellowfive@57: content = 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:RegisterAsContainer(widget) yellowfive@57: end yellowfive@57: yellowfive@57: AceGUI:RegisterWidgetType(Type, Constructor, Version)