All pastes #82434 Raw Edit

Etch-A-Sketch

public text v1 · immutable
·published 2006-07-08 14:07 UTC
rendered paste body
MyAddOn_Design = {
    { 
        type="Frame",
        name="$parent_Frame", 
        parent="UIParent", 
        inherits=nil,
        methods = {
            SetHeight = { 100 },
            SetWidth = { 100 },
            SetPoint = { "TOPRIGHT", -50, -50 },
        }
        children = {
            {
                type="Button",
                name="$parent_SomethingButton", 
                inherits="UIPanelButtonTemplate",
                methods = {
                    SetPoint = { "TOPLEFT", 20,-20 },
                    SetWidth = { 100 },
                    SetHeight = { 20 },
                }
            },
            {
                type="Texture",
                methods = {
                    SetAllPoints = { "&parent" },
                    SetTexture = { 0.6,0.1,0.1,0.5 },
                    Show { true },
                }
            },
        },
    },
    {
        type="Frame",
        name="$parent_Frame2", parent="MyFrame", inherits=nil, 
        methods = {
            SetPoint = { }
        }
    },
}

MyAddOn_UI = {
    Design = MyAddOn_Design,
    Cache = {}
    ArgSubsts = { },
    FixArgs = function(self, args)
        
    end
    Worker = function(self, collection, root, parent, lastname)
        self.ArgSubsts["&parent"] = parent;
        for _,obj in ipairs(frames) do
            local n = obj.name and gsub(obj.name, "%$parent", lastname);
            local p = obj.parent and getglobal(obj.parent) or parent;
            f = CreateFrame(obj.type, n, p, obj.inherits);
            for method,args in pairs(obj.methods) do
                f[method](f, self:FixArgs(args));
            end
            if(obj.children) then
                Worker(self,obj.children,root,f,n);
            end
        end
    end
    
    Init = function(self)
        Worker(self, self.Design, self.Design, nil, "MyAddOn");
    end
}



MyAddOn_UI:Init();