annotate Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua @ 0:fc346da3afd9

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