View Single Post
03-20-19, 10:05 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
One fairly basic approach depending on knowing the total number of buttons ahead of time and the gridFrame size being absolute.

Lua Code:
  1. local gridFrame = CreateFrame("Frame", "DragFrame2", UIParent)
  2. gridFrame:SetMovable(true)
  3. gridFrame:EnableMouse(true)
  4. gridFrame:RegisterForDrag("LeftButton")
  5. gridFrame:SetScript("OnDragStart", gridFrame.StartMoving)
  6. gridFrame:SetScript("OnDragStop", gridFrame.StopMovingOrSizing)
  7. -- The code below makes the frame visible, and is not necessary to enable dragging.
  8. gridFrame:SetPoint("CENTER"); gridFrame:SetWidth(300); gridFrame:SetHeight(300);
  9. local gridFrameTexture = gridFrame:CreateTexture("ARTWORK");
  10. gridFrameTexture:SetAllPoints();
  11. gridFrameTexture:SetColorTexture(0.89,0.44,0.1, 0.5)
  12.  
  13. local last = gridFrame
  14. local count = 8
  15. local height = gridFrame:GetHeight()/count
  16. local point = "TOPLEFT"
  17. -- SubFrame
  18. for i=1, count do
  19.     local subFrame = CreateFrame("Button", "subFrame"..i, gridFrame)
  20.     subFrame:SetSize(300, height);
  21.     subFrame:SetHighlightTexture(136477)
  22.     subFrame:SetPoint("TOPLEFT", last, point)
  23.     last = subFrame
  24.     if i == 1 then
  25.         point = "BOTTOMLEFT"
  26.     end
  27.     local texture = subFrame:CreateTexture("ARTWORK")
  28.     texture:SetAllPoints()
  29.     texture:SetColorTexture(1,0,0.1, 1)
  30.     local fontString = subFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  31.     fontString:SetPoint("CENTER")
  32.     fontString:SetText("hej")
  33. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 03-20-19 at 10:13 AM.
  Reply With Quote