1 --[[-----------------------------------------------------------------------------
3 -------------------------------------------------------------------------------]]
4 local Type, Version = "Frame", 26
5 local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
6 if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end
9 local pairs, assert, type = pairs, assert, type
10 local wipe = table.wipe
13 local PlaySound = PlaySound
14 local CreateFrame, UIParent = CreateFrame, UIParent
16 -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded
17 -- List them here for Mikk's FindGlobals script
20 --[[-----------------------------------------------------------------------------
22 -------------------------------------------------------------------------------]]
23 local function Button_OnClick(frame)
24 PlaySound(PlaySoundKitID and "gsTitleOptionExit" or 799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
28 local function Frame_OnShow(frame)
29 frame.obj:Fire("OnShow")
32 local function Frame_OnClose(frame)
33 frame.obj:Fire("OnClose")
36 local function Frame_OnMouseDown(frame)
40 local function Title_OnMouseDown(frame)
41 frame:GetParent():StartMoving()
45 local function MoverSizer_OnMouseUp(mover)
46 local frame = mover:GetParent()
47 frame:StopMovingOrSizing()
48 local self = frame.obj
49 local status = self.status or self.localstatus
50 status.width = frame:GetWidth()
51 status.height = frame:GetHeight()
52 status.top = frame:GetTop()
53 status.left = frame:GetLeft()
56 local function SizerSE_OnMouseDown(frame)
57 frame:GetParent():StartSizing("BOTTOMRIGHT")
61 local function SizerS_OnMouseDown(frame)
62 frame:GetParent():StartSizing("BOTTOM")
66 local function SizerE_OnMouseDown(frame)
67 frame:GetParent():StartSizing("RIGHT")
71 local function StatusBar_OnEnter(frame)
72 frame.obj:Fire("OnEnterStatusBar")
75 local function StatusBar_OnLeave(frame)
76 frame.obj:Fire("OnLeaveStatusBar")
79 --[[-----------------------------------------------------------------------------
81 -------------------------------------------------------------------------------]]
83 ["OnAcquire"] = function(self)
84 self.frame:SetParent(UIParent)
85 self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
90 self:EnableResize(true)
93 ["OnRelease"] = function(self)
95 wipe(self.localstatus)
98 ["OnWidthSet"] = function(self, width)
99 local content = self.content
100 local contentwidth = width - 34
101 if contentwidth < 0 then
104 content:SetWidth(contentwidth)
105 content.width = contentwidth
108 ["OnHeightSet"] = function(self, height)
109 local content = self.content
110 local contentheight = height - 57
111 if contentheight < 0 then
114 content:SetHeight(contentheight)
115 content.height = contentheight
118 ["SetTitle"] = function(self, title)
119 self.titletext:SetText(title)
120 self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
123 ["SetStatusText"] = function(self, text)
124 self.statustext:SetText(text)
127 ["Hide"] = function(self)
131 ["Show"] = function(self)
135 ["EnableResize"] = function(self, state)
136 local func = state and "Show" or "Hide"
137 self.sizer_se[func](self.sizer_se)
138 self.sizer_s[func](self.sizer_s)
139 self.sizer_e[func](self.sizer_e)
142 -- called to set an external table to store status in
143 ["SetStatusTable"] = function(self, status)
144 assert(type(status) == "table")
149 ["ApplyStatus"] = function(self)
150 local status = self.status or self.localstatus
151 local frame = self.frame
152 self:SetWidth(status.width or 700)
153 self:SetHeight(status.height or 500)
154 frame:ClearAllPoints()
155 if status.top and status.left then
156 frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
157 frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
159 frame:SetPoint("CENTER")
164 --[[-----------------------------------------------------------------------------
166 -------------------------------------------------------------------------------]]
167 local FrameBackdrop = {
168 bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
169 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
170 tile = true, tileSize = 32, edgeSize = 32,
171 insets = { left = 8, right = 8, top = 8, bottom = 8 }
174 local PaneBackdrop = {
175 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
176 edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
177 tile = true, tileSize = 16, edgeSize = 16,
178 insets = { left = 3, right = 3, top = 5, bottom = 3 }
181 local function Constructor()
182 local frame = CreateFrame("Frame", nil, UIParent)
185 frame:EnableMouse(true)
186 frame:SetMovable(true)
187 frame:SetResizable(true)
188 frame:SetFrameStrata("FULLSCREEN_DIALOG")
189 frame:SetBackdrop(FrameBackdrop)
190 frame:SetBackdropColor(0, 0, 0, 1)
191 frame:SetMinResize(400, 200)
192 frame:SetToplevel(true)
193 frame:SetScript("OnShow", Frame_OnShow)
194 frame:SetScript("OnHide", Frame_OnClose)
195 frame:SetScript("OnMouseDown", Frame_OnMouseDown)
197 local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
198 closebutton:SetScript("OnClick", Button_OnClick)
199 closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
200 closebutton:SetHeight(20)
201 closebutton:SetWidth(100)
202 closebutton:SetText(CLOSE)
204 local statusbg = CreateFrame("Button", nil, frame)
205 statusbg:SetPoint("BOTTOMLEFT", 15, 15)
206 statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
207 statusbg:SetHeight(24)
208 statusbg:SetBackdrop(PaneBackdrop)
209 statusbg:SetBackdropColor(0.1,0.1,0.1)
210 statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
211 statusbg:SetScript("OnEnter", StatusBar_OnEnter)
212 statusbg:SetScript("OnLeave", StatusBar_OnLeave)
214 local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
215 statustext:SetPoint("TOPLEFT", 7, -2)
216 statustext:SetPoint("BOTTOMRIGHT", -7, 2)
217 statustext:SetHeight(20)
218 statustext:SetJustifyH("LEFT")
219 statustext:SetText("")
221 local titlebg = frame:CreateTexture(nil, "OVERLAY")
222 titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
223 titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
224 titlebg:SetPoint("TOP", 0, 12)
225 titlebg:SetWidth(100)
226 titlebg:SetHeight(40)
228 local title = CreateFrame("Frame", nil, frame)
229 title:EnableMouse(true)
230 title:SetScript("OnMouseDown", Title_OnMouseDown)
231 title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
232 title:SetAllPoints(titlebg)
234 local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
235 titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)
237 local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
238 titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
239 titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
240 titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
241 titlebg_l:SetWidth(30)
242 titlebg_l:SetHeight(40)
244 local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
245 titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header")
246 titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
247 titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
248 titlebg_r:SetWidth(30)
249 titlebg_r:SetHeight(40)
251 local sizer_se = CreateFrame("Frame", nil, frame)
252 sizer_se:SetPoint("BOTTOMRIGHT")
253 sizer_se:SetWidth(25)
254 sizer_se:SetHeight(25)
255 sizer_se:EnableMouse()
256 sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
257 sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
259 local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
262 line1:SetPoint("BOTTOMRIGHT", -8, 8)
263 line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
264 local x = 0.1 * 14/17
265 line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
267 local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
270 line2:SetPoint("BOTTOMRIGHT", -8, 8)
271 line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border")
273 line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)
275 local sizer_s = CreateFrame("Frame", nil, frame)
276 sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
277 sizer_s:SetPoint("BOTTOMLEFT")
278 sizer_s:SetHeight(25)
279 sizer_s:EnableMouse(true)
280 sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
281 sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
283 local sizer_e = CreateFrame("Frame", nil, frame)
284 sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
285 sizer_e:SetPoint("TOPRIGHT")
287 sizer_e:EnableMouse(true)
288 sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
289 sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
292 local content = CreateFrame("Frame", nil, frame)
293 content:SetPoint("TOPLEFT", 17, -27)
294 content:SetPoint("BOTTOMRIGHT", -17, 40)
298 titletext = titletext,
299 statustext = statustext,
308 for method, func in pairs(methods) do
309 widget[method] = func
311 closebutton.obj, statusbg.obj = widget, widget
313 return AceGUI:RegisterAsContainer(widget)
316 AceGUI:RegisterWidgetType(Type, Constructor, Version)