yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Frame Container yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@106: local Type, Version = "Frame", 25 yellowfive@57: local AceGUI = LibStub and LibStub("AceGUI-3.0", true) yellowfive@57: if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end yellowfive@57: yellowfive@57: -- Lua APIs yellowfive@57: local pairs, assert, type = pairs, assert, type yellowfive@57: local wipe = table.wipe yellowfive@57: yellowfive@57: -- WoW APIs yellowfive@57: local PlaySound = PlaySound yellowfive@57: local CreateFrame, UIParent = CreateFrame, UIParent yellowfive@57: yellowfive@57: -- Global vars/functions that we don't upvalue since they might get hooked, or upgraded yellowfive@57: -- List them here for Mikk's FindGlobals script yellowfive@57: -- GLOBALS: CLOSE yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Scripts yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local function Button_OnClick(frame) yellowfive@57: PlaySound("gsTitleOptionExit") yellowfive@57: frame.obj:Hide() yellowfive@57: end yellowfive@57: yellowfive@106: local function Frame_OnShow(frame) yellowfive@106: frame.obj:Fire("OnShow") yellowfive@106: end yellowfive@106: yellowfive@57: local function Frame_OnClose(frame) yellowfive@57: frame.obj:Fire("OnClose") yellowfive@57: end yellowfive@57: yellowfive@57: local function Frame_OnMouseDown(frame) yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function Title_OnMouseDown(frame) yellowfive@57: frame:GetParent():StartMoving() yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function MoverSizer_OnMouseUp(mover) yellowfive@57: local frame = mover:GetParent() yellowfive@57: frame:StopMovingOrSizing() yellowfive@57: local self = frame.obj yellowfive@57: local status = self.status or self.localstatus yellowfive@57: status.width = frame:GetWidth() yellowfive@57: status.height = frame:GetHeight() yellowfive@57: status.top = frame:GetTop() yellowfive@57: status.left = frame:GetLeft() yellowfive@57: end yellowfive@57: yellowfive@57: local function SizerSE_OnMouseDown(frame) yellowfive@57: frame:GetParent():StartSizing("BOTTOMRIGHT") yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function SizerS_OnMouseDown(frame) yellowfive@57: frame:GetParent():StartSizing("BOTTOM") yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function SizerE_OnMouseDown(frame) yellowfive@57: frame:GetParent():StartSizing("RIGHT") yellowfive@57: AceGUI:ClearFocus() yellowfive@57: end yellowfive@57: yellowfive@57: local function StatusBar_OnEnter(frame) yellowfive@57: frame.obj:Fire("OnEnterStatusBar") yellowfive@57: end yellowfive@57: yellowfive@57: local function StatusBar_OnLeave(frame) yellowfive@57: frame.obj:Fire("OnLeaveStatusBar") yellowfive@57: end yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Methods yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local methods = { yellowfive@57: ["OnAcquire"] = function(self) yellowfive@57: self.frame:SetParent(UIParent) yellowfive@57: self.frame:SetFrameStrata("FULLSCREEN_DIALOG") yellowfive@57: self:SetTitle() yellowfive@57: self:SetStatusText() yellowfive@57: self:ApplyStatus() yellowfive@57: self:Show() yellowfive@57: self:EnableResize(true) yellowfive@57: end, yellowfive@57: yellowfive@57: ["OnRelease"] = function(self) yellowfive@57: self.status = nil yellowfive@57: wipe(self.localstatus) yellowfive@57: end, yellowfive@57: yellowfive@57: ["OnWidthSet"] = function(self, width) yellowfive@57: local content = self.content yellowfive@57: local contentwidth = width - 34 yellowfive@57: if contentwidth < 0 then yellowfive@57: contentwidth = 0 yellowfive@57: end yellowfive@57: content:SetWidth(contentwidth) yellowfive@57: content.width = contentwidth yellowfive@57: end, yellowfive@57: yellowfive@57: ["OnHeightSet"] = function(self, height) yellowfive@57: local content = self.content yellowfive@57: local contentheight = height - 57 yellowfive@57: if contentheight < 0 then yellowfive@57: contentheight = 0 yellowfive@57: end yellowfive@57: content:SetHeight(contentheight) yellowfive@57: content.height = contentheight yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetTitle"] = function(self, title) yellowfive@57: self.titletext:SetText(title) yellowfive@57: self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10) yellowfive@57: end, yellowfive@57: yellowfive@57: ["SetStatusText"] = function(self, text) yellowfive@57: self.statustext:SetText(text) yellowfive@57: end, yellowfive@57: yellowfive@57: ["Hide"] = function(self) yellowfive@57: self.frame:Hide() yellowfive@57: end, yellowfive@57: yellowfive@57: ["Show"] = function(self) yellowfive@57: self.frame:Show() yellowfive@57: end, yellowfive@57: yellowfive@57: ["EnableResize"] = function(self, state) yellowfive@57: local func = state and "Show" or "Hide" yellowfive@57: self.sizer_se[func](self.sizer_se) yellowfive@57: self.sizer_s[func](self.sizer_s) yellowfive@57: self.sizer_e[func](self.sizer_e) yellowfive@57: end, yellowfive@57: yellowfive@57: -- called to set an external table to store status in yellowfive@57: ["SetStatusTable"] = function(self, status) yellowfive@57: assert(type(status) == "table") yellowfive@57: self.status = status yellowfive@57: self:ApplyStatus() yellowfive@57: end, yellowfive@57: yellowfive@57: ["ApplyStatus"] = function(self) yellowfive@57: local status = self.status or self.localstatus yellowfive@57: local frame = self.frame yellowfive@57: self:SetWidth(status.width or 700) yellowfive@57: self:SetHeight(status.height or 500) yellowfive@57: frame:ClearAllPoints() yellowfive@57: if status.top and status.left then yellowfive@57: frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top) yellowfive@57: frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0) yellowfive@57: else yellowfive@57: frame:SetPoint("CENTER") yellowfive@57: end yellowfive@57: end yellowfive@57: } yellowfive@57: yellowfive@57: --[[----------------------------------------------------------------------------- yellowfive@57: Constructor yellowfive@57: -------------------------------------------------------------------------------]] yellowfive@57: local FrameBackdrop = { yellowfive@57: bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background", yellowfive@57: edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", yellowfive@57: tile = true, tileSize = 32, edgeSize = 32, yellowfive@57: insets = { left = 8, right = 8, top = 8, bottom = 8 } yellowfive@57: } yellowfive@57: yellowfive@57: local PaneBackdrop = { yellowfive@57: bgFile = "Interface\\ChatFrame\\ChatFrameBackground", yellowfive@57: edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", yellowfive@57: tile = true, tileSize = 16, edgeSize = 16, yellowfive@57: insets = { left = 3, right = 3, top = 5, bottom = 3 } yellowfive@57: } yellowfive@57: yellowfive@57: local function Constructor() yellowfive@57: local frame = CreateFrame("Frame", nil, UIParent) yellowfive@57: frame:Hide() yellowfive@57: yellowfive@57: frame:EnableMouse(true) yellowfive@57: frame:SetMovable(true) yellowfive@57: frame:SetResizable(true) yellowfive@57: frame:SetFrameStrata("FULLSCREEN_DIALOG") yellowfive@57: frame:SetBackdrop(FrameBackdrop) yellowfive@57: frame:SetBackdropColor(0, 0, 0, 1) yellowfive@57: frame:SetMinResize(400, 200) yellowfive@57: frame:SetToplevel(true) yellowfive@106: frame:SetScript("OnShow", Frame_OnShow) yellowfive@57: frame:SetScript("OnHide", Frame_OnClose) yellowfive@57: frame:SetScript("OnMouseDown", Frame_OnMouseDown) yellowfive@57: yellowfive@57: local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate") yellowfive@57: closebutton:SetScript("OnClick", Button_OnClick) yellowfive@57: closebutton:SetPoint("BOTTOMRIGHT", -27, 17) yellowfive@57: closebutton:SetHeight(20) yellowfive@57: closebutton:SetWidth(100) yellowfive@57: closebutton:SetText(CLOSE) yellowfive@57: yellowfive@57: local statusbg = CreateFrame("Button", nil, frame) yellowfive@57: statusbg:SetPoint("BOTTOMLEFT", 15, 15) yellowfive@57: statusbg:SetPoint("BOTTOMRIGHT", -132, 15) yellowfive@57: statusbg:SetHeight(24) yellowfive@57: statusbg:SetBackdrop(PaneBackdrop) yellowfive@57: statusbg:SetBackdropColor(0.1,0.1,0.1) yellowfive@57: statusbg:SetBackdropBorderColor(0.4,0.4,0.4) yellowfive@57: statusbg:SetScript("OnEnter", StatusBar_OnEnter) yellowfive@57: statusbg:SetScript("OnLeave", StatusBar_OnLeave) yellowfive@57: yellowfive@57: local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal") yellowfive@57: statustext:SetPoint("TOPLEFT", 7, -2) yellowfive@57: statustext:SetPoint("BOTTOMRIGHT", -7, 2) yellowfive@57: statustext:SetHeight(20) yellowfive@57: statustext:SetJustifyH("LEFT") yellowfive@57: statustext:SetText("") yellowfive@57: yellowfive@57: local titlebg = frame:CreateTexture(nil, "OVERLAY") yellowfive@57: titlebg:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") yellowfive@57: titlebg:SetTexCoord(0.31, 0.67, 0, 0.63) yellowfive@57: titlebg:SetPoint("TOP", 0, 12) yellowfive@57: titlebg:SetWidth(100) yellowfive@57: titlebg:SetHeight(40) yellowfive@57: yellowfive@57: local title = CreateFrame("Frame", nil, frame) yellowfive@57: title:EnableMouse(true) yellowfive@57: title:SetScript("OnMouseDown", Title_OnMouseDown) yellowfive@57: title:SetScript("OnMouseUp", MoverSizer_OnMouseUp) yellowfive@57: title:SetAllPoints(titlebg) yellowfive@57: yellowfive@57: local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal") yellowfive@57: titletext:SetPoint("TOP", titlebg, "TOP", 0, -14) yellowfive@57: yellowfive@57: local titlebg_l = frame:CreateTexture(nil, "OVERLAY") yellowfive@57: titlebg_l:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") yellowfive@57: titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63) yellowfive@57: titlebg_l:SetPoint("RIGHT", titlebg, "LEFT") yellowfive@57: titlebg_l:SetWidth(30) yellowfive@57: titlebg_l:SetHeight(40) yellowfive@57: yellowfive@57: local titlebg_r = frame:CreateTexture(nil, "OVERLAY") yellowfive@57: titlebg_r:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header") yellowfive@57: titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63) yellowfive@57: titlebg_r:SetPoint("LEFT", titlebg, "RIGHT") yellowfive@57: titlebg_r:SetWidth(30) yellowfive@57: titlebg_r:SetHeight(40) yellowfive@57: yellowfive@57: local sizer_se = CreateFrame("Frame", nil, frame) yellowfive@57: sizer_se:SetPoint("BOTTOMRIGHT") yellowfive@57: sizer_se:SetWidth(25) yellowfive@57: sizer_se:SetHeight(25) yellowfive@57: sizer_se:EnableMouse() yellowfive@57: sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown) yellowfive@57: sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp) yellowfive@57: yellowfive@57: local line1 = sizer_se:CreateTexture(nil, "BACKGROUND") yellowfive@57: line1:SetWidth(14) yellowfive@57: line1:SetHeight(14) yellowfive@57: line1:SetPoint("BOTTOMRIGHT", -8, 8) yellowfive@57: line1:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") yellowfive@57: local x = 0.1 * 14/17 yellowfive@57: line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) yellowfive@57: yellowfive@57: local line2 = sizer_se:CreateTexture(nil, "BACKGROUND") yellowfive@57: line2:SetWidth(8) yellowfive@57: line2:SetHeight(8) yellowfive@57: line2:SetPoint("BOTTOMRIGHT", -8, 8) yellowfive@57: line2:SetTexture("Interface\\Tooltips\\UI-Tooltip-Border") yellowfive@57: local x = 0.1 * 8/17 yellowfive@57: line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5) yellowfive@57: yellowfive@57: local sizer_s = CreateFrame("Frame", nil, frame) yellowfive@57: sizer_s:SetPoint("BOTTOMRIGHT", -25, 0) yellowfive@57: sizer_s:SetPoint("BOTTOMLEFT") yellowfive@57: sizer_s:SetHeight(25) yellowfive@57: sizer_s:EnableMouse(true) yellowfive@57: sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown) yellowfive@57: sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp) yellowfive@57: yellowfive@57: local sizer_e = CreateFrame("Frame", nil, frame) yellowfive@57: sizer_e:SetPoint("BOTTOMRIGHT", 0, 25) yellowfive@57: sizer_e:SetPoint("TOPRIGHT") yellowfive@57: sizer_e:SetWidth(25) yellowfive@57: sizer_e:EnableMouse(true) yellowfive@57: sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown) yellowfive@57: sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp) yellowfive@57: yellowfive@57: --Container Support yellowfive@57: local content = CreateFrame("Frame", nil, frame) yellowfive@57: content:SetPoint("TOPLEFT", 17, -27) yellowfive@57: content:SetPoint("BOTTOMRIGHT", -17, 40) yellowfive@57: yellowfive@57: local widget = { yellowfive@57: localstatus = {}, yellowfive@57: titletext = titletext, yellowfive@57: statustext = statustext, yellowfive@57: titlebg = titlebg, yellowfive@57: sizer_se = sizer_se, yellowfive@57: sizer_s = sizer_s, yellowfive@57: sizer_e = sizer_e, yellowfive@57: content = content, yellowfive@57: frame = frame, yellowfive@57: type = Type yellowfive@57: } yellowfive@57: for method, func in pairs(methods) do yellowfive@57: widget[method] = func yellowfive@57: end yellowfive@57: closebutton.obj, statusbg.obj = widget, widget yellowfive@57: yellowfive@57: return AceGUI:RegisterAsContainer(widget) yellowfive@57: end yellowfive@57: yellowfive@57: AceGUI:RegisterWidgetType(Type, Constructor, Version)