Toolkit.lua 14.9 KB
Newer Older
Azilroka's avatar
Azilroka committed
1
local E, L, V, P, G = unpack(select(2, ...)); --Import: Engine, Locales, PrivateDB, ProfileDB, GlobalDB
2
local UF = E:GetModule('UnitFrames')
Azilroka's avatar
Azilroka committed
3
local NP = E:GetModule('NamePlates')
Elv's avatar
Elv committed
4

5
local _G = _G
Simpy's avatar
Simpy committed
6
local pairs, pcall = pairs, pcall
Simpy's avatar
stuff  
Simpy committed
7
local unpack, type, select, getmetatable = unpack, type, select, getmetatable
8
local EnumerateFrames = EnumerateFrames
Simpy's avatar
Simpy committed
9
local hooksecurefunc = hooksecurefunc
Simpy's avatar
stuff  
Simpy committed
10
local CreateFrame = CreateFrame
11

12 13
local backdropr, backdropg, backdropb, backdropa = 0, 0, 0, 1
local borderr, borderg, borderb, bordera = 0, 0, 0, 1
Simpy's avatar
Simpy committed
14

15
-- 8.2 restricted frame check
Azilroka's avatar
Azilroka committed
16
function E:SetPointsRestricted(frame)
17
	if frame and not pcall(frame.GetPoint, frame) then
18 19 20 21
		return true
	end
end

22
function E:SafeGetPoint(frame)
Azilroka's avatar
Azilroka committed
23
	if frame and frame.GetPoint and not E:SetPointsRestricted(frame) then
24 25 26 27
		return frame:GetPoint()
	end
end

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
local function WatchPixelSnap(frame, snap)
	if (frame and not frame:IsForbidden()) and frame.PixelSnapDisabled and snap then
		frame.PixelSnapDisabled = nil
	end
end

local function DisablePixelSnap(frame)
	if (frame and not frame:IsForbidden()) and not frame.PixelSnapDisabled then
		if frame.SetSnapToPixelGrid then
			frame:SetSnapToPixelGrid(false)
			frame:SetTexelSnappingBias(0)
		elseif frame.GetStatusBarTexture then
			local texture = frame:GetStatusBarTexture()
			if texture and texture.SetSnapToPixelGrid then
				texture:SetSnapToPixelGrid(false)
				texture:SetTexelSnappingBias(0)
			end
		end

		frame.PixelSnapDisabled = true
	end
end

51
local function GetTemplate(template, isUnitFrameElement)
52
	backdropa, bordera = 1, 1
Blazeflack's avatar
Blazeflack committed
53

54
	if template == 'ClassColor' then
55
		local color = E:ClassColor(E.myclass)
Simpy's avatar
Simpy committed
56
		borderr, borderg, borderb = color.r, color.g, color.b
Simpy's avatar
Simpy committed
57
		backdropr, backdropg, backdropb = unpack(E.media.backdropcolor)
58
	elseif template == 'Transparent' then
Simpy's avatar
Simpy committed
59
		borderr, borderg, borderb = unpack(isUnitFrameElement and E.media.unitframeBorderColor or E.media.bordercolor)
Simpy's avatar
Simpy committed
60
		backdropr, backdropg, backdropb, backdropa = unpack(E.media.backdropfadecolor)
Elv's avatar
Elv committed
61
	else
Simpy's avatar
Simpy committed
62
		borderr, borderg, borderb = unpack(isUnitFrameElement and E.media.unitframeBorderColor or E.media.bordercolor)
Simpy's avatar
Simpy committed
63
		backdropr, backdropg, backdropb = unpack(E.media.backdropcolor)
Elv's avatar
Elv committed
64 65 66
	end
end

67
local function Size(frame, width, height, ...)
Simpy's avatar
Simpy committed
68 69
	local w = E:Scale(width)
	frame:SetSize(w, (height and E:Scale(height)) or w, ...)
Elv's avatar
Elv committed
70 71
end

72
local function Width(frame, width, ...)
Simpy's avatar
Simpy committed
73
	frame:SetWidth(E:Scale(width), ...)
74 75 76
end

local function Height(frame, height, ...)
Simpy's avatar
Simpy committed
77
	frame:SetHeight(E:Scale(height), ...)
78 79 80
end

local function Point(obj, arg1, arg2, arg3, arg4, arg5, ...)
Simpy's avatar
Simpy committed
81
	if not arg2 then arg2 = obj:GetParent() end
Simpy's avatar
Simpy committed
82

Simpy's avatar
Simpy committed
83 84 85 86 87
	if type(arg2)=='number' then arg2 = E:Scale(arg2) end
	if type(arg3)=='number' then arg3 = E:Scale(arg3) end
	if type(arg4)=='number' then arg4 = E:Scale(arg4) end
	if type(arg5)=='number' then arg5 = E:Scale(arg5) end

88 89 90
	obj:SetPoint(arg1, arg2, arg3, arg4, arg5, ...)
end

91
local function SetOutside(obj, anchor, xOffset, yOffset, anchor2, noScale)
Simpy's avatar
Simpy committed
92 93
	if not anchor then anchor = obj:GetParent() end

94 95 96 97
	if not xOffset then xOffset = E.Border end
	if not yOffset then yOffset = E.Border end
	local x = (noScale and xOffset) or E:Scale(xOffset)
	local y = (noScale and yOffset) or E:Scale(yOffset)
Rubgrsch's avatar
Rubgrsch committed
98

Azilroka's avatar
Azilroka committed
99
	if E:SetPointsRestricted(obj) or obj:GetPoint() then
Elv's avatar
Elv committed
100 101
		obj:ClearAllPoints()
	end
102

103
	DisablePixelSnap(obj)
104 105
	obj:SetPoint('TOPLEFT', anchor, 'TOPLEFT', -x, y)
	obj:SetPoint('BOTTOMRIGHT', anchor2 or anchor, 'BOTTOMRIGHT', x, -y)
Elv's avatar
Elv committed
106 107
end

108
local function SetInside(obj, anchor, xOffset, yOffset, anchor2, noScale)
Simpy's avatar
Simpy committed
109 110
	if not anchor then anchor = obj:GetParent() end

111 112 113 114
	if not xOffset then xOffset = E.Border end
	if not yOffset then yOffset = E.Border end
	local x = (noScale and xOffset) or E:Scale(xOffset)
	local y = (noScale and yOffset) or E:Scale(yOffset)
Rubgrsch's avatar
Rubgrsch committed
115

Azilroka's avatar
Azilroka committed
116
	if E:SetPointsRestricted(obj) or obj:GetPoint() then
Elv's avatar
Elv committed
117 118
		obj:ClearAllPoints()
	end
119

120
	DisablePixelSnap(obj)
121 122
	obj:SetPoint('TOPLEFT', anchor, 'TOPLEFT', x, -y)
	obj:SetPoint('BOTTOMRIGHT', anchor2 or anchor, 'BOTTOMRIGHT', -x, y)
Elv's avatar
Elv committed
123 124
end

Azilroka's avatar
Azilroka committed
125
local function SetTemplate(frame, template, glossTex, ignoreUpdates, forcePixelMode, isUnitFrameElement, isNamePlateElement)
126
	GetTemplate(template, isUnitFrameElement)
127

128
	frame.template = template or 'Default'
Simpy's avatar
Simpy committed
129 130 131 132
	frame.glossTex = glossTex
	frame.ignoreUpdates = ignoreUpdates
	frame.forcePixelMode = forcePixelMode
	frame.isUnitFrameElement = isUnitFrameElement
Azilroka's avatar
Azilroka committed
133
	frame.isNamePlateElement = isNamePlateElement
134

135
	if template == 'NoBackdrop' then
Simpy's avatar
Simpy committed
136
		frame:SetBackdrop()
Simpy's avatar
Simpy committed
137
	else
Simpy's avatar
Simpy committed
138 139 140 141 142
		frame:SetBackdrop({
			edgeFile = E.media.blankTex,
			bgFile = glossTex and (type(glossTex) == 'string' and glossTex or E.media.glossTex) or E.media.blankTex,
			edgeSize = E:Scale(E.twoPixelsPlease and 2 or 1)
		})
143

144 145
		if frame.callbackBackdropColor then
			frame:callbackBackdropColor()
146
		else
147
			frame:SetBackdropColor(backdropr, backdropg, backdropb, frame.customBackdropAlpha or (template == 'Transparent' and backdropa) or 1)
148 149
		end

Simpy's avatar
Simpy committed
150
		local notPixelMode = not isUnitFrameElement and not isNamePlateElement and not E.PixelMode
Simpy's avatar
Simpy committed
151
		local notThinBorders = (isUnitFrameElement and not UF.thinBorders) or (isNamePlateElement and not NP.thinBorders)
Simpy's avatar
Simpy committed
152
		if (notPixelMode or notThinBorders) and not forcePixelMode then
Simpy's avatar
Simpy committed
153 154 155 156
			local backdrop = {
				edgeFile = E.media.blankTex,
				edgeSize = E:Scale(1)
			}
Simpy's avatar
Simpy committed
157

158
			if not frame.iborder then
Simpy's avatar
Simpy committed
159
				local border = CreateFrame('Frame', nil, frame, 'BackdropTemplate')
Simpy's avatar
Simpy committed
160
				border:SetBackdrop(backdrop)
Simpy's avatar
Simpy committed
161
				border:SetBackdropBorderColor(0, 0, 0, 1)
Simpy's avatar
Simpy committed
162
				border:SetInside(frame, 1, 1)
163
				frame.iborder = border
164
			end
165

166
			if not frame.oborder then
Simpy's avatar
Simpy committed
167
				local border = CreateFrame('Frame', nil, frame, 'BackdropTemplate')
Simpy's avatar
Simpy committed
168
				border:SetBackdrop(backdrop)
Simpy's avatar
Simpy committed
169
				border:SetBackdropBorderColor(0, 0, 0, 1)
Simpy's avatar
Simpy committed
170
				border:SetOutside(frame, 1, 1)
171
				frame.oborder = border
172
			end
Blazeflack's avatar
Blazeflack committed
173
		end
Elv's avatar
Elv committed
174
	end
175

176 177
	if frame.forcedBorderColors then
		borderr, borderg, borderb, bordera = unpack(frame.forcedBorderColors)
178
	end
179

180 181
	frame:SetBackdropBorderColor(borderr, borderg, borderb, bordera)

182 183 184
	if not frame.ignoreUpdates then
		if frame.isUnitFrameElement then
			E.unitFrameElements[frame] = true
185
		else
186
			E.frames[frame] = true
187
		end
Elv's avatar
Elv committed
188 189 190
	end
end

Simpy's avatar
Simpy committed
191
local function CreateBackdrop(frame, template, glossTex, ignoreUpdates, forcePixelMode, isUnitFrameElement, isNamePlateElement, allPoints, frameLevel)
192
	local parent = (frame.IsObjectType and frame:IsObjectType('Texture') and frame:GetParent()) or frame
Simpy's avatar
Simpy committed
193
	local backdrop = frame.backdrop or CreateFrame('Frame', nil, parent, 'BackdropTemplate')
194
	if not frame.backdrop then frame.backdrop = backdrop end
195

Simpy's avatar
Simpy committed
196 197
	backdrop:SetTemplate(template, glossTex, ignoreUpdates, forcePixelMode, isUnitFrameElement, isNamePlateElement)

Simpy's avatar
Simpy committed
198 199
	if allPoints then
		if allPoints == true then
Simpy's avatar
Simpy committed
200 201
			backdrop:SetAllPoints()
		else
Simpy's avatar
Simpy committed
202
			backdrop:SetAllPoints(allPoints)
Simpy's avatar
Simpy committed
203
		end
Blazeflack's avatar
Blazeflack committed
204
	else
205 206 207 208 209 210
		if forcePixelMode then
			backdrop:SetOutside(frame, E.twoPixelsPlease and 2 or 1, E.twoPixelsPlease and 2 or 1)
		else
			local border = (isUnitFrameElement and UF.BORDER) or (isNamePlateElement and NP.BORDER)
			backdrop:SetOutside(frame, border, border)
		end
Blazeflack's avatar
Blazeflack committed
211
	end
212

Simpy's avatar
Simpy committed
213 214
	if frameLevel then
		if frameLevel == true then
Simpy's avatar
Simpy committed
215 216
			backdrop:SetFrameLevel(parent:GetFrameLevel())
		else
Simpy's avatar
Simpy committed
217
			backdrop:SetFrameLevel(frameLevel)
Simpy's avatar
Simpy committed
218
		end
Elv's avatar
Elv committed
219
	else
Simpy's avatar
Simpy committed
220 221 222 223
		local level = parent:GetFrameLevel()
		local minus = level and (level - 1)
		if minus and (minus >= 0) then
			backdrop:SetFrameLevel(minus)
Simpy's avatar
Simpy committed
224 225 226
		else
			backdrop:SetFrameLevel(0)
		end
Elv's avatar
Elv committed
227 228 229
	end
end

230 231
local function CreateShadow(frame, size, pass)
	if not pass and frame.shadow then return end
232
	if not size then size = 3 end
233

Simpy's avatar
Simpy committed
234
	backdropr, backdropg, backdropb, borderr, borderg, borderb = 0, 0, 0, 0, 0, 0
Elv's avatar
Elv committed
235

236
	local offset = (E.PixelMode and size) or (size + 1)
Simpy's avatar
Simpy committed
237
	local shadow = CreateFrame('Frame', nil, frame, 'BackdropTemplate')
Elv's avatar
Elv committed
238
	shadow:SetFrameLevel(1)
239
	shadow:SetFrameStrata(frame:GetFrameStrata())
240
	shadow:SetOutside(frame, offset, offset, nil, true)
Simpy's avatar
Simpy committed
241
	shadow:SetBackdrop({edgeFile = E.Media.Textures.GlowTex, edgeSize = size})
242 243
	shadow:SetBackdropColor(backdropr, backdropg, backdropb, 0)
	shadow:SetBackdropBorderColor(borderr, borderg, borderb, 0.9)
244 245 246 247 248 249

	if pass then
		return shadow
	else
		frame.shadow = shadow
	end
Elv's avatar
Elv committed
250 251 252 253 254 255 256 257 258
end

local function Kill(object)
	if object.UnregisterAllEvents then
		object:UnregisterAllEvents()
		object:SetParent(E.HiddenFrame)
	else
		object.Show = object.Hide
	end
259

Elv's avatar
Elv committed
260 261 262
	object:Hide()
end

Simpy's avatar
Simpy committed
263
local StripTexturesBlizzFrames = {
264 265 266 267 268 269
	'Inset',
	'inset',
	'InsetFrame',
	'LeftInset',
	'RightInset',
	'NineSlice',
270 271 272
	'BG',
	'border',
	'Border',
273 274 275 276 277 278
	'BorderFrame',
	'bottomInset',
	'BottomInset',
	'bgLeft',
	'bgRight',
	'FilligreeOverlay',
Azilroka's avatar
Azilroka committed
279 280 281 282
	'PortraitOverlay',
	'ArtOverlayFrame',
	'Portrait',
	'portrait',
283
	'ScrollFrameBorder',
284 285
}

Simpy's avatar
Simpy committed
286 287
local STRIP_TEX = 'Texture'
local STRIP_FONT = 'FontString'
Simpy's avatar
Simpy committed
288
local function StripRegion(which, object, kill, alpha)
Simpy's avatar
Simpy committed
289 290 291
	if kill then
		object:Kill()
	elseif which == STRIP_TEX then
Simpy's avatar
Simpy committed
292 293
		object:SetTexture('')
		object:SetAtlas('')
Simpy's avatar
Simpy committed
294
	elseif which == STRIP_FONT then
295
		object:SetText('')
Simpy's avatar
Simpy committed
296
	end
297 298 299 300

	if alpha then
		object:SetAlpha(0)
	end
Simpy's avatar
Simpy committed
301
end
Azilroka's avatar
Azilroka committed
302

Simpy's avatar
Simpy committed
303 304 305 306 307 308 309 310
local function StripType(which, object, kill, alpha)
	if object:IsObjectType(which) then
		StripRegion(which, object, kill, alpha)
	else
		if which == STRIP_TEX then
			local FrameName = object.GetName and object:GetName()
			for _, Blizzard in pairs(StripTexturesBlizzFrames) do
				local BlizzFrame = object[Blizzard] or (FrameName and _G[FrameName..Blizzard])
Simpy's avatar
Simpy committed
311
				if BlizzFrame and BlizzFrame.StripTextures then
Simpy's avatar
Simpy committed
312 313
					BlizzFrame:StripTextures(kill, alpha)
				end
Azilroka's avatar
Azilroka committed
314
			end
315 316
		end

Azilroka's avatar
Azilroka committed
317 318 319
		if object.GetNumRegions then
			for i = 1, object:GetNumRegions() do
				local region = select(i, object:GetRegions())
Simpy's avatar
Simpy committed
320 321
				if region and region.IsObjectType and region:IsObjectType(which) then
					StripRegion(which, region, kill, alpha)
322
				end
Elv's avatar
Elv committed
323 324
			end
		end
Elv's avatar
Elv committed
325
	end
Elv's avatar
Elv committed
326 327
end

Simpy's avatar
Simpy committed
328 329 330 331
local function StripTextures(object, kill, alpha)
	StripType(STRIP_TEX, object, kill, alpha)
end

Elv's avatar
Elv committed
332
local function StripTexts(object, kill, alpha)
Simpy's avatar
Simpy committed
333
	StripType(STRIP_FONT, object, kill, alpha)
Elv's avatar
Elv committed
334 335
end

336 337 338 339 340 341
local function FontTemplate(fs, font, size, style, skip)
	if not skip then -- ignore updates from UpdateFontTemplates
		fs.font, fs.fontSize, fs.fontStyle = font, size, style
	end

	fs:SetFont(font or E.media.normFont, size or E.db.general.fontSize, style or E.db.general.fontStyle)
Simpy's avatar
Simpy committed
342

343
	if style == 'NONE' then
Simpy's avatar
Simpy committed
344
		fs:SetShadowOffset(1, -0.5)
Simpy's avatar
Simpy committed
345 346 347 348 349
		fs:SetShadowColor(0, 0, 0, 1)
	else
		fs:SetShadowOffset(0, 0)
		fs:SetShadowColor(0, 0, 0, 0)
	end
Azilroka's avatar
Azilroka committed
350

Simpy's avatar
Simpy committed
351
	E.texts[fs] = true
Elv's avatar
Elv committed
352 353
end

354
local function StyleButton(button, noHover, noPushed, noChecked)
Elv's avatar
Elv committed
355
	if button.SetHighlightTexture and not button.hover and not noHover then
356
		local hover = button:CreateTexture()
Elv's avatar
Elv committed
357
		hover:SetInside()
Simpy's avatar
Simpy committed
358
		hover:SetBlendMode('ADD')
Simpy's avatar
Simpy committed
359
		hover:SetColorTexture(1, 1, 1, 0.3)
Elv's avatar
Elv committed
360
		button:SetHighlightTexture(hover)
Simpy's avatar
Simpy committed
361
		button.hover = hover
Elv's avatar
Elv committed
362
	end
363

Elv's avatar
Elv committed
364
	if button.SetPushedTexture and not button.pushed and not noPushed then
365
		local pushed = button:CreateTexture()
Elv's avatar
Elv committed
366
		pushed:SetInside()
Simpy's avatar
Simpy committed
367
		pushed:SetBlendMode('ADD')
Simpy's avatar
Simpy committed
368
		pushed:SetColorTexture(0.9, 0.8, 0.1, 0.3)
Elv's avatar
Elv committed
369
		button:SetPushedTexture(pushed)
Simpy's avatar
Simpy committed
370
		button.pushed = pushed
Elv's avatar
Elv committed
371
	end
372

Elv's avatar
Elv committed
373
	if button.SetCheckedTexture and not button.checked and not noChecked then
374
		local checked = button:CreateTexture()
Elv's avatar
Elv committed
375
		checked:SetInside()
Simpy's avatar
Simpy committed
376
		checked:SetBlendMode('ADD')
Simpy's avatar
Simpy committed
377
		checked:SetColorTexture(1, 1, 1, 0.3)
Elv's avatar
Elv committed
378
		button:SetCheckedTexture(checked)
Simpy's avatar
Simpy committed
379
		button.checked = checked
Elv's avatar
Elv committed
380
	end
381

Simpy's avatar
Simpy committed
382
	local name = button.GetName and button:GetName()
Simpy's avatar
Simpy committed
383
	local cooldown = name and _G[name..'Cooldown']
384
	if cooldown then
Elv's avatar
Elv committed
385
		cooldown:ClearAllPoints()
Elv's avatar
Elv committed
386
		cooldown:SetInside()
387
		cooldown:SetDrawEdge(false)
388
		cooldown:SetSwipeColor(0, 0, 0, 1)
Elv's avatar
Elv committed
389 390 391
	end
end

Simpy's avatar
Simpy committed
392 393 394 395 396 397
local CreateCloseButton
do
	local CloseButtonOnClick = function(btn) btn:GetParent():Hide() end
	local CloseButtonOnEnter = function(btn) if btn.Texture then btn.Texture:SetVertexColor(unpack(E.media.rgbvaluecolor)) end end
	local CloseButtonOnLeave = function(btn) if btn.Texture then btn.Texture:SetVertexColor(1, 1, 1) end end
	CreateCloseButton = function(frame, size, offset, texture, backdrop)
398 399
		if frame.CloseButton then return end

400
		local CloseButton = CreateFrame('Button', nil, frame)
Simpy's avatar
Simpy committed
401 402
		CloseButton:Size(size or 16)
		CloseButton:Point('TOPRIGHT', offset or -6, offset or -6)
403 404 405
		if backdrop then
			CloseButton:CreateBackdrop(nil, true)
		end
Blazeflack's avatar
Blazeflack committed
406

Simpy's avatar
Simpy committed
407
		CloseButton.Texture = CloseButton:CreateTexture(nil, 'OVERLAY')
Simpy's avatar
Simpy committed
408
		CloseButton.Texture:SetAllPoints()
409
		CloseButton.Texture:SetTexture(texture or E.Media.Textures.Close)
Simpy's avatar
Simpy committed
410

Simpy's avatar
Simpy committed
411 412 413
		CloseButton:SetScript('OnClick', CloseButtonOnClick)
		CloseButton:SetScript('OnEnter', CloseButtonOnEnter)
		CloseButton:SetScript('OnLeave', CloseButtonOnLeave)
Blazeflack's avatar
Blazeflack committed
414

Simpy's avatar
Simpy committed
415 416
		frame.CloseButton = CloseButton
	end
Blazeflack's avatar
Blazeflack committed
417 418
end

419
local function GetNamedChild(frame, childName, index)
Simpy's avatar
Simpy committed
420
	local name = frame and frame.GetName and frame:GetName()
Simpy's avatar
Simpy committed
421
	if not name or not childName then return nil end
Simpy's avatar
Simpy committed
422
	return _G[name..childName..(index or '')]
Nihilistzsche's avatar
Nihilistzsche committed
423 424
end

Elv's avatar
Elv committed
425 426 427 428
local function addapi(object)
	local mt = getmetatable(object).__index
	if not object.Size then mt.Size = Size end
	if not object.Point then mt.Point = Point end
Elv's avatar
Elv committed
429 430
	if not object.SetOutside then mt.SetOutside = SetOutside end
	if not object.SetInside then mt.SetInside = SetInside end
Elv's avatar
Elv committed
431 432 433 434 435 436 437 438
	if not object.SetTemplate then mt.SetTemplate = SetTemplate end
	if not object.CreateBackdrop then mt.CreateBackdrop = CreateBackdrop end
	if not object.CreateShadow then mt.CreateShadow = CreateShadow end
	if not object.Kill then mt.Kill = Kill end
	if not object.Width then mt.Width = Width end
	if not object.Height then mt.Height = Height end
	if not object.FontTemplate then mt.FontTemplate = FontTemplate end
	if not object.StripTextures then mt.StripTextures = StripTextures end
Elv's avatar
Elv committed
439
	if not object.StripTexts then mt.StripTexts = StripTexts end
Elv's avatar
Elv committed
440
	if not object.StyleButton then mt.StyleButton = StyleButton end
Blazeflack's avatar
Blazeflack committed
441
	if not object.CreateCloseButton then mt.CreateCloseButton = CreateCloseButton end
Nihilistzsche's avatar
Nihilistzsche committed
442
	if not object.GetNamedChild then mt.GetNamedChild = GetNamedChild end
443 444 445 446 447 448 449 450 451 452
	if not object.DisabledPixelSnap and (mt.SetSnapToPixelGrid or mt.SetStatusBarTexture or mt.SetColorTexture or mt.SetVertexColor or mt.CreateTexture or mt.SetTexCoord or mt.SetTexture) then
		if mt.SetSnapToPixelGrid then hooksecurefunc(mt, 'SetSnapToPixelGrid', WatchPixelSnap) end
		if mt.SetStatusBarTexture then hooksecurefunc(mt, 'SetStatusBarTexture', DisablePixelSnap) end
		if mt.SetColorTexture then hooksecurefunc(mt, 'SetColorTexture', DisablePixelSnap) end
		if mt.SetVertexColor then hooksecurefunc(mt, 'SetVertexColor', DisablePixelSnap) end
		if mt.CreateTexture then hooksecurefunc(mt, 'CreateTexture', DisablePixelSnap) end
		if mt.SetTexCoord then hooksecurefunc(mt, 'SetTexCoord', DisablePixelSnap) end
		if mt.SetTexture then hooksecurefunc(mt, 'SetTexture', DisablePixelSnap) end
		mt.DisabledPixelSnap = true
	end
Elv's avatar
Elv committed
453 454
end

Simpy's avatar
nothing  
Simpy committed
455
local handled = {Frame = true}
456
local object = CreateFrame('Frame')
Elv's avatar
Elv committed
457 458 459
addapi(object)
addapi(object:CreateTexture())
addapi(object:CreateFontString())
460
addapi(object:CreateMaskTexture())
Elv's avatar
Elv committed
461 462 463

object = EnumerateFrames()
while object do
464
	if not object:IsForbidden() and not handled[object:GetObjectType()] then
Elv's avatar
Elv committed
465 466 467
		addapi(object)
		handled[object:GetObjectType()] = true
	end
468

Elv's avatar
Elv committed
469
	object = EnumerateFrames(object)
470 471
end

472 473
addapi(_G.GameFontNormal) --Add API to `CreateFont` objects without actually creating one
addapi(CreateFrame('ScrollFrame')) --Hacky fix for issue on 7.1 PTR where scroll frames no longer seem to inherit the methods from the 'Frame' widget