WoWInterface SVN mRunes

[/] [trunk/] [mRunes/] [Libs/] [LibGUIFactory-1.0/] [Widgets/] [UIF-InlineGroup.lua] - Rev 8

Compare with Previous | Blame | View Log

local Type, Version = "UIF-InlineGroup", 4
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI.GetWidgetVersion and AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

-- Lua APIs
local pairs = pairs

-- WoW APIs
local CreateFrame, UIParent = CreateFrame, UIParent

--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
        ["OnAcquire"] = function(self)
                self:SetWidth(300)
                self:SetHeight(100)
        end,

        -- ["OnRelease"] = nil,

        ["SetTitle"] = function(self,title)
                self.titletext:SetText(title)
        end,


        ["LayoutFinished"] = function(self, width, height)
                if self.noAutoHeight then return end
                self:SetHeight((height or 0) + 40)
        end,

        ["OnWidthSet"] = function(self, width)
                local content = self.content
                local contentwidth = width - 20
                if contentwidth < 0 then
                        contentwidth = 0
                end
                content:SetWidth(contentwidth)
                content.width = contentwidth
        end,

        ["OnHeightSet"] = function(self, height)
                local content = self.content
                local contentheight = height - 20
                if contentheight < 0 then
                        contentheight = 0
                end
                content:SetHeight(contentheight)
                content.height = contentheight
        end,
        
        ["SetFont"] = function(self, font, size, flags)
                self.titletext:SetFont(font, size, flags)
        end,
        
        ["SetFontColor"] = function(self, color)
                self.titletext:SetTextColor(unpack(color))
        end,
        
        ["SetBGTexture"] = function(self, texture)
                PaneBackdrop.bgFile = texture
                self.border:SetBackdrop(PaneBackdrop)
        end,
        
        ["SetBorderTexture"] = function(self, texture)
                PaneBackdrop.edgeFile = texture
                self.border:SetBackdrop(PaneBackdrop)
        end,
        
        ["SetBGColor"] = function(self, color)
                self.border:SetBackdropColor(unpack(color))             
        end,
        
        ["SetBorderColor"] = function(self, color)
                self.border:SetBackdropBorderColor(unpack(color))
        end,
}

--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local PaneBackdrop  = {
        bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
        edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
        tile = true, tileSize = 16, edgeSize = 16,
        insets = { left = 3, right = 3, top = 5, bottom = 3 }
}

local function Constructor()
        local frame = CreateFrame("Frame", nil, UIParent)
        frame:SetFrameStrata("FULLSCREEN_DIALOG")

        local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
        titletext:SetPoint("TOPLEFT", 14, 0)
        titletext:SetPoint("TOPRIGHT", -14, 0)
        titletext:SetJustifyH("LEFT")
        titletext:SetHeight(18)

        local border = CreateFrame("Frame", nil, frame)
        border:SetPoint("TOPLEFT", 0, -17)
        border:SetPoint("BOTTOMRIGHT", -1, 3)
        border:SetBackdrop(PaneBackdrop)
        border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
        border:SetBackdropBorderColor(0.4, 0.4, 0.4)

        --Container Support
        local content = CreateFrame("Frame", nil, border)
        content:SetPoint("TOPLEFT", 10, -10)
        content:SetPoint("BOTTOMRIGHT", -10, 10)

        local widget = {
                frame     = frame,
                content   = content,
                titletext = titletext,
                border    = border,
                type      = Type
        }
        for method, func in pairs(methods) do
                widget[method] = func
        end

        return AceGUI:RegisterAsContainer(widget)
end

AceGUI:RegisterWidgetType(Type, Constructor, Version)

Compare with Previous | Blame