annotate Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua @ 15:21cefa363c73 tip

Last modification to ready checking broke something ... Now its fixed and ready checking is working as intended.
author Xiiph
date Fri, 25 Feb 2011 01:21:13 +0100
parents 98c6f55e6619
children
rev   line source
Xiiph@0 1 --[[-----------------------------------------------------------------------------
Xiiph@0 2 InlineGroup Container
Xiiph@0 3 Simple container widget that creates a visible "box" with an optional title.
Xiiph@0 4 -------------------------------------------------------------------------------]]
Xiiph@0 5 local Type, Version = "InlineGroup", 20
Xiiph@0 6 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
Xiiph@0 7 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
Xiiph@0 8
Xiiph@0 9 -- Lua APIs
Xiiph@0 10 local pairs = pairs
Xiiph@0 11
Xiiph@0 12 -- WoW APIs
Xiiph@0 13 local CreateFrame, UIParent = CreateFrame, UIParent
Xiiph@0 14
Xiiph@0 15 --[[-----------------------------------------------------------------------------
Xiiph@0 16 Methods
Xiiph@0 17 -------------------------------------------------------------------------------]]
Xiiph@0 18 local methods = {
Xiiph@0 19 ["OnAcquire"] = function(self)
Xiiph@0 20 self:SetWidth(300)
Xiiph@0 21 self:SetHeight(100)
Xiiph@0 22 end,
Xiiph@0 23
Xiiph@0 24 -- ["OnRelease"] = nil,
Xiiph@0 25
Xiiph@0 26 ["SetTitle"] = function(self,title)
Xiiph@0 27 self.titletext:SetText(title)
Xiiph@0 28 end,
Xiiph@0 29
Xiiph@0 30
Xiiph@0 31 ["LayoutFinished"] = function(self, width, height)
Xiiph@0 32 if self.noAutoHeight then return end
Xiiph@0 33 self:SetHeight((height or 0) + 40)
Xiiph@0 34 end,
Xiiph@0 35
Xiiph@0 36 ["OnWidthSet"] = function(self, width)
Xiiph@0 37 local content = self.content
Xiiph@0 38 local contentwidth = width - 20
Xiiph@0 39 if contentwidth < 0 then
Xiiph@0 40 contentwidth = 0
Xiiph@0 41 end
Xiiph@0 42 content:SetWidth(contentwidth)
Xiiph@0 43 content.width = contentwidth
Xiiph@0 44 end,
Xiiph@0 45
Xiiph@0 46 ["OnHeightSet"] = function(self, height)
Xiiph@0 47 local content = self.content
Xiiph@0 48 local contentheight = height - 20
Xiiph@0 49 if contentheight < 0 then
Xiiph@0 50 contentheight = 0
Xiiph@0 51 end
Xiiph@0 52 content:SetHeight(contentheight)
Xiiph@0 53 content.height = contentheight
Xiiph@0 54 end
Xiiph@0 55 }
Xiiph@0 56
Xiiph@0 57 --[[-----------------------------------------------------------------------------
Xiiph@0 58 Constructor
Xiiph@0 59 -------------------------------------------------------------------------------]]
Xiiph@0 60 local PaneBackdrop = {
Xiiph@0 61 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Xiiph@0 62 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
Xiiph@0 63 tile = true, tileSize = 16, edgeSize = 16,
Xiiph@0 64 insets = { left = 3, right = 3, top = 5, bottom = 3 }
Xiiph@0 65 }
Xiiph@0 66
Xiiph@0 67 local function Constructor()
Xiiph@0 68 local frame = CreateFrame("Frame", nil, UIParent)
Xiiph@0 69 frame:SetFrameStrata("FULLSCREEN_DIALOG")
Xiiph@0 70
Xiiph@0 71 local titletext = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
Xiiph@0 72 titletext:SetPoint("TOPLEFT", 14, 0)
Xiiph@0 73 titletext:SetPoint("TOPRIGHT", -14, 0)
Xiiph@0 74 titletext:SetJustifyH("LEFT")
Xiiph@0 75 titletext:SetHeight(18)
Xiiph@0 76
Xiiph@0 77 local border = CreateFrame("Frame", nil, frame)
Xiiph@0 78 border:SetPoint("TOPLEFT", 0, -17)
Xiiph@0 79 border:SetPoint("BOTTOMRIGHT", -1, 3)
Xiiph@0 80 border:SetBackdrop(PaneBackdrop)
Xiiph@0 81 border:SetBackdropColor(0.1, 0.1, 0.1, 0.5)
Xiiph@0 82 border:SetBackdropBorderColor(0.4, 0.4, 0.4)
Xiiph@0 83
Xiiph@0 84 --Container Support
Xiiph@0 85 local content = CreateFrame("Frame", nil, border)
Xiiph@0 86 content:SetPoint("TOPLEFT", 10, -10)
Xiiph@0 87 content:SetPoint("BOTTOMRIGHT", -10, 10)
Xiiph@0 88
Xiiph@0 89 local widget = {
Xiiph@0 90 frame = frame,
Xiiph@0 91 content = content,
Xiiph@0 92 titletext = titletext,
Xiiph@0 93 type = Type
Xiiph@0 94 }
Xiiph@0 95 for method, func in pairs(methods) do
Xiiph@0 96 widget[method] = func
Xiiph@0 97 end
Xiiph@0 98
Xiiph@0 99 return AceGUI:RegisterAsContainer(widget)
Xiiph@0 100 end
Xiiph@0 101
Xiiph@0 102 AceGUI:RegisterWidgetType(Type, Constructor, Version)