Thread Tools Display Modes
03-06-12, 04:13 AM   #1
kaels
A Cyclonian
AddOn Author - Click to view addons
Join Date: Jan 2011
Posts: 46
Minimal code for creating a SecureGroupHeader?

I think I've read through about a dozen unit/raid frames addons by now (oUF, Grid, Pitbull (aargh), Vuhdo (omgwtf), Healbot, who knows how many others) and I still don't understand how headers get created. I can't find a simplified example online; I have the book from wowprogramming, which does a simple raid frame, but half of it's in XML.

All I want to do (for now) is create a header that displays a frame for each of my raid members when I am in a raid. It doesn't need to do anything yet, I just want it to appear on my screen.

I have the following:

lua Code:
  1. function KaelFrames:Create(unit)
  2.     local frame = CreateFrame("Button", "KaelFrames_"..unit, UIParent, "SecureUnitButtonTemplate")
  3.     frame.backdrop = CreateFrame("Frame", nil, frame)
  4.     SecureUnitButton_OnLoad(frame, unit)
  5.     RegisterUnitWatch(frame)
  6.     frame.elements = {}
  7.     self:ConfigureFrame(frame)
  8.     return frame
  9. end
  10.  
  11. function KaelFrames:CreateHeader(header)
  12.     local frame = CreateFrame("Frame", "KaelFrames_"..header, UIParent, "SecureGroupHeaderTemplate")
  13.     -- what goes here?
  14.     return frame
  15. end
ConfigureFrame() sets the width, height, backdrop, etc. and inherits some functions.

When I feed "player" or "target" or "raid1" into Create(), it produces a clickable frame with a visible backdrop that appears when the unit exists and works for targeting the unit, which is all I expect it to do at this point.

What I would like CreateHeader() to do is, when I feed it "raid", to create a header and call Create() to create a frame for each raid member. Or some equivalent.

I know I need to define the header's initialConfigFunction, which needs to be some sort of superlong string, but I don't know what needs to be in that string and I don't know what else needs to happen.

Can anyone help?
  Reply With Quote
03-06-12, 07:42 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
https://github.com/haste/oUF/blob/a0...419bd1/ouf.lua

436-546

That is the spawnHeader function from oUF.
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Minimal code for creating a SecureGroupHeader?


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