PageRenderTime 119ms CodeModel.GetById 60ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 1ms

/TelUI_AddonSkins/skins/QBar.lua

http://github.com/Asphyxia/Tukui
Lua | 60 lines | 46 code | 2 blank | 12 comment | 8 complexity | ac0d8e92767f4e8255de8a8d9d669311 MD5 | raw file
 1--[[
 2	QBar Skin by Darth Android / Telroth - The Venture Co.
 3	
 4	Skins QBar to look like TelUI.
 5	
 6	Todo:
 7	 + Reorganize to support skin subclass overrides
 8	 + Reorganize to support layout subclass overrides
 9	 
10	(C)2010 Darth Android / Telroth - The Venture Co.
11	File version v91.109
12]]
13
14if not Mod_AddonSkins or not QBar then return end
15local QBar = _G["QBar"]
16local db = _G["QBar_Config"] or {error = true}
17
18Mod_AddonSkins:RegisterSkin("QBar",function(Skin,skin,Layout,layout,config)
19	QBar.UpdateButtons_  = QBar.UpdateButtons
20	QBar.UpdateButtons = function()
21		local self = QBar
22		db.padding = config.buttonSpacing
23		db.scale = 1
24		db.btnSize = config.buttonSize
25		if not InCombatLockdown() then
26			self:SetScale(db.scale)
27		end
28		self:UpdateButtons_()
29		if not self.bg and #self.items > 0 then
30			self.bg = CreateFrame("Frame",nil,self.items[1])
31			skin:SkinBackgroundFrame(self.bg)
32			self.bg:SetFrameStrata("BACKGROUND")
33			if not db.mirrored then
34				self.bg:SetPoint("TOPLEFT",self.items[1],"TOPLEFT",-config.buttonSpacing,config.buttonSpacing)
35			else
36				self.bg:SetPoint("BOTTOMRIGHT",self.items[1],"BOTTOMRIGHT",config.buttonSpacing,-config.buttonSpacing)
37			end
38		end
39		local visible = 0
40		for i,k in ipairs(self.items) do
41			if k:IsVisible() then
42				visible = visible + 1
43				skin:SkinFrame(k)
44				k.icon:ClearAllPoints()
45				k.icon:SetPoint("TOPLEFT",k,"TOPLEFT",config.borderWidth,-config.borderWidth)
46				k.icon:SetPoint("BOTTOMRIGHT",k,"BOTTOMRIGHT",-config.borderWidth,config.borderWidth)
47				k.icon:SetTexCoord(unpack(config.buttonZoom))
48			end
49		end
50		if self.bg then
51			if db.vertical then
52				self.bg:SetWidth(config.buttonSpacing * 2 + config.buttonSize)
53				self.bg:SetHeight(config.buttonSpacing + (config.buttonSize + config.buttonSpacing) * visible)
54			else
55				self.bg:SetHeight(config.buttonSpacing * 2 + config.buttonSize)
56				self.bg:SetWidth(config.buttonSpacing + (config.buttonSize + config.buttonSpacing) * visible)
57			end
58		end
59	end
60end)