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