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