Thread Tools Display Modes
07-13-19, 10:36 PM   #1
thewizard20
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 2
Question Trouble Showing Icons Inside of Scrolling Frame

I'm still trying to wrap my head around building interfaces and was hoping someone can point me in a direction. I currently have a frame with a scrollbar, and I'm trying to populate rows in that frame with a loop:

Lua Code:
  1. for index=1,GetNumShapeshiftForms(),1 do
  2.         icon, name, active = GetShapeshiftFormInfo(index)
  3.         MyAddOn_BuildStanceListItem(f.ScrollFrame, index, icon, name, active);
  4.     end

Inside my function to build each row, I'm currently attempting to load the texture for each shapeshift form inside my scrolling frame, but I don't seem to get a single icon to appear.

Lua Code:
  1. function MyAddOn_BuildStanceListItem(f, index, icon, name, active)
  2.     print("Building List Item");
  3.     print("Icon: " .. icon);
  4.     local texture = GetSpellTexture(icon);
  5.     print("Texture: " .. texture);
  6.     local ListItem = CreateFrame("Frame", "MyAddOnListItem"..index, f);
  7.     print("Created ListItem");
  8.     ListItem:ClearAllPoints();
  9.     ListItem:SetPoint("TOPLEFT", f);
  10.     ListItem:SetSize(315, 68);
  11.     print("Creating AuraIcon");
  12.     local AuraIcon = CreateFrame("Frame", "StanceIcon"..index, ListItem);
  13.     print("Setting Width");
  14.     AuraIcon:SetWidth(68);
  15.     print("Setting Height");
  16.     AuraIcon:SetHeight(68);
  17.     print("Creating Texture");
  18.     local tg = AuraIcon:CreateTexture(nil, "ARTWORK");
  19.     tg:SetTexture(texture);
  20.     tg:SetSize(68, 68);
  21.     tg:SetPoint("LEFT");
  22.     AuraIcon.texture = tg;
  23. end

I'm floundering trying to figure out if I'm incorrectly loading the textures, dealing with frames in an incorrect way, or both. I don't need anything to happen if the texture is pressed, I just want to use it as artwork inside the scroll frame to accompany a font string. While I may need to consider offsets between indicies, I anticipated at least one icon to appear.
  Reply With Quote
07-14-19, 01:16 AM   #2
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Since the first value of the GetShapeshiftFormInfo is the texture, you should use
Lua Code:
  1. local texture = icon

instead of

Lua Code:
  1. local texture = GetSpellTexture(icon);

And about the scroll frame, since the shapeshift form count is little, there is no need to use a scroll frame to contains all them.

If you really need, you should create a frame as the scrollframe's child

Lua Code:
  1. local scrollFrame = CreateFrame("ScrollFrame")
  2. local container = CreateFrame("Frame", nil, scrollFrame)
  3. scrollFrame:SetScrollChild(container)

And then create all list items on the container. Scroll childs in the scroll frame is just moving the container, you can set its location by yourself or just use method:

Lua Code:
  1. scrollFrame:SetVerticalScroll(value)

Last edited by kurapica.igas : 07-14-19 at 01:18 AM.
  Reply With Quote
07-14-19, 02:29 AM   #3
thewizard20
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 2
Thanks for your response. I went ahead and tried to give it another shot based off your feedback. I also tried to move all of my interface code into wowlua so I could give the full picture and the framestack of my result.

Unfortunately I'm still not getting an icon so I'm still a bit puzzled. Attached is the result of that.



The reason I was thinking of using a ScrollFrame is because I was going to have options for each stance.

Here is the code in case anyone would like to try it locally:

Lua Code:
  1. local function MyAddOn_BuildStanceListItem(f, index, icon, name, active)
  2.    StanceIconFrame = CreateFrame("Frame", "StanceIconFrame"..index, f);
  3.    StanceIconFrame:SetSize(68, 68);
  4.    StanceIconFrame:SetPoint("TOPLEFT");
  5.    StanceIcon = StanceIconFrame:CreateTexture("StanceIcon"..index, "ARTWORK");
  6.    StanceIcon:SetTexture(icon);
  7.    StanceIcon:SetSize(68, 68);
  8.    StanceIcon:SetPoint("TOPLEFT");
  9.    StanceIconFrame.texture = StanceIcon;
  10. end
  11.  
  12.  
  13. local f = CreateFrame("Frame", "MyAddOnFrame", UIParent, "UIPanelDialogTemplate");
  14. f:SetSize(384, 512);
  15. f:SetPoint("LEFT");
  16. f.Title:ClearAllPoints();
  17. f.Title:SetFontObject("GameFontHighlight");
  18. f.Title:SetPoint("LEFT", MyAddOnFrameTitleBG, "LEFT", 6, 1);
  19. f.Title:SetText("My Awesome AddOn");
  20. f.ScrollFrame = CreateFrame("ScrollFrame", nil, f, "UIPanelScrollFrameTemplate");
  21. f.ScrollFrame:SetPoint("TOPLEFT", MyAddOnFrameDialogBG, "TOPLEFT", 4, -8);
  22. f.ScrollFrame:SetPoint("BOTTOMRIGHT", MyAddOnFrameDialogBG, "BOTTOMRIGHT", -3, 4);
  23. f.ScrollFrame:SetClipsChildren(true);
  24. f.ScrollFrame:SetScript("OnMouseWheel", ScrollFrame_OnMouseWheel);
  25. f.ScrollFrame.ScrollBar:ClearAllPoints();
  26. f.ScrollFrame.ScrollBar:SetPoint("TOPLEFT", f.ScrollFrame, "TOPRIGHT", -12, -18);
  27. f.ScrollFrame.ScrollBar:SetPoint("BOTTOMRIGHT", f.ScrollFrame, "BOTTOMRIGHT", -7, 18);
  28.  
  29. f.ScrollChild = CreateFrame("Frame", nil, f.ScrollFrame)
  30. f.ScrollFrame:SetScrollChild(f.ScrollChild)
  31.  
  32. for index=1,GetNumShapeshiftForms(),1 do
  33.    icon, name, active = GetShapeshiftFormInfo(index)
  34.    MyAddOn_BuildStanceListItem(f.ScrollChild, index, icon, name, active);
  35. end

Last edited by thewizard20 : 07-14-19 at 02:31 AM.
  Reply With Quote
07-14-19, 02:54 AM   #4
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Lua Code:
  1. local function MyAddOn_BuildStanceListItem(f, index, icon, name, active)
  2.     local StanceIconFrame = CreateFrame("Frame", nil, f);
  3.     f[index] = StanceIconFrame;
  4.    
  5.     StanceIconFrame:SetSize(68, 68);
  6.     StanceIconFrame:SetPoint("TOPLEFT", 0, - 68 * (index - 1));
  7.    
  8.     local StanceIcon = StanceIconFrame:CreateTexture(nil, "ARTWORK");
  9.     StanceIcon:SetTexture(icon);
  10.     StanceIcon:SetAllPoints();
  11.     StanceIconFrame.texture = StanceIcon;
  12.    
  13.     f:SetHeight(68 * index);
  14. end
  15.  
  16.  
  17. local f = CreateFrame("Frame", "MyAddOnFrame", UIParent, "UIPanelDialogTemplate");
  18. f:SetSize(384, 512);
  19. f:SetPoint("CENTER");
  20. f.Title:ClearAllPoints();
  21. f.Title:SetFontObject("GameFontHighlight");
  22. f.Title:SetPoint("TOPLEFT", f, "TOPLEFT", 12, - 6);
  23. f.Title:SetText("My Awesome AddOn");
  24.  
  25. f.ScrollFrame = CreateFrame("ScrollFrame", nil, f, "UIPanelScrollFrameTemplate");
  26. f.ScrollFrame:SetPoint("TOPLEFT", f, "TOPLEFT", 14, - 36);
  27. f.ScrollFrame:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", - 34, 14);
  28.  
  29. f.ScrollChild = CreateFrame("Frame", nil, f.ScrollFrame)
  30. f.ScrollFrame:SetScrollChild(f.ScrollChild)
  31. f.ScrollChild:SetPoint("TOPLEFT")
  32. f.ScrollChild:SetPoint("RIGHT")
  33.  
  34. for index = 1, GetNumShapeshiftForms() do
  35.     MyAddOn_BuildStanceListItem(f.ScrollChild, index, GetShapeshiftFormInfo(index));
  36. end

A little modification, you need give the container a location and size, so it can be displayed, I attach the container to the topleft and right, so it has width, I update its height in the MyAddOn_BuildStanceListItem, so it has the whole size settings.

You can test more with in-game editor.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Trouble Showing Icons Inside of Scrolling Frame

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