yellowfive@57
|
1 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
2 Frame Container
|
yellowfive@57
|
3 -------------------------------------------------------------------------------]]
|
yellowfive@106
|
4 local Type, Version = "Frame", 25
|
yellowfive@57
|
5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
|
yellowfive@57
|
6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
|
yellowfive@57
|
7
|
yellowfive@57
|
8 -- Lua APIs
|
yellowfive@57
|
9 local pairs, assert, type = pairs, assert, type
|
yellowfive@57
|
10 local wipe = table.wipe
|
yellowfive@57
|
11
|
yellowfive@57
|
12 -- WoW APIs
|
yellowfive@57
|
13 local PlaySound = PlaySound
|
yellowfive@57
|
14 local CreateFrame, UIParent = CreateFrame, UIParent
|
yellowfive@57
|
15
|
yellowfive@57
|
16 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
|
yellowfive@57
|
17 -- List them here for Mikk's FindGlobals script
|
yellowfive@57
|
18 -- GLOBALS: CLOSE
|
yellowfive@57
|
19
|
yellowfive@57
|
20 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
21 Scripts
|
yellowfive@57
|
22 -------------------------------------------------------------------------------]]
|
yellowfive@57
|
23 local function Button_OnClick(frame)
|
yellowfive@57
|
24 PlaySound("gsTitleOptionExit")
|
yellowfive@57
|
25 frame.obj:Hide()
|
yellowfive@57
|
26 end
|
yellowfive@57
|
27
|
yellowfive@106
|
28 local function Frame_OnShow(frame)
|
yellowfive@106
|
29 frame.obj:Fire("OnShow")
|
yellowfive@106
|
30 end
|
yellowfive@106
|
31
|
yellowfive@57
|
32 local function Frame_OnClose(frame)
|
yellowfive@57
|
33 frame.obj:Fire("OnClose")
|
yellowfive@57
|
34 end
|
yellowfive@57
|
35
|
yellowfive@57
|
36 local function Frame_OnMouseDown(frame)
|
yellowfive@57
|
37 AceGUI:ClearFocus()
|
yellowfive@57
|
38 end
|
yellowfive@57
|
39
|
yellowfive@57
|
40 local function Title_OnMouseDown(frame)
|
yellowfive@57
|
41 frame:GetParent():StartMoving()
|
yellowfive@57
|
42 AceGUI:ClearFocus()
|
yellowfive@57
|
43 end
|
yellowfive@57
|
44
|
yellowfive@57
|
45 local function MoverSizer_OnMouseUp(mover)
|
yellowfive@57
|
46 local frame = mover:GetParent()
|
yellowfive@57
|
47 frame:StopMovingOrSizing()
|
yellowfive@57
|
48 local self = frame.obj
|
yellowfive@57
|
49 local status = self.status or self.localstatus
|
yellowfive@57
|
50 status.width = frame:GetWidth()
|
yellowfive@57
|
51 status.height = frame:GetHeight()
|
yellowfive@57
|
52 status.top = frame:GetTop()
|
yellowfive@57
|
53 status.left = frame:GetLeft()
|
yellowfive@57
|
54 end
|
yellowfive@57
|
55
|
yellowfive@57
|
56 local function SizerSE_OnMouseDown(frame)
|
yellowfive@57
|
57 frame:GetParent():StartSizing("BOTTOMRIGHT")
|
yellowfive@57
|
58 AceGUI:ClearFocus()
|
yellowfive@57
|
59 end
|
yellowfive@57
|
60
|
yellowfive@57
|
61 local function SizerS_OnMouseDown(frame)
|
yellowfive@57
|
62 frame:GetParent():StartSizing("BOTTOM")
|
yellowfive@57
|
63 AceGUI:ClearFocus()
|
yellowfive@57
|
64 end
|
yellowfive@57
|
65
|
yellowfive@57
|
66 local function SizerE_OnMouseDown(frame)
|
yellowfive@57
|
67 frame:GetParent():StartSizing("RIGHT")
|
yellowfive@57
|
68 AceGUI:ClearFocus()
|
yellowfive@57
|
69 end
|
yellowfive@57
|
70
|
yellowfive@57
|
71 local function StatusBar_OnEnter(frame)
|
yellowfive@57
|
72 frame.obj:Fire("OnEnterStatusBar")
|
yellowfive@57
|
73 end
|
yellowfive@57
|
74
|
yellowfive@57
|
75 local function StatusBar_OnLeave(frame)
|
yellowfive@57
|
76 frame.obj:Fire("OnLeaveStatusBar")
|
yellowfive@57
|
77 end
|
yellowfive@57
|
78
|
yellowfive@57
|
79 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
80 Methods
|
yellowfive@57
|
81 -------------------------------------------------------------------------------]]
|
yellowfive@57
|
82 local methods = {
|
yellowfive@57
|
83 ["OnAcquire"] = function(self)
|
yellowfive@57
|
84 self.frame:SetParent(UIParent)
|
yellowfive@57
|
85 self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
yellowfive@57
|
86 self:SetTitle()
|
yellowfive@57
|
87 self:SetStatusText()
|
yellowfive@57
|
88 self:ApplyStatus()
|
yellowfive@57
|
89 self:Show()
|
yellowfive@57
|
90 self:EnableResize(true)
|
yellowfive@57
|
91 end,
|
yellowfive@57
|
92
|
yellowfive@57
|
93 ["OnRelease"] = function(self)
|
yellowfive@57
|
94 self.status = nil
|
yellowfive@57
|
95 wipe(self.localstatus)
|
yellowfive@57
|
96 end,
|
yellowfive@57
|
97
|
yellowfive@57
|
98 ["OnWidthSet"] = function(self, width)
|
yellowfive@57
|
99 local content = self.content
|
yellowfive@57
|
100 local contentwidth = width - 34
|
yellowfive@57
|
101 if contentwidth < 0 then
|
yellowfive@57
|
102 contentwidth = 0
|
yellowfive@57
|
103 end
|
yellowfive@57
|
104 content:SetWidth(contentwidth)
|
yellowfive@57
|
105 content.width = contentwidth
|
yellowfive@57
|
106 end,
|
yellowfive@57
|
107
|
yellowfive@57
|
108 ["OnHeightSet"] = function(self, height)
|
yellowfive@57
|
109 local content = self.content
|
yellowfive@57
|
110 local contentheight = height - 57
|
yellowfive@57
|
111 if contentheight < 0 then
|
yellowfive@57
|
112 contentheight = 0
|
yellowfive@57
|
113 end
|
yellowfive@57
|
114 content:SetHeight(contentheight)
|
yellowfive@57
|
115 content.height = contentheight
|
yellowfive@57
|
116 end,
|
yellowfive@57
|
117
|
yellowfive@57
|
118 ["SetTitle"] = function(self, title)
|
yellowfive@57
|
119 self.titletext:SetText(title)
|
yellowfive@57
|
120 self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
|
yellowfive@57
|
121 end,
|
yellowfive@57
|
122
|
yellowfive@57
|
123 ["SetStatusText"] = function(self, text)
|
yellowfive@57
|
124 self.statustext:SetText(text)
|
yellowfive@57
|
125 end,
|
yellowfive@57
|
126
|
yellowfive@57
|
127 ["Hide"] = function(self)
|
yellowfive@57
|
128 self.frame:Hide()
|
yellowfive@57
|
129 end,
|
yellowfive@57
|
130
|
yellowfive@57
|
131 ["Show"] = function(self)
|
yellowfive@57
|
132 self.frame:Show()
|
yellowfive@57
|
133 end,
|
yellowfive@57
|
134
|
yellowfive@57
|
135 ["EnableResize"] = function(self, state)
|
yellowfive@57
|
136 local func = state and "Show" or "Hide"
|
yellowfive@57
|
137 self.sizer_se[func](self.sizer_se)
|
yellowfive@57
|
138 self.sizer_s[func](self.sizer_s)
|
yellowfive@57
|
139 self.sizer_e[func](self.sizer_e)
|
yellowfive@57
|
140 end,
|
yellowfive@57
|
141
|
yellowfive@57
|
142 -- called to set an external table to store status in
|
yellowfive@57
|
143 ["SetStatusTable"] = function(self, status)
|
yellowfive@57
|
144 assert(type(status) == "table")
|
yellowfive@57
|
145 self.status = status
|
yellowfive@57
|
146 self:ApplyStatus()
|
yellowfive@57
|
147 end,
|
yellowfive@57
|
148
|
yellowfive@57
|
149 ["ApplyStatus"] = function(self)
|
yellowfive@57
|
150 local status = self.status or self.localstatus
|
yellowfive@57
|
151 local frame = self.frame
|
yellowfive@57
|
152 self:SetWidth(status.width or 700)
|
yellowfive@57
|
153 self:SetHeight(status.height or 500)
|
yellowfive@57
|
154 frame:ClearAllPoints()
|
yellowfive@57
|
155 if status.top and status.left then
|
yellowfive@57
|
156 frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
|
yellowfive@57
|
157 frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
|
yellowfive@57
|
158 else
|
yellowfive@57
|
159 frame:SetPoint("CENTER")
|
yellowfive@57
|
160 end
|
yellowfive@57
|
161 end
|
yellowfive@57
|
162 }
|
yellowfive@57
|
163
|
yellowfive@57
|
164 --[[-----------------------------------------------------------------------------
|
yellowfive@57
|
165 Constructor
|
yellowfive@57
|
166 -------------------------------------------------------------------------------]]
|
yellowfive@57
|
167 local FrameBackdrop = {
|
yellowfive@57
|
168 bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
|
yellowfive@57
|
169 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
|
yellowfive@57
|
170 tile = true, tileSize = 32, edgeSize = 32,
|
yellowfive@57
|
171 insets = { left = 8, right = 8, top = 8, bottom = 8 }
|
yellowfive@57
|
172 }
|
yellowfive@57
|
173
|
yellowfive@57
|
174 local PaneBackdrop = {
|
yellowfive@57
|
175 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
|
yellowfive@57
|
176 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
|
yellowfive@57
|
177 tile = true, tileSize = 16, edgeSize = 16,
|
yellowfive@57
|
178 insets = { left = 3, right = 3, top = 5, bottom = 3 }
|
yellowfive@57
|
179 }
|
yellowfive@57
|
180
|
yellowfive@57
|
181 local function Constructor()
|
yellowfive@57
|
182 local frame = CreateFrame("Frame", nil, UIParent)
|
yellowfive@57
|
183 frame:Hide()
|
yellowfive@57
|
184
|
yellowfive@57
|
185 frame:EnableMouse(true)
|
yellowfive@57
|
186 frame:SetMovable(true)
|
yellowfive@57
|
187 frame:SetResizable(true)
|
yellowfive@57
|
188 frame:SetFrameStrata("FULLSCREEN_DIALOG")
|
yellowfive@57
|
189 frame:SetBackdrop(FrameBackdrop)
|
yellowfive@57
|
190 frame:SetBackdropColor(0, 0, 0, 1)
|
yellowfive@57
|
191 frame:SetMinResize(400, 200)
|
yellowfive@57
|
192 frame:SetToplevel(true)
|
yellowfive@106
|
193 frame:SetScript("OnShow", Frame_OnShow)
|
yellowfive@57
|
194 frame:SetScript("OnHide", Frame_OnClose)
|
yellowfive@57
|
195 frame:SetScript("OnMouseDown", Frame_OnMouseDown)
|
yellowfive@57
|
196
|
yellowfive@57
|
197 local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
|
yellowfive@57
|
198 closebutton:SetScript("OnClick", Button_OnClick)
|
yellowfive@57
|
199 closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
|
yellowfive@57
|
200 closebutton:SetHeight(20)
|
yellowfive@57
|
201 closebutton:SetWidth(100)
|
yellowfive@57
|
202 closebutton:SetText(CLOSE)
|
yellowfive@57
|
203
|
yellowfive@57
|
204 local statusbg = CreateFrame("Button", nil, frame)
|
yellowfive@57
|
205 statusbg:SetPoint("BOTTOMLEFT", 15, 15)
|
yellowfive@57
|
206 statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
|
yellowfive@57
|
207 statusbg:SetHeight(24)
|
yellowfive@57
|
208 statusbg:SetBackdrop(PaneBackdrop)
|
yellowfive@57
|
209 statusbg:SetBackdropColor(0.1,0.1,0.1)
|
yellowfive@57
|
210 statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
|
yellowfive@57
|
211 statusbg:SetScript("OnEnter", StatusBar_OnEnter)
|
yellowfive@57
|
212 statusbg:SetScript("OnLeave", StatusBar_OnLeave)
|
yellowfive@57
|
213
|
yellowfive@57
|
214 local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
yellowfive@57
|
215 statustext:SetPoint("TOPLEFT", 7, -2)
|
yellowfive@57
|
216 statustext:SetPoint("BOTTOMRIGHT", -7, 2)
|
yellowfive@57
|
217 statustext:SetHeight(20)
|
yellowfive@57
|
218 statustext:SetJustifyH("LEFT")
|
yellowfive@57
|
219 statustext:SetText("")
|
yellowfive@57
|
220
|
yellowfive@57
|
221 local titlebg = frame:CreateTexture(nil, "OVERLAY")
|
yellowfive@57
|
222 titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
|
yellowfive@57
|
223 titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
|
yellowfive@57
|
224 titlebg:SetPoint("TOP", 0, 12)
|
yellowfive@57
|
225 titlebg:SetWidth(100)
|
yellowfive@57
|
226 titlebg:SetHeight(40)
|
yellowfive@57
|
227
|
yellowfive@57
|
228 local title = CreateFrame("Frame", nil, frame)
|
yellowfive@57
|
229 title:EnableMouse(true)
|
yellowfive@57
|
230 title:SetScript("OnMouseDown", Title_OnMouseDown)
|
yellowfive@57
|
231 title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
|
yellowfive@57
|
232 title:SetAllPoints(titlebg)
|
yellowfive@57
|
233
|
yellowfive@57
|
234 local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
|
yellowfive@57
|
235 titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)
|
yellowfive@57
|
236
|
yellowfive@57
|
237 local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
|
yellowfive@57
|
238 titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
|
yellowfive@57
|
239 titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
|
yellowfive@57
|
240 titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
|
yellowfive@57
|
241 titlebg_l:SetWidth(30)
|
yellowfive@57
|
242 titlebg_l:SetHeight(40)
|
yellowfive@57
|
243
|
yellowfive@57
|
244 local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
|
yellowfive@57
|
245 titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
|
yellowfive@57
|
246 titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
|
yellowfive@57
|
247 titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
|
yellowfive@57
|
248 titlebg_r:SetWidth(30)
|
yellowfive@57
|
249 titlebg_r:SetHeight(40)
|
yellowfive@57
|
250
|
yellowfive@57
|
251 local sizer_se = CreateFrame("Frame", nil, frame)
|
yellowfive@57
|
252 sizer_se:SetPoint("BOTTOMRIGHT")
|
yellowfive@57
|
253 sizer_se:SetWidth(25)
|
yellowfive@57
|
254 sizer_se:SetHeight(25)
|
yellowfive@57
|
255 sizer_se:EnableMouse()
|
yellowfive@57
|
256 sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
|
yellowfive@57
|
257 sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
|
yellowfive@57
|
258
|
yellowfive@57
|
259 local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
|
yellowfive@57
|
260 line1:SetWidth(14)
|
yellowfive@57
|
261 line1:SetHeight(14)
|
yellowfive@57
|
262 line1:SetPoint("BOTTOMRIGHT", -8, 8)
|
yellowfive@57
|
263 line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
|
yellowfive@57
|
264 local x = 0.1 * 14/17
|
yellowfive@57
|
265 line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
|
yellowfive@57
|
266
|
yellowfive@57
|
267 local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
|
yellowfive@57
|
268 line2:SetWidth(8)
|
yellowfive@57
|
269 line2:SetHeight(8)
|
yellowfive@57
|
270 line2:SetPoint("BOTTOMRIGHT", -8, 8)
|
yellowfive@57
|
271 line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
|
yellowfive@57
|
272 local x = 0.1 * 8/17
|
yellowfive@57
|
273 line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
|
yellowfive@57
|
274
|
yellowfive@57
|
275 local sizer_s = CreateFrame("Frame", nil, frame)
|
yellowfive@57
|
276 sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
|
yellowfive@57
|
277 sizer_s:SetPoint("BOTTOMLEFT")
|
yellowfive@57
|
278 sizer_s:SetHeight(25)
|
yellowfive@57
|
279 sizer_s:EnableMouse(true)
|
yellowfive@57
|
280 sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
|
yellowfive@57
|
281 sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
|
yellowfive@57
|
282
|
yellowfive@57
|
283 local sizer_e = CreateFrame("Frame", nil, frame)
|
yellowfive@57
|
284 sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
|
yellowfive@57
|
285 sizer_e:SetPoint("TOPRIGHT")
|
yellowfive@57
|
286 sizer_e:SetWidth(25)
|
yellowfive@57
|
287 sizer_e:EnableMouse(true)
|
yellowfive@57
|
288 sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
|
yellowfive@57
|
289 sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
|
yellowfive@57
|
290
|
yellowfive@57
|
291 --Container Support
|
yellowfive@57
|
292 local content = CreateFrame("Frame", nil, frame)
|
yellowfive@57
|
293 content:SetPoint("TOPLEFT", 17, -27)
|
yellowfive@57
|
294 content:SetPoint("BOTTOMRIGHT", -17, 40)
|
yellowfive@57
|
295
|
yellowfive@57
|
296 local widget = {
|
yellowfive@57
|
297 localstatus = {},
|
yellowfive@57
|
298 titletext = titletext,
|
yellowfive@57
|
299 statustext = statustext,
|
yellowfive@57
|
300 titlebg = titlebg,
|
yellowfive@57
|
301 sizer_se = sizer_se,
|
yellowfive@57
|
302 sizer_s = sizer_s,
|
yellowfive@57
|
303 sizer_e = sizer_e,
|
yellowfive@57
|
304 content = content,
|
yellowfive@57
|
305 frame = frame,
|
yellowfive@57
|
306 type = Type
|
yellowfive@57
|
307 }
|
yellowfive@57
|
308 for method, func in pairs(methods) do
|
yellowfive@57
|
309 widget[method] = func
|
yellowfive@57
|
310 end
|
yellowfive@57
|
311 closebutton.obj, statusbg.obj = widget, widget
|
yellowfive@57
|
312
|
yellowfive@57
|
313 return AceGUI:RegisterAsContainer(widget)
|
yellowfive@57
|
314 end
|
yellowfive@57
|
315
|
yellowfive@57
|
316 AceGUI:RegisterWidgetType(Type, Constructor, Version)
|