Thread: AceGUI help
View Single Post
10-01-20, 12:45 AM   #1
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
AceGUI help

I'm using AceGUI to create a frame and I'm having trouble with nested tree groups. I want to have a main frame with a sidebar that's dynamically populated. The main "content" panel of each sidebar option will have a bunch of options, but also another tree group within it for another set of options.

This is a sample of what the database looks like (at this point in time, anyway; trying to design a GUI and database at the same time so some of the things I drew out in my plan I haven't implemented yet):
Lua Code:
  1. self.db.global.objectives["test objective"] = {
  2.         enabled = true,
  3.         items = {
  4.             includeBank = true,
  5.             objective = 0,
  6.             includeAllChars = false,
  7.             exclude = {},
  8.         },
  9.         icon = "134400",
  10.         autoIcon = true,
  11.         trackType = "ALL",
  12.     }

This is what I have so far for the frame:
Lua Code:
  1. local frame = AceGUI:Create("Frame")
  2.     frame:SetWidth(600)
  3.     frame:SetHeight(525)
  4.     frame:SetTitle(L._ObjectiveBuilder("title"))
  5.     frame:SetLayout("Fill")
  6.  
  7.     self.ObjectiveBuilder = frame
  8.  
  9.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  10.  
  11.     local scrollcontainer = AceGUI:Create("SimpleGroup")
  12.     scrollcontainer:SetFullWidth(true)
  13.     scrollcontainer:SetLayout("Fill")
  14.     frame:AddChild(scrollcontainer)
  15.  
  16.     local scrollframe = AceGUI:Create("ScrollFrame")
  17.     scrollframe:SetFullWidth(true)
  18.     scrollframe:SetLayout("Fill")
  19.     scrollcontainer:AddChild(scrollframe)
  20.  
  21.     local treecontainer = AceGUI:Create("SimpleGroup")
  22.     treecontainer:SetFullWidth(true)
  23.     treecontainer:SetLayout("Fill")
  24.     scrollframe:AddChild(treecontainer)
  25.  
  26.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  27.  
  28.     local tree = AceGUI:Create("TreeGroup")
  29.     tree:SetFullHeight(true)
  30.     tree:SetLayout("Flow")
  31.     tree:SetTree(self:GetObjectiveTree())
  32.     treecontainer:AddChild(tree)
  33.  
  34.     tree:SetCallback("OnGroupSelected", function(container, _, group, ...)
  35.         container:ReleaseChildren()
  36.         if group == "newObjective" then
  37.             print("Create a new objective.")
  38.         else
  39.             -- Draw Objective Group and load objective info
  40.             local group = {strsplit("\001", group)}
  41.             tremove(group, 1)
  42.             group = strjoin("?", unpack(group))
  43.  
  44.             if group ~= "" then
  45.                 frame:DrawObjectiveGroup(container, group)
  46.             end
  47.         end
  48.     end)
  49.  
  50.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  51.  
  52.     function frame:DrawObjectiveGroup(container, objectiveTitle)
  53.         container:ReleaseChildren()
  54.  
  55.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  56.         -- Objective info
  57.  
  58.         container.objectiveTitle = objectiveTitle
  59.         local objectiveInfo = addon.db.global.objectives[objectiveTitle]
  60.  
  61.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  62.         -- titleEditBox
  63.  
  64.         local titleEditBox = AceGUI:Create("EditBox")
  65.         titleEditBox:SetFullWidth(true)
  66.         titleEditBox:SetLabel(L["Title"])
  67.         titleEditBox:SetText(objectiveTitle)
  68.         container:AddChild(titleEditBox)
  69.  
  70.         titleEditBox:SetCallback("OnEnterPressed", function(self)
  71.             local success, err = addon:UpdateObjectiveTitle(container.objectiveTitle, self:GetText())
  72.             self:ClearFocus()
  73.             if err then
  74.                 self:SetText(objectiveTitle)
  75.                 if err == "exists" then
  76.                     self:SetFocus()
  77.                     self:HighlightText()
  78.                 end
  79.             elseif success then
  80.                 tree:SetTree(addon:GetObjectiveTree())
  81.                 container.objectiveTitle = self:GetText()
  82.             end
  83.         end)
  84.  
  85.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  86.         -- automaticIconCheck
  87.  
  88.         local iconEditBox, iconChooseButton
  89.         local automaticIconCheck = AceGUI:Create("CheckBox")
  90.         automaticIconCheck:SetType("checkbox")
  91.         automaticIconCheck:SetFullWidth(true)
  92.         automaticIconCheck:SetLabel(L["Automatic Icon"])
  93.         automaticIconCheck:SetValue(objectiveInfo.autoIcon)
  94.         container:AddChild(automaticIconCheck)
  95.  
  96.         automaticIconCheck:SetCallback("OnValueChanged", function(self)
  97.             addon.db.global.objectives[container.objectiveTitle].autoIcon = self:GetValue()
  98.             frame:DrawObjectiveGroup(container, objectiveTitle)
  99.         end)
  100.  
  101.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  102.         -- iconEditBox
  103.  
  104.         iconEditBox = AceGUI:Create("EditBox")
  105.         iconEditBox:SetRelativeWidth(1/2)
  106.         iconEditBox:SetLabel(L["Display Icon"])
  107.         iconEditBox:SetText(objectiveInfo.icon)
  108.  
  109.         iconEditBox:SetCallback("OnEnterPressed", function(self)
  110.             addon.db.global.objectives[container.objectiveTitle].icon = self:GetText()
  111.             self:ClearFocus()
  112.         end)
  113.  
  114.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  115.         -- iconChooseButton
  116.  
  117.         iconChooseButton = AceGUI:Create("Button")
  118.         iconChooseButton:SetRelativeWidth(1/4)
  119.         iconChooseButton:SetText(L["Choose"])
  120.  
  121.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  122.  
  123.         if not automaticIconCheck:GetValue() then
  124.             container:AddChild(iconEditBox)
  125.             container:AddChild(iconChooseButton)
  126.         end
  127.  
  128.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  129.         -- buttonHeading
  130.  
  131.         local buttonHeading = AceGUI:Create("Heading")
  132.         buttonHeading:SetFullWidth(true)
  133.         buttonHeading:SetText(L["Button Settings"])
  134.         container:AddChild(buttonHeading)
  135.  
  136.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  137.         -- buttonEditBox
  138.  
  139.         local buttonEditBox = AceGUI:Create("EditBox")
  140.         buttonEditBox:SetRelativeWidth(1/2)
  141.         buttonEditBox:SetLabel(L["Button ID"])
  142.         container:AddChild(buttonEditBox)
  143.  
  144.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  145.         -- buttonChooseButton
  146.  
  147.         local buttonChooseButton = AceGUI:Create("Button")
  148.         buttonChooseButton:SetRelativeWidth(1/4)
  149.         buttonChooseButton:SetText(L["Choose"])
  150.         container:AddChild(buttonChooseButton)
  151.  
  152.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  153.         -- trackersHeading
  154.  
  155.         local trackersHeading = AceGUI:Create("Heading")
  156.         trackersHeading:SetFullWidth(true)
  157.         trackersHeading:SetText(L["Trackers"])
  158.         container:AddChild(trackersHeading)
  159.  
  160.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  161.         -- trackDropDown
  162.  
  163.         local trackDropDown = AceGUI:Create("Dropdown")
  164.         trackDropDown:SetFullWidth(true)
  165.         trackDropDown:SetList({ALL = L["All"], ANY = L["Any"], CUSTOM = L["Custom"]}, {"ALL", "ANY", "CUSTOM"})
  166.         trackDropDown:SetLabel("Track")
  167.         trackDropDown:SetValue(objectiveInfo.trackType)
  168.         container:AddChild(trackDropDown)
  169.  
  170.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  171.         -- newTrackerButton
  172.  
  173.         local newTrackerButton = AceGUI:Create("Button")
  174.         newTrackerButton:SetRelativeWidth(1/4)
  175.         newTrackerButton:SetText("New")
  176.         container:AddChild(newTrackerButton)
  177.  
  178.         -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  179.         -- trackerTree
  180.  
  181.         local trackerTreeContainer = AceGUI:Create("SimpleGroup")
  182.         trackerTreeContainer:SetFullWidth(true)
  183.         trackerTreeContainer:SetLayout("Fill")
  184.         container:AddChild(trackerTreeContainer)
  185.  
  186.         local trackerTree = AceGUI:Create("TreeGroup")
  187.         trackerTree:SetLayout("Flow")
  188.         trackerTree:SetTree(addon:GetTrackerTree())
  189.         trackerTreeContainer:AddChild(trackerTree)
  190.     end
  191.  
  192.     tree:SelectByPath("Active")

The problems:
1. The main tree group (tree) does not fill the entire frame (frame). There is space at the bottom. It looks like one of the containers are filling the frame right but the tree isn't filling it.
2. I want to make the nested tree group (trackerTree) larger, but doing so causes it to be drawn outside of the main tree's container and thus could go outside of the frame. I've already got a headache trying to get the original tree to stay contained within the frame as it is, let alone trying to get this one too as well.

I haven't done a whole lot with AceGUI, so I'm sure I'm doing lots plenty wrong. Any tips on how to go about what I want in the right way are appreciated. I'm also open to other options designs to an extent, but only if it aligns with the goal I'm trying to achieve.


This is what it looks like so far:


If you look at it with ElvUI enabled, you can see more clearly that the container within the main frame is the right height, but the tree group isn't.


This was the rough sketch of the general idea:
  Reply With Quote