annotate Libs/AceGUI-3.0/widgets/AceGUIContainer-InlineGroup.lua @ 44:7f9a7d2000ea

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