Quantcast
AceGUI help - WoWInterface
Thread Tools Display Modes
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
10-01-20, 08:32 AM   #2
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Nevermind

I figured it out. I guess all I needed to do was sleep so I could think clearly. The solution was to take the outer tree out of the scrollframe and add a scrollframe to the tree's container group instead. Fixed both problems.

The updated code, for anyone in the future having the same issues:
Lua Code:
  1. function addon:CreateObjectiveBuilder()
  2.     -- self:AddTestDBValues()
  3.  
  4.     local frame = AceGUI:Create("Frame")
  5.     frame:SetTitle(L._ObjectiveBuilder("title"))
  6.     frame:SetWidth(600)
  7.     frame:SetHeight(525)
  8.     frame:SetLayout("Fill")
  9.  
  10.     self.ObjectiveBuilder = frame
  11.  
  12.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  13.  
  14.     local objectiveTree = AceGUI:Create("TreeGroup")
  15.     objectiveTree:SetFullHeight(true)
  16.     objectiveTree:SetLayout("Flow")
  17.     objectiveTree:SetTree(self:GetObjectiveTree())
  18.     frame:AddChild(objectiveTree)
  19.  
  20.     objectiveTree:SetCallback("OnGroupSelected", function(container, _, selected)
  21.         container:ReleaseChildren()
  22.  
  23.         if selected == "newObjective" then
  24.             print("Create a new objective.")
  25.         else
  26.             -- Finding out the selected path to get the objectiveTitle
  27.             -- Not conerned with ever clicking on Active/Inactive itself
  28.             local objectiveTitle = {strsplit("\001", selected)}
  29.             tremove(objectiveTitle, 1)
  30.             objectiveTitle = strjoin("?", unpack(objectiveTitle))
  31.  
  32.             if objectiveTitle ~= "" then
  33.                 addon:DrawObjectiveGroup(container, objectiveTitle)
  34.             end
  35.         end
  36.     end)
  37.  
  38.     objectiveTree:SelectByPath("Active")
  39. end
  40.  
  41. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  42.  
  43. function addon:DrawObjectiveGroup(group, objectiveTitle)
  44.     local objectiveInfo = self.db.global.objectives[objectiveTitle]
  45.     group.objectiveTitle = objectiveTitle
  46.  
  47.     -- Need to redraw again for when icon editbox/button are shown and hidden
  48.     group:ReleaseChildren()
  49.  
  50.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  51.     -- groupScrollContainer
  52.  
  53.     local groupScrollContainer = AceGUI:Create("SimpleGroup")
  54.     groupScrollContainer:SetFullWidth(true)
  55.     groupScrollContainer:SetFullHeight(true)
  56.     groupScrollContainer:SetLayout("Fill")
  57.     group:AddChild(groupScrollContainer)
  58.  
  59.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  60.     -- groupScrollFrame
  61.  
  62.     local groupScrollFrame = AceGUI:Create("ScrollFrame")
  63.     groupScrollFrame:SetFullWidth(true)
  64.     groupScrollFrame:SetLayout("Flow")
  65.     groupScrollContainer:AddChild(groupScrollFrame)
  66.  
  67.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  68.     -- titleEditBox
  69.  
  70.     local titleEditBox = AceGUI:Create("EditBox")
  71.     titleEditBox:SetFullWidth(true)
  72.     titleEditBox:SetLabel(L["Title"])
  73.     titleEditBox:SetText(group.objectiveTitle)
  74.     groupScrollFrame:AddChild(titleEditBox)
  75.  
  76.     titleEditBox:SetCallback("OnEnterPressed", function(self)
  77.         local success, err = addon:UpdateObjectiveTitle(group.objectiveTitle, self:GetText())
  78.  
  79.         self:ClearFocus()
  80.  
  81.         if err and err == "exists" then
  82.             -- If err is because objective exists, restore title, focus and highlight for user to change
  83.             -- The other err would be because the title hasn't changed
  84.             self:SetText(group.objectiveTitle)
  85.             self:SetFocus()
  86.             self:HighlightText()
  87.         elseif success then
  88.             -- Update the objectiveTree to repopulate objectiveTitles
  89.             group:SetTree(addon:GetObjectiveTree())
  90.             -- Update the container's title reference
  91.             group.objectiveTitle = self:GetText()
  92.         end
  93.     end)
  94.  
  95.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  96.     -- autoIconCheckBox
  97.  
  98.     local autoIconCheckBox = AceGUI:Create("CheckBox")
  99.     autoIconCheckBox:SetType("checkbox")
  100.     autoIconCheckBox:SetFullWidth(true)
  101.     autoIconCheckBox:SetLabel(L["Automatic Icon"])
  102.     autoIconCheckBox:SetValue(objectiveInfo.autoIcon)
  103.     groupScrollFrame:AddChild(autoIconCheckBox)
  104.  
  105.     autoIconCheckBox:SetCallback("OnValueChanged", function(self)
  106.         addon.db.global.objectives[group.objectiveTitle].autoIcon = self:GetValue()
  107.         -- Redraw the group container to display/hide icon editbox and choose button
  108.         addon:DrawObjectiveGroup(group, objectiveTitle)
  109.     end)
  110.  
  111.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  112.     -- iconDisplayEditBox
  113.  
  114.     local iconDisplayEditBox = AceGUI:Create("EditBox")
  115.     iconDisplayEditBox:SetRelativeWidth(1/2)
  116.     iconDisplayEditBox:SetLabel(L["Display Icon"])
  117.     iconDisplayEditBox:SetText(objectiveInfo.icon)
  118.  
  119.     iconDisplayEditBox:SetCallback("OnEnterPressed", function(self)
  120.         addon.db.global.objectives[group.objectiveTitle].icon = self:GetText()
  121.         self:ClearFocus()
  122.     end)
  123.  
  124.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  125.     -- iconChooseButton
  126.  
  127.     local iconChooseButton = AceGUI:Create("Button")
  128.     iconChooseButton:SetRelativeWidth(1/4)
  129.     iconChooseButton:SetText(L["Choose"])
  130.  
  131.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  132.  
  133.     if not objectiveInfo.autoIcon then
  134.         groupScrollFrame:AddChild(iconDisplayEditBox)
  135.         groupScrollFrame:AddChild(iconChooseButton)
  136.     end
  137.  
  138.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  139.     -- buttonsHeading
  140.  
  141.     local buttonsHeading = AceGUI:Create("Heading")
  142.     buttonsHeading:SetFullWidth(true)
  143.     buttonsHeading:SetText(L["Buttons"])
  144.     groupScrollFrame:AddChild(buttonsHeading)
  145.  
  146.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  147.     -- buttonIDEditBox
  148.  
  149.     local buttonIDEditBox = AceGUI:Create("EditBox")
  150.     buttonIDEditBox:SetRelativeWidth(1/2)
  151.     buttonIDEditBox:SetLabel(L["Button ID"])
  152.     groupScrollFrame:AddChild(buttonIDEditBox)
  153.  
  154.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  155.     -- buttonIDChooseButton
  156.  
  157.     local buttonIDChooseButton = AceGUI:Create("Button")
  158.     buttonIDChooseButton:SetRelativeWidth(1/4)
  159.     buttonIDChooseButton:SetText(L["Choose"])
  160.     groupScrollFrame:AddChild(buttonIDChooseButton)
  161.  
  162.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  163.     -- trackersHeading
  164.  
  165.     local trackersHeading = AceGUI:Create("Heading")
  166.     trackersHeading:SetFullWidth(true)
  167.     trackersHeading:SetText(L["Trackers"])
  168.     groupScrollFrame:AddChild(trackersHeading)
  169.  
  170.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  171.     -- trackDropDown
  172.  
  173.     local trackDropDown = AceGUI:Create("Dropdown")
  174.     trackDropDown:SetFullWidth(true)
  175.     trackDropDown:SetLabel(L["Track"])
  176.     trackDropDown:SetList({ALL = L["All"], ANY = L["Any"], CUSTOM = L["Custom"]}, {"ALL", "ANY", "CUSTOM"})
  177.     trackDropDown:SetValue(objectiveInfo.trackType)
  178.     groupScrollFrame:AddChild(trackDropDown)
  179.  
  180.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  181.     -- newTrackerButton
  182.  
  183.     local newTrackerButton = AceGUI:Create("Button")
  184.     newTrackerButton:SetRelativeWidth(1/4)
  185.     newTrackerButton:SetText(L["New Tracker"])
  186.     groupScrollFrame:AddChild(newTrackerButton)
  187.  
  188.     -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
  189.     -- trackerTree
  190.  
  191.     local trackerTreeContainer = AceGUI:Create("SimpleGroup")
  192.     trackerTreeContainer:SetFullWidth(true)
  193.     trackerTreeContainer:SetHeight(400)
  194.     trackerTreeContainer:SetLayout("Fill")
  195.     groupScrollFrame:AddChild(trackerTreeContainer)
  196.  
  197.     local trackerTree = AceGUI:Create("TreeGroup")
  198.     trackerTree:SetLayout("Flow")
  199.     trackerTree:SetTree(addon:GetTrackerTree())
  200.     trackerTreeContainer:AddChild(trackerTree)
  201. end

Picture of solution:

Last edited by Niketa : 10-01-20 at 08:40 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AceGUI help

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off