Code:
local AceGUI = LibStub("AceGUI-3.0")
local tconcat, tremove, tinsert = table.concat, table.remove, table.insert
local function CreateDispatcher(argCount)
local code = [[
local xpcall, eh = ...
local method, ARGS
local function call() return method(ARGS) end
local function dispatch(func, ...)
method = func
if not method then return end
ARGS = ...
return xpcall(call, eh)
end
return dispatch
]]
local ARGS = {}
for i = 1, argCount do ARGS[i] = "arg"..i end
code = code:gsub("ARGS", tconcat(ARGS, ", "))
return assert(loadstring(code, "safecall Dispatcher["..argCount.."]"))(xpcall, errorhandler)
end
local Dispatchers = setmetatable({}, {__index=function(self, argCount)
local dispatcher = CreateDispatcher(argCount)
rawset(self, argCount, dispatcher)
return dispatcher
end})
Dispatchers[0] = function(func)
return xpcall(func, errorhandler)
end
local function safecall(func, ...)
return Dispatchers[select("#", ...)](func, ...)
end
AceGUI:RegisterLayout("Custom_Layout", function(content, children)
if children[1] then
children[1]:SetWidth(150)
children[1].frame:SetPoint("TOPLEFT", content, "TOPLEFT", 0, 0)
children[1].frame:SetPoint("BOTTOMLEFT", content, "BOTTOMLEFT", 0, 0)
children[1].frame:Show()
end
if children[2] then
children[2].frame:SetPoint("TOPLEFT", children[1].frame, "TOPRIGHT", 0, 0)
children[2].frame:SetPoint("BOTTOMRIGHT", content, "BOTTOMRIGHT", 0, 0)
children[2].frame:Show()
end
safecall(content.obj.LayoutFinished, content.obj, nil, nil)
end)
local f = AceGUI:Create("Frame")
f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
f:SetTitle("test")
f:SetLayout("Custom_Layout")
local container1 = AceGUI:Create("InlineGroup")
container1:SetLayout("Fill")
local container2 = AceGUI:Create("InlineGroup")
container2:SetLayout("Fill")
f:AddChild(container1)
f:AddChild(container2)
The safecall stuff is taken from AceGUI-3.0.lua