1. #1

    AceGUI: filling rest of free frame space with InlineGroup

    I'm playing around a bit with AceGUI, but I got a problem. What I want to do is to have a InlineGroup container with a fixed width on the left side of the frame, and a InlineGroup container that fills the right space of the frame (and also changes its width when the frame is resized by the user). What it looks right now is this:



    As you can see the right part of the frame is empty. Here's the code:

    Code:
    local AceGUI = LibStub("AceGUI-3.0")
    
    local f = AceGUI:Create("Frame")
    f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end)
    f:SetTitle("test")
    f:SetLayout("Flow")
    
    local container1 = AceGUI:Create("InlineGroup")
    container1:SetWidth(150)
    container1:SetFullHeight(true)
    container1:SetLayout("Fill")
    
    local container2 = AceGUI:Create("InlineGroup")
    container2:SetFullWidth(true)
    container2:SetFullHeight(true)
    container2:SetLayout("Fill")
    
    f:AddChild(container1)
    f:AddChild(container2)
    Anybody got an idea how to do that in a proper way?

  2. #2
    Apparently the idea is to use a custom layout, something like this:

    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

  3. #3
    Quote Originally Posted by thebdc View Post
    Apparently the idea is to use a custom layout, something like this:

    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
    What's the purposes of the safecall stuff? I'm mostly just curious as I'm not seeing an immediate advantage to that complexity unless it's getting around something related to blizzard's protected calls.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •