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