/branches
function VFLUI.Framing.None(self, titleHeight) |
-------------------------- WINDOW DECOR |
local perfText = VFLUI.CreateFontString(self); |
perfText:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 4, 0); |
perfText:SetHeight(14); |
VFLUI.SetFont(perfText, Fonts.Default, 8); |
perfText:SetJustifyH("LEFT"); perfText:Show(); |
function self:SetPerfText(txt) perfText:SetText(txt); end |
local perf, perfText; |
if VFLP.IsEnabled() then |
perf = VFLUI.AcquireFrame("Frame"); |
perf:SetParent(self); |
perf:SetFrameLevel(self:GetFrameLevel() + 6); |
perf:SetHeight(5); |
perf:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT"); |
VFLUI.SetBackdrop(perf, {bgFile="Interface\\Addons\\VFL\\Skin\\black", tile = true, tileSize = 16,}); |
perf:Show(); |
perfText = VFLUI.CreateFontString(perf); |
perfText:SetAllPoints(perf); |
VFLUI.SetFont(perfText, Fonts.DefaultShadowed, 8); |
--perfText:SetTextColor(1, 0, 0, 1); |
perfText:SetJustifyH("RIGHT"); |
perfText:Show(); |
function self:SetPerfText(txt) perfText:SetFormattedText("%0.2fms", txt); end |
end |
---------------------------- FIXED ELEMENT LAYOUT |
if self.SetInsets then |
local l,r = self:GetLeft(), self:GetRight(); |
if not l then return; end |
local tw = math.abs(r-l); |
perfText:SetWidth(tw); |
if VFLP.IsEnabled() then |
if tw > 50 then |
perf:SetWidth(50); |
else |
perf:SetWidth(tw); |
end |
end |
if not self.SetInsets then |
local ca = self:GetClientArea(); |
ca:SetWidth(self:GetWidth()); ca:SetHeight(self:GetHeight()); |
end |
end |
function self:_FrameDestroy() |
perfText:ClearAllPoints(); |
VFLUI.ReleaseRegion(perfText); perfText = nil; |
function self:_FrameDestroy() |
if VFLP.IsEnabled() then |
perfText:ClearAllPoints(); |
VFLUI.ReleaseRegion(perfText); perfText = nil; |
perf:ClearAllPoints(); |
perf:Destroy(); perf = nil; |
end |
end |
self:_FrameLayout(); |
function self:SetText(txt) titleText:SetText(txt); end |
function self:SetTitleColor(r,g,b) tx2:SetTexture(r,g,b); end |
local perf = VFLUI.AcquireFrame("Frame"); |
perf:SetParent(self); |
perf:SetFrameLevel(self:GetFrameLevel() + 6); |
perf:SetHeight(5); |
perf:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT"); |
VFLUI.SetBackdrop(perf, {bgFile="Interface\\Addons\\VFL\\Skin\\black", tile = true, tileSize = 16,}); |
perf:Show(); |
local perfText = VFLUI.CreateFontString(perf); |
perfText:SetAllPoints(perf); |
VFLUI.SetFont(perfText, Fonts.DefaultShadowed, 8); |
--perfText:SetTextColor(1, 0, 0, 1); |
perfText:SetJustifyH("RIGHT"); |
perfText:Show(); |
function self:SetPerfText(txt) perfText:SetFormattedText("%0.2fms", txt); end |
---------------------------- FIXED ELEMENT LAYOUT |
if self.SetInsets then |
local mtw = tw - 10 - (table.getn(self.ctlButtons) * .7 * titleHeight); |
titleBar:SetWidth(mtw); |
titleText:SetWidth(mtw); |
if tw > 50 then |
perf:SetWidth(50); |
else |
perf:SetWidth(tw); |
end |
if not self.SetInsets then |
local ca = self:GetClientArea(); |
ca:SetWidth(tw - 10); ca:SetHeight(self:GetHeight() - titleHeight - 7); |
end |
function self:_FrameDestroy() |
perfText:ClearAllPoints(); |
VFLUI.ReleaseRegion(perfText); perfText = nil; |
perf:ClearAllPoints(); |
perf:Destroy(); perf = nil; |
self:SetBackdrop(nil); |
VFLUI.ReleaseRegion(titleText); titleText = nil; |
VFLUI.ReleaseRegion(tx1); tx1 = nil; |
-- Create the columns. |
local w, af, ap = 0, self, "TOPLEFT"; |
self.col = {}; |
for i=1,9 do |
if i == 1 then |
local chkbox = VFLUI.Checkbox:new(self) |
chkbox:SetPoint("TOPLEFT", af, ap); |
chkbox:SetHeight(10); |
chkbox:Show(); |
self.col[i] = chkbox; |
-- Update iterative variables |
af = chkbox; ap = "TOPRIGHT"; |
else |
-- Create the text object. |
local colText = VFLUI.CreateFontString(self); |
colText:SetDrawLayer("OVERLAY"); |
VFLUI.SetFont(colText, Fonts.Default, 9); |
colText:SetShadowOffset(1,-1); |
colText:SetShadowColor(0,0,0,.6); |
colText:SetTextColor(1,1,1,1); colText:SetJustifyH("LEFT"); |
colText:SetPoint("TOPLEFT", af, ap); |
colText:SetHeight(10); |
colText:Show(); |
-- Save it |
self.col[i] = colText; |
-- Update iterative variables |
af = colText; ap = "TOPRIGHT"; |
end |
for i=1,8 do |
-- Create the text object. |
local colText = VFLUI.CreateFontString(self); |
colText:SetDrawLayer("OVERLAY"); |
VFLUI.SetFont(colText, Fonts.Default, 9); |
colText:SetShadowOffset(1,-1); |
colText:SetShadowColor(0,0,0,.6); |
colText:SetTextColor(1,1,1,1); colText:SetJustifyH("LEFT"); |
colText:SetPoint("TOPLEFT", af, ap); |
colText:SetHeight(10); |
colText:Show(); |
-- Save it |
self.col[i] = colText; |
-- Update iterative variables |
af = colText; ap = "TOPRIGHT"; |
end |
-- Create the selection texture |
local cs, col; |
local function SetupLayout(colspec, cols) |
for i=1,9 do |
for i=1,8 do |
cs, col = colspec[i], cols[i]; |
if cs then |
if i == 1 then |
col:Show(); col:SetWidth(colspec[i].width); |
else |
col:Show(); col:SetWidth(colspec[i].width); col:SetJustifyH(cs.jh or "LEFT"); |
end |
col:Show(); col:SetWidth(colspec[i].width); col:SetJustifyH(cs.jh or "LEFT"); |
else |
col:Hide(); |
end |
end |
local function PaintTitle(colspec, cols) |
for i=1,9 do |
for i=1,8 do |
cs, col = colspec[i], cols[i]; |
if cs then |
if i == 1 then |
col:Hide(); |
else |
col:SetTextColor(1,1,1); col:SetText(cs.title); |
end |
col:SetTextColor(1,1,1); col:SetText(cs.title); |
end |
end |
end |
local function PaintData(colspec, cols, data) |
for i=1,9 do |
for i=1,8 do |
cs,col = colspec[i], cols[i]; |
if cs then |
if i == 1 then |
if data.type == "category" then |
col:Hide(); |
col.check:SetScript("OnClick", nil); |
else |
col:Show(); |
col.check:SetScript("OnClick", cs.Onclick); |
end |
else |
col:SetTextColor(cs.r, cs.g, cs.b); |
end |
col:SetTextColor(cs.r, cs.g, cs.b); |
cs.paint(col, data); |
end |
end |
end |
local colspec_summ = { |
{ title = " "; width = 20; r=1; g=1; b=1; |
paint = function(cell, data) cell.check.title = data.title; if VFLConfig.summary[data.title] then cell:SetChecked(true); else cell:SetChecked(nil); end; end; Onclick = function(self) if self:GetChecked() then VFLConfig.summary[self.title] = true; else VFLConfig.summary[self.title] = nil; end; end; }; |
{ title = "Name"; width = 150; r=1; g=1; b=1; |
paint = function(cell, data) cell:SetText(data.title); end; }; |
{ title = "mem"; width = 55; r=.95; g=.95; b=.45; jh="RIGHT"; |
paint = function(cell, data) cell:SetFormattedText("%0.2fk", data.raMem / VFLP.GetSummaryUpdateInterval()); end; }; |
{ title = "CPU%"; width = 50; r=.95; g=.95; b=.45; jh="RIGHT"; |
paint = function(cell, data) cell:SetFormattedText("%0.2f%%", data.raCPU * 100 / VFLP.GetSummaryUpdateInterval()); end; }; |
--{ title = "PIC%"; width = 50; r=.95; g=.95; b=.45; jh="RIGHT"; |
-- paint = function(cell, data) cell:SetFormattedText("%0.2f%%", data.PicCPU * 100 / VFLP.GetSummaryUpdateInterval()); end; }; |
--{ title = "NbPIC"; width = 45; r=.95; g=.95; b=.45; jh="RIGHT"; |
-- paint = function(cell, data) cell:SetText(data.nbPicCPU); end; }; |
{ title = "CPU/frame"; width = 55; r=.75; g=.35; b=.35; jh="RIGHT"; |
paint = function(cell, data) cell:SetText(FormatMicro(data.raCPU / VFLP.GetFramesPerSummaryUpdate())); end; }; |
{ title = "FPS impact"; width = 65; r=0;g=.7;b=0; jh="RIGHT"; |
end |
local colspec_obj = { |
{ title = " "; width = 20; r=1; g=1; b=1; |
paint = function(cell, data) cell.check.title = data.title; if VFLConfig.object[data.title] then cell:SetChecked(true); else cell:SetChecked(nil); end; end; Onclick = function(self) if self:GetChecked() then VFLConfig.object[self.title] = true; else VFLConfig.object[self.title] = nil; end; end; }; |
{ title = "Name"; width = 110; r=1; g=1; b=1; |
paint = function(cell, data) cell:SetText(data.title); end; }; |
{ title = "call"; width = 55; r=.95; g=.95; b=.45; jh="RIGHT"; |
end |
local colspec_event = { |
{ title = " "; width = 20; r=1; g=1; b=1; |
paint = function(cell, data) cell.check.title = data.title; if VFLConfig.event[data.title] then cell:SetChecked(true); else cell:SetChecked(nil); end; end; Onclick = function(self) if self:GetChecked() then VFLConfig.event[self.title] = true; else VFLConfig.event[self.title] = nil; end; end; }; |
{ title = "Name"; width = 110; r=1; g=1; b=1; |
paint = function(cell, data) cell:SetText(data.title); end; }; |
{ title = "call"; width = 55; r=.95; g=.95; b=.45; jh="RIGHT"; |
end |
local colspec_pool = { |
{ title = " "; width = 20; r=1; g=1; b=1; |
paint = function(cell, data) cell.check.title = data.title; if VFLConfig.pool[data.title] then cell:SetChecked(true); else cell:SetChecked(nil); end; end; Onclick = function(self) if self:GetChecked() then VFLConfig.pool[self.title] = true; else VFLConfig.pool[self.title] = nil; end; end; }; |
{ title = "Name"; width = 150; r=1; g=1; b=1; |
paint = function(cell, data) cell:SetText(data.title); end; }; |
{ title = "create"; width = 55; r=.95; g=.95; b=.45; jh="RIGHT"; |
-- @param n the number |
-- @param color The table color definition, _red = {r=0.9,g=0,b=0,a=1}; |
function VFL.KayMemory(n, color) |
if not color then color = _white end |
tn = abs(n); |
if tn < 1000 then |
return VFL.tcolorize(strformat("%d", n), color) .. "b"; |
local UpdateMemorySummary = VFL.Noop; |
if VFLP.IsEnabled() then |
function UpdateMemorySummary() |
UpdateAddOnMemoryUsage(); |
--UpdateAddOnMemoryUsage(); |
-- /script UpdateAddOnMemoryUsage(); |
mem, memusage, memtot, memratot, memx, memaindex = 0, 0, 0, 0, nil, 1; |
-- For each addon... |
for i=3,#alist do |
memx = alist[i]; memaindex = memx.addon_index; |
if VFLConfig.summary[alist[i].title] then |
--if VFLConfig.summary[alist[i].title] then |
mem = GetAddOnMemoryUsage(memaindex); |
else |
mem = 0; |
end |
--else |
-- mem = 0; |
--end |
memtot = memtot + mem; |
memusage = mem - memx.mem; |
memx.raMem = ( (memx.raMem * 4) + memusage ) / 5; -- weight-5 rolling average |
for i=3, #alist do |
acpux = alist[i]; |
acpuaindex = acpux.addon_index; |
if VFLConfig.summary[alist[i].title] then |
--if VFLConfig.summary[alist[i].title] then |
acpu = GetAddOnCPUUsage(acpuaindex) / 1000; |
else |
acpu = 0; |
end |
--else |
-- acpu = 0; |
--end |
acputot = acputot + acpu; |
acpuusage = acpu - acpux.CPU; |
end |
totCPU = 0; totCalls = 0; curCat = obj; |
else |
if VFLConfig.object[obj.title] then |
--if VFLConfig.object[obj.title] then |
if obj.type == "function" then |
cpu, calls = GetFunctionCPUUsage(obj.object, obj.includeSubObjects); |
cpu = cpu / 1000; |
delta = cpu - obj.CPU; |
obj.raCPU = ( ( obj.raCPU * 4) + delta ) / 5; |
obj.lastCPU = obj.CPU; obj.CPU = cpu; |
end |
--end |
end |
end |
-- Update last category |
VFLP.RegisterFunc("VFL Profiler", "Object Updater", UpdateObjProfile, true); |
VFLP.RegisterFunc("VFL Profiler", "Pool Updater", UpdatePoolSummary, true); |
local textperf = ""; |
local textperf, textdebit = "", ""; |
local memtotal_color, ips_color, latency_color; |
local memtotal = 0; |
local memtotal, memtmp, memsave = 0, 0, 0; |
local SAMPLESIZE = 5; |
local fWeight = ( (SAMPLESIZE-1)/SAMPLESIZE ); |
local sWeight = 1 - fWeight; |
local vps, val = 0 , 0; |
local function updateTextPerf() |
UpdateAddOnMemoryUsage(); |
memtotal_color, ips_color, latency_color = _green, _red, _green; |
memtotal = (GetAddOnMemoryUsage("RDX") + GetAddOnMemoryUsage("VFL")) / 1000; |
memtmp = GetAddOnMemoryUsage("RDX") + GetAddOnMemoryUsage("VFL"); |
memtotal = memtmp / 1000; |
if memtotal > 50 then memtotal_color = _yellow; end |
if memtotal > 65 then memtotal_color = _orange; end |
if memtotal > 80 then memtotal_color = _red; end |
if latency > 500 then latency_color = _orange; end |
if latency > 750 then latency_color = _red; end |
textperf = VFL.tcolorize(memtotal, memtotal_color) .. "Mb " .. VFL.tcolorize(ips, ips_color) .. "fps " .. VFL.tcolorize(latency, latency_color) .. "ms"; |
vps = (memtmp - memsave) * 1000; |
val = ((val * fWeight) + (vps * sWeight)); |
if vps < 0 then |
textdebit = "Garbage Collecting"; val = 0; |
elseif vps > 1000000 then |
textdebit = "Calcul"; val = 0; |
else |
textdebit = "Mem debit: " .. VFL.KayMemory(val); |
end |
memsave = memtmp; |
end |
function VFLP.GetTextPerf() |
return textperf; |
return textperf, textdebit; |
end |
WoWEvents:Bind("VARIABLES_LOADED", nil, function() |