PageRenderTime 259ms CodeModel.GetById 83ms app.highlight 9ms RepoModel.GetById 84ms app.codeStats 0ms

/Tukui/core/deprecated.lua

http://github.com/Asphyxia/Tukui
Lua | 150 lines | 124 code | 14 blank | 12 comment | 5 complexity | 15bc15ff526dbfe7c917b917366aac36 MD5 | raw file
  1--[[	
  2		In computer software or authoring programs standards and documentation, 
  3		the term deprecation is applied to software features that are superseded 
  4		and should be avoided. Although deprecated features remain in the current 
  5		version, their use may raise warning messages recommending alternative practices, 
  6		and deprecation may indicate that the feature will be removed in the future. 
  7		Features are deprecated�rather than being removed�in order to provide 
  8		backward compatibility and give programmers who have used the feature time to
  9		bring their code into compliance with the new standard.
 10--]]
 11
 12local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
 13
 14-- pixel perfect script of custom ui scale.
 15local mult = 768/string.match(GetCVar("gxResolution"), "%d+x(%d+)")/C["general"].uiscale
 16local scale = function(x)
 17    return mult*math.floor(x/mult+.5)
 18end
 19
 20T.Scale = function(x) return scale(x) end
 21T.mult = mult
 22
 23T.CreatePanel = function(f, w, h, a1, p, a2, x, y)
 24	local sh = scale(h)
 25	local sw = scale(w)
 26	f:SetFrameLevel(1)
 27	f:SetHeight(sh)
 28	f:SetWidth(sw)
 29	f:SetFrameStrata("BACKGROUND")
 30	f:SetPoint(a1, p, a2, x, y)
 31	f:SetBackdrop({
 32	  bgFile = C["media"].blank, 
 33	  edgeFile = C["media"].blank, 
 34	  tile = false, tileSize = 0, edgeSize = mult, 
 35	  insets = { left = -mult, right = -mult, top = -mult, bottom = -mult}
 36	})
 37	f:SetBackdropColor(unpack(C["media"].backdropcolor))
 38	f:SetBackdropBorderColor(unpack(C["media"].bordercolor))
 39end
 40
 41T.CreateTransparentPanel = function(f, w, h, a1, p, a2, x, y)
 42	if t == "Tukui" then
 43		local sh = Scale(h)
 44		local sw = Scale(w)
 45		f:SetFrameLevel(1)
 46		f:SetHeight(sh)
 47		f:SetWidth(sw)
 48		f:SetFrameStrata("BACKGROUND")
 49		f:SetPoint(a1, p, a2, x, y)
 50		f:SetBackdrop({
 51		  bgFile = C["media"].blank,
 52		  edgeFile = C["media"].blank,
 53		  tile = false, tileSize = 0, edgeSize = mult,
 54		  insets = { left = T.Scale(2), right = T.Scale(2), top = T.Scale(2), bottom = T.Scale(2)}
 55		})
 56		f:SetBackdropColor(.075,.075,.075,.8) -- (red, green, blue, alpha)
 57		f:SetBackdropBorderColor(unpack(C["media"].bordercolor))
 58
 59		local border = CreateFrame("Frame", nil, f)
 60		border:SetFrameLevel(0)
 61		border:SetPoint("TOPLEFT", f, "TOPLEFT", T.Scale(-1), T.Scale(1))
 62		border:SetFrameStrata("BACKGROUND")
 63		border:SetBackdrop {
 64			edgeFile = C["media"].blank, edgeSize = T.Scale(3),
 65			insets = {left = 0, right = 0, top = 0, bottom = 0}
 66		}
 67		border:SetBackdropColor(unpack(C["media"].backdropcolor))
 68		border:SetBackdropBorderColor(unpack(C["media"].backdropcolor))
 69		border:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", T.Scale(1), T.Scale(-1))
 70	end
 71end
 72
 73T.SetTemplate = function(f)
 74	f:SetBackdrop({
 75	  bgFile = C["media"].blank, 
 76	  edgeFile = C["media"].blank, 
 77	  tile = false, tileSize = 0, edgeSize = mult, 
 78	  insets = { left = -mult, right = -mult, top = -mult, bottom = -mult}
 79	})
 80	f:SetBackdropColor(unpack(C["media"].backdropcolor))
 81	f:SetBackdropBorderColor(unpack(C["media"].bordercolor))
 82end
 83
 84T.CreateShadow = function(f)
 85	if f.shadow then return end -- we seriously don't want to create shadow 2 times in a row on the same frame.
 86	local shadow = CreateFrame("Frame", nil, f)
 87	shadow:SetFrameLevel(1)
 88	shadow:SetFrameStrata(f:GetFrameStrata())
 89	shadow:SetPoint("TOPLEFT", T.Scale(-4), T.Scale(4))
 90	shadow:SetPoint("BOTTOMLEFT", T.Scale(-4), T.Scale(-4))
 91	shadow:SetPoint("TOPRIGHT", T.Scale(4), T.Scale(4))
 92	shadow:SetPoint("BOTTOMRIGHT", T.Scale(4), T.Scale(-4))
 93	shadow:SetBackdrop( { 
 94		edgeFile = C["media"].glowTex, edgeSize = T.Scale(3),
 95		insets = {left = T.Scale(5), right = T.Scale(5), top = T.Scale(5), bottom = T.Scale(5)},
 96	})
 97	shadow:SetBackdropColor(0, 0, 0, 0)
 98	shadow:SetBackdropBorderColor(0, 0, 0, 0.5)
 99	f.shadow = shadow
100end
101
102T.Kill = function(object)
103	if object.UnregisterAllEvents then
104		object:UnregisterAllEvents()
105	end
106	object.Show = T.dummy
107	object:Hide()
108end
109
110-- styleButton function authors are Chiril & Karudon.
111T.StyleButton = function(b, checked) 
112    local name = b:GetName()
113 
114    local button          = _G[name]
115    local icon            = _G[name.."Icon"]
116    local count           = _G[name.."Count"]
117    local border          = _G[name.."Border"]
118    local hotkey          = _G[name.."HotKey"]
119    local cooldown        = _G[name.."Cooldown"]
120    local nametext        = _G[name.."Name"]
121    local flash           = _G[name.."Flash"]
122    local normaltexture   = _G[name.."NormalTexture"]
123	local icontexture     = _G[name.."IconTexture"]
124
125	local hover = b:CreateTexture("frame", nil, self) -- hover
126	hover:SetTexture(1,1,1,0.3)
127	hover:SetHeight(button:GetHeight())
128	hover:SetWidth(button:GetWidth())
129	hover:Point("TOPLEFT",button,2,-2)
130	hover:Point("BOTTOMRIGHT",button,-2,2)
131	button:SetHighlightTexture(hover)
132
133	local pushed = b:CreateTexture("frame", nil, self) -- pushed
134	pushed:SetTexture(0.9,0.8,0.1,0.3)
135	pushed:SetHeight(button:GetHeight())
136	pushed:SetWidth(button:GetWidth())
137	pushed:Point("TOPLEFT",button,2,-2)
138	pushed:Point("BOTTOMRIGHT",button,-2,2)
139	button:SetPushedTexture(pushed)
140 
141	if checked then
142		local checked = b:CreateTexture("frame", nil, self) -- checked
143		checked:SetTexture(0,1,0,0.3)
144		checked:SetHeight(button:GetHeight())
145		checked:SetWidth(button:GetWidth())
146		checked:Point("TOPLEFT",button,2,-2)
147		checked:Point("BOTTOMRIGHT",button,-2,2)
148		button:SetCheckedTexture(checked)
149	end
150end