So as I was working some more on the config ui for my raid frames, I found that by allowing a group to be anchored on any edge of another required a different approach to the way I resized the background frame.
Remembering that the background frames main purpose is for those who have click to move enabled and sometimes miss the frame they are trying to click on.
So consider for a moment that you are in Alterac Valley and that for some reason you have chosen to have the groups setup like thus :
Code:
[g4: u1,u2,u3,u4,u5][g8: u1,u2,u3,u4,u5]
[g3: u1,u2,u3,u4,u5][g7: u1,u2,u3,u4,u5]
[g2: u1,u2,u3,u4,u5][g6: u1,u2,u3,u4,u5]
[g1: u1,u2,u3,u4,u5][g5: u1,u2,u3,u4,u5]
The code in oUF_Grid expects that each group is anchored to the previous groups adjacent edge.
However the above layout example will cause the background frame to incorrectly resize itself.
I found that via some experimentation a far more simple method of determining the boundaries at which to resize the background frame works regardless of the way the frames are setup :
Code:
-- raidFrame is our background frame
local raidFrame = oUF_Smee2_Groups.units.raid
-- pseudo reference to show that I grab this number from a savedvariable table
local padding = db.raid.margin
local left,bottom,width,height
local extremeLeft,extremeRight,extremeBottom,extremeTop
for unit,frame in pairs(oUF.units)do
--step through our units but only do anything if its a raid unit.
if( unit:gmatch("raid")() == "raid" )then
left,bottom,height,width = frame.Health:GetRect()
if(extremeLeft==nil or left < extremeLeft )then
extremeLeft = left
end
if(extremeBottom==nil or bottom < extremeBottom )then
extremeBottom = bottom
end
if(extremeTop==nil or bottom+height > extremeTop )then
extremeTop = bottom+height
end
if(extremeRight==nil or left+width > extremeRight)then
extremeRight = left+width
end
end
end
--with our findings, resize our raidframe background based on the locations found.
raidFrame:SetWidth( extremeRight - raidFrame:GetLeft() + db.raid.margin)
raidFrame:SetHeight( extremeTop - raidFrame:GetBottom() + db.raid.margin)
One last thing to remember is that the raidFrame object is also the object I use to allow the user to unlock and drag around in order to place the raidframes where they wish.
At least one group is anchored to the backgroundframe to preclude me from the requirement of manually placing the position of each group when being dragged around.