View Single Post
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