local h,m="\066\117\116\116\111\110",24 local t=LibStub and LibStub("\065\099\101\071\085\073-\051\046\048",true)if not t or(t:GetWidgetVersion(h)or 0)>=m then return end local a=pairs local N=_G local z,s,S=PlaySound,CreateFrame,UIParent local function g(h,...)t:ClearFocus()z(852)h.obj:Fire("\079\110\067\108\105\099\107",...)end local function i(h)h.obj:Fire("\079\110\069\110\116\101\114")end local function j(h)h.obj:Fire("\079\110\076\101\097\118\101")end local D={OnAcquire=function(h)h:SetHeight(24)h:SetWidth(200)h:SetDisabled(false)h:SetAutoWidth(false)h:SetText()end;SetText=function(h,m)h.text:SetText(m)if h.autoWidth then h:SetWidth(h.text:GetStringWidth()+30)end end,SetAutoWidth=function(h,m)h.autoWidth=m if h.autoWidth then h:SetWidth(h.text:GetStringWidth()+30)end end;SetDisabled=function(h,m)h.disabled=m if m then h.frame:Disable()else h.frame:Enable()end end}local function U()local m="\065\099\101\071\085\073\051\048\066\117\116\116\111\110"..t:GetNextWidgetNum(h)local N=s("\066\117\116\116\111\110",m,S,"\085\073\080\097\110\101\108\066\117\116\116\111\110\084\101\109\112\108\097\116\101")N:Hide()N:EnableMouse(true)N:SetScript("\079\110\067\108\105\099\107",g)N:SetScript("\079\110\069\110\116\101\114",i)N:SetScript("\079\110\076\101\097\118\101",j)local z=N:GetFontString()z:ClearAllPoints()z:SetPoint("\084\079\080\076\069\070\084",15,-1)z:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-15,1)z:SetJustifyV("\077\073\068\068\076\069")local U={text=z;frame=N;type=h}for h,m in a(D)do U[h]=m end return t:RegisterAsWidget(U)end t:RegisterWidgetType(h,U,m)
--[[-----------------------------------------------------------------------------
Button Widget
Graphical Button.
-------------------------------------------------------------------------------]]
local Type, Version = "Button", 24
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

-- Lua APIs
local pairs = pairs

-- WoW APIs
local _G = _G
local PlaySound, CreateFrame, UIParent = PlaySound, CreateFrame, UIParent

--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame, ...)
	AceGUI:ClearFocus()
	PlaySound(852) -- SOUNDKIT.IG_MAINMENU_OPTION
	frame.obj:Fire("OnClick", ...)
end

local function Control_OnEnter(frame)
	frame.obj:Fire("OnEnter")
end

local function Control_OnLeave(frame)
	frame.obj:Fire("OnLeave")
end

--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
	["OnAcquire"] = function(self)
		-- restore default values
		self:SetHeight(24)
		self:SetWidth(200)
		self:SetDisabled(false)
		self:SetAutoWidth(false)
		self:SetText()
	end,

	-- ["OnRelease"] = nil,

	["SetText"] = function(self, text)
		self.text:SetText(text)
		if self.autoWidth then
			self:SetWidth(self.text:GetStringWidth() + 30)
		end
	end,

	["SetAutoWidth"] = function(self, autoWidth)
		self.autoWidth = autoWidth
		if self.autoWidth then
			self:SetWidth(self.text:GetStringWidth() + 30)
		end
	end,

	["SetDisabled"] = function(self, disabled)
		self.disabled = disabled
		if disabled then
			self.frame:Disable()
		else
			self.frame:Enable()
		end
	end
}

--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local function Constructor()
	local name = "AceGUI30Button" .. AceGUI:GetNextWidgetNum(Type)
	local frame = CreateFrame("Button", name, UIParent, "UIPanelButtonTemplate")
	frame:Hide()

	frame:EnableMouse(true)
	frame:SetScript("OnClick", Button_OnClick)
	frame:SetScript("OnEnter", Control_OnEnter)
	frame:SetScript("OnLeave", Control_OnLeave)

	local text = frame:GetFontString()
	text:ClearAllPoints()
	text:SetPoint("TOPLEFT", 15, -1)
	text:SetPoint("BOTTOMRIGHT", -15, 1)
	text:SetJustifyV("MIDDLE")

	local widget = {
		text  = text,
		frame = frame,
		type  = Type
	}
	for method, func in pairs(methods) do
		widget[method] = func
	end

	return AceGUI:RegisterAsWidget(widget)
end

AceGUI:RegisterWidgetType(Type, Constructor, Version)
